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 char *bgp_origin_str
[];
60 extern 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 struct bgp_info
*new;
134 new = XMALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
135 memset (new, 0, sizeof (struct bgp_info
));
140 /* Free bgp route information. */
142 bgp_info_free (struct bgp_info
*binfo
)
145 bgp_attr_unintern (binfo
->attr
);
147 bgp_info_extra_free (&binfo
->extra
);
149 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
151 XFREE (MTYPE_BGP_ROUTE
, binfo
);
155 bgp_info_lock (struct bgp_info
*binfo
)
162 bgp_info_unlock (struct bgp_info
*binfo
)
164 assert (binfo
&& binfo
->lock
> 0);
167 if (binfo
->lock
== 0)
170 zlog_debug ("%s: unlocked and freeing", __func__
);
171 zlog_backtrace (LOG_DEBUG
);
173 bgp_info_free (binfo
);
178 if (binfo
->lock
== 1)
180 zlog_debug ("%s: unlocked to 1", __func__
);
181 zlog_backtrace (LOG_DEBUG
);
189 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
191 struct bgp_info
*top
;
203 peer_lock (ri
->peer
); /* bgp_info peer reference */
206 /* Do the actual removal of info from RIB, for use by bgp_process
207 completion callback *only* */
209 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
212 ri
->next
->prev
= ri
->prev
;
214 ri
->prev
->next
= ri
->next
;
218 bgp_info_unlock (ri
);
219 bgp_unlock_node (rn
);
223 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
225 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
226 /* set of previous already took care of pcount */
227 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
230 /* undo the effects of a previous call to bgp_info_delete; typically
231 called when a route is deleted and then quickly re-added before the
232 deletion has been processed */
234 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
236 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
237 /* unset of previous already took care of pcount */
238 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
241 /* Adjust pcount as required */
243 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
245 assert (rn
&& rn
->table
);
246 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
248 /* Ignore 'pcount' for RS-client tables */
249 if (rn
->table
->type
!= BGP_TABLE_MAIN
250 || ri
->peer
== ri
->peer
->bgp
->peer_self
)
253 if (BGP_INFO_HOLDDOWN (ri
)
254 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
257 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
259 /* slight hack, but more robust against errors. */
260 if (ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
])
261 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]--;
264 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
265 __func__
, ri
->peer
->host
);
266 zlog_backtrace (LOG_WARNING
);
267 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
270 else if (!BGP_INFO_HOLDDOWN (ri
)
271 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
273 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
274 ri
->peer
->pcount
[rn
->table
->afi
][rn
->table
->safi
]++;
279 /* Set/unset bgp_info flags, adjusting any other state as needed.
280 * This is here primarily to keep prefix-count in check.
283 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
285 SET_FLAG (ri
->flags
, flag
);
287 /* early bath if we know it's not a flag that changes useability state */
288 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
291 bgp_pcount_adjust (rn
, ri
);
295 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
297 UNSET_FLAG (ri
->flags
, flag
);
299 /* early bath if we know it's not a flag that changes useability state */
300 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_UNUSEABLE
))
303 bgp_pcount_adjust (rn
, ri
);
306 /* Get MED value. If MED value is missing and "bgp bestpath
307 missing-as-worst" is specified, treat it as the worst value. */
309 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
311 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
315 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
322 /* Compare two bgp route entity. br is preferable then return 1. */
324 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
)
327 u_int32_t exist_pref
;
330 u_int32_t new_weight
= 0;
331 u_int32_t exist_weight
= 0;
332 struct in_addr new_id
;
333 struct in_addr exist_id
;
336 int internal_as_route
= 0;
337 int confed_as_route
= 0;
346 /* 1. Weight check. */
347 if (new->attr
->extra
)
348 new_weight
= new->attr
->extra
->weight
;
349 if (exist
->attr
->extra
)
350 exist_weight
= exist
->attr
->extra
->weight
;
351 if (new_weight
> exist_weight
)
353 if (new_weight
< exist_weight
)
356 /* 2. Local preference check. */
357 if (new->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
358 new_pref
= new->attr
->local_pref
;
360 new_pref
= bgp
->default_local_pref
;
362 if (exist
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
363 exist_pref
= exist
->attr
->local_pref
;
365 exist_pref
= bgp
->default_local_pref
;
367 if (new_pref
> exist_pref
)
369 if (new_pref
< exist_pref
)
372 /* 3. Local route check. */
373 if (new->sub_type
== BGP_ROUTE_STATIC
)
375 if (exist
->sub_type
== BGP_ROUTE_STATIC
)
378 if (new->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
380 if (exist
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
383 if (new->sub_type
== BGP_ROUTE_AGGREGATE
)
385 if (exist
->sub_type
== BGP_ROUTE_AGGREGATE
)
388 /* 4. AS path length check. */
389 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
391 int exist_hops
= aspath_count_hops (exist
->attr
->aspath
);
392 int exist_confeds
= aspath_count_confeds (exist
->attr
->aspath
);
394 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
398 aspath_hops
= aspath_count_hops (new->attr
->aspath
);
399 aspath_hops
+= aspath_count_confeds (new->attr
->aspath
);
401 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
403 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
408 int newhops
= aspath_count_hops (new->attr
->aspath
);
410 if (newhops
< exist_hops
)
412 if (newhops
> exist_hops
)
417 /* 5. Origin check. */
418 if (new->attr
->origin
< exist
->attr
->origin
)
420 if (new->attr
->origin
> exist
->attr
->origin
)
424 internal_as_route
= (aspath_count_hops (new->attr
->aspath
) == 0
425 && aspath_count_hops (exist
->attr
->aspath
) == 0);
426 confed_as_route
= (aspath_count_confeds (new->attr
->aspath
) > 0
427 && aspath_count_confeds (exist
->attr
->aspath
) > 0
428 && aspath_count_hops (new->attr
->aspath
) == 0
429 && aspath_count_hops (exist
->attr
->aspath
) == 0);
431 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
432 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
434 || aspath_cmp_left (new->attr
->aspath
, exist
->attr
->aspath
)
435 || aspath_cmp_left_confed (new->attr
->aspath
, exist
->attr
->aspath
)
436 || internal_as_route
)
438 new_med
= bgp_med_value (new->attr
, bgp
);
439 exist_med
= bgp_med_value (exist
->attr
, bgp
);
441 if (new_med
< exist_med
)
443 if (new_med
> exist_med
)
447 /* 7. Peer type check. */
448 if (peer_sort (new->peer
) == BGP_PEER_EBGP
449 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
)
451 if (peer_sort (new->peer
) == BGP_PEER_EBGP
452 && peer_sort (exist
->peer
) == BGP_PEER_CONFED
)
454 if (peer_sort (new->peer
) == BGP_PEER_IBGP
455 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
457 if (peer_sort (new->peer
) == BGP_PEER_CONFED
458 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
461 /* 8. IGP metric check. */
462 if (new->extra
|| exist
->extra
)
464 uint32_t newm
= (new->extra
? new->extra
->igpmetric
: 0);
465 uint32_t existm
= (exist
->extra
? exist
->extra
->igpmetric
: 0);
473 /* 9. Maximum path check. */
475 /* 10. If both paths are external, prefer the path that was received
476 first (the oldest one). This step minimizes route-flap, since a
477 newer path won't displace an older one, even if it was the
478 preferred route based on the additional decision criteria below. */
479 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
480 && peer_sort (new->peer
) == BGP_PEER_EBGP
481 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
483 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
485 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
489 /* 11. Rourter-ID comparision. */
490 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
491 new_id
.s_addr
= new->attr
->extra
->originator_id
.s_addr
;
493 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
494 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
495 exist_id
.s_addr
= exist
->attr
->extra
->originator_id
.s_addr
;
497 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
499 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
501 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
504 /* 12. Cluster length comparision. */
505 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
506 new_cluster
= new->attr
->extra
->cluster
->length
;
509 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
510 exist_cluster
= exist
->attr
->extra
->cluster
->length
;
514 if (new_cluster
< exist_cluster
)
516 if (new_cluster
> exist_cluster
)
519 /* 13. Neighbor address comparision. */
520 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
530 static enum filter_type
531 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
532 afi_t afi
, safi_t safi
)
534 struct bgp_filter
*filter
;
536 filter
= &peer
->filter
[afi
][safi
];
538 if (DISTRIBUTE_IN_NAME (filter
))
539 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
542 if (PREFIX_LIST_IN_NAME (filter
))
543 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
546 if (FILTER_LIST_IN_NAME (filter
))
547 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
550 return FILTER_PERMIT
;
553 static enum filter_type
554 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
555 afi_t afi
, safi_t safi
)
557 struct bgp_filter
*filter
;
559 filter
= &peer
->filter
[afi
][safi
];
561 if (DISTRIBUTE_OUT_NAME (filter
))
562 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
565 if (PREFIX_LIST_OUT_NAME (filter
))
566 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
569 if (FILTER_LIST_OUT_NAME (filter
))
570 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
573 return FILTER_PERMIT
;
576 /* If community attribute includes no_export then return 1. */
578 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
582 /* NO_ADVERTISE check. */
583 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
586 /* NO_EXPORT check. */
587 if (peer_sort (peer
) == BGP_PEER_EBGP
&&
588 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
591 /* NO_EXPORT_SUBCONFED check. */
592 if (peer_sort (peer
) == BGP_PEER_EBGP
593 || peer_sort (peer
) == BGP_PEER_CONFED
)
594 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
600 /* Route reflection loop check. */
602 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
604 struct in_addr cluster_id
;
606 if (attr
->extra
&& attr
->extra
->cluster
)
608 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
609 cluster_id
= peer
->bgp
->cluster_id
;
611 cluster_id
= peer
->bgp
->router_id
;
613 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
620 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
621 afi_t afi
, safi_t safi
)
623 struct bgp_filter
*filter
;
624 struct bgp_info info
;
625 route_map_result_t ret
;
627 filter
= &peer
->filter
[afi
][safi
];
629 /* Apply default weight value. */
631 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
633 /* Route map apply. */
634 if (ROUTE_MAP_IN_NAME (filter
))
636 /* Duplicate current value to new strucutre for modification. */
640 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
642 /* Apply BGP route map to the attribute. */
643 ret
= route_map_apply (ROUTE_MAP_IN (filter
), p
, RMAP_BGP
, &info
);
647 if (ret
== RMAP_DENYMATCH
)
649 /* Free newly generated AS path and community by route-map. */
650 bgp_attr_flush (attr
);
658 bgp_export_modifier (struct peer
*rsclient
, struct peer
*peer
,
659 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
661 struct bgp_filter
*filter
;
662 struct bgp_info info
;
663 route_map_result_t ret
;
665 filter
= &peer
->filter
[afi
][safi
];
667 /* Route map apply. */
668 if (ROUTE_MAP_EXPORT_NAME (filter
))
670 /* Duplicate current value to new strucutre for modification. */
671 info
.peer
= rsclient
;
674 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
676 /* Apply BGP route map to the attribute. */
677 ret
= route_map_apply (ROUTE_MAP_EXPORT (filter
), p
, RMAP_BGP
, &info
);
679 rsclient
->rmap_type
= 0;
681 if (ret
== RMAP_DENYMATCH
)
683 /* Free newly generated AS path and community by route-map. */
684 bgp_attr_flush (attr
);
692 bgp_import_modifier (struct peer
*rsclient
, struct peer
*peer
,
693 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
695 struct bgp_filter
*filter
;
696 struct bgp_info info
;
697 route_map_result_t ret
;
699 filter
= &rsclient
->filter
[afi
][safi
];
701 /* Apply default weight value. */
703 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
705 /* Route map apply. */
706 if (ROUTE_MAP_IMPORT_NAME (filter
))
708 /* Duplicate current value to new strucutre for modification. */
712 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IMPORT
);
714 /* Apply BGP route map to the attribute. */
715 ret
= route_map_apply (ROUTE_MAP_IMPORT (filter
), p
, RMAP_BGP
, &info
);
719 if (ret
== RMAP_DENYMATCH
)
721 /* Free newly generated AS path and community by route-map. */
722 bgp_attr_flush (attr
);
730 bgp_announce_check (struct bgp_info
*ri
, struct peer
*peer
, struct prefix
*p
,
731 struct attr
*attr
, afi_t afi
, safi_t safi
)
734 char buf
[SU_ADDRSTRLEN
];
735 struct bgp_filter
*filter
;
742 filter
= &peer
->filter
[afi
][safi
];
745 #ifdef DISABLE_BGP_ANNOUNCE
749 /* Do not send announces to RS-clients from the 'normal' bgp_table. */
750 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
753 /* Do not send back route to sender. */
757 /* If peer's id and route's nexthop are same. draft-ietf-idr-bgp4-23 5.1.3 */
758 if (p
->family
== AF_INET
759 && IPV4_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
762 if (p
->family
== AF_INET6
763 && IPV6_ADDR_SAME(&peer
->remote_id
, &ri
->attr
->nexthop
))
767 /* Aggregate-address suppress check. */
768 if (ri
->extra
&& ri
->extra
->suppress
)
769 if (! UNSUPPRESS_MAP_NAME (filter
))
772 /* Default route check. */
773 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
775 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
778 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
780 #endif /* HAVE_IPV6 */
783 /* Transparency check. */
784 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
785 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
790 /* If community is not disabled check the no-export and local. */
791 if (! transparent
&& bgp_community_filter (peer
, ri
->attr
))
794 /* If the attribute has originator-id and it is same as remote
796 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
798 if (IPV4_ADDR_SAME (&peer
->remote_id
, &ri
->attr
->extra
->originator_id
))
800 if (BGP_DEBUG (filter
, FILTER
))
801 zlog (peer
->log
, LOG_DEBUG
,
802 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
804 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
810 /* ORF prefix-list filter check */
811 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
812 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
813 || CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
814 if (peer
->orf_plist
[afi
][safi
])
816 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
820 /* Output filter check. */
821 if (bgp_output_filter (peer
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
823 if (BGP_DEBUG (filter
, FILTER
))
824 zlog (peer
->log
, LOG_DEBUG
,
825 "%s [Update:SEND] %s/%d is filtered",
827 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
832 #ifdef BGP_SEND_ASPATH_CHECK
833 /* AS path loop check. */
834 if (aspath_loop_check (ri
->attr
->aspath
, peer
->as
))
836 if (BGP_DEBUG (filter
, FILTER
))
837 zlog (peer
->log
, LOG_DEBUG
,
838 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
839 peer
->host
, peer
->as
);
842 #endif /* BGP_SEND_ASPATH_CHECK */
844 /* If we're a CONFED we need to loop check the CONFED ID too */
845 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
847 if (aspath_loop_check(ri
->attr
->aspath
, bgp
->confed_id
))
849 if (BGP_DEBUG (filter
, FILTER
))
850 zlog (peer
->log
, LOG_DEBUG
,
851 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
858 /* Route-Reflect check. */
859 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
864 /* IBGP reflection check. */
867 /* A route from a Client peer. */
868 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
870 /* Reflect to all the Non-Client peers and also to the
871 Client peers other than the originator. Originator check
872 is already done. So there is noting to do. */
873 /* no bgp client-to-client reflection check. */
874 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
875 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
880 /* A route from a Non-client peer. Reflect to all other
882 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
887 /* AS-Pathlimit check */
888 if (ri
->attr
->pathlimit
.ttl
&& peer_sort (peer
) == BGP_PEER_EBGP
)
889 /* Our ASN has not yet been pre-pended, that's done in packet_attribute
890 * on output. Hence the test here is for >=.
892 if (aspath_count_hops (ri
->attr
->aspath
) >= ri
->attr
->pathlimit
.ttl
)
894 if (BGP_DEBUG (filter
, FILTER
))
895 zlog_info ("%s [Update:SEND] suppressed, AS-Pathlimit TTL %u exceeded",
896 peer
->host
, ri
->attr
->pathlimit
.ttl
);
900 /* For modify attribute, copy it to temporary structure. */
901 bgp_attr_dup (attr
, ri
->attr
);
903 /* If local-preference is not set. */
904 if ((peer_sort (peer
) == BGP_PEER_IBGP
905 || peer_sort (peer
) == BGP_PEER_CONFED
)
906 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
908 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
909 attr
->local_pref
= bgp
->default_local_pref
;
912 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
913 if (peer_sort (peer
) == BGP_PEER_EBGP
914 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
916 if (ri
->peer
!= bgp
->peer_self
&& ! transparent
917 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
918 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
922 if (transparent
|| reflect
923 || (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
)
924 && ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
)
926 || (p
->family
== AF_INET6
&&
927 ! IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
928 #endif /* HAVE_IPV6 */
931 /* NEXT-HOP Unchanged. */
933 else if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
934 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
936 || (p
->family
== AF_INET6
&&
937 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
938 #endif /* HAVE_IPV6 */
939 || (peer_sort (peer
) == BGP_PEER_EBGP
940 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0))
942 /* Set IPv4 nexthop. */
943 if (p
->family
== AF_INET
)
945 if (safi
== SAFI_MPLS_VPN
)
946 memcpy (&attr
->extra
->mp_nexthop_global_in
, &peer
->nexthop
.v4
,
949 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
952 /* Set IPv6 nexthop. */
953 if (p
->family
== AF_INET6
)
955 /* IPv6 global nexthop must be included. */
956 memcpy (&attr
->extra
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
958 attr
->extra
->mp_nexthop_len
= 16;
960 #endif /* HAVE_IPV6 */
964 if (p
->family
== AF_INET6
)
966 /* Left nexthop_local unchanged if so configured. */
967 if ( CHECK_FLAG (peer
->af_flags
[afi
][safi
],
968 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
970 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
) )
971 attr
->extra
->mp_nexthop_len
=32;
973 attr
->extra
->mp_nexthop_len
=16;
976 /* Default nexthop_local treatment for non-RS-Clients */
979 /* Link-local address should not be transit to different peer. */
980 attr
->extra
->mp_nexthop_len
= 16;
982 /* Set link-local address for shared network peer. */
983 if (peer
->shared_network
984 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
986 memcpy (&attr
->extra
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
988 attr
->extra
->mp_nexthop_len
= 32;
991 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
994 attr
->extra
->mp_nexthop_len
= 16;
996 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
997 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
998 attr
->extra
->mp_nexthop_len
= 16;
1002 #endif /* HAVE_IPV6 */
1004 /* AS-Pathlimit: Check ASN for private/confed */
1005 if (attr
->pathlimit
.ttl
)
1007 /* locally originated update */
1008 if (!attr
->pathlimit
.as
)
1009 attr
->pathlimit
.as
= peer
->local_as
;
1011 /* if the AS_PATHLIMIT attribute is attached to a prefix by a
1012 member of a confederation, then when the prefix is advertised outside
1013 of the confederation boundary, then the AS number of the
1014 confederation member inside of the AS_PATHLIMIT attribute should be
1015 replaced by the confederation's AS number. */
1016 if (peer_sort (from
) == BGP_PEER_CONFED
1017 && peer_sort (peer
) != BGP_PEER_CONFED
)
1018 attr
->pathlimit
.as
= peer
->local_as
;
1020 /* Private ASN should be updated whenever announcement leaves
1021 * private space. This is deliberately done after simple confed
1024 if (attr
->pathlimit
.as
>= BGP_PRIVATE_AS_MIN
1025 && attr
->pathlimit
.as
<= BGP_PRIVATE_AS_MAX
)
1027 if (peer
->local_as
< BGP_PRIVATE_AS_MIN
1028 || peer
->local_as
> BGP_PRIVATE_AS_MAX
)
1029 attr
->pathlimit
.as
= peer
->local_as
;
1030 /* Ours is private, try using theirs.. */
1031 else if (peer
->as
< BGP_PRIVATE_AS_MIN
1032 || peer
->local_as
> BGP_PRIVATE_AS_MAX
)
1033 attr
->pathlimit
.as
= peer
->as
;
1037 /* If this is EBGP peer and remove-private-AS is set. */
1038 if (peer_sort (peer
) == BGP_PEER_EBGP
1039 && peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1040 && aspath_private_as_check (attr
->aspath
))
1041 attr
->aspath
= aspath_empty_get ();
1043 /* Route map & unsuppress-map apply. */
1044 if (ROUTE_MAP_OUT_NAME (filter
)
1045 || (ri
->extra
&& ri
->extra
->suppress
) )
1047 struct bgp_info info
;
1048 struct attr dummy_attr
= { 0 };
1053 /* The route reflector is not allowed to modify the attributes
1054 of the reflected IBGP routes. */
1055 if (peer_sort (from
) == BGP_PEER_IBGP
1056 && peer_sort (peer
) == BGP_PEER_IBGP
)
1058 bgp_attr_dup (&dummy_attr
, attr
);
1059 info
.attr
= &dummy_attr
;
1062 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1064 if (ri
->extra
&& ri
->extra
->suppress
)
1065 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1067 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1069 peer
->rmap_type
= 0;
1071 if (dummy_attr
.extra
)
1072 bgp_attr_extra_free (&dummy_attr
);
1074 if (ret
== RMAP_DENYMATCH
)
1076 bgp_attr_flush (attr
);
1084 bgp_announce_check_rsclient (struct bgp_info
*ri
, struct peer
*rsclient
,
1085 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1088 char buf
[SU_ADDRSTRLEN
];
1089 struct bgp_filter
*filter
;
1090 struct bgp_info info
;
1095 filter
= &rsclient
->filter
[afi
][safi
];
1096 bgp
= rsclient
->bgp
;
1098 #ifdef DISABLE_BGP_ANNOUNCE
1102 /* Do not send back route to sender. */
1103 if (from
== rsclient
)
1106 /* Aggregate-address suppress check. */
1107 if (ri
->extra
&& ri
->extra
->suppress
)
1108 if (! UNSUPPRESS_MAP_NAME (filter
))
1111 /* Default route check. */
1112 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1113 PEER_STATUS_DEFAULT_ORIGINATE
))
1115 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1118 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1120 #endif /* HAVE_IPV6 */
1123 /* If the attribute has originator-id and it is same as remote
1125 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1127 if (IPV4_ADDR_SAME (&rsclient
->remote_id
,
1128 &ri
->attr
->extra
->originator_id
))
1130 if (BGP_DEBUG (filter
, FILTER
))
1131 zlog (rsclient
->log
, LOG_DEBUG
,
1132 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1134 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1140 /* ORF prefix-list filter check */
1141 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1142 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1143 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1144 if (rsclient
->orf_plist
[afi
][safi
])
1146 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1150 /* Output filter check. */
1151 if (bgp_output_filter (rsclient
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
1153 if (BGP_DEBUG (filter
, FILTER
))
1154 zlog (rsclient
->log
, LOG_DEBUG
,
1155 "%s [Update:SEND] %s/%d is filtered",
1157 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1162 #ifdef BGP_SEND_ASPATH_CHECK
1163 /* AS path loop check. */
1164 if (aspath_loop_check (ri
->attr
->aspath
, rsclient
->as
))
1166 if (BGP_DEBUG (filter
, FILTER
))
1167 zlog (rsclient
->log
, LOG_DEBUG
,
1168 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
1169 rsclient
->host
, rsclient
->as
);
1172 #endif /* BGP_SEND_ASPATH_CHECK */
1174 /* For modify attribute, copy it to temporary structure. */
1175 bgp_attr_dup (attr
, ri
->attr
);
1178 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1180 || (p
->family
== AF_INET6
&&
1181 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
1182 #endif /* HAVE_IPV6 */
1185 /* Set IPv4 nexthop. */
1186 if (p
->family
== AF_INET
)
1188 if (safi
== SAFI_MPLS_VPN
)
1189 memcpy (&attr
->extra
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1192 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1195 /* Set IPv6 nexthop. */
1196 if (p
->family
== AF_INET6
)
1198 /* IPv6 global nexthop must be included. */
1199 memcpy (&attr
->extra
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1201 attr
->extra
->mp_nexthop_len
= 16;
1203 #endif /* HAVE_IPV6 */
1207 if (p
->family
== AF_INET6
)
1209 struct attr_extra
*attre
= attr
->extra
;
1211 assert (attr
->extra
);
1213 /* Left nexthop_local unchanged if so configured. */
1214 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1215 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1217 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1218 attre
->mp_nexthop_len
=32;
1220 attre
->mp_nexthop_len
=16;
1223 /* Default nexthop_local treatment for RS-Clients */
1226 /* Announcer and RS-Client are both in the same network */
1227 if (rsclient
->shared_network
&& from
->shared_network
&&
1228 (rsclient
->ifindex
== from
->ifindex
))
1230 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1231 attre
->mp_nexthop_len
=32;
1233 attre
->mp_nexthop_len
=16;
1236 /* Set link-local address for shared network peer. */
1237 else if (rsclient
->shared_network
1238 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1240 memcpy (&attre
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1242 attre
->mp_nexthop_len
= 32;
1246 attre
->mp_nexthop_len
= 16;
1250 #endif /* HAVE_IPV6 */
1253 /* If this is EBGP peer and remove-private-AS is set. */
1254 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1255 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1256 && aspath_private_as_check (attr
->aspath
))
1257 attr
->aspath
= aspath_empty_get ();
1259 /* Route map & unsuppress-map apply. */
1260 if (ROUTE_MAP_OUT_NAME (filter
) || (ri
->extra
&& ri
->extra
->suppress
) )
1262 info
.peer
= rsclient
;
1265 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1267 if (ri
->extra
&& ri
->extra
->suppress
)
1268 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1270 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1272 rsclient
->rmap_type
= 0;
1274 if (ret
== RMAP_DENYMATCH
)
1276 bgp_attr_flush (attr
);
1284 struct bgp_info_pair
1286 struct bgp_info
*old
;
1287 struct bgp_info
*new;
1291 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
, struct bgp_info_pair
*result
)
1293 struct bgp_info
*new_select
;
1294 struct bgp_info
*old_select
;
1295 struct bgp_info
*ri
;
1296 struct bgp_info
*ri1
;
1297 struct bgp_info
*ri2
;
1298 struct bgp_info
*nextri
= NULL
;
1300 /* bgp deterministic-med */
1302 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1303 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1305 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1307 if (BGP_INFO_HOLDDOWN (ri1
))
1312 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1314 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1316 if (BGP_INFO_HOLDDOWN (ri2
))
1319 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1320 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1323 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1325 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1329 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1332 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1333 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1336 /* Check old selected route and new selected route. */
1339 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1341 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1344 if (BGP_INFO_HOLDDOWN (ri
))
1346 /* reap REMOVED routes, if needs be
1347 * selected route must stay for a while longer though
1349 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1350 && (ri
!= old_select
))
1351 bgp_info_reap (rn
, ri
);
1356 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1357 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1359 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1362 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1363 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1365 if (bgp_info_cmp (bgp
, ri
, new_select
))
1369 result
->old
= old_select
;
1370 result
->new = new_select
;
1376 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1377 struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1380 struct attr attr
= { 0 };
1384 /* Announce route to Established peer. */
1385 if (peer
->status
!= Established
)
1388 /* Address family configuration check. */
1389 if (! peer
->afc_nego
[afi
][safi
])
1392 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1393 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1394 PEER_STATUS_ORF_WAIT_REFRESH
))
1397 switch (rn
->table
->type
)
1399 case BGP_TABLE_MAIN
:
1400 /* Announcement to peer->conf. If the route is filtered,
1402 if (selected
&& bgp_announce_check (selected
, peer
, p
, &attr
, afi
, safi
))
1403 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1405 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1407 case BGP_TABLE_RSCLIENT
:
1408 /* Announcement to peer->conf. If the route is filtered,
1411 bgp_announce_check_rsclient (selected
, peer
, p
, &attr
, afi
, safi
))
1412 bgp_adj_out_set (rn
, peer
, p
, &attr
, afi
, safi
, selected
);
1414 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1418 bgp_attr_extra_free (&attr
);
1423 struct bgp_process_queue
1426 struct bgp_node
*rn
;
1431 static wq_item_status
1432 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1434 struct bgp_process_queue
*pq
= data
;
1435 struct bgp
*bgp
= pq
->bgp
;
1436 struct bgp_node
*rn
= pq
->rn
;
1437 afi_t afi
= pq
->afi
;
1438 safi_t safi
= pq
->safi
;
1439 struct bgp_info
*new_select
;
1440 struct bgp_info
*old_select
;
1441 struct bgp_info_pair old_and_new
;
1443 struct listnode
*node
, *nnode
;
1444 struct peer
*rsclient
= rn
->table
->owner
;
1446 memset (&attr
, 0, sizeof (struct attr
));
1447 /* Best path selection. */
1448 bgp_best_selection (bgp
, rn
, &old_and_new
);
1449 new_select
= old_and_new
.new;
1450 old_select
= old_and_new
.old
;
1452 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1454 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1456 /* Nothing to do. */
1457 if (old_select
&& old_select
== new_select
)
1458 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1462 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1465 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1466 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1469 bgp_process_announce_selected (rsclient
, new_select
, rn
, afi
, safi
);
1475 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1478 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1479 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1481 bgp_process_announce_selected (rsclient
, new_select
, rn
, afi
, safi
);
1484 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1485 bgp_info_reap (rn
, old_select
);
1487 bgp_attr_extra_free (&attr
);
1489 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1493 static wq_item_status
1494 bgp_process_main (struct work_queue
*wq
, void *data
)
1496 struct bgp_process_queue
*pq
= data
;
1497 struct bgp
*bgp
= pq
->bgp
;
1498 struct bgp_node
*rn
= pq
->rn
;
1499 afi_t afi
= pq
->afi
;
1500 safi_t safi
= pq
->safi
;
1501 struct prefix
*p
= &rn
->p
;
1502 struct bgp_info
*new_select
;
1503 struct bgp_info
*old_select
;
1504 struct bgp_info_pair old_and_new
;
1505 struct listnode
*node
, *nnode
;
1508 /* Best path selection. */
1509 bgp_best_selection (bgp
, rn
, &old_and_new
);
1510 old_select
= old_and_new
.old
;
1511 new_select
= old_and_new
.new;
1513 /* Nothing to do. */
1514 if (old_select
&& old_select
== new_select
)
1516 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1518 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1519 bgp_zebra_announce (p
, old_select
, bgp
);
1521 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1527 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1530 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1531 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1535 /* Check each BGP peer. */
1536 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1538 bgp_process_announce_selected (peer
, new_select
, rn
, afi
, safi
);
1542 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&&
1543 ! bgp_option_check (BGP_OPT_NO_FIB
))
1546 && new_select
->type
== ZEBRA_ROUTE_BGP
1547 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1548 bgp_zebra_announce (p
, new_select
, bgp
);
1551 /* Withdraw the route from the kernel. */
1553 && old_select
->type
== ZEBRA_ROUTE_BGP
1554 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1555 bgp_zebra_withdraw (p
, old_select
);
1559 /* Reap old select bgp_info, it it has been removed */
1560 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1561 bgp_info_reap (rn
, old_select
);
1563 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1568 bgp_processq_del (struct work_queue
*wq
, void *data
)
1570 struct bgp_process_queue
*pq
= data
;
1572 bgp_unlock_node (pq
->rn
);
1573 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1577 bgp_process_queue_init (void)
1579 bm
->process_main_queue
1580 = work_queue_new (bm
->master
, "process_main_queue");
1581 bm
->process_rsclient_queue
1582 = work_queue_new (bm
->master
, "process_rsclient_queue");
1584 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1586 zlog_err ("%s: Failed to allocate work queue", __func__
);
1590 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1591 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1592 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1593 bm
->process_rsclient_queue
->spec
.del_item_data
1594 = bm
->process_main_queue
->spec
.del_item_data
;
1595 bm
->process_main_queue
->spec
.max_retries
1596 = bm
->process_main_queue
->spec
.max_retries
= 0;
1597 bm
->process_rsclient_queue
->spec
.hold
1598 = bm
->process_main_queue
->spec
.hold
= 50;
1602 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1604 struct bgp_process_queue
*pqnode
;
1606 /* already scheduled for processing? */
1607 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1610 if ( (bm
->process_main_queue
== NULL
) ||
1611 (bm
->process_rsclient_queue
== NULL
) )
1612 bgp_process_queue_init ();
1614 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1615 sizeof (struct bgp_process_queue
));
1619 pqnode
->rn
= bgp_lock_node (rn
); /* unlocked by bgp_processq_del */
1622 pqnode
->safi
= safi
;
1624 switch (rn
->table
->type
)
1626 case BGP_TABLE_MAIN
:
1627 work_queue_add (bm
->process_main_queue
, pqnode
);
1629 case BGP_TABLE_RSCLIENT
:
1630 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1638 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1642 peer
= THREAD_ARG (thread
);
1643 peer
->t_pmax_restart
= NULL
;
1645 if (BGP_DEBUG (events
, EVENTS
))
1646 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1655 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1656 safi_t safi
, int always
)
1658 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1661 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1663 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1667 zlog (peer
->log
, LOG_INFO
,
1668 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1669 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1670 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1671 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1673 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1679 if (safi
== SAFI_MPLS_VPN
)
1680 safi
= BGP_SAFI_VPNV4
;
1682 ndata
[0] = (afi
>> 8);
1685 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1686 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1687 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1688 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1690 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1691 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1692 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1695 /* restart timer start */
1696 if (peer
->pmax_restart
[afi
][safi
])
1698 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1700 if (BGP_DEBUG (events
, EVENTS
))
1701 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1702 peer
->host
, peer
->v_pmax_restart
);
1704 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1705 peer
->v_pmax_restart
);
1711 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1713 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1715 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1719 zlog (peer
->log
, LOG_INFO
,
1720 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1721 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1722 peer
->pmax
[afi
][safi
]);
1723 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1726 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1730 /* Unconditionally remove the route from the RIB, without taking
1731 * damping into consideration (eg, because the session went down)
1734 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1735 afi_t afi
, safi_t safi
)
1737 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1739 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1740 bgp_info_delete (rn
, ri
); /* keep historical info */
1742 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1746 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1747 afi_t afi
, safi_t safi
)
1749 int status
= BGP_DAMP_NONE
;
1751 /* apply dampening, if result is suppressed, we'll be retaining
1752 * the bgp_info in the RIB for historical reference.
1754 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1755 && peer_sort (peer
) == BGP_PEER_EBGP
)
1756 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1757 == BGP_DAMP_SUPPRESSED
)
1759 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1763 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1767 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1768 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1769 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1771 struct bgp_node
*rn
;
1773 struct attr new_attr
= { 0 };
1774 struct attr
*attr_new
;
1775 struct attr
*attr_new2
;
1776 struct bgp_info
*ri
;
1777 struct bgp_info
*new;
1779 char buf
[SU_ADDRSTRLEN
];
1781 //memset (new_attr, 0, sizeof (struct attr));
1783 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1784 if (peer
== rsclient
)
1788 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1790 /* Check previously received route. */
1791 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1792 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1795 /* AS path loop check. */
1796 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1798 reason
= "as-path contains our own AS;";
1802 /* Route reflector originator ID check. */
1803 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1804 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->extra
->originator_id
))
1806 reason
= "originator is us;";
1810 bgp_attr_dup (&new_attr
, attr
);
1812 /* Apply export policy. */
1813 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1814 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1816 reason
= "export-policy;";
1820 attr_new2
= bgp_attr_intern (&new_attr
);
1822 /* Apply import policy. */
1823 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1825 bgp_attr_unintern (attr_new2
);
1827 reason
= "import-policy;";
1831 attr_new
= bgp_attr_intern (&new_attr
);
1832 bgp_attr_unintern (attr_new2
);
1834 /* IPv4 unicast next hop check. */
1835 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1837 /* Next hop must not be 0.0.0.0 nor Class E address. */
1838 if (new_attr
.nexthop
.s_addr
== 0
1839 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1841 bgp_attr_unintern (attr_new
);
1843 reason
= "martian next-hop;";
1848 /* new_attr isn't passed to any functions after here */
1849 bgp_attr_extra_free (&new_attr
);
1851 /* If the update is implicit withdraw. */
1854 ri
->uptime
= time (NULL
);
1856 /* Same attribute comes in. */
1857 if (!CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
)
1858 && attrhash_cmp (ri
->attr
, attr_new
))
1861 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1863 if (BGP_DEBUG (update
, UPDATE_IN
))
1864 zlog (peer
->log
, LOG_DEBUG
,
1865 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1867 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1868 p
->prefixlen
, rsclient
->host
);
1870 bgp_unlock_node (rn
);
1871 bgp_attr_unintern (attr_new
);
1876 /* Withdraw/Announce before we fully processed the withdraw */
1877 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
1878 bgp_info_restore (rn
, ri
);
1880 /* Received Logging. */
1881 if (BGP_DEBUG (update
, UPDATE_IN
))
1882 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1884 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1885 p
->prefixlen
, rsclient
->host
);
1887 /* The attribute is changed. */
1888 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1890 /* Update to new attribute. */
1891 bgp_attr_unintern (ri
->attr
);
1892 ri
->attr
= attr_new
;
1894 /* Update MPLS tag. */
1895 if (safi
== SAFI_MPLS_VPN
)
1896 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
1898 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1900 /* Process change. */
1901 bgp_process (bgp
, rn
, afi
, safi
);
1902 bgp_unlock_node (rn
);
1907 /* Received Logging. */
1908 if (BGP_DEBUG (update
, UPDATE_IN
))
1910 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1912 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1913 p
->prefixlen
, rsclient
->host
);
1916 /* Make new BGP info. */
1917 new = bgp_info_new ();
1919 new->sub_type
= sub_type
;
1921 new->attr
= attr_new
;
1922 new->uptime
= time (NULL
);
1924 /* Update MPLS tag. */
1925 if (safi
== SAFI_MPLS_VPN
)
1926 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
1928 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1930 /* Register new BGP information. */
1931 bgp_info_add (rn
, new);
1933 /* route_node_get lock */
1934 bgp_unlock_node (rn
);
1936 /* Process change. */
1937 bgp_process (bgp
, rn
, afi
, safi
);
1939 bgp_attr_extra_free (&new_attr
);
1945 /* This BGP update is filtered. Log the reason then update BGP entry. */
1946 if (BGP_DEBUG (update
, UPDATE_IN
))
1947 zlog (peer
->log
, LOG_DEBUG
,
1948 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1950 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1951 p
->prefixlen
, rsclient
->host
, reason
);
1954 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1956 bgp_unlock_node (rn
);
1959 bgp_attr_extra_free (&new_attr
);
1965 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1966 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
1967 struct prefix_rd
*prd
, u_char
*tag
)
1969 struct bgp_node
*rn
;
1970 struct bgp_info
*ri
;
1971 char buf
[SU_ADDRSTRLEN
];
1973 if (rsclient
== peer
)
1976 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1978 /* Lookup withdrawn route. */
1979 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1980 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1983 /* Withdraw specified route from routing table. */
1984 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1985 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
1986 else if (BGP_DEBUG (update
, UPDATE_IN
))
1987 zlog (peer
->log
, LOG_DEBUG
,
1988 "%s Can't find the route %s/%d", peer
->host
,
1989 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1992 /* Unlock bgp_node_get() lock. */
1993 bgp_unlock_node (rn
);
1997 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1998 afi_t afi
, safi_t safi
, int type
, int sub_type
,
1999 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2002 int aspath_loop_count
= 0;
2003 struct bgp_node
*rn
;
2005 struct attr new_attr
= { 0 };
2006 struct attr
*attr_new
;
2007 struct bgp_info
*ri
;
2008 struct bgp_info
*new;
2010 char buf
[SU_ADDRSTRLEN
];
2013 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2015 /* When peer's soft reconfiguration enabled. Record input packet in
2017 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2018 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
2019 bgp_adj_in_set (rn
, peer
, attr
);
2021 /* Check previously received route. */
2022 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2023 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2026 /* AS path local-as loop check. */
2027 if (peer
->change_local_as
)
2029 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2030 aspath_loop_count
= 1;
2032 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2034 reason
= "as-path contains our own AS;";
2039 /* AS path loop check. */
2040 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2041 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2042 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2043 > peer
->allowas_in
[afi
][safi
]))
2045 reason
= "as-path contains our own AS;";
2049 /* Route reflector originator ID check. */
2050 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2051 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2053 reason
= "originator is us;";
2057 /* Route reflector cluster ID check. */
2058 if (bgp_cluster_filter (peer
, attr
))
2060 reason
= "reflected from the same cluster;";
2064 /* Apply incoming filter. */
2065 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2071 /* Apply incoming route-map. */
2072 bgp_attr_dup (&new_attr
, attr
);
2074 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
2076 reason
= "route-map;";
2080 /* IPv4 unicast next hop check. */
2081 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2083 /* If the peer is EBGP and nexthop is not on connected route,
2085 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
2086 && ! bgp_nexthop_check_ebgp (afi
, &new_attr
)
2087 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
2089 reason
= "non-connected next-hop;";
2093 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
2094 must not be my own address. */
2095 if (bgp_nexthop_self (afi
, &new_attr
)
2096 || new_attr
.nexthop
.s_addr
== 0
2097 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
2099 reason
= "martian next-hop;";
2104 attr_new
= bgp_attr_intern (&new_attr
);
2106 /* If the update is implicit withdraw. */
2109 ri
->uptime
= time (NULL
);
2111 /* Same attribute comes in. */
2112 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2113 && attrhash_cmp (ri
->attr
, attr_new
))
2115 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2117 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2118 && peer_sort (peer
) == BGP_PEER_EBGP
2119 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2121 if (BGP_DEBUG (update
, UPDATE_IN
))
2122 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2124 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2127 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2129 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2130 bgp_process (bgp
, rn
, afi
, safi
);
2133 else /* Duplicate - odd */
2135 if (BGP_DEBUG (update
, UPDATE_IN
))
2136 zlog (peer
->log
, LOG_DEBUG
,
2137 "%s rcvd %s/%d...duplicate ignored",
2139 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2142 /* graceful restart STALE flag unset. */
2143 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2145 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2146 bgp_process (bgp
, rn
, afi
, safi
);
2150 bgp_unlock_node (rn
);
2151 bgp_attr_unintern (attr_new
);
2152 bgp_attr_extra_free (&new_attr
);
2157 /* Withdraw/Announce before we fully processed the withdraw */
2158 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2160 if (BGP_DEBUG (update
, UPDATE_IN
))
2161 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d, flapped quicker than processing",
2163 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2165 bgp_info_restore (rn
, ri
);
2168 /* Received Logging. */
2169 if (BGP_DEBUG (update
, UPDATE_IN
))
2170 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2172 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2175 /* graceful restart STALE flag unset. */
2176 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2177 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2179 /* The attribute is changed. */
2180 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2182 /* implicit withdraw, decrement aggregate and pcount here.
2183 * only if update is accepted, they'll increment below.
2185 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2187 /* Update bgp route dampening information. */
2188 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2189 && peer_sort (peer
) == BGP_PEER_EBGP
)
2191 /* This is implicit withdraw so we should update dampening
2193 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2194 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2197 /* Update to new attribute. */
2198 bgp_attr_unintern (ri
->attr
);
2199 ri
->attr
= attr_new
;
2201 /* Update MPLS tag. */
2202 if (safi
== SAFI_MPLS_VPN
)
2203 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2205 /* Update bgp route dampening information. */
2206 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2207 && peer_sort (peer
) == BGP_PEER_EBGP
)
2209 /* Now we do normal update dampening. */
2210 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2211 if (ret
== BGP_DAMP_SUPPRESSED
)
2213 bgp_unlock_node (rn
);
2214 bgp_attr_extra_free (&new_attr
);
2219 /* Nexthop reachability check. */
2220 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2221 && safi
== SAFI_UNICAST
2222 && (peer_sort (peer
) == BGP_PEER_IBGP
2223 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2224 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2226 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2227 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2229 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2232 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2234 /* Process change. */
2235 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2237 bgp_process (bgp
, rn
, afi
, safi
);
2238 bgp_unlock_node (rn
);
2239 bgp_attr_extra_free (&new_attr
);
2244 /* Received Logging. */
2245 if (BGP_DEBUG (update
, UPDATE_IN
))
2247 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2249 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2253 /* Make new BGP info. */
2254 new = bgp_info_new ();
2256 new->sub_type
= sub_type
;
2258 new->attr
= attr_new
;
2259 new->uptime
= time (NULL
);
2261 /* Update MPLS tag. */
2262 if (safi
== SAFI_MPLS_VPN
)
2263 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2265 /* Nexthop reachability check. */
2266 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2267 && safi
== SAFI_UNICAST
2268 && (peer_sort (peer
) == BGP_PEER_IBGP
2269 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2270 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2272 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2273 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2275 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2278 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2280 /* Increment prefix */
2281 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2283 /* Register new BGP information. */
2284 bgp_info_add (rn
, new);
2286 /* route_node_get lock */
2287 bgp_unlock_node (rn
);
2289 bgp_attr_extra_free (&new_attr
);
2291 /* If maximum prefix count is configured and current prefix
2293 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2296 /* Process change. */
2297 bgp_process (bgp
, rn
, afi
, safi
);
2301 /* This BGP update is filtered. Log the reason then update BGP
2304 if (BGP_DEBUG (update
, UPDATE_IN
))
2305 zlog (peer
->log
, LOG_DEBUG
,
2306 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2308 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2309 p
->prefixlen
, reason
);
2312 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2314 bgp_unlock_node (rn
);
2316 bgp_attr_extra_free (&new_attr
);
2322 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2323 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2324 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2326 struct peer
*rsclient
;
2327 struct listnode
*node
, *nnode
;
2331 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2336 /* Process the update for each RS-client. */
2337 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2339 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2340 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2341 sub_type
, prd
, tag
);
2348 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2349 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2350 struct prefix_rd
*prd
, u_char
*tag
)
2353 char buf
[SU_ADDRSTRLEN
];
2354 struct bgp_node
*rn
;
2355 struct bgp_info
*ri
;
2356 struct peer
*rsclient
;
2357 struct listnode
*node
, *nnode
;
2361 /* Process the withdraw for each RS-client. */
2362 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2364 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2365 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2369 if (BGP_DEBUG (update
, UPDATE_IN
))
2370 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2372 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2376 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2378 /* If peer is soft reconfiguration enabled. Record input packet for
2379 further calculation. */
2380 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2381 && peer
!= bgp
->peer_self
)
2382 bgp_adj_in_unset (rn
, peer
);
2384 /* Lookup withdrawn route. */
2385 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2386 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2389 /* Withdraw specified route from routing table. */
2390 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2391 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2392 else if (BGP_DEBUG (update
, UPDATE_IN
))
2393 zlog (peer
->log
, LOG_DEBUG
,
2394 "%s Can't find the route %s/%d", peer
->host
,
2395 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2398 /* Unlock bgp_node_get() lock. */
2399 bgp_unlock_node (rn
);
2405 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2409 struct aspath
*aspath
= { 0 };
2411 struct bgp_info binfo
;
2413 int ret
= RMAP_DENYMATCH
;
2415 if (!(afi
== AFI_IP
|| afi
== AFI_IP6
))
2419 from
= bgp
->peer_self
;
2421 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2422 aspath
= attr
.aspath
;
2423 attr
.local_pref
= bgp
->default_local_pref
;
2424 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2427 str2prefix ("0.0.0.0/0", &p
);
2429 else if (afi
== AFI_IP6
)
2431 struct attr_extra
*ae
;
2434 ae
= bgp_attr_extra_get (&attr
);
2437 str2prefix ("::/0", &p
);
2439 /* IPv6 global nexthop must be included. */
2440 memcpy (&ae
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2442 ae
->mp_nexthop_len
= 16;
2444 /* If the peer is on shared nextwork and we have link-local
2446 if (peer
->shared_network
2447 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2449 memcpy (&ae
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2451 ae
->mp_nexthop_len
= 32;
2454 #endif /* HAVE_IPV6 */
2456 if (peer
->default_rmap
[afi
][safi
].name
)
2458 binfo
.peer
= bgp
->peer_self
;
2461 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2463 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2466 bgp
->peer_self
->rmap_type
= 0;
2468 if (ret
== RMAP_DENYMATCH
)
2470 bgp_attr_flush (&attr
);
2477 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2478 bgp_default_withdraw_send (peer
, afi
, safi
);
2479 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2483 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2484 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2487 bgp_attr_extra_free (&attr
);
2488 aspath_unintern (aspath
);
2492 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2493 struct bgp_table
*table
, int rsclient
)
2495 struct bgp_node
*rn
;
2496 struct bgp_info
*ri
;
2499 memset (&attr
, 0, sizeof (struct attr
));
2502 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2504 if (safi
!= SAFI_MPLS_VPN
2505 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2506 bgp_default_originate (peer
, afi
, safi
, 0);
2508 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2509 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2510 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2513 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2514 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2515 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2517 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2519 bgp_attr_extra_free (&attr
);
2524 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2526 struct bgp_node
*rn
;
2527 struct bgp_table
*table
;
2529 if (peer
->status
!= Established
)
2532 if (! peer
->afc_nego
[afi
][safi
])
2535 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2536 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2539 if (safi
!= SAFI_MPLS_VPN
)
2540 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2542 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2543 rn
= bgp_route_next(rn
))
2544 if ((table
= (rn
->info
)) != NULL
)
2545 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2547 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2548 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2552 bgp_announce_route_all (struct peer
*peer
)
2557 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2558 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2559 bgp_announce_route (peer
, afi
, safi
);
2563 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2564 safi_t safi
, struct bgp_table
*table
)
2566 struct bgp_node
*rn
;
2567 struct bgp_adj_in
*ain
;
2570 table
= rsclient
->bgp
->rib
[afi
][safi
];
2572 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2573 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2575 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2576 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2581 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2583 struct bgp_table
*table
;
2584 struct bgp_node
*rn
;
2586 if (safi
!= SAFI_MPLS_VPN
)
2587 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2590 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2591 rn
= bgp_route_next (rn
))
2592 if ((table
= rn
->info
) != NULL
)
2593 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2597 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2598 struct bgp_table
*table
)
2601 struct bgp_node
*rn
;
2602 struct bgp_adj_in
*ain
;
2605 table
= peer
->bgp
->rib
[afi
][safi
];
2607 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2608 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2610 if (ain
->peer
== peer
)
2612 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2613 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2617 bgp_unlock_node (rn
);
2626 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2628 struct bgp_node
*rn
;
2629 struct bgp_table
*table
;
2631 if (peer
->status
!= Established
)
2634 if (safi
!= SAFI_MPLS_VPN
)
2635 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2637 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2638 rn
= bgp_route_next (rn
))
2639 if ((table
= rn
->info
) != NULL
)
2640 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2643 static wq_item_status
2644 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2646 struct bgp_node
*rn
= data
;
2647 struct peer
*peer
= wq
->spec
.data
;
2648 struct bgp_info
*ri
;
2649 afi_t afi
= rn
->table
->afi
;
2650 safi_t safi
= rn
->table
->safi
;
2652 assert (rn
&& peer
);
2654 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2655 if (ri
->peer
== peer
)
2657 /* graceful restart STALE flag set. */
2658 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2659 && peer
->nsf
[afi
][safi
]
2660 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2661 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2662 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2664 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2671 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2673 struct bgp_node
*rn
= data
;
2675 bgp_unlock_node (rn
);
2679 bgp_clear_node_complete (struct work_queue
*wq
)
2681 struct peer
*peer
= wq
->spec
.data
;
2683 peer_unlock (peer
); /* bgp_clear_node_complete */
2685 /* Tickle FSM to start moving again */
2686 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2690 bgp_clear_node_queue_init (struct peer
*peer
)
2692 #define CLEAR_QUEUE_NAME_LEN 26 /* "clear 2001:123:123:123::1" */
2693 char wname
[CLEAR_QUEUE_NAME_LEN
];
2695 snprintf (wname
, CLEAR_QUEUE_NAME_LEN
, "clear %s", peer
->host
);
2696 #undef CLEAR_QUEUE_NAME_LEN
2698 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2700 zlog_err ("%s: Failed to allocate work queue", __func__
);
2703 peer
->clear_node_queue
->spec
.hold
= 10;
2704 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2705 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2706 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2707 peer
->clear_node_queue
->spec
.max_retries
= 0;
2709 /* we only 'lock' this peer reference when the queue is actually active */
2710 peer
->clear_node_queue
->spec
.data
= peer
;
2714 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2715 struct bgp_table
*table
, struct peer
*rsclient
)
2717 struct bgp_node
*rn
;
2721 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2723 /* If still no table => afi/safi isn't configured at all or smth. */
2727 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2729 struct bgp_info
*ri
;
2730 struct bgp_adj_in
*ain
;
2731 struct bgp_adj_out
*aout
;
2733 if (rn
->info
== NULL
)
2736 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2737 * queued for every clearing peer, regardless of whether it is
2738 * relevant to the peer at hand.
2740 * Overview: There are 3 different indices which need to be
2741 * scrubbed, potentially, when a peer is removed:
2743 * 1 peer's routes visible via the RIB (ie accepted routes)
2744 * 2 peer's routes visible by the (optional) peer's adj-in index
2745 * 3 other routes visible by the peer's adj-out index
2747 * 3 there is no hurry in scrubbing, once the struct peer is
2748 * removed from bgp->peer, we could just GC such deleted peer's
2749 * adj-outs at our leisure.
2751 * 1 and 2 must be 'scrubbed' in some way, at least made
2752 * invisible via RIB index before peer session is allowed to be
2753 * brought back up. So one needs to know when such a 'search' is
2758 * - there'd be a single global queue or a single RIB walker
2759 * - rather than tracking which route_nodes still need to be
2760 * examined on a peer basis, we'd track which peers still
2763 * Given that our per-peer prefix-counts now should be reliable,
2764 * this may actually be achievable. It doesn't seem to be a huge
2765 * problem at this time,
2767 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2768 if (ri
->peer
== peer
)
2770 bgp_lock_node (rn
); /* unlocked: bgp_clear_node_queue_del */
2771 work_queue_add (peer
->clear_node_queue
, rn
);
2774 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2775 if (ain
->peer
== peer
)
2777 bgp_adj_in_remove (rn
, ain
);
2778 bgp_unlock_node (rn
);
2781 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2782 if (aout
->peer
== peer
)
2784 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2785 bgp_unlock_node (rn
);
2793 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2795 struct bgp_node
*rn
;
2796 struct bgp_table
*table
;
2797 struct peer
*rsclient
;
2798 struct listnode
*node
, *nnode
;
2800 if (peer
->clear_node_queue
== NULL
)
2801 bgp_clear_node_queue_init (peer
);
2803 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2804 * Idle until it receives a Clearing_Completed event. This protects
2805 * against peers which flap faster than we can we clear, which could
2808 * a) race with routes from the new session being installed before
2809 * clear_route_node visits the node (to delete the route of that
2811 * b) resource exhaustion, clear_route_node likely leads to an entry
2812 * on the process_main queue. Fast-flapping could cause that queue
2815 if (!peer
->clear_node_queue
->thread
)
2816 peer_lock (peer
); /* bgp_clear_node_complete */
2818 if (safi
!= SAFI_MPLS_VPN
)
2819 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
);
2821 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2822 rn
= bgp_route_next (rn
))
2823 if ((table
= rn
->info
) != NULL
)
2824 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
);
2826 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2828 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2829 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
);
2832 /* If no routes were cleared, nothing was added to workqueue, the
2833 * completion function won't be run by workqueue code - call it here.
2834 * XXX: Actually, this assumption doesn't hold, see
2835 * bgp_clear_route_table(), we queue all non-empty nodes.
2837 * Additionally, there is a presumption in FSM that clearing is only
2838 * really needed if peer state is Established - peers in
2839 * pre-Established states shouldn't have any route-update state
2840 * associated with them (in or out).
2842 * We still can get here in pre-Established though, through
2843 * peer_delete -> bgp_fsm_change_status, so this is a useful sanity
2844 * check to ensure the assumption above holds.
2846 * At some future point, this check could be move to the top of the
2847 * function, and do a quick early-return when state is
2848 * pre-Established, avoiding above list and table scans. Once we're
2851 if (!peer
->clear_node_queue
->thread
)
2852 bgp_clear_node_complete (peer
->clear_node_queue
);
2855 /* clearing queue scheduled. Normal if in Established state
2856 * (and about to transition out of it), but otherwise...
2858 if (peer
->status
!= Established
)
2860 plog_err (peer
->log
, "%s [Error] State %s is not Established,"
2861 " but routes were cleared - bug!",
2862 peer
->host
, LOOKUP (bgp_status_msg
, peer
->status
));
2863 assert (peer
->status
== Established
);
2869 bgp_clear_route_all (struct peer
*peer
)
2874 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2875 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2876 bgp_clear_route (peer
, afi
, safi
);
2880 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2882 struct bgp_table
*table
;
2883 struct bgp_node
*rn
;
2884 struct bgp_adj_in
*ain
;
2886 table
= peer
->bgp
->rib
[afi
][safi
];
2888 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2889 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2890 if (ain
->peer
== peer
)
2892 bgp_adj_in_remove (rn
, ain
);
2893 bgp_unlock_node (rn
);
2899 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2901 struct bgp_node
*rn
;
2902 struct bgp_info
*ri
;
2903 struct bgp_table
*table
;
2905 table
= peer
->bgp
->rib
[afi
][safi
];
2907 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2909 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2910 if (ri
->peer
== peer
)
2912 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2913 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2919 /* Delete all kernel routes. */
2921 bgp_cleanup_routes ()
2924 struct listnode
*node
, *nnode
;
2925 struct bgp_node
*rn
;
2926 struct bgp_table
*table
;
2927 struct bgp_info
*ri
;
2929 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2931 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2933 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2934 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2935 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2936 && ri
->type
== ZEBRA_ROUTE_BGP
2937 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2938 bgp_zebra_withdraw (&rn
->p
, ri
);
2940 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2942 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2943 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2944 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2945 && ri
->type
== ZEBRA_ROUTE_BGP
2946 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2947 bgp_zebra_withdraw (&rn
->p
, ri
);
2955 bgp_zclient_reset ();
2956 access_list_reset ();
2957 prefix_list_reset ();
2960 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2963 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
2971 /* Check peer status. */
2972 if (peer
->status
!= Established
)
2976 lim
= pnt
+ packet
->length
;
2978 for (; pnt
< lim
; pnt
+= psize
)
2980 /* Clear prefix structure. */
2981 memset (&p
, 0, sizeof (struct prefix
));
2983 /* Fetch prefix length. */
2984 p
.prefixlen
= *pnt
++;
2985 p
.family
= afi2family (packet
->afi
);
2987 /* Already checked in nlri_sanity_check(). We do double check
2989 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
2990 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
2993 /* Packet size overflow check. */
2994 psize
= PSIZE (p
.prefixlen
);
2996 /* When packet overflow occur return immediately. */
2997 if (pnt
+ psize
> lim
)
3000 /* Fetch prefix from NLRI packet. */
3001 memcpy (&p
.u
.prefix
, pnt
, psize
);
3003 /* Check address. */
3004 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
3006 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3009 * From draft-ietf-idr-bgp4-22, Section 6.3:
3010 * If a BGP router receives an UPDATE message with a
3011 * semantically incorrect NLRI field, in which a prefix is
3012 * semantically incorrect (eg. an unexpected multicast IP
3013 * address), it should ignore the prefix.
3015 zlog (peer
->log
, LOG_ERR
,
3016 "IPv4 unicast NLRI is multicast address %s",
3017 inet_ntoa (p
.u
.prefix4
));
3024 /* Check address. */
3025 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
3027 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3031 zlog (peer
->log
, LOG_WARNING
,
3032 "IPv6 link-local NLRI received %s ignore this NLRI",
3033 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3038 #endif /* HAVE_IPV6 */
3040 /* Normal process. */
3042 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3043 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3045 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3046 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3048 /* Address family configuration mismatch or maximum-prefix count
3054 /* Packet length consistency check. */
3061 /* NLRI encode syntax check routine. */
3063 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
3072 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3073 syntactic validity. If the field is syntactically incorrect,
3074 then the Error Subcode is set to Invalid Network Field. */
3080 /* Prefix length check. */
3081 if ((afi
== AFI_IP
&& prefixlen
> 32)
3082 || (afi
== AFI_IP6
&& prefixlen
> 128))
3084 plog_err (peer
->log
,
3085 "%s [Error] Update packet error (wrong prefix length %d)",
3086 peer
->host
, prefixlen
);
3087 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3088 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3092 /* Packet size overflow check. */
3093 psize
= PSIZE (prefixlen
);
3095 if (pnt
+ psize
> end
)
3097 plog_err (peer
->log
,
3098 "%s [Error] Update packet error"
3099 " (prefix data overflow prefix size is %d)",
3101 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3102 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3109 /* Packet length consistency check. */
3112 plog_err (peer
->log
,
3113 "%s [Error] Update packet error"
3114 " (prefix length mismatch with total length)",
3116 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3117 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3123 static struct bgp_static
*
3126 struct bgp_static
*new;
3127 new = XMALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3128 memset (new, 0, sizeof (struct bgp_static
));
3133 bgp_static_free (struct bgp_static
*bgp_static
)
3135 if (bgp_static
->rmap
.name
)
3136 free (bgp_static
->rmap
.name
);
3137 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3141 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
3142 struct prefix
*p
, afi_t afi
, safi_t safi
)
3144 struct bgp_node
*rn
;
3145 struct bgp_info
*ri
;
3147 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3149 /* Check selected route and self inserted route. */
3150 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3151 if (ri
->peer
== bgp
->peer_self
3152 && ri
->type
== ZEBRA_ROUTE_BGP
3153 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3156 /* Withdraw static BGP route from routing table. */
3159 bgp_info_delete (rn
, ri
);
3160 bgp_process (bgp
, rn
, afi
, safi
);
3163 /* Unlock bgp_node_lookup. */
3164 bgp_unlock_node (rn
);
3168 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
3169 struct bgp_static
*bgp_static
,
3170 afi_t afi
, safi_t safi
)
3172 struct bgp_node
*rn
;
3173 struct bgp_info
*ri
;
3174 struct bgp_info
*new;
3175 struct bgp_info info
;
3176 struct attr
*attr_new
;
3177 struct attr attr
= {0 };
3178 struct attr new_attr
= { .extra
= 0 };
3181 char buf
[SU_ADDRSTRLEN
];
3183 bgp
= rsclient
->bgp
;
3185 assert (bgp_static
);
3189 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3191 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3193 attr
.nexthop
= bgp_static
->igpnexthop
;
3194 attr
.med
= bgp_static
->igpmetric
;
3195 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3197 if (bgp_static
->ttl
)
3199 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT
);
3200 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3201 attr
.pathlimit
.as
= 0;
3202 attr
.pathlimit
.ttl
= bgp_static
->ttl
;
3205 if (bgp_static
->atomic
)
3206 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3208 /* Apply network route-map for export to this rsclient. */
3209 if (bgp_static
->rmap
.name
)
3211 struct attr attr_tmp
= attr
;
3212 info
.peer
= rsclient
;
3213 info
.attr
= &attr_tmp
;
3215 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3216 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3218 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3220 rsclient
->rmap_type
= 0;
3222 if (ret
== RMAP_DENYMATCH
)
3224 /* Free uninterned attribute. */
3225 bgp_attr_flush (&attr_tmp
);
3227 /* Unintern original. */
3228 aspath_unintern (attr
.aspath
);
3229 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3230 bgp_attr_extra_free (&attr
);
3234 attr_new
= bgp_attr_intern (&attr_tmp
);
3237 attr_new
= bgp_attr_intern (&attr
);
3239 new_attr
= *attr_new
;
3241 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3243 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
)
3246 /* This BGP update is filtered. Log the reason then update BGP entry. */
3247 if (BGP_DEBUG (update
, UPDATE_IN
))
3248 zlog (rsclient
->log
, LOG_DEBUG
,
3249 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3250 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3251 p
->prefixlen
, rsclient
->host
);
3253 bgp
->peer_self
->rmap_type
= 0;
3255 bgp_attr_unintern (attr_new
);
3256 aspath_unintern (attr
.aspath
);
3257 bgp_attr_extra_free (&attr
);
3259 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3264 bgp
->peer_self
->rmap_type
= 0;
3266 bgp_attr_unintern (attr_new
);
3267 attr_new
= bgp_attr_intern (&new_attr
);
3269 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3270 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3271 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3276 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3277 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3279 bgp_unlock_node (rn
);
3280 bgp_attr_unintern (attr_new
);
3281 aspath_unintern (attr
.aspath
);
3282 bgp_attr_extra_free (&attr
);
3287 /* The attribute is changed. */
3288 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3290 /* Rewrite BGP route information. */
3291 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3292 bgp_info_restore(rn
, ri
);
3293 bgp_attr_unintern (ri
->attr
);
3294 ri
->attr
= attr_new
;
3295 ri
->uptime
= time (NULL
);
3297 /* Process change. */
3298 bgp_process (bgp
, rn
, afi
, safi
);
3299 bgp_unlock_node (rn
);
3300 aspath_unintern (attr
.aspath
);
3301 bgp_attr_extra_free (&attr
);
3306 /* Make new BGP info. */
3307 new = bgp_info_new ();
3308 new->type
= ZEBRA_ROUTE_BGP
;
3309 new->sub_type
= BGP_ROUTE_STATIC
;
3310 new->peer
= bgp
->peer_self
;
3311 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3312 new->attr
= attr_new
;
3313 new->uptime
= time (NULL
);
3315 /* Register new BGP information. */
3316 bgp_info_add (rn
, new);
3318 /* route_node_get lock */
3319 bgp_unlock_node (rn
);
3321 /* Process change. */
3322 bgp_process (bgp
, rn
, afi
, safi
);
3324 /* Unintern original. */
3325 aspath_unintern (attr
.aspath
);
3326 bgp_attr_extra_free (&attr
);
3330 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3331 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3333 struct bgp_node
*rn
;
3334 struct bgp_info
*ri
;
3335 struct bgp_info
*new;
3336 struct bgp_info info
;
3337 struct attr attr
= { 0 };
3338 struct attr
*attr_new
;
3341 assert (bgp_static
);
3345 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3347 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3349 attr
.nexthop
= bgp_static
->igpnexthop
;
3350 attr
.med
= bgp_static
->igpmetric
;
3351 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3353 if (bgp_static
->ttl
)
3355 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT
);
3356 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3357 attr
.pathlimit
.as
= 0;
3358 attr
.pathlimit
.ttl
= bgp_static
->ttl
;
3361 if (bgp_static
->atomic
)
3362 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3364 /* Apply route-map. */
3365 if (bgp_static
->rmap
.name
)
3367 struct attr attr_tmp
= attr
;
3368 info
.peer
= bgp
->peer_self
;
3369 info
.attr
= &attr_tmp
;
3371 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3373 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3375 bgp
->peer_self
->rmap_type
= 0;
3377 if (ret
== RMAP_DENYMATCH
)
3379 /* Free uninterned attribute. */
3380 bgp_attr_flush (&attr_tmp
);
3382 /* Unintern original. */
3383 aspath_unintern (attr
.aspath
);
3384 bgp_attr_extra_free (&attr
);
3385 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3388 attr_new
= bgp_attr_intern (&attr_tmp
);
3391 attr_new
= bgp_attr_intern (&attr
);
3393 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3394 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3395 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3400 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3401 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3403 bgp_unlock_node (rn
);
3404 bgp_attr_unintern (attr_new
);
3405 aspath_unintern (attr
.aspath
);
3406 bgp_attr_extra_free (&attr
);
3411 /* The attribute is changed. */
3412 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3414 /* Rewrite BGP route information. */
3415 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3416 bgp_info_restore(rn
, ri
);
3418 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3419 bgp_attr_unintern (ri
->attr
);
3420 ri
->attr
= attr_new
;
3421 ri
->uptime
= time (NULL
);
3423 /* Process change. */
3424 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3425 bgp_process (bgp
, rn
, afi
, safi
);
3426 bgp_unlock_node (rn
);
3427 aspath_unintern (attr
.aspath
);
3428 bgp_attr_extra_free (&attr
);
3433 /* Make new BGP info. */
3434 new = bgp_info_new ();
3435 new->type
= ZEBRA_ROUTE_BGP
;
3436 new->sub_type
= BGP_ROUTE_STATIC
;
3437 new->peer
= bgp
->peer_self
;
3438 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3439 new->attr
= attr_new
;
3440 new->uptime
= time (NULL
);
3442 /* Aggregate address increment. */
3443 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3445 /* Register new BGP information. */
3446 bgp_info_add (rn
, new);
3448 /* route_node_get lock */
3449 bgp_unlock_node (rn
);
3451 /* Process change. */
3452 bgp_process (bgp
, rn
, afi
, safi
);
3454 /* Unintern original. */
3455 aspath_unintern (attr
.aspath
);
3456 bgp_attr_extra_free (&attr
);
3460 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3461 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3463 struct peer
*rsclient
;
3464 struct listnode
*node
, *nnode
;
3466 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3468 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3470 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3471 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3476 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3477 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3479 struct bgp_node
*rn
;
3480 struct bgp_info
*new;
3482 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3484 /* Make new BGP info. */
3485 new = bgp_info_new ();
3486 new->type
= ZEBRA_ROUTE_BGP
;
3487 new->sub_type
= BGP_ROUTE_STATIC
;
3488 new->peer
= bgp
->peer_self
;
3489 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3490 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3491 new->uptime
= time (NULL
);
3492 new->extra
= bgp_info_extra_new();
3493 memcpy (new->extra
->tag
, tag
, 3);
3495 /* Aggregate address increment. */
3496 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3498 /* Register new BGP information. */
3499 bgp_info_add (rn
, new);
3501 /* route_node_get lock */
3502 bgp_unlock_node (rn
);
3504 /* Process change. */
3505 bgp_process (bgp
, rn
, afi
, safi
);
3509 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3512 struct bgp_node
*rn
;
3513 struct bgp_info
*ri
;
3515 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3517 /* Check selected route and self inserted route. */
3518 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3519 if (ri
->peer
== bgp
->peer_self
3520 && ri
->type
== ZEBRA_ROUTE_BGP
3521 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3524 /* Withdraw static BGP route from routing table. */
3527 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3528 bgp_info_delete (rn
, ri
);
3529 bgp_process (bgp
, rn
, afi
, safi
);
3532 /* Unlock bgp_node_lookup. */
3533 bgp_unlock_node (rn
);
3537 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3539 struct bgp_static
*bgp_static
;
3541 struct bgp_node
*rn
;
3544 bgp
= rsclient
->bgp
;
3546 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3547 if ((bgp_static
= rn
->info
) != NULL
)
3551 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3557 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3558 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3560 struct bgp_node
*rn
;
3561 struct bgp_info
*ri
;
3563 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3565 /* Check selected route and self inserted route. */
3566 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3567 if (ri
->peer
== bgp
->peer_self
3568 && ri
->type
== ZEBRA_ROUTE_BGP
3569 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3572 /* Withdraw static BGP route from routing table. */
3575 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3576 bgp_info_delete (rn
, ri
);
3577 bgp_process (bgp
, rn
, afi
, safi
);
3580 /* Unlock bgp_node_lookup. */
3581 bgp_unlock_node (rn
);
3585 bgp_pathlimit_update_parents (struct bgp
*bgp
, struct bgp_node
*rn
,
3588 struct bgp_node
*parent
= rn
;
3589 struct bgp_static
*sp
;
3591 /* Existing static changed TTL, search parents and adjust their atomic */
3592 while ((parent
= parent
->parent
))
3593 if ((sp
= parent
->info
))
3595 int sp_level
= (sp
->atomic
? 1 : 0);
3596 ttl_edge
? sp
->atomic
++ : sp
->atomic
--;
3598 /* did we change state of parent whether atomic is set or not? */
3599 if (sp_level
!= (sp
->atomic
? 1 : 0))
3601 bgp_static_update (bgp
, &parent
->p
, sp
,
3602 rn
->table
->afi
, rn
->table
->safi
);
3607 /* Configure static BGP network. When user don't run zebra, static
3608 route should be installed as valid. */
3610 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3611 u_int16_t afi
, u_char safi
, const char *rmap
, int backdoor
,
3616 struct bgp_static
*bgp_static
;
3617 struct bgp_node
*rn
;
3618 u_char need_update
= 0;
3619 u_char ttl_change
= 0;
3620 u_char ttl_edge
= (ttl
? 1 : 0);
3623 /* Convert IP prefix string to struct prefix. */
3624 ret
= str2prefix (ip_str
, &p
);
3627 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3631 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3633 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3637 #endif /* HAVE_IPV6 */
3641 /* Set BGP static route configuration. */
3642 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3646 /* Configuration change. */
3647 bgp_static
= rn
->info
;
3649 /* Check previous routes are installed into BGP. */
3650 if (bgp_static
->valid
)
3652 if (bgp_static
->backdoor
!= backdoor
3653 || bgp_static
->ttl
!= ttl
)
3657 /* need to catch TTL set/unset transitions for handling of
3660 if ((bgp_static
->ttl
? 1 : 0) != ttl_edge
)
3663 bgp_static
->backdoor
= backdoor
;
3664 bgp_static
->ttl
= ttl
;
3668 if (bgp_static
->rmap
.name
)
3669 free (bgp_static
->rmap
.name
);
3670 bgp_static
->rmap
.name
= strdup (rmap
);
3671 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3675 if (bgp_static
->rmap
.name
)
3676 free (bgp_static
->rmap
.name
);
3677 bgp_static
->rmap
.name
= NULL
;
3678 bgp_static
->rmap
.map
= NULL
;
3679 bgp_static
->valid
= 0;
3681 bgp_unlock_node (rn
);
3685 /* New configuration. */
3686 bgp_static
= bgp_static_new ();
3687 bgp_static
->backdoor
= backdoor
;
3688 bgp_static
->valid
= 0;
3689 bgp_static
->igpmetric
= 0;
3690 bgp_static
->igpnexthop
.s_addr
= 0;
3691 bgp_static
->ttl
= ttl
;
3692 ttl_change
= ttl_edge
;
3697 if (bgp_static
->rmap
.name
)
3698 free (bgp_static
->rmap
.name
);
3699 bgp_static
->rmap
.name
= strdup (rmap
);
3700 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3702 rn
->info
= bgp_static
;
3705 /* ".. sites that choose to advertise the
3706 * AS_PATHLIMIT path attribute SHOULD advertise the ATOMIC_AGGREGATE on
3707 * all less specific covering prefixes as well as the more specific
3711 * Prefix that has just had pathlimit set/unset:
3712 * - Must bump ATOMIC refcount on all parents.
3714 * To catch less specific prefixes:
3715 * - Must search children for ones with TTL, bump atomic refcount
3716 * (we dont care if we're deleting a less specific prefix..)
3720 /* Existing static changed TTL, search parents and adjust their atomic */
3721 bgp_pathlimit_update_parents (bgp
, rn
, ttl_edge
);
3726 struct bgp_node
*child
;
3727 struct bgp_static
*sc
;
3729 /* New static, search children and bump this statics atomic.. */
3730 child
= bgp_lock_node (rn
); /* route_next_until unlocks it.. */
3731 while ((child
= bgp_route_next_until (child
, rn
)))
3733 if ((sc
= child
->info
) && sc
->ttl
)
3734 bgp_static
->atomic
++;
3738 /* If BGP scan is not enabled, we should install this route here. */
3739 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3741 bgp_static
->valid
= 1;
3744 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3746 if (! bgp_static
->backdoor
)
3747 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3753 /* Configure static BGP network. */
3755 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3756 u_int16_t afi
, u_char safi
)
3760 struct bgp_static
*bgp_static
;
3761 struct bgp_node
*rn
;
3763 /* Convert IP prefix string to struct prefix. */
3764 ret
= str2prefix (ip_str
, &p
);
3767 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3771 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3773 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3777 #endif /* HAVE_IPV6 */
3781 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3784 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3789 bgp_static
= rn
->info
;
3791 /* decrement atomic in parents, see bgp_static_set */
3792 bgp_pathlimit_update_parents (bgp
, rn
, 0);
3794 /* Update BGP RIB. */
3795 if (! bgp_static
->backdoor
)
3796 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3798 /* Clear configuration. */
3799 bgp_static_free (bgp_static
);
3801 bgp_unlock_node (rn
);
3802 bgp_unlock_node (rn
);
3807 /* Called from bgp_delete(). Delete all static routes from the BGP
3810 bgp_static_delete (struct bgp
*bgp
)
3814 struct bgp_node
*rn
;
3815 struct bgp_node
*rm
;
3816 struct bgp_table
*table
;
3817 struct bgp_static
*bgp_static
;
3819 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3820 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3821 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3822 if (rn
->info
!= NULL
)
3824 if (safi
== SAFI_MPLS_VPN
)
3828 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3830 bgp_static
= rn
->info
;
3831 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3832 AFI_IP
, SAFI_MPLS_VPN
,
3833 (struct prefix_rd
*)&rn
->p
,
3835 bgp_static_free (bgp_static
);
3837 bgp_unlock_node (rn
);
3842 bgp_static
= rn
->info
;
3843 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3844 bgp_static_free (bgp_static
);
3846 bgp_unlock_node (rn
);
3852 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3853 const char *tag_str
)
3857 struct prefix_rd prd
;
3859 struct bgp_node
*prn
;
3860 struct bgp_node
*rn
;
3861 struct bgp_table
*table
;
3862 struct bgp_static
*bgp_static
;
3867 ret
= str2prefix (ip_str
, &p
);
3870 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3875 ret
= str2prefix_rd (rd_str
, &prd
);
3878 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3882 ret
= str2tag (tag_str
, tag
);
3885 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3889 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3890 (struct prefix
*)&prd
);
3891 if (prn
->info
== NULL
)
3892 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3894 bgp_unlock_node (prn
);
3897 rn
= bgp_node_get (table
, &p
);
3901 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3902 bgp_unlock_node (rn
);
3906 /* New configuration. */
3907 bgp_static
= bgp_static_new ();
3908 bgp_static
->valid
= 1;
3909 memcpy (bgp_static
->tag
, tag
, 3);
3910 rn
->info
= bgp_static
;
3912 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3918 /* Configure static BGP network. */
3920 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3921 const char *rd_str
, const char *tag_str
)
3926 struct prefix_rd prd
;
3927 struct bgp_node
*prn
;
3928 struct bgp_node
*rn
;
3929 struct bgp_table
*table
;
3930 struct bgp_static
*bgp_static
;
3935 /* Convert IP prefix string to struct prefix. */
3936 ret
= str2prefix (ip_str
, &p
);
3939 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3944 ret
= str2prefix_rd (rd_str
, &prd
);
3947 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3951 ret
= str2tag (tag_str
, tag
);
3954 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3958 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3959 (struct prefix
*)&prd
);
3960 if (prn
->info
== NULL
)
3961 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3963 bgp_unlock_node (prn
);
3966 rn
= bgp_node_lookup (table
, &p
);
3970 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3972 bgp_static
= rn
->info
;
3973 bgp_static_free (bgp_static
);
3975 bgp_unlock_node (rn
);
3976 bgp_unlock_node (rn
);
3979 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3986 "network A.B.C.D/M",
3987 "Specify a network to announce via BGP\n"
3988 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3993 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
3995 return bgp_static_set (vty
, vty
->index
, argv
[0],
3996 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4000 bgp_network_ttl_cmd
,
4001 "network A.B.C.D/M pathlimit <0-255>",
4002 "Specify a network to announce via BGP\n"
4003 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4004 "AS-Path hopcount limit attribute\n"
4005 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4007 DEFUN (bgp_network_route_map
,
4008 bgp_network_route_map_cmd
,
4009 "network A.B.C.D/M route-map WORD",
4010 "Specify a network to announce via BGP\n"
4011 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4012 "Route-map to modify the attributes\n"
4013 "Name of the route map\n")
4015 return bgp_static_set (vty
, vty
->index
, argv
[0],
4016 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0, 0);
4019 DEFUN (bgp_network_backdoor
,
4020 bgp_network_backdoor_cmd
,
4021 "network A.B.C.D/M backdoor",
4022 "Specify a network to announce via BGP\n"
4023 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4024 "Specify a BGP backdoor route\n")
4029 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4031 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4035 ALIAS (bgp_network_backdoor
,
4036 bgp_network_backdoor_ttl_cmd
,
4037 "network A.B.C.D/M backdoor pathlimit <0-255>",
4038 "Specify a network to announce via BGP\n"
4039 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4040 "Specify a BGP backdoor route\n"
4041 "AS-Path hopcount limit attribute\n"
4042 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4044 DEFUN (bgp_network_mask
,
4045 bgp_network_mask_cmd
,
4046 "network A.B.C.D mask A.B.C.D",
4047 "Specify a network to announce via BGP\n"
4053 char prefix_str
[BUFSIZ
];
4057 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[2], 1, 255);
4059 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4062 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4066 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4067 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4070 ALIAS (bgp_network_mask
,
4071 bgp_network_mask_ttl_cmd
,
4072 "network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4073 "Specify a network to announce via BGP\n"
4077 "AS-Path hopcount limit attribute\n"
4078 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4080 DEFUN (bgp_network_mask_route_map
,
4081 bgp_network_mask_route_map_cmd
,
4082 "network A.B.C.D mask A.B.C.D route-map WORD",
4083 "Specify a network to announce via BGP\n"
4087 "Route-map to modify the attributes\n"
4088 "Name of the route map\n")
4091 char prefix_str
[BUFSIZ
];
4093 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4096 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4100 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4101 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0, 0);
4104 DEFUN (bgp_network_mask_backdoor
,
4105 bgp_network_mask_backdoor_cmd
,
4106 "network A.B.C.D mask A.B.C.D backdoor",
4107 "Specify a network to announce via BGP\n"
4111 "Specify a BGP backdoor route\n")
4114 char prefix_str
[BUFSIZ
];
4118 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[2], 1, 255);
4120 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4123 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4127 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4131 ALIAS (bgp_network_mask_backdoor
,
4132 bgp_network_mask_backdoor_ttl_cmd
,
4133 "network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4134 "Specify a network to announce via BGP\n"
4138 "Specify a BGP backdoor route\n"
4139 "AS-Path hopcount limit attribute\n"
4140 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4142 DEFUN (bgp_network_mask_natural
,
4143 bgp_network_mask_natural_cmd
,
4145 "Specify a network to announce via BGP\n"
4149 char prefix_str
[BUFSIZ
];
4153 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4155 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4158 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4162 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4163 AFI_IP
, bgp_node_safi (vty
), NULL
, 0, ttl
);
4166 ALIAS (bgp_network_mask_natural
,
4167 bgp_network_mask_natural_ttl_cmd
,
4168 "network A.B.C.D pathlimit <0-255>",
4169 "Specify a network to announce via BGP\n"
4171 "AS-Path hopcount limit attribute\n"
4172 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4174 DEFUN (bgp_network_mask_natural_route_map
,
4175 bgp_network_mask_natural_route_map_cmd
,
4176 "network A.B.C.D route-map WORD",
4177 "Specify a network to announce via BGP\n"
4179 "Route-map to modify the attributes\n"
4180 "Name of the route map\n")
4183 char prefix_str
[BUFSIZ
];
4185 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4188 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4192 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4193 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0, 0);
4196 DEFUN (bgp_network_mask_natural_backdoor
,
4197 bgp_network_mask_natural_backdoor_cmd
,
4198 "network A.B.C.D backdoor",
4199 "Specify a network to announce via BGP\n"
4201 "Specify a BGP backdoor route\n")
4204 char prefix_str
[BUFSIZ
];
4208 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4210 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4213 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4217 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4221 ALIAS (bgp_network_mask_natural_backdoor
,
4222 bgp_network_mask_natural_backdoor_ttl_cmd
,
4223 "network A.B.C.D backdoor pathlimit (1-255>",
4224 "Specify a network to announce via BGP\n"
4226 "Specify a BGP backdoor route\n"
4227 "AS-Path hopcount limit attribute\n"
4228 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4230 DEFUN (no_bgp_network
,
4232 "no network A.B.C.D/M",
4234 "Specify a network to announce via BGP\n"
4235 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4237 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4238 bgp_node_safi (vty
));
4241 ALIAS (no_bgp_network
,
4242 no_bgp_network_ttl_cmd
,
4243 "no network A.B.C.D/M pathlimit <0-255>",
4245 "Specify a network to announce via BGP\n"
4246 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4247 "AS-Path hopcount limit attribute\n"
4248 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4250 ALIAS (no_bgp_network
,
4251 no_bgp_network_route_map_cmd
,
4252 "no network A.B.C.D/M route-map WORD",
4254 "Specify a network to announce via BGP\n"
4255 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4256 "Route-map to modify the attributes\n"
4257 "Name of the route map\n")
4259 ALIAS (no_bgp_network
,
4260 no_bgp_network_backdoor_cmd
,
4261 "no network A.B.C.D/M backdoor",
4263 "Specify a network to announce via BGP\n"
4264 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4265 "Specify a BGP backdoor route\n")
4267 ALIAS (no_bgp_network
,
4268 no_bgp_network_backdoor_ttl_cmd
,
4269 "no network A.B.C.D/M backdoor pathlimit <0-255>",
4271 "Specify a network to announce via BGP\n"
4272 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4273 "Specify a BGP backdoor route\n"
4274 "AS-Path hopcount limit attribute\n"
4275 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4277 DEFUN (no_bgp_network_mask
,
4278 no_bgp_network_mask_cmd
,
4279 "no network A.B.C.D mask A.B.C.D",
4281 "Specify a network to announce via BGP\n"
4287 char prefix_str
[BUFSIZ
];
4289 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4292 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4296 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4297 bgp_node_safi (vty
));
4300 ALIAS (no_bgp_network
,
4301 no_bgp_network_mask_ttl_cmd
,
4302 "no network A.B.C.D mask A.B.C.D pathlimit <0-255>",
4304 "Specify a network to announce via BGP\n"
4308 "AS-Path hopcount limit attribute\n"
4309 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4311 ALIAS (no_bgp_network_mask
,
4312 no_bgp_network_mask_route_map_cmd
,
4313 "no network A.B.C.D mask A.B.C.D route-map WORD",
4315 "Specify a network to announce via BGP\n"
4319 "Route-map to modify the attributes\n"
4320 "Name of the route map\n")
4322 ALIAS (no_bgp_network_mask
,
4323 no_bgp_network_mask_backdoor_cmd
,
4324 "no network A.B.C.D mask A.B.C.D backdoor",
4326 "Specify a network to announce via BGP\n"
4330 "Specify a BGP backdoor route\n")
4332 ALIAS (no_bgp_network_mask
,
4333 no_bgp_network_mask_backdoor_ttl_cmd
,
4334 "no network A.B.C.D mask A.B.C.D backdoor pathlimit <0-255>",
4336 "Specify a network to announce via BGP\n"
4340 "Specify a BGP backdoor route\n"
4341 "AS-Path hopcount limit attribute\n"
4342 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4344 DEFUN (no_bgp_network_mask_natural
,
4345 no_bgp_network_mask_natural_cmd
,
4346 "no network A.B.C.D",
4348 "Specify a network to announce via BGP\n"
4352 char prefix_str
[BUFSIZ
];
4354 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4357 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4361 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4362 bgp_node_safi (vty
));
4365 ALIAS (no_bgp_network_mask_natural
,
4366 no_bgp_network_mask_natural_route_map_cmd
,
4367 "no network A.B.C.D route-map WORD",
4369 "Specify a network to announce via BGP\n"
4371 "Route-map to modify the attributes\n"
4372 "Name of the route map\n")
4374 ALIAS (no_bgp_network_mask_natural
,
4375 no_bgp_network_mask_natural_backdoor_cmd
,
4376 "no network A.B.C.D backdoor",
4378 "Specify a network to announce via BGP\n"
4380 "Specify a BGP backdoor route\n")
4382 ALIAS (no_bgp_network_mask_natural
,
4383 no_bgp_network_mask_natural_ttl_cmd
,
4384 "no network A.B.C.D pathlimit <0-255>",
4386 "Specify a network to announce via BGP\n"
4388 "AS-Path hopcount limit attribute\n"
4389 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4391 ALIAS (no_bgp_network_mask_natural
,
4392 no_bgp_network_mask_natural_backdoor_ttl_cmd
,
4393 "no network A.B.C.D backdoor pathlimit <0-255>",
4395 "Specify a network to announce via BGP\n"
4397 "Specify a BGP backdoor route\n"
4398 "AS-Path hopcount limit attribute\n"
4399 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4402 DEFUN (ipv6_bgp_network
,
4403 ipv6_bgp_network_cmd
,
4404 "network X:X::X:X/M",
4405 "Specify a network to announce via BGP\n"
4406 "IPv6 prefix <network>/<length>\n")
4411 VTY_GET_INTEGER_RANGE ("Pathlimit TTL", ttl
, argv
[1], 1, 255);
4413 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4417 ALIAS (ipv6_bgp_network
,
4418 ipv6_bgp_network_ttl_cmd
,
4419 "network X:X::X:X/M pathlimit <0-255>",
4420 "Specify a network to announce via BGP\n"
4421 "IPv6 prefix <network>/<length>\n"
4422 "AS-Path hopcount limit attribute\n"
4423 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4425 DEFUN (ipv6_bgp_network_route_map
,
4426 ipv6_bgp_network_route_map_cmd
,
4427 "network X:X::X:X/M route-map WORD",
4428 "Specify a network to announce via BGP\n"
4429 "IPv6 prefix <network>/<length>\n"
4430 "Route-map to modify the attributes\n"
4431 "Name of the route map\n")
4433 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4434 bgp_node_safi (vty
), argv
[1], 0, 0);
4437 DEFUN (no_ipv6_bgp_network
,
4438 no_ipv6_bgp_network_cmd
,
4439 "no network X:X::X:X/M",
4441 "Specify a network to announce via BGP\n"
4442 "IPv6 prefix <network>/<length>\n")
4444 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4447 ALIAS (no_ipv6_bgp_network
,
4448 no_ipv6_bgp_network_route_map_cmd
,
4449 "no network X:X::X:X/M route-map WORD",
4451 "Specify a network to announce via BGP\n"
4452 "IPv6 prefix <network>/<length>\n"
4453 "Route-map to modify the attributes\n"
4454 "Name of the route map\n")
4456 ALIAS (no_ipv6_bgp_network
,
4457 no_ipv6_bgp_network_ttl_cmd
,
4458 "no network X:X::X:X/M pathlimit <0-255>",
4460 "Specify a network to announce via BGP\n"
4461 "IPv6 prefix <network>/<length>\n"
4462 "AS-Path hopcount limit attribute\n"
4463 "AS-Pathlimit TTL, in number of AS-Path hops\n")
4465 ALIAS (ipv6_bgp_network
,
4466 old_ipv6_bgp_network_cmd
,
4467 "ipv6 bgp network X:X::X:X/M",
4470 "Specify a network to announce via BGP\n"
4471 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4473 ALIAS (no_ipv6_bgp_network
,
4474 old_no_ipv6_bgp_network_cmd
,
4475 "no ipv6 bgp network X:X::X:X/M",
4479 "Specify a network to announce via BGP\n"
4480 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4481 #endif /* HAVE_IPV6 */
4483 /* Aggreagete address:
4485 advertise-map Set condition to advertise attribute
4486 as-set Generate AS set path information
4487 attribute-map Set attributes of aggregate
4488 route-map Set parameters of aggregate
4489 summary-only Filter more specific routes from updates
4490 suppress-map Conditionally filter more specific routes from updates
4493 struct bgp_aggregate
4495 /* Summary-only flag. */
4496 u_char summary_only
;
4498 /* AS set generation. */
4501 /* Route-map for aggregated route. */
4502 struct route_map
*map
;
4504 /* Suppress-count. */
4505 unsigned long count
;
4507 /* SAFI configuration. */
4511 static struct bgp_aggregate
*
4512 bgp_aggregate_new ()
4514 struct bgp_aggregate
*new;
4515 new = XMALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4516 memset (new, 0, sizeof (struct bgp_aggregate
));
4521 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4523 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4527 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4528 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4529 struct bgp_aggregate
*aggregate
)
4531 struct bgp_table
*table
;
4532 struct bgp_node
*top
;
4533 struct bgp_node
*rn
;
4535 struct aspath
*aspath
= NULL
;
4536 struct aspath
*asmerge
= NULL
;
4537 struct community
*community
= NULL
;
4538 struct community
*commerge
= NULL
;
4539 struct in_addr nexthop
;
4541 struct bgp_info
*ri
;
4542 struct bgp_info
*new;
4544 unsigned long match
= 0;
4546 /* Record adding route's nexthop and med. */
4549 nexthop
= rinew
->attr
->nexthop
;
4550 med
= rinew
->attr
->med
;
4553 /* ORIGIN attribute: If at least one route among routes that are
4554 aggregated has ORIGIN with the value INCOMPLETE, then the
4555 aggregated route must have the ORIGIN attribute with the value
4556 INCOMPLETE. Otherwise, if at least one route among routes that
4557 are aggregated has ORIGIN with the value EGP, then the aggregated
4558 route must have the origin attribute with the value EGP. In all
4559 other case the value of the ORIGIN attribute of the aggregated
4560 route is INTERNAL. */
4561 origin
= BGP_ORIGIN_IGP
;
4563 table
= bgp
->rib
[afi
][safi
];
4565 top
= bgp_node_get (table
, p
);
4566 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4567 if (rn
->p
.prefixlen
> p
->prefixlen
)
4571 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4573 if (BGP_INFO_HOLDDOWN (ri
))
4576 if (del
&& ri
== del
)
4579 if (! rinew
&& first
)
4581 nexthop
= ri
->attr
->nexthop
;
4582 med
= ri
->attr
->med
;
4586 #ifdef AGGREGATE_NEXTHOP_CHECK
4587 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4588 || ri
->attr
->med
!= med
)
4591 aspath_free (aspath
);
4593 community_free (community
);
4594 bgp_unlock_node (rn
);
4595 bgp_unlock_node (top
);
4598 #endif /* AGGREGATE_NEXTHOP_CHECK */
4600 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4602 if (aggregate
->summary_only
)
4604 (bgp_info_extra_get (ri
))->suppress
++;
4605 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4611 if (aggregate
->as_set
)
4613 if (origin
< ri
->attr
->origin
)
4614 origin
= ri
->attr
->origin
;
4618 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4619 aspath_free (aspath
);
4623 aspath
= aspath_dup (ri
->attr
->aspath
);
4625 if (ri
->attr
->community
)
4629 commerge
= community_merge (community
,
4630 ri
->attr
->community
);
4631 community
= community_uniq_sort (commerge
);
4632 community_free (commerge
);
4635 community
= community_dup (ri
->attr
->community
);
4641 bgp_process (bgp
, rn
, afi
, safi
);
4643 bgp_unlock_node (top
);
4649 if (aggregate
->summary_only
)
4650 (bgp_info_extra_get (rinew
))->suppress
++;
4652 if (aggregate
->as_set
)
4654 if (origin
< rinew
->attr
->origin
)
4655 origin
= rinew
->attr
->origin
;
4659 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4660 aspath_free (aspath
);
4664 aspath
= aspath_dup (rinew
->attr
->aspath
);
4666 if (rinew
->attr
->community
)
4670 commerge
= community_merge (community
,
4671 rinew
->attr
->community
);
4672 community
= community_uniq_sort (commerge
);
4673 community_free (commerge
);
4676 community
= community_dup (rinew
->attr
->community
);
4681 if (aggregate
->count
> 0)
4683 rn
= bgp_node_get (table
, p
);
4684 new = bgp_info_new ();
4685 new->type
= ZEBRA_ROUTE_BGP
;
4686 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4687 new->peer
= bgp
->peer_self
;
4688 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4689 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4690 new->uptime
= time (NULL
);
4692 bgp_info_add (rn
, new);
4693 bgp_unlock_node (rn
);
4694 bgp_process (bgp
, rn
, afi
, safi
);
4699 aspath_free (aspath
);
4701 community_free (community
);
4705 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4706 struct bgp_aggregate
*);
4709 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4710 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4712 struct bgp_node
*child
;
4713 struct bgp_node
*rn
;
4714 struct bgp_aggregate
*aggregate
;
4716 /* MPLS-VPN aggregation is not yet supported. */
4717 if (safi
== SAFI_MPLS_VPN
)
4720 if (p
->prefixlen
== 0)
4723 if (BGP_INFO_HOLDDOWN (ri
))
4726 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4728 /* Aggregate address configuration check. */
4729 for (rn
= child
; rn
; rn
= rn
->parent
)
4730 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4732 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4733 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4735 bgp_unlock_node (child
);
4739 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4740 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4742 struct bgp_node
*child
;
4743 struct bgp_node
*rn
;
4744 struct bgp_aggregate
*aggregate
;
4746 /* MPLS-VPN aggregation is not yet supported. */
4747 if (safi
== SAFI_MPLS_VPN
)
4750 if (p
->prefixlen
== 0)
4753 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4755 /* Aggregate address configuration check. */
4756 for (rn
= child
; rn
; rn
= rn
->parent
)
4757 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4759 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4760 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4762 bgp_unlock_node (child
);
4766 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4767 struct bgp_aggregate
*aggregate
)
4769 struct bgp_table
*table
;
4770 struct bgp_node
*top
;
4771 struct bgp_node
*rn
;
4772 struct bgp_info
*new;
4773 struct bgp_info
*ri
;
4774 unsigned long match
;
4775 u_char origin
= BGP_ORIGIN_IGP
;
4776 struct aspath
*aspath
= NULL
;
4777 struct aspath
*asmerge
= NULL
;
4778 struct community
*community
= NULL
;
4779 struct community
*commerge
= NULL
;
4781 table
= bgp
->rib
[afi
][safi
];
4784 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4786 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4789 /* If routes exists below this node, generate aggregate routes. */
4790 top
= bgp_node_get (table
, p
);
4791 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4792 if (rn
->p
.prefixlen
> p
->prefixlen
)
4796 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4798 if (BGP_INFO_HOLDDOWN (ri
))
4801 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4803 /* summary-only aggregate route suppress aggregated
4804 route announcement. */
4805 if (aggregate
->summary_only
)
4807 (bgp_info_extra_get (ri
))->suppress
++;
4808 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4811 /* as-set aggregate route generate origin, as path,
4812 community aggregation. */
4813 if (aggregate
->as_set
)
4815 if (origin
< ri
->attr
->origin
)
4816 origin
= ri
->attr
->origin
;
4820 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4821 aspath_free (aspath
);
4825 aspath
= aspath_dup (ri
->attr
->aspath
);
4827 if (ri
->attr
->community
)
4831 commerge
= community_merge (community
,
4832 ri
->attr
->community
);
4833 community
= community_uniq_sort (commerge
);
4834 community_free (commerge
);
4837 community
= community_dup (ri
->attr
->community
);
4844 /* If this node is suppressed, process the change. */
4846 bgp_process (bgp
, rn
, afi
, safi
);
4848 bgp_unlock_node (top
);
4850 /* Add aggregate route to BGP table. */
4851 if (aggregate
->count
)
4853 rn
= bgp_node_get (table
, p
);
4855 new = bgp_info_new ();
4856 new->type
= ZEBRA_ROUTE_BGP
;
4857 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4858 new->peer
= bgp
->peer_self
;
4859 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4860 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4861 new->uptime
= time (NULL
);
4863 bgp_info_add (rn
, new);
4864 bgp_unlock_node (rn
);
4866 /* Process change. */
4867 bgp_process (bgp
, rn
, afi
, safi
);
4872 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4873 safi_t safi
, struct bgp_aggregate
*aggregate
)
4875 struct bgp_table
*table
;
4876 struct bgp_node
*top
;
4877 struct bgp_node
*rn
;
4878 struct bgp_info
*ri
;
4879 unsigned long match
;
4881 table
= bgp
->rib
[afi
][safi
];
4883 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4885 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4888 /* If routes exists below this node, generate aggregate routes. */
4889 top
= bgp_node_get (table
, p
);
4890 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4891 if (rn
->p
.prefixlen
> p
->prefixlen
)
4895 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4897 if (BGP_INFO_HOLDDOWN (ri
))
4900 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4902 if (aggregate
->summary_only
&& ri
->extra
)
4904 ri
->extra
->suppress
--;
4906 if (ri
->extra
->suppress
== 0)
4908 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4916 /* If this node was suppressed, process the change. */
4918 bgp_process (bgp
, rn
, afi
, safi
);
4920 bgp_unlock_node (top
);
4922 /* Delete aggregate route from BGP table. */
4923 rn
= bgp_node_get (table
, p
);
4925 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4926 if (ri
->peer
== bgp
->peer_self
4927 && ri
->type
== ZEBRA_ROUTE_BGP
4928 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4931 /* Withdraw static BGP route from routing table. */
4934 bgp_info_delete (rn
, ri
);
4935 bgp_process (bgp
, rn
, afi
, safi
);
4938 /* Unlock bgp_node_lookup. */
4939 bgp_unlock_node (rn
);
4942 /* Aggregate route attribute. */
4943 #define AGGREGATE_SUMMARY_ONLY 1
4944 #define AGGREGATE_AS_SET 1
4947 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4948 afi_t afi
, safi_t safi
,
4949 u_char summary_only
, u_char as_set
)
4953 struct bgp_node
*rn
;
4955 struct bgp_aggregate
*aggregate
;
4957 /* Convert string to prefix structure. */
4958 ret
= str2prefix (prefix_str
, &p
);
4961 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4966 /* Get BGP structure. */
4969 /* Old configuration check. */
4970 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4974 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4975 bgp_unlock_node (rn
);
4979 /* Make aggregate address structure. */
4980 aggregate
= bgp_aggregate_new ();
4981 aggregate
->summary_only
= summary_only
;
4982 aggregate
->as_set
= as_set
;
4983 aggregate
->safi
= safi
;
4984 rn
->info
= aggregate
;
4986 /* Aggregate address insert into BGP routing table. */
4987 if (safi
& SAFI_UNICAST
)
4988 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4989 if (safi
& SAFI_MULTICAST
)
4990 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4996 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4997 afi_t afi
, safi_t safi
)
5001 struct bgp_node
*rn
;
5003 struct bgp_aggregate
*aggregate
;
5005 /* Convert string to prefix structure. */
5006 ret
= str2prefix (prefix_str
, &p
);
5009 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5014 /* Get BGP structure. */
5017 /* Old configuration check. */
5018 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5021 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5026 aggregate
= rn
->info
;
5027 if (aggregate
->safi
& SAFI_UNICAST
)
5028 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5029 if (aggregate
->safi
& SAFI_MULTICAST
)
5030 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5032 /* Unlock aggregate address configuration. */
5034 bgp_aggregate_free (aggregate
);
5035 bgp_unlock_node (rn
);
5036 bgp_unlock_node (rn
);
5041 DEFUN (aggregate_address
,
5042 aggregate_address_cmd
,
5043 "aggregate-address A.B.C.D/M",
5044 "Configure BGP aggregate entries\n"
5045 "Aggregate prefix\n")
5047 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5050 DEFUN (aggregate_address_mask
,
5051 aggregate_address_mask_cmd
,
5052 "aggregate-address A.B.C.D A.B.C.D",
5053 "Configure BGP aggregate entries\n"
5054 "Aggregate address\n"
5058 char prefix_str
[BUFSIZ
];
5060 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5064 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5068 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5072 DEFUN (aggregate_address_summary_only
,
5073 aggregate_address_summary_only_cmd
,
5074 "aggregate-address A.B.C.D/M summary-only",
5075 "Configure BGP aggregate entries\n"
5076 "Aggregate prefix\n"
5077 "Filter more specific routes from updates\n")
5079 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5080 AGGREGATE_SUMMARY_ONLY
, 0);
5083 DEFUN (aggregate_address_mask_summary_only
,
5084 aggregate_address_mask_summary_only_cmd
,
5085 "aggregate-address A.B.C.D A.B.C.D summary-only",
5086 "Configure BGP aggregate entries\n"
5087 "Aggregate address\n"
5089 "Filter more specific routes from updates\n")
5092 char prefix_str
[BUFSIZ
];
5094 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5098 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5102 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5103 AGGREGATE_SUMMARY_ONLY
, 0);
5106 DEFUN (aggregate_address_as_set
,
5107 aggregate_address_as_set_cmd
,
5108 "aggregate-address A.B.C.D/M as-set",
5109 "Configure BGP aggregate entries\n"
5110 "Aggregate prefix\n"
5111 "Generate AS set path information\n")
5113 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5114 0, AGGREGATE_AS_SET
);
5117 DEFUN (aggregate_address_mask_as_set
,
5118 aggregate_address_mask_as_set_cmd
,
5119 "aggregate-address A.B.C.D A.B.C.D as-set",
5120 "Configure BGP aggregate entries\n"
5121 "Aggregate address\n"
5123 "Generate AS set path information\n")
5126 char prefix_str
[BUFSIZ
];
5128 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5132 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5136 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5137 0, AGGREGATE_AS_SET
);
5141 DEFUN (aggregate_address_as_set_summary
,
5142 aggregate_address_as_set_summary_cmd
,
5143 "aggregate-address A.B.C.D/M as-set summary-only",
5144 "Configure BGP aggregate entries\n"
5145 "Aggregate prefix\n"
5146 "Generate AS set path information\n"
5147 "Filter more specific routes from updates\n")
5149 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5150 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5153 ALIAS (aggregate_address_as_set_summary
,
5154 aggregate_address_summary_as_set_cmd
,
5155 "aggregate-address A.B.C.D/M summary-only as-set",
5156 "Configure BGP aggregate entries\n"
5157 "Aggregate prefix\n"
5158 "Filter more specific routes from updates\n"
5159 "Generate AS set path information\n")
5161 DEFUN (aggregate_address_mask_as_set_summary
,
5162 aggregate_address_mask_as_set_summary_cmd
,
5163 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5164 "Configure BGP aggregate entries\n"
5165 "Aggregate address\n"
5167 "Generate AS set path information\n"
5168 "Filter more specific routes from updates\n")
5171 char prefix_str
[BUFSIZ
];
5173 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5177 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5181 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5182 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5185 ALIAS (aggregate_address_mask_as_set_summary
,
5186 aggregate_address_mask_summary_as_set_cmd
,
5187 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5188 "Configure BGP aggregate entries\n"
5189 "Aggregate address\n"
5191 "Filter more specific routes from updates\n"
5192 "Generate AS set path information\n")
5194 DEFUN (no_aggregate_address
,
5195 no_aggregate_address_cmd
,
5196 "no aggregate-address A.B.C.D/M",
5198 "Configure BGP aggregate entries\n"
5199 "Aggregate prefix\n")
5201 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5204 ALIAS (no_aggregate_address
,
5205 no_aggregate_address_summary_only_cmd
,
5206 "no aggregate-address A.B.C.D/M summary-only",
5208 "Configure BGP aggregate entries\n"
5209 "Aggregate prefix\n"
5210 "Filter more specific routes from updates\n")
5212 ALIAS (no_aggregate_address
,
5213 no_aggregate_address_as_set_cmd
,
5214 "no aggregate-address A.B.C.D/M as-set",
5216 "Configure BGP aggregate entries\n"
5217 "Aggregate prefix\n"
5218 "Generate AS set path information\n")
5220 ALIAS (no_aggregate_address
,
5221 no_aggregate_address_as_set_summary_cmd
,
5222 "no aggregate-address A.B.C.D/M as-set summary-only",
5224 "Configure BGP aggregate entries\n"
5225 "Aggregate prefix\n"
5226 "Generate AS set path information\n"
5227 "Filter more specific routes from updates\n")
5229 ALIAS (no_aggregate_address
,
5230 no_aggregate_address_summary_as_set_cmd
,
5231 "no aggregate-address A.B.C.D/M summary-only as-set",
5233 "Configure BGP aggregate entries\n"
5234 "Aggregate prefix\n"
5235 "Filter more specific routes from updates\n"
5236 "Generate AS set path information\n")
5238 DEFUN (no_aggregate_address_mask
,
5239 no_aggregate_address_mask_cmd
,
5240 "no aggregate-address A.B.C.D A.B.C.D",
5242 "Configure BGP aggregate entries\n"
5243 "Aggregate address\n"
5247 char prefix_str
[BUFSIZ
];
5249 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5253 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5257 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5260 ALIAS (no_aggregate_address_mask
,
5261 no_aggregate_address_mask_summary_only_cmd
,
5262 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5264 "Configure BGP aggregate entries\n"
5265 "Aggregate address\n"
5267 "Filter more specific routes from updates\n")
5269 ALIAS (no_aggregate_address_mask
,
5270 no_aggregate_address_mask_as_set_cmd
,
5271 "no aggregate-address A.B.C.D A.B.C.D as-set",
5273 "Configure BGP aggregate entries\n"
5274 "Aggregate address\n"
5276 "Generate AS set path information\n")
5278 ALIAS (no_aggregate_address_mask
,
5279 no_aggregate_address_mask_as_set_summary_cmd
,
5280 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5282 "Configure BGP aggregate entries\n"
5283 "Aggregate address\n"
5285 "Generate AS set path information\n"
5286 "Filter more specific routes from updates\n")
5288 ALIAS (no_aggregate_address_mask
,
5289 no_aggregate_address_mask_summary_as_set_cmd
,
5290 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5292 "Configure BGP aggregate entries\n"
5293 "Aggregate address\n"
5295 "Filter more specific routes from updates\n"
5296 "Generate AS set path information\n")
5299 DEFUN (ipv6_aggregate_address
,
5300 ipv6_aggregate_address_cmd
,
5301 "aggregate-address X:X::X:X/M",
5302 "Configure BGP aggregate entries\n"
5303 "Aggregate prefix\n")
5305 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5308 DEFUN (ipv6_aggregate_address_summary_only
,
5309 ipv6_aggregate_address_summary_only_cmd
,
5310 "aggregate-address X:X::X:X/M summary-only",
5311 "Configure BGP aggregate entries\n"
5312 "Aggregate prefix\n"
5313 "Filter more specific routes from updates\n")
5315 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5316 AGGREGATE_SUMMARY_ONLY
, 0);
5319 DEFUN (no_ipv6_aggregate_address
,
5320 no_ipv6_aggregate_address_cmd
,
5321 "no aggregate-address X:X::X:X/M",
5323 "Configure BGP aggregate entries\n"
5324 "Aggregate prefix\n")
5326 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5329 DEFUN (no_ipv6_aggregate_address_summary_only
,
5330 no_ipv6_aggregate_address_summary_only_cmd
,
5331 "no aggregate-address X:X::X:X/M summary-only",
5333 "Configure BGP aggregate entries\n"
5334 "Aggregate prefix\n"
5335 "Filter more specific routes from updates\n")
5337 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5340 ALIAS (ipv6_aggregate_address
,
5341 old_ipv6_aggregate_address_cmd
,
5342 "ipv6 bgp aggregate-address X:X::X:X/M",
5345 "Configure BGP aggregate entries\n"
5346 "Aggregate prefix\n")
5348 ALIAS (ipv6_aggregate_address_summary_only
,
5349 old_ipv6_aggregate_address_summary_only_cmd
,
5350 "ipv6 bgp 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 ALIAS (no_ipv6_aggregate_address
,
5358 old_no_ipv6_aggregate_address_cmd
,
5359 "no ipv6 bgp aggregate-address X:X::X:X/M",
5363 "Configure BGP aggregate entries\n"
5364 "Aggregate prefix\n")
5366 ALIAS (no_ipv6_aggregate_address_summary_only
,
5367 old_no_ipv6_aggregate_address_summary_only_cmd
,
5368 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5372 "Configure BGP aggregate entries\n"
5373 "Aggregate prefix\n"
5374 "Filter more specific routes from updates\n")
5375 #endif /* HAVE_IPV6 */
5377 /* Redistribute route treatment. */
5379 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
5380 u_int32_t metric
, u_char type
)
5383 struct listnode
*node
, *nnode
;
5384 struct bgp_info
*new;
5385 struct bgp_info
*bi
;
5386 struct bgp_info info
;
5387 struct bgp_node
*bn
;
5388 struct attr attr
= { 0 };
5389 struct attr attr_new
= { 0 };
5390 struct attr
*new_attr
;
5394 /* Make default attribute. */
5395 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5397 attr
.nexthop
= *nexthop
;
5400 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5402 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5404 afi
= family2afi (p
->family
);
5406 if (bgp
->redist
[afi
][type
])
5408 /* Copy attribute for modification. */
5409 bgp_attr_dup (&attr_new
, &attr
);
5411 if (bgp
->redist_metric_flag
[afi
][type
])
5412 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
5414 /* Apply route-map. */
5415 if (bgp
->rmap
[afi
][type
].map
)
5417 info
.peer
= bgp
->peer_self
;
5418 info
.attr
= &attr_new
;
5420 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5422 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
5425 bgp
->peer_self
->rmap_type
= 0;
5427 if (ret
== RMAP_DENYMATCH
)
5429 /* Free uninterned attribute. */
5430 bgp_attr_flush (&attr_new
);
5431 bgp_attr_extra_free (&attr_new
);
5433 /* Unintern original. */
5434 aspath_unintern (attr
.aspath
);
5435 bgp_attr_extra_free (&attr
);
5436 bgp_redistribute_delete (p
, type
);
5441 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5442 afi
, SAFI_UNICAST
, p
, NULL
);
5444 new_attr
= bgp_attr_intern (&attr_new
);
5445 bgp_attr_extra_free (&attr_new
);
5447 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5448 if (bi
->peer
== bgp
->peer_self
5449 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5454 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5455 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5457 bgp_attr_unintern (new_attr
);
5458 aspath_unintern (attr
.aspath
);
5459 bgp_attr_extra_free (&attr
);
5460 bgp_unlock_node (bn
);
5465 /* The attribute is changed. */
5466 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5468 /* Rewrite BGP route information. */
5469 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5470 bgp_info_restore(bn
, bi
);
5472 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5473 bgp_attr_unintern (bi
->attr
);
5474 bi
->attr
= new_attr
;
5475 bi
->uptime
= time (NULL
);
5477 /* Process change. */
5478 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5479 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5480 bgp_unlock_node (bn
);
5481 aspath_unintern (attr
.aspath
);
5482 bgp_attr_extra_free (&attr
);
5487 new = bgp_info_new ();
5489 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5490 new->peer
= bgp
->peer_self
;
5491 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5492 new->attr
= new_attr
;
5493 new->uptime
= time (NULL
);
5495 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5496 bgp_info_add (bn
, new);
5497 bgp_unlock_node (bn
);
5498 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5502 /* Unintern original. */
5503 aspath_unintern (attr
.aspath
);
5504 bgp_attr_extra_free (&attr
);
5508 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5511 struct listnode
*node
, *nnode
;
5513 struct bgp_node
*rn
;
5514 struct bgp_info
*ri
;
5516 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5518 afi
= family2afi (p
->family
);
5520 if (bgp
->redist
[afi
][type
])
5522 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5524 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5525 if (ri
->peer
== bgp
->peer_self
5526 && ri
->type
== type
)
5531 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5532 bgp_info_delete (rn
, ri
);
5533 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5535 bgp_unlock_node (rn
);
5540 /* Withdraw specified route type's route. */
5542 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5544 struct bgp_node
*rn
;
5545 struct bgp_info
*ri
;
5546 struct bgp_table
*table
;
5548 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5550 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5552 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5553 if (ri
->peer
== bgp
->peer_self
5554 && ri
->type
== type
)
5559 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5560 bgp_info_delete (rn
, ri
);
5561 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5566 /* Static function to display route. */
5568 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5571 u_int32_t destination
;
5574 if (p
->family
== AF_INET
)
5576 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5577 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5579 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5580 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5581 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5582 || p
->u
.prefix4
.s_addr
== 0)
5584 /* When mask is natural, mask is not displayed. */
5587 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5590 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5595 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5597 vty_out (vty
, "%*s", len
, " ");
5600 enum bgp_display_type
5605 /* Print the short form route status for a bgp_info */
5607 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5609 /* Route status display. */
5610 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5612 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5614 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5616 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5622 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5624 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5626 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5631 /* Internal route. */
5632 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5638 /* called from terminal list command */
5640 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5641 struct bgp_info
*binfo
, int display
, safi_t safi
)
5645 /* short status lead text */
5646 route_vty_short_status_out (vty
, binfo
);
5648 /* print prefix and mask */
5650 route_vty_out_route (p
, vty
);
5652 vty_out (vty
, "%*s", 17, " ");
5654 /* Print attribute */
5658 if (p
->family
== AF_INET
)
5660 if (safi
== SAFI_MPLS_VPN
)
5661 vty_out (vty
, "%-16s",
5662 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5664 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5667 else if (p
->family
== AF_INET6
)
5672 len
= vty_out (vty
, "%s",
5673 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5677 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5679 vty_out (vty
, "%*s", len
, " ");
5681 #endif /* HAVE_IPV6 */
5683 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5684 vty_out (vty
, "%10d", attr
->med
);
5688 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5689 vty_out (vty
, "%7d", attr
->local_pref
);
5693 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5697 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5700 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5702 vty_out (vty
, "%s", VTY_NEWLINE
);
5705 /* called from terminal list command */
5707 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5708 struct attr
*attr
, safi_t safi
)
5710 /* Route status display. */
5715 /* print prefix and mask */
5716 route_vty_out_route (p
, vty
);
5718 /* Print attribute */
5721 if (p
->family
== AF_INET
)
5723 if (safi
== SAFI_MPLS_VPN
)
5724 vty_out (vty
, "%-16s",
5725 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5727 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5730 else if (p
->family
== AF_INET6
)
5735 assert (attr
->extra
);
5737 len
= vty_out (vty
, "%s",
5738 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5742 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5744 vty_out (vty
, "%*s", len
, " ");
5746 #endif /* HAVE_IPV6 */
5748 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5749 vty_out (vty
, "%10d", attr
->med
);
5753 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5754 vty_out (vty
, "%7d", attr
->local_pref
);
5758 vty_out (vty
, "%7d ", (attr
->extra
? attr
->extra
->weight
: 0));
5762 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5765 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5768 vty_out (vty
, "%s", VTY_NEWLINE
);
5772 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5773 struct bgp_info
*binfo
, int display
, safi_t safi
)
5776 u_int32_t label
= 0;
5781 /* short status lead text */
5782 route_vty_short_status_out (vty
, binfo
);
5784 /* print prefix and mask */
5786 route_vty_out_route (p
, vty
);
5788 vty_out (vty
, "%*s", 17, " ");
5790 /* Print attribute */
5794 if (p
->family
== AF_INET
)
5796 if (safi
== SAFI_MPLS_VPN
)
5797 vty_out (vty
, "%-16s",
5798 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5800 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5803 else if (p
->family
== AF_INET6
)
5805 assert (attr
->extra
);
5808 if (attr
->extra
->mp_nexthop_len
== 16)
5810 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5812 else if (attr
->extra
->mp_nexthop_len
== 32)
5813 vty_out (vty
, "%s(%s)",
5814 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5816 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5820 #endif /* HAVE_IPV6 */
5823 label
= decode_label (binfo
->extra
->tag
);
5825 vty_out (vty
, "notag/%d", label
);
5827 vty_out (vty
, "%s", VTY_NEWLINE
);
5830 /* dampening route */
5832 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5833 struct bgp_info
*binfo
, int display
, safi_t safi
)
5838 /* short status lead text */
5839 route_vty_short_status_out (vty
, binfo
);
5841 /* print prefix and mask */
5843 route_vty_out_route (p
, vty
);
5845 vty_out (vty
, "%*s", 17, " ");
5847 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5850 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5852 vty_out (vty
, "%*s", len
, " ");
5854 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
));
5856 /* Print attribute */
5862 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5865 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5867 vty_out (vty
, "%s", VTY_NEWLINE
);
5870 #define BGP_UPTIME_LEN 25
5874 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5875 struct bgp_info
*binfo
, int display
, safi_t safi
)
5878 struct bgp_damp_info
*bdi
;
5879 char timebuf
[BGP_UPTIME_LEN
];
5885 bdi
= binfo
->extra
->damp_info
;
5887 /* short status lead text */
5888 route_vty_short_status_out (vty
, binfo
);
5890 /* print prefix and mask */
5892 route_vty_out_route (p
, vty
);
5894 vty_out (vty
, "%*s", 17, " ");
5896 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5899 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5901 vty_out (vty
, "%*s", len
, " ");
5903 len
= vty_out (vty
, "%d", bdi
->flap
);
5908 vty_out (vty
, "%*s ", len
, " ");
5910 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5911 timebuf
, BGP_UPTIME_LEN
));
5913 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5914 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5915 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
));
5917 vty_out (vty
, "%*s ", 8, " ");
5919 /* Print attribute */
5925 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5928 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5930 vty_out (vty
, "%s", VTY_NEWLINE
);
5934 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5935 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5937 char buf
[INET6_ADDRSTRLEN
];
5940 int sockunion_vty_out (struct vty
*, union sockunion
*);
5946 /* Line1 display AS-path, Aggregator */
5950 if (aspath_count_hops (attr
->aspath
) == 0)
5951 vty_out (vty
, "Local");
5953 aspath_print_vty (vty
, "%s", attr
->aspath
, "");
5956 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5957 vty_out (vty
, ", (removed)");
5958 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5959 vty_out (vty
, ", (stale)");
5960 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
5961 vty_out (vty
, ", (aggregated by %d %s)",
5962 attr
->extra
->aggregator_as
,
5963 inet_ntoa (attr
->extra
->aggregator_addr
));
5964 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
5965 vty_out (vty
, ", (Received from a RR-client)");
5966 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
5967 vty_out (vty
, ", (Received from a RS-client)");
5968 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5969 vty_out (vty
, ", (history entry)");
5970 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5971 vty_out (vty
, ", (suppressed due to dampening)");
5972 vty_out (vty
, "%s", VTY_NEWLINE
);
5974 /* Line2 display Next-hop, Neighbor, Router-id */
5975 if (p
->family
== AF_INET
)
5977 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
5978 inet_ntoa (attr
->extra
->mp_nexthop_global_in
) :
5979 inet_ntoa (attr
->nexthop
));
5984 assert (attr
->extra
);
5985 vty_out (vty
, " %s",
5986 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5987 buf
, INET6_ADDRSTRLEN
));
5989 #endif /* HAVE_IPV6 */
5991 if (binfo
->peer
== bgp
->peer_self
)
5993 vty_out (vty
, " from %s ",
5994 p
->family
== AF_INET
? "0.0.0.0" : "::");
5995 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
5999 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6000 vty_out (vty
, " (inaccessible)");
6001 else if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6002 vty_out (vty
, " (metric %d)", binfo
->extra
->igpmetric
);
6003 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6004 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6005 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6007 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6009 vty_out (vty
, "%s", VTY_NEWLINE
);
6012 /* display nexthop local */
6013 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== 32)
6015 vty_out (vty
, " (%s)%s",
6016 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6017 buf
, INET6_ADDRSTRLEN
),
6020 #endif /* HAVE_IPV6 */
6022 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
6023 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6025 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6026 vty_out (vty
, ", metric %d", attr
->med
);
6028 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6029 vty_out (vty
, ", localpref %d", attr
->local_pref
);
6031 vty_out (vty
, ", localpref %d", bgp
->default_local_pref
);
6033 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6034 vty_out (vty
, ", weight %d", attr
->extra
->weight
);
6036 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6037 vty_out (vty
, ", valid");
6039 if (binfo
->peer
!= bgp
->peer_self
)
6041 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6042 vty_out (vty
, ", internal");
6044 vty_out (vty
, ", %s",
6045 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
6047 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6048 vty_out (vty
, ", aggregated, local");
6049 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
6050 vty_out (vty
, ", sourced");
6052 vty_out (vty
, ", sourced, local");
6054 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
6055 vty_out (vty
, ", atomic-aggregate");
6057 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6058 vty_out (vty
, ", best");
6060 vty_out (vty
, "%s", VTY_NEWLINE
);
6062 /* Line 4 display Community */
6063 if (attr
->community
)
6064 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
6067 /* Line 5 display Extended-community */
6068 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
6069 vty_out (vty
, " Extended Community: %s%s",
6070 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
6072 /* Line 6 display Originator, Cluster-id */
6073 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
6074 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
6076 assert (attr
->extra
);
6077 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6078 vty_out (vty
, " Originator: %s",
6079 inet_ntoa (attr
->extra
->originator_id
));
6081 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
6084 vty_out (vty
, ", Cluster list: ");
6085 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6086 vty_out (vty
, "%s ",
6087 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6089 vty_out (vty
, "%s", VTY_NEWLINE
);
6092 /* 7: AS Pathlimit */
6093 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_AS_PATHLIMIT
))
6096 vty_out (vty
, " AS-Pathlimit: %u",
6097 attr
->pathlimit
.ttl
);
6098 if (attr
->pathlimit
.as
)
6099 vty_out (vty
, " (%u)", attr
->pathlimit
.as
);
6100 vty_out (vty
, "%s", VTY_NEWLINE
);
6103 if (binfo
->extra
&& binfo
->extra
->damp_info
)
6104 bgp_damp_info_vty (vty
, binfo
);
6106 /* Line 7 display Uptime */
6107 vty_out (vty
, " Last update: %s", ctime (&binfo
->uptime
));
6109 vty_out (vty
, "%s", VTY_NEWLINE
);
6112 #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"
6113 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
6114 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
6115 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6116 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6120 bgp_show_type_normal
,
6121 bgp_show_type_regexp
,
6122 bgp_show_type_prefix_list
,
6123 bgp_show_type_filter_list
,
6124 bgp_show_type_route_map
,
6125 bgp_show_type_neighbor
,
6126 bgp_show_type_cidr_only
,
6127 bgp_show_type_prefix_longer
,
6128 bgp_show_type_community_all
,
6129 bgp_show_type_community
,
6130 bgp_show_type_community_exact
,
6131 bgp_show_type_community_list
,
6132 bgp_show_type_community_list_exact
,
6133 bgp_show_type_flap_statistics
,
6134 bgp_show_type_flap_address
,
6135 bgp_show_type_flap_prefix
,
6136 bgp_show_type_flap_cidr_only
,
6137 bgp_show_type_flap_regexp
,
6138 bgp_show_type_flap_filter_list
,
6139 bgp_show_type_flap_prefix_list
,
6140 bgp_show_type_flap_prefix_longer
,
6141 bgp_show_type_flap_route_map
,
6142 bgp_show_type_flap_neighbor
,
6143 bgp_show_type_dampend_paths
,
6144 bgp_show_type_damp_neighbor
6148 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
6149 enum bgp_show_type type
, void *output_arg
)
6151 struct bgp_info
*ri
;
6152 struct bgp_node
*rn
;
6155 unsigned long output_count
;
6157 /* This is first entry point, so reset total line. */
6160 /* Start processing of routes. */
6161 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6162 if (rn
->info
!= NULL
)
6166 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6168 if (type
== bgp_show_type_flap_statistics
6169 || type
== bgp_show_type_flap_address
6170 || type
== bgp_show_type_flap_prefix
6171 || type
== bgp_show_type_flap_cidr_only
6172 || type
== bgp_show_type_flap_regexp
6173 || type
== bgp_show_type_flap_filter_list
6174 || type
== bgp_show_type_flap_prefix_list
6175 || type
== bgp_show_type_flap_prefix_longer
6176 || type
== bgp_show_type_flap_route_map
6177 || type
== bgp_show_type_flap_neighbor
6178 || type
== bgp_show_type_dampend_paths
6179 || type
== bgp_show_type_damp_neighbor
)
6181 if (!(ri
->extra
&& ri
->extra
->damp_info
))
6184 if (type
== bgp_show_type_regexp
6185 || type
== bgp_show_type_flap_regexp
)
6187 regex_t
*regex
= output_arg
;
6189 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
6192 if (type
== bgp_show_type_prefix_list
6193 || type
== bgp_show_type_flap_prefix_list
)
6195 struct prefix_list
*plist
= output_arg
;
6197 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
6200 if (type
== bgp_show_type_filter_list
6201 || type
== bgp_show_type_flap_filter_list
)
6203 struct as_list
*as_list
= output_arg
;
6205 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
6208 if (type
== bgp_show_type_route_map
6209 || type
== bgp_show_type_flap_route_map
)
6211 struct route_map
*rmap
= output_arg
;
6212 struct bgp_info binfo
;
6213 struct attr dummy_attr
= { 0 };
6216 bgp_attr_dup (&dummy_attr
, ri
->attr
);
6217 binfo
.peer
= ri
->peer
;
6218 binfo
.attr
= &dummy_attr
;
6220 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
6222 bgp_attr_extra_free (&dummy_attr
);
6224 if (ret
== RMAP_DENYMATCH
)
6227 if (type
== bgp_show_type_neighbor
6228 || type
== bgp_show_type_flap_neighbor
6229 || type
== bgp_show_type_damp_neighbor
)
6231 union sockunion
*su
= output_arg
;
6233 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
6236 if (type
== bgp_show_type_cidr_only
6237 || type
== bgp_show_type_flap_cidr_only
)
6239 u_int32_t destination
;
6241 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
6242 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
6244 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
6246 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
6249 if (type
== bgp_show_type_prefix_longer
6250 || type
== bgp_show_type_flap_prefix_longer
)
6252 struct prefix
*p
= output_arg
;
6254 if (! prefix_match (p
, &rn
->p
))
6257 if (type
== bgp_show_type_community_all
)
6259 if (! ri
->attr
->community
)
6262 if (type
== bgp_show_type_community
)
6264 struct community
*com
= output_arg
;
6266 if (! ri
->attr
->community
||
6267 ! community_match (ri
->attr
->community
, com
))
6270 if (type
== bgp_show_type_community_exact
)
6272 struct community
*com
= output_arg
;
6274 if (! ri
->attr
->community
||
6275 ! community_cmp (ri
->attr
->community
, com
))
6278 if (type
== bgp_show_type_community_list
)
6280 struct community_list
*list
= output_arg
;
6282 if (! community_list_match (ri
->attr
->community
, list
))
6285 if (type
== bgp_show_type_community_list_exact
)
6287 struct community_list
*list
= output_arg
;
6289 if (! community_list_exact_match (ri
->attr
->community
, list
))
6292 if (type
== bgp_show_type_flap_address
6293 || type
== bgp_show_type_flap_prefix
)
6295 struct prefix
*p
= output_arg
;
6297 if (! prefix_match (&rn
->p
, p
))
6300 if (type
== bgp_show_type_flap_prefix
)
6301 if (p
->prefixlen
!= rn
->p
.prefixlen
)
6304 if (type
== bgp_show_type_dampend_paths
6305 || type
== bgp_show_type_damp_neighbor
)
6307 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
6308 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
6314 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
6315 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6316 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
6317 if (type
== bgp_show_type_dampend_paths
6318 || type
== bgp_show_type_damp_neighbor
)
6319 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
6320 else if (type
== bgp_show_type_flap_statistics
6321 || type
== bgp_show_type_flap_address
6322 || type
== bgp_show_type_flap_prefix
6323 || type
== bgp_show_type_flap_cidr_only
6324 || type
== bgp_show_type_flap_regexp
6325 || type
== bgp_show_type_flap_filter_list
6326 || type
== bgp_show_type_flap_prefix_list
6327 || type
== bgp_show_type_flap_prefix_longer
6328 || type
== bgp_show_type_flap_route_map
6329 || type
== bgp_show_type_flap_neighbor
)
6330 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
6332 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
6336 if (type
== bgp_show_type_dampend_paths
6337 || type
== bgp_show_type_damp_neighbor
)
6338 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6339 else if (type
== bgp_show_type_flap_statistics
6340 || type
== bgp_show_type_flap_address
6341 || type
== bgp_show_type_flap_prefix
6342 || type
== bgp_show_type_flap_cidr_only
6343 || type
== bgp_show_type_flap_regexp
6344 || type
== bgp_show_type_flap_filter_list
6345 || type
== bgp_show_type_flap_prefix_list
6346 || type
== bgp_show_type_flap_prefix_longer
6347 || type
== bgp_show_type_flap_route_map
6348 || type
== bgp_show_type_flap_neighbor
)
6349 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6351 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6358 /* No route is displayed */
6359 if (output_count
== 0)
6361 if (type
== bgp_show_type_normal
)
6362 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
6365 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6366 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6372 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
6373 enum bgp_show_type type
, void *output_arg
)
6375 struct bgp_table
*table
;
6378 bgp
= bgp_get_default ();
6383 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6388 table
= bgp
->rib
[afi
][safi
];
6390 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
6393 /* Header of detailed BGP route information */
6395 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
6396 struct bgp_node
*rn
,
6397 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
6399 struct bgp_info
*ri
;
6402 struct listnode
*node
, *nnode
;
6403 char buf1
[INET6_ADDRSTRLEN
];
6404 char buf2
[INET6_ADDRSTRLEN
];
6409 int no_advertise
= 0;
6414 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
6415 (safi
== SAFI_MPLS_VPN
?
6416 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
6417 safi
== SAFI_MPLS_VPN
? ":" : "",
6418 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
6419 p
->prefixlen
, VTY_NEWLINE
);
6421 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6424 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
6427 if (ri
->extra
&& ri
->extra
->suppress
)
6429 if (ri
->attr
->community
!= NULL
)
6431 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
6433 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
6435 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
6441 vty_out (vty
, "Paths: (%d available", count
);
6444 vty_out (vty
, ", best #%d", best
);
6445 if (safi
== SAFI_UNICAST
)
6446 vty_out (vty
, ", table Default-IP-Routing-Table");
6449 vty_out (vty
, ", no best path");
6451 vty_out (vty
, ", not advertised to any peer");
6453 vty_out (vty
, ", not advertised to EBGP peer");
6455 vty_out (vty
, ", not advertised outside local AS");
6457 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
6458 vty_out (vty
, ")%s", VTY_NEWLINE
);
6460 /* advertised peer */
6461 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6463 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
6466 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
6467 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6472 vty_out (vty
, " Not advertised to any peer");
6473 vty_out (vty
, "%s", VTY_NEWLINE
);
6476 /* Display specified route of BGP table. */
6478 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
6479 struct bgp_table
*rib
, const char *ip_str
,
6480 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6486 struct prefix match
;
6487 struct bgp_node
*rn
;
6488 struct bgp_node
*rm
;
6489 struct bgp_info
*ri
;
6490 struct bgp_table
*table
;
6492 /* Check IP address argument. */
6493 ret
= str2prefix (ip_str
, &match
);
6496 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
6500 match
.family
= afi2family (afi
);
6502 if (safi
== SAFI_MPLS_VPN
)
6504 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
6506 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
6509 if ((table
= rn
->info
) != NULL
)
6513 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
6515 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
6518 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6522 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6523 AFI_IP
, SAFI_MPLS_VPN
);
6528 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6538 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6540 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6542 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6546 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6550 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6558 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6565 /* Display specified route of Main RIB */
6567 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6568 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6573 /* BGP structure lookup. */
6576 bgp
= bgp_lookup_by_name (view_name
);
6579 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6585 bgp
= bgp_get_default ();
6588 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6593 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6594 afi
, safi
, prd
, prefix_check
);
6597 /* BGP route print out function. */
6605 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6608 DEFUN (show_ip_bgp_ipv4
,
6609 show_ip_bgp_ipv4_cmd
,
6610 "show ip bgp ipv4 (unicast|multicast)",
6615 "Address Family modifier\n"
6616 "Address Family modifier\n")
6618 if (strncmp (argv
[0], "m", 1) == 0)
6619 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6622 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6625 DEFUN (show_ip_bgp_route
,
6626 show_ip_bgp_route_cmd
,
6627 "show ip bgp A.B.C.D",
6631 "Network in the BGP routing table to display\n")
6633 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6636 DEFUN (show_ip_bgp_ipv4_route
,
6637 show_ip_bgp_ipv4_route_cmd
,
6638 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6643 "Address Family modifier\n"
6644 "Address Family modifier\n"
6645 "Network in the BGP routing table to display\n")
6647 if (strncmp (argv
[0], "m", 1) == 0)
6648 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6650 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6653 DEFUN (show_ip_bgp_vpnv4_all_route
,
6654 show_ip_bgp_vpnv4_all_route_cmd
,
6655 "show ip bgp vpnv4 all A.B.C.D",
6659 "Display VPNv4 NLRI specific information\n"
6660 "Display information about all VPNv4 NLRIs\n"
6661 "Network in the BGP routing table to display\n")
6663 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6666 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6667 show_ip_bgp_vpnv4_rd_route_cmd
,
6668 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6672 "Display VPNv4 NLRI specific information\n"
6673 "Display information for a route distinguisher\n"
6674 "VPN Route Distinguisher\n"
6675 "Network in the BGP routing table to display\n")
6678 struct prefix_rd prd
;
6680 ret
= str2prefix_rd (argv
[0], &prd
);
6683 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6686 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6689 DEFUN (show_ip_bgp_prefix
,
6690 show_ip_bgp_prefix_cmd
,
6691 "show ip bgp A.B.C.D/M",
6695 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6697 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6700 DEFUN (show_ip_bgp_ipv4_prefix
,
6701 show_ip_bgp_ipv4_prefix_cmd
,
6702 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6707 "Address Family modifier\n"
6708 "Address Family modifier\n"
6709 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6711 if (strncmp (argv
[0], "m", 1) == 0)
6712 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6714 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6717 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6718 show_ip_bgp_vpnv4_all_prefix_cmd
,
6719 "show ip bgp vpnv4 all A.B.C.D/M",
6723 "Display VPNv4 NLRI specific information\n"
6724 "Display information about all VPNv4 NLRIs\n"
6725 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6727 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6730 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6731 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6732 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6736 "Display VPNv4 NLRI specific information\n"
6737 "Display information for a route distinguisher\n"
6738 "VPN Route Distinguisher\n"
6739 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6742 struct prefix_rd prd
;
6744 ret
= str2prefix_rd (argv
[0], &prd
);
6747 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6750 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6753 DEFUN (show_ip_bgp_view
,
6754 show_ip_bgp_view_cmd
,
6755 "show ip bgp view WORD",
6764 /* BGP structure lookup. */
6765 bgp
= bgp_lookup_by_name (argv
[0]);
6768 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6772 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6775 DEFUN (show_ip_bgp_view_route
,
6776 show_ip_bgp_view_route_cmd
,
6777 "show ip bgp view WORD A.B.C.D",
6783 "Network in the BGP routing table to display\n")
6785 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6788 DEFUN (show_ip_bgp_view_prefix
,
6789 show_ip_bgp_view_prefix_cmd
,
6790 "show ip bgp view WORD A.B.C.D/M",
6796 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6798 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6808 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6820 DEFUN (show_ipv6_bgp
,
6827 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6831 DEFUN (show_bgp_route
,
6833 "show bgp X:X::X:X",
6836 "Network in the BGP routing table to display\n")
6838 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6841 ALIAS (show_bgp_route
,
6842 show_bgp_ipv6_route_cmd
,
6843 "show bgp ipv6 X:X::X:X",
6847 "Network in the BGP routing table to display\n")
6850 DEFUN (show_ipv6_bgp_route
,
6851 show_ipv6_bgp_route_cmd
,
6852 "show ipv6 bgp X:X::X:X",
6856 "Network in the BGP routing table to display\n")
6858 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6861 DEFUN (show_bgp_prefix
,
6862 show_bgp_prefix_cmd
,
6863 "show bgp X:X::X:X/M",
6866 "IPv6 prefix <network>/<length>\n")
6868 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6871 ALIAS (show_bgp_prefix
,
6872 show_bgp_ipv6_prefix_cmd
,
6873 "show bgp ipv6 X:X::X:X/M",
6877 "IPv6 prefix <network>/<length>\n")
6880 DEFUN (show_ipv6_bgp_prefix
,
6881 show_ipv6_bgp_prefix_cmd
,
6882 "show ipv6 bgp X:X::X:X/M",
6886 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6888 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6891 DEFUN (show_bgp_view
,
6893 "show bgp view WORD",
6901 /* BGP structure lookup. */
6902 bgp
= bgp_lookup_by_name (argv
[0]);
6905 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6909 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6912 ALIAS (show_bgp_view
,
6913 show_bgp_view_ipv6_cmd
,
6914 "show bgp view WORD ipv6",
6921 DEFUN (show_bgp_view_route
,
6922 show_bgp_view_route_cmd
,
6923 "show bgp view WORD X:X::X:X",
6928 "Network in the BGP routing table to display\n")
6930 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6933 ALIAS (show_bgp_view_route
,
6934 show_bgp_view_ipv6_route_cmd
,
6935 "show bgp view WORD ipv6 X:X::X:X",
6941 "Network in the BGP routing table to display\n")
6943 DEFUN (show_bgp_view_prefix
,
6944 show_bgp_view_prefix_cmd
,
6945 "show bgp view WORD X:X::X:X/M",
6950 "IPv6 prefix <network>/<length>\n")
6952 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6955 ALIAS (show_bgp_view_prefix
,
6956 show_bgp_view_ipv6_prefix_cmd
,
6957 "show bgp view WORD ipv6 X:X::X:X/M",
6963 "IPv6 prefix <network>/<length>\n")
6966 DEFUN (show_ipv6_mbgp
,
6973 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6978 DEFUN (show_ipv6_mbgp_route
,
6979 show_ipv6_mbgp_route_cmd
,
6980 "show ipv6 mbgp X:X::X:X",
6984 "Network in the MBGP routing table to display\n")
6986 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6990 DEFUN (show_ipv6_mbgp_prefix
,
6991 show_ipv6_mbgp_prefix_cmd
,
6992 "show ipv6 mbgp X:X::X:X/M",
6996 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6998 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
7004 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
7005 safi_t safi
, enum bgp_show_type type
)
7015 b
= buffer_new (1024);
7016 for (i
= 0; i
< argc
; i
++)
7019 buffer_putc (b
, ' ');
7022 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7027 buffer_putstr (b
, argv
[i
]);
7029 buffer_putc (b
, '\0');
7031 regstr
= buffer_getstr (b
);
7034 regex
= bgp_regcomp (regstr
);
7035 XFREE(MTYPE_TMP
, regstr
);
7038 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
7043 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
7044 bgp_regex_free (regex
);
7048 DEFUN (show_ip_bgp_regexp
,
7049 show_ip_bgp_regexp_cmd
,
7050 "show ip bgp regexp .LINE",
7054 "Display routes matching the AS path regular expression\n"
7055 "A regular-expression to match the BGP AS paths\n")
7057 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7058 bgp_show_type_regexp
);
7061 DEFUN (show_ip_bgp_flap_regexp
,
7062 show_ip_bgp_flap_regexp_cmd
,
7063 "show ip bgp flap-statistics regexp .LINE",
7067 "Display flap statistics of routes\n"
7068 "Display routes matching the AS path regular expression\n"
7069 "A regular-expression to match the BGP AS paths\n")
7071 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7072 bgp_show_type_flap_regexp
);
7075 DEFUN (show_ip_bgp_ipv4_regexp
,
7076 show_ip_bgp_ipv4_regexp_cmd
,
7077 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
7082 "Address Family modifier\n"
7083 "Address Family modifier\n"
7084 "Display routes matching the AS path regular expression\n"
7085 "A regular-expression to match the BGP AS paths\n")
7087 if (strncmp (argv
[0], "m", 1) == 0)
7088 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
7089 bgp_show_type_regexp
);
7091 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
7092 bgp_show_type_regexp
);
7096 DEFUN (show_bgp_regexp
,
7097 show_bgp_regexp_cmd
,
7098 "show bgp regexp .LINE",
7101 "Display routes matching the AS path regular expression\n"
7102 "A regular-expression to match the BGP AS paths\n")
7104 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7105 bgp_show_type_regexp
);
7108 ALIAS (show_bgp_regexp
,
7109 show_bgp_ipv6_regexp_cmd
,
7110 "show bgp ipv6 regexp .LINE",
7114 "Display routes matching the AS path regular expression\n"
7115 "A regular-expression to match the BGP AS paths\n")
7118 DEFUN (show_ipv6_bgp_regexp
,
7119 show_ipv6_bgp_regexp_cmd
,
7120 "show ipv6 bgp regexp .LINE",
7124 "Display routes matching the AS path regular expression\n"
7125 "A regular-expression to match the BGP AS paths\n")
7127 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
7128 bgp_show_type_regexp
);
7132 DEFUN (show_ipv6_mbgp_regexp
,
7133 show_ipv6_mbgp_regexp_cmd
,
7134 "show ipv6 mbgp regexp .LINE",
7138 "Display routes matching the AS path regular expression\n"
7139 "A regular-expression to match the MBGP AS paths\n")
7141 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
7142 bgp_show_type_regexp
);
7144 #endif /* HAVE_IPV6 */
7147 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
7148 safi_t safi
, enum bgp_show_type type
)
7150 struct prefix_list
*plist
;
7152 plist
= prefix_list_lookup (afi
, prefix_list_str
);
7155 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
7156 prefix_list_str
, VTY_NEWLINE
);
7160 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
7163 DEFUN (show_ip_bgp_prefix_list
,
7164 show_ip_bgp_prefix_list_cmd
,
7165 "show ip bgp prefix-list WORD",
7169 "Display routes conforming to the prefix-list\n"
7170 "IP prefix-list name\n")
7172 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7173 bgp_show_type_prefix_list
);
7176 DEFUN (show_ip_bgp_flap_prefix_list
,
7177 show_ip_bgp_flap_prefix_list_cmd
,
7178 "show ip bgp flap-statistics prefix-list WORD",
7182 "Display flap statistics of routes\n"
7183 "Display routes conforming to the prefix-list\n"
7184 "IP prefix-list name\n")
7186 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7187 bgp_show_type_flap_prefix_list
);
7190 DEFUN (show_ip_bgp_ipv4_prefix_list
,
7191 show_ip_bgp_ipv4_prefix_list_cmd
,
7192 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
7197 "Address Family modifier\n"
7198 "Address Family modifier\n"
7199 "Display routes conforming to the prefix-list\n"
7200 "IP prefix-list name\n")
7202 if (strncmp (argv
[0], "m", 1) == 0)
7203 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7204 bgp_show_type_prefix_list
);
7206 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7207 bgp_show_type_prefix_list
);
7211 DEFUN (show_bgp_prefix_list
,
7212 show_bgp_prefix_list_cmd
,
7213 "show bgp prefix-list WORD",
7216 "Display routes conforming to the prefix-list\n"
7217 "IPv6 prefix-list name\n")
7219 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7220 bgp_show_type_prefix_list
);
7223 ALIAS (show_bgp_prefix_list
,
7224 show_bgp_ipv6_prefix_list_cmd
,
7225 "show bgp ipv6 prefix-list WORD",
7229 "Display routes conforming to the prefix-list\n"
7230 "IPv6 prefix-list name\n")
7233 DEFUN (show_ipv6_bgp_prefix_list
,
7234 show_ipv6_bgp_prefix_list_cmd
,
7235 "show ipv6 bgp prefix-list WORD",
7239 "Display routes matching the prefix-list\n"
7240 "IPv6 prefix-list name\n")
7242 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7243 bgp_show_type_prefix_list
);
7247 DEFUN (show_ipv6_mbgp_prefix_list
,
7248 show_ipv6_mbgp_prefix_list_cmd
,
7249 "show ipv6 mbgp prefix-list WORD",
7253 "Display routes matching the prefix-list\n"
7254 "IPv6 prefix-list name\n")
7256 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7257 bgp_show_type_prefix_list
);
7259 #endif /* HAVE_IPV6 */
7262 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
7263 safi_t safi
, enum bgp_show_type type
)
7265 struct as_list
*as_list
;
7267 as_list
= as_list_lookup (filter
);
7268 if (as_list
== NULL
)
7270 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
7274 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
7277 DEFUN (show_ip_bgp_filter_list
,
7278 show_ip_bgp_filter_list_cmd
,
7279 "show ip bgp filter-list WORD",
7283 "Display routes conforming to the filter-list\n"
7284 "Regular expression access list name\n")
7286 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7287 bgp_show_type_filter_list
);
7290 DEFUN (show_ip_bgp_flap_filter_list
,
7291 show_ip_bgp_flap_filter_list_cmd
,
7292 "show ip bgp flap-statistics filter-list WORD",
7296 "Display flap statistics of routes\n"
7297 "Display routes conforming to the filter-list\n"
7298 "Regular expression access list name\n")
7300 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7301 bgp_show_type_flap_filter_list
);
7304 DEFUN (show_ip_bgp_ipv4_filter_list
,
7305 show_ip_bgp_ipv4_filter_list_cmd
,
7306 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
7311 "Address Family modifier\n"
7312 "Address Family modifier\n"
7313 "Display routes conforming to the filter-list\n"
7314 "Regular expression access list name\n")
7316 if (strncmp (argv
[0], "m", 1) == 0)
7317 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7318 bgp_show_type_filter_list
);
7320 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7321 bgp_show_type_filter_list
);
7325 DEFUN (show_bgp_filter_list
,
7326 show_bgp_filter_list_cmd
,
7327 "show bgp filter-list WORD",
7330 "Display routes conforming to the filter-list\n"
7331 "Regular expression access list name\n")
7333 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7334 bgp_show_type_filter_list
);
7337 ALIAS (show_bgp_filter_list
,
7338 show_bgp_ipv6_filter_list_cmd
,
7339 "show bgp ipv6 filter-list WORD",
7343 "Display routes conforming to the filter-list\n"
7344 "Regular expression access list name\n")
7347 DEFUN (show_ipv6_bgp_filter_list
,
7348 show_ipv6_bgp_filter_list_cmd
,
7349 "show ipv6 bgp filter-list WORD",
7353 "Display routes conforming to the filter-list\n"
7354 "Regular expression access list name\n")
7356 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7357 bgp_show_type_filter_list
);
7361 DEFUN (show_ipv6_mbgp_filter_list
,
7362 show_ipv6_mbgp_filter_list_cmd
,
7363 "show ipv6 mbgp filter-list WORD",
7367 "Display routes conforming to the filter-list\n"
7368 "Regular expression access list name\n")
7370 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7371 bgp_show_type_filter_list
);
7373 #endif /* HAVE_IPV6 */
7376 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
7377 safi_t safi
, enum bgp_show_type type
)
7379 struct route_map
*rmap
;
7381 rmap
= route_map_lookup_by_name (rmap_str
);
7384 vty_out (vty
, "%% %s is not a valid route-map name%s",
7385 rmap_str
, VTY_NEWLINE
);
7389 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
7392 DEFUN (show_ip_bgp_route_map
,
7393 show_ip_bgp_route_map_cmd
,
7394 "show ip bgp route-map WORD",
7398 "Display routes matching the route-map\n"
7399 "A route-map to match on\n")
7401 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7402 bgp_show_type_route_map
);
7405 DEFUN (show_ip_bgp_flap_route_map
,
7406 show_ip_bgp_flap_route_map_cmd
,
7407 "show ip bgp flap-statistics route-map WORD",
7411 "Display flap statistics of routes\n"
7412 "Display routes matching the route-map\n"
7413 "A route-map to match on\n")
7415 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7416 bgp_show_type_flap_route_map
);
7419 DEFUN (show_ip_bgp_ipv4_route_map
,
7420 show_ip_bgp_ipv4_route_map_cmd
,
7421 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
7426 "Address Family modifier\n"
7427 "Address Family modifier\n"
7428 "Display routes matching the route-map\n"
7429 "A route-map to match on\n")
7431 if (strncmp (argv
[0], "m", 1) == 0)
7432 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7433 bgp_show_type_route_map
);
7435 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7436 bgp_show_type_route_map
);
7439 DEFUN (show_bgp_route_map
,
7440 show_bgp_route_map_cmd
,
7441 "show bgp route-map WORD",
7444 "Display routes matching the route-map\n"
7445 "A route-map to match on\n")
7447 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7448 bgp_show_type_route_map
);
7451 ALIAS (show_bgp_route_map
,
7452 show_bgp_ipv6_route_map_cmd
,
7453 "show bgp ipv6 route-map WORD",
7457 "Display routes matching the route-map\n"
7458 "A route-map to match on\n")
7460 DEFUN (show_ip_bgp_cidr_only
,
7461 show_ip_bgp_cidr_only_cmd
,
7462 "show ip bgp cidr-only",
7466 "Display only routes with non-natural netmasks\n")
7468 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7469 bgp_show_type_cidr_only
, NULL
);
7472 DEFUN (show_ip_bgp_flap_cidr_only
,
7473 show_ip_bgp_flap_cidr_only_cmd
,
7474 "show ip bgp flap-statistics cidr-only",
7478 "Display flap statistics of routes\n"
7479 "Display only routes with non-natural netmasks\n")
7481 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7482 bgp_show_type_flap_cidr_only
, NULL
);
7485 DEFUN (show_ip_bgp_ipv4_cidr_only
,
7486 show_ip_bgp_ipv4_cidr_only_cmd
,
7487 "show ip bgp ipv4 (unicast|multicast) cidr-only",
7492 "Address Family modifier\n"
7493 "Address Family modifier\n"
7494 "Display only routes with non-natural netmasks\n")
7496 if (strncmp (argv
[0], "m", 1) == 0)
7497 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7498 bgp_show_type_cidr_only
, NULL
);
7500 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7501 bgp_show_type_cidr_only
, NULL
);
7504 DEFUN (show_ip_bgp_community_all
,
7505 show_ip_bgp_community_all_cmd
,
7506 "show ip bgp community",
7510 "Display routes matching the communities\n")
7512 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7513 bgp_show_type_community_all
, NULL
);
7516 DEFUN (show_ip_bgp_ipv4_community_all
,
7517 show_ip_bgp_ipv4_community_all_cmd
,
7518 "show ip bgp ipv4 (unicast|multicast) community",
7523 "Address Family modifier\n"
7524 "Address Family modifier\n"
7525 "Display routes matching the communities\n")
7527 if (strncmp (argv
[0], "m", 1) == 0)
7528 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7529 bgp_show_type_community_all
, NULL
);
7531 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7532 bgp_show_type_community_all
, NULL
);
7536 DEFUN (show_bgp_community_all
,
7537 show_bgp_community_all_cmd
,
7538 "show bgp community",
7541 "Display routes matching the communities\n")
7543 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7544 bgp_show_type_community_all
, NULL
);
7547 ALIAS (show_bgp_community_all
,
7548 show_bgp_ipv6_community_all_cmd
,
7549 "show bgp ipv6 community",
7553 "Display routes matching the communities\n")
7556 DEFUN (show_ipv6_bgp_community_all
,
7557 show_ipv6_bgp_community_all_cmd
,
7558 "show ipv6 bgp community",
7562 "Display routes matching the communities\n")
7564 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7565 bgp_show_type_community_all
, NULL
);
7569 DEFUN (show_ipv6_mbgp_community_all
,
7570 show_ipv6_mbgp_community_all_cmd
,
7571 "show ipv6 mbgp community",
7575 "Display routes matching the communities\n")
7577 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7578 bgp_show_type_community_all
, NULL
);
7580 #endif /* HAVE_IPV6 */
7583 bgp_show_community (struct vty
*vty
, int argc
, const char **argv
, int exact
,
7584 u_int16_t afi
, u_char safi
)
7586 struct community
*com
;
7592 b
= buffer_new (1024);
7593 for (i
= 0; i
< argc
; i
++)
7596 buffer_putc (b
, ' ');
7599 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7604 buffer_putstr (b
, argv
[i
]);
7606 buffer_putc (b
, '\0');
7608 str
= buffer_getstr (b
);
7611 com
= community_str2com (str
);
7612 XFREE (MTYPE_TMP
, str
);
7615 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7619 return bgp_show (vty
, NULL
, afi
, safi
,
7620 (exact
? bgp_show_type_community_exact
:
7621 bgp_show_type_community
), com
);
7624 DEFUN (show_ip_bgp_community
,
7625 show_ip_bgp_community_cmd
,
7626 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7630 "Display routes matching the communities\n"
7631 "community number\n"
7632 "Do not send outside local AS (well-known community)\n"
7633 "Do not advertise to any peer (well-known community)\n"
7634 "Do not export to next AS (well-known community)\n")
7636 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7639 ALIAS (show_ip_bgp_community
,
7640 show_ip_bgp_community2_cmd
,
7641 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7645 "Display routes matching the communities\n"
7646 "community number\n"
7647 "Do not send outside local AS (well-known community)\n"
7648 "Do not advertise to any peer (well-known community)\n"
7649 "Do not export to next AS (well-known community)\n"
7650 "community number\n"
7651 "Do not send outside local AS (well-known community)\n"
7652 "Do not advertise to any peer (well-known community)\n"
7653 "Do not export to next AS (well-known community)\n")
7655 ALIAS (show_ip_bgp_community
,
7656 show_ip_bgp_community3_cmd
,
7657 "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)",
7661 "Display routes matching the communities\n"
7662 "community number\n"
7663 "Do not send outside local AS (well-known community)\n"
7664 "Do not advertise to any peer (well-known community)\n"
7665 "Do not export to next AS (well-known community)\n"
7666 "community number\n"
7667 "Do not send outside local AS (well-known community)\n"
7668 "Do not advertise to any peer (well-known community)\n"
7669 "Do not export to next AS (well-known community)\n"
7670 "community number\n"
7671 "Do not send outside local AS (well-known community)\n"
7672 "Do not advertise to any peer (well-known community)\n"
7673 "Do not export to next AS (well-known community)\n")
7675 ALIAS (show_ip_bgp_community
,
7676 show_ip_bgp_community4_cmd
,
7677 "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)",
7681 "Display routes matching the communities\n"
7682 "community number\n"
7683 "Do not send outside local AS (well-known community)\n"
7684 "Do not advertise to any peer (well-known community)\n"
7685 "Do not export to next AS (well-known community)\n"
7686 "community number\n"
7687 "Do not send outside local AS (well-known community)\n"
7688 "Do not advertise to any peer (well-known community)\n"
7689 "Do not export to next AS (well-known community)\n"
7690 "community number\n"
7691 "Do not send outside local AS (well-known community)\n"
7692 "Do not advertise to any peer (well-known community)\n"
7693 "Do not export to next AS (well-known community)\n"
7694 "community number\n"
7695 "Do not send outside local AS (well-known community)\n"
7696 "Do not advertise to any peer (well-known community)\n"
7697 "Do not export to next AS (well-known community)\n")
7699 DEFUN (show_ip_bgp_ipv4_community
,
7700 show_ip_bgp_ipv4_community_cmd
,
7701 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7706 "Address Family modifier\n"
7707 "Address Family modifier\n"
7708 "Display routes matching the communities\n"
7709 "community number\n"
7710 "Do not send outside local AS (well-known community)\n"
7711 "Do not advertise to any peer (well-known community)\n"
7712 "Do not export to next AS (well-known community)\n")
7714 if (strncmp (argv
[0], "m", 1) == 0)
7715 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7717 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7720 ALIAS (show_ip_bgp_ipv4_community
,
7721 show_ip_bgp_ipv4_community2_cmd
,
7722 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7727 "Address Family modifier\n"
7728 "Address Family modifier\n"
7729 "Display routes matching the communities\n"
7730 "community number\n"
7731 "Do not send outside local AS (well-known community)\n"
7732 "Do not advertise to any peer (well-known community)\n"
7733 "Do not export to next AS (well-known community)\n"
7734 "community number\n"
7735 "Do not send outside local AS (well-known community)\n"
7736 "Do not advertise to any peer (well-known community)\n"
7737 "Do not export to next AS (well-known community)\n")
7739 ALIAS (show_ip_bgp_ipv4_community
,
7740 show_ip_bgp_ipv4_community3_cmd
,
7741 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7746 "Address Family modifier\n"
7747 "Address Family modifier\n"
7748 "Display routes matching the communities\n"
7749 "community number\n"
7750 "Do not send outside local AS (well-known community)\n"
7751 "Do not advertise to any peer (well-known community)\n"
7752 "Do not export to next AS (well-known community)\n"
7753 "community number\n"
7754 "Do not send outside local AS (well-known community)\n"
7755 "Do not advertise to any peer (well-known community)\n"
7756 "Do not export to next AS (well-known community)\n"
7757 "community number\n"
7758 "Do not send outside local AS (well-known community)\n"
7759 "Do not advertise to any peer (well-known community)\n"
7760 "Do not export to next AS (well-known community)\n")
7762 ALIAS (show_ip_bgp_ipv4_community
,
7763 show_ip_bgp_ipv4_community4_cmd
,
7764 "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)",
7769 "Address Family modifier\n"
7770 "Address Family modifier\n"
7771 "Display routes matching the communities\n"
7772 "community number\n"
7773 "Do not send outside local AS (well-known community)\n"
7774 "Do not advertise to any peer (well-known community)\n"
7775 "Do not export to next AS (well-known community)\n"
7776 "community number\n"
7777 "Do not send outside local AS (well-known community)\n"
7778 "Do not advertise to any peer (well-known community)\n"
7779 "Do not export to next AS (well-known community)\n"
7780 "community number\n"
7781 "Do not send outside local AS (well-known community)\n"
7782 "Do not advertise to any peer (well-known community)\n"
7783 "Do not export to next AS (well-known community)\n"
7784 "community number\n"
7785 "Do not send outside local AS (well-known community)\n"
7786 "Do not advertise to any peer (well-known community)\n"
7787 "Do not export to next AS (well-known community)\n")
7789 DEFUN (show_ip_bgp_community_exact
,
7790 show_ip_bgp_community_exact_cmd
,
7791 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7795 "Display routes matching the communities\n"
7796 "community number\n"
7797 "Do not send outside local AS (well-known community)\n"
7798 "Do not advertise to any peer (well-known community)\n"
7799 "Do not export to next AS (well-known community)\n"
7800 "Exact match of the communities")
7802 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7805 ALIAS (show_ip_bgp_community_exact
,
7806 show_ip_bgp_community2_exact_cmd
,
7807 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7811 "Display routes matching the communities\n"
7812 "community number\n"
7813 "Do not send outside local AS (well-known community)\n"
7814 "Do not advertise to any peer (well-known community)\n"
7815 "Do not export to next AS (well-known community)\n"
7816 "community number\n"
7817 "Do not send outside local AS (well-known community)\n"
7818 "Do not advertise to any peer (well-known community)\n"
7819 "Do not export to next AS (well-known community)\n"
7820 "Exact match of the communities")
7822 ALIAS (show_ip_bgp_community_exact
,
7823 show_ip_bgp_community3_exact_cmd
,
7824 "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",
7828 "Display routes matching the communities\n"
7829 "community number\n"
7830 "Do not send outside local AS (well-known community)\n"
7831 "Do not advertise to any peer (well-known community)\n"
7832 "Do not export to next AS (well-known community)\n"
7833 "community number\n"
7834 "Do not send outside local AS (well-known community)\n"
7835 "Do not advertise to any peer (well-known community)\n"
7836 "Do not export to next AS (well-known community)\n"
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 ALIAS (show_ip_bgp_community_exact
,
7844 show_ip_bgp_community4_exact_cmd
,
7845 "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",
7849 "Display routes matching the communities\n"
7850 "community number\n"
7851 "Do not send outside local AS (well-known community)\n"
7852 "Do not advertise to any peer (well-known community)\n"
7853 "Do not export to next AS (well-known community)\n"
7854 "community number\n"
7855 "Do not send outside local AS (well-known community)\n"
7856 "Do not advertise to any peer (well-known community)\n"
7857 "Do not export to next AS (well-known community)\n"
7858 "community number\n"
7859 "Do not send outside local AS (well-known community)\n"
7860 "Do not advertise to any peer (well-known community)\n"
7861 "Do not export to next AS (well-known community)\n"
7862 "community number\n"
7863 "Do not send outside local AS (well-known community)\n"
7864 "Do not advertise to any peer (well-known community)\n"
7865 "Do not export to next AS (well-known community)\n"
7866 "Exact match of the communities")
7868 DEFUN (show_ip_bgp_ipv4_community_exact
,
7869 show_ip_bgp_ipv4_community_exact_cmd
,
7870 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7875 "Address Family modifier\n"
7876 "Address Family modifier\n"
7877 "Display routes matching the communities\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 if (strncmp (argv
[0], "m", 1) == 0)
7885 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
7887 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7890 ALIAS (show_ip_bgp_ipv4_community_exact
,
7891 show_ip_bgp_ipv4_community2_exact_cmd
,
7892 "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",
7897 "Address Family modifier\n"
7898 "Address Family modifier\n"
7899 "Display routes matching the communities\n"
7900 "community number\n"
7901 "Do not send outside local AS (well-known community)\n"
7902 "Do not advertise to any peer (well-known community)\n"
7903 "Do not export to next AS (well-known community)\n"
7904 "community number\n"
7905 "Do not send outside local AS (well-known community)\n"
7906 "Do not advertise to any peer (well-known community)\n"
7907 "Do not export to next AS (well-known community)\n"
7908 "Exact match of the communities")
7910 ALIAS (show_ip_bgp_ipv4_community_exact
,
7911 show_ip_bgp_ipv4_community3_exact_cmd
,
7912 "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",
7917 "Address Family modifier\n"
7918 "Address Family modifier\n"
7919 "Display routes matching the communities\n"
7920 "community number\n"
7921 "Do not send outside local AS (well-known community)\n"
7922 "Do not advertise to any peer (well-known community)\n"
7923 "Do not export to next AS (well-known community)\n"
7924 "community number\n"
7925 "Do not send outside local AS (well-known community)\n"
7926 "Do not advertise to any peer (well-known community)\n"
7927 "Do not export to next AS (well-known community)\n"
7928 "community number\n"
7929 "Do not send outside local AS (well-known community)\n"
7930 "Do not advertise to any peer (well-known community)\n"
7931 "Do not export to next AS (well-known community)\n"
7932 "Exact match of the communities")
7934 ALIAS (show_ip_bgp_ipv4_community_exact
,
7935 show_ip_bgp_ipv4_community4_exact_cmd
,
7936 "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",
7941 "Address Family modifier\n"
7942 "Address Family modifier\n"
7943 "Display routes matching the communities\n"
7944 "community number\n"
7945 "Do not send outside local AS (well-known community)\n"
7946 "Do not advertise to any peer (well-known community)\n"
7947 "Do not export to next AS (well-known community)\n"
7948 "community number\n"
7949 "Do not send outside local AS (well-known community)\n"
7950 "Do not advertise to any peer (well-known community)\n"
7951 "Do not export to next AS (well-known community)\n"
7952 "community number\n"
7953 "Do not send outside local AS (well-known community)\n"
7954 "Do not advertise to any peer (well-known community)\n"
7955 "Do not export to next AS (well-known community)\n"
7956 "community number\n"
7957 "Do not send outside local AS (well-known community)\n"
7958 "Do not advertise to any peer (well-known community)\n"
7959 "Do not export to next AS (well-known community)\n"
7960 "Exact match of the communities")
7963 DEFUN (show_bgp_community
,
7964 show_bgp_community_cmd
,
7965 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
7968 "Display routes matching the communities\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")
7974 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7977 ALIAS (show_bgp_community
,
7978 show_bgp_ipv6_community_cmd
,
7979 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
7983 "Display routes matching the communities\n"
7984 "community number\n"
7985 "Do not send outside local AS (well-known community)\n"
7986 "Do not advertise to any peer (well-known community)\n"
7987 "Do not export to next AS (well-known community)\n")
7989 ALIAS (show_bgp_community
,
7990 show_bgp_community2_cmd
,
7991 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7994 "Display routes matching the communities\n"
7995 "community number\n"
7996 "Do not send outside local AS (well-known community)\n"
7997 "Do not advertise to any peer (well-known community)\n"
7998 "Do not export to next AS (well-known community)\n"
7999 "community number\n"
8000 "Do not send outside local AS (well-known community)\n"
8001 "Do not advertise to any peer (well-known community)\n"
8002 "Do not export to next AS (well-known community)\n")
8004 ALIAS (show_bgp_community
,
8005 show_bgp_ipv6_community2_cmd
,
8006 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8010 "Display routes matching the communities\n"
8011 "community number\n"
8012 "Do not send outside local AS (well-known community)\n"
8013 "Do not advertise to any peer (well-known community)\n"
8014 "Do not export to next AS (well-known community)\n"
8015 "community number\n"
8016 "Do not send outside local AS (well-known community)\n"
8017 "Do not advertise to any peer (well-known community)\n"
8018 "Do not export to next AS (well-known community)\n")
8020 ALIAS (show_bgp_community
,
8021 show_bgp_community3_cmd
,
8022 "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)",
8025 "Display routes matching the communities\n"
8026 "community number\n"
8027 "Do not send outside local AS (well-known community)\n"
8028 "Do not advertise to any peer (well-known community)\n"
8029 "Do not export to next AS (well-known community)\n"
8030 "community number\n"
8031 "Do not send outside local AS (well-known community)\n"
8032 "Do not advertise to any peer (well-known community)\n"
8033 "Do not export to next AS (well-known community)\n"
8034 "community number\n"
8035 "Do not send outside local AS (well-known community)\n"
8036 "Do not advertise to any peer (well-known community)\n"
8037 "Do not export to next AS (well-known community)\n")
8039 ALIAS (show_bgp_community
,
8040 show_bgp_ipv6_community3_cmd
,
8041 "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)",
8045 "Display routes matching the communities\n"
8046 "community number\n"
8047 "Do not send outside local AS (well-known community)\n"
8048 "Do not advertise to any peer (well-known community)\n"
8049 "Do not export to next AS (well-known community)\n"
8050 "community number\n"
8051 "Do not send outside local AS (well-known community)\n"
8052 "Do not advertise to any peer (well-known community)\n"
8053 "Do not export to next AS (well-known community)\n"
8054 "community number\n"
8055 "Do not send outside local AS (well-known community)\n"
8056 "Do not advertise to any peer (well-known community)\n"
8057 "Do not export to next AS (well-known community)\n")
8059 ALIAS (show_bgp_community
,
8060 show_bgp_community4_cmd
,
8061 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8064 "Display routes matching the communities\n"
8065 "community number\n"
8066 "Do not send outside local AS (well-known community)\n"
8067 "Do not advertise to any peer (well-known community)\n"
8068 "Do not export to next AS (well-known community)\n"
8069 "community number\n"
8070 "Do not send outside local AS (well-known community)\n"
8071 "Do not advertise to any peer (well-known community)\n"
8072 "Do not export to next AS (well-known community)\n"
8073 "community number\n"
8074 "Do not send outside local AS (well-known community)\n"
8075 "Do not advertise to any peer (well-known community)\n"
8076 "Do not export to next AS (well-known community)\n"
8077 "community number\n"
8078 "Do not send outside local AS (well-known community)\n"
8079 "Do not advertise to any peer (well-known community)\n"
8080 "Do not export to next AS (well-known community)\n")
8082 ALIAS (show_bgp_community
,
8083 show_bgp_ipv6_community4_cmd
,
8084 "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)",
8088 "Display routes matching the communities\n"
8089 "community number\n"
8090 "Do not send outside local AS (well-known community)\n"
8091 "Do not advertise to any peer (well-known community)\n"
8092 "Do not export to next AS (well-known community)\n"
8093 "community number\n"
8094 "Do not send outside local AS (well-known community)\n"
8095 "Do not advertise to any peer (well-known community)\n"
8096 "Do not export to next AS (well-known community)\n"
8097 "community number\n"
8098 "Do not send outside local AS (well-known community)\n"
8099 "Do not advertise to any peer (well-known community)\n"
8100 "Do not export to next AS (well-known community)\n"
8101 "community number\n"
8102 "Do not send outside local AS (well-known community)\n"
8103 "Do not advertise to any peer (well-known community)\n"
8104 "Do not export to next AS (well-known community)\n")
8107 DEFUN (show_ipv6_bgp_community
,
8108 show_ipv6_bgp_community_cmd
,
8109 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
8113 "Display routes matching the communities\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")
8119 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
8123 ALIAS (show_ipv6_bgp_community
,
8124 show_ipv6_bgp_community2_cmd
,
8125 "show ipv6 bgp community (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")
8140 ALIAS (show_ipv6_bgp_community
,
8141 show_ipv6_bgp_community3_cmd
,
8142 "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)",
8146 "Display routes matching the communities\n"
8147 "community number\n"
8148 "Do not send outside local AS (well-known community)\n"
8149 "Do not advertise to any peer (well-known community)\n"
8150 "Do not export to next AS (well-known community)\n"
8151 "community number\n"
8152 "Do not send outside local AS (well-known community)\n"
8153 "Do not advertise to any peer (well-known community)\n"
8154 "Do not export to next AS (well-known community)\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")
8161 ALIAS (show_ipv6_bgp_community
,
8162 show_ipv6_bgp_community4_cmd
,
8163 "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)",
8167 "Display routes matching the communities\n"
8168 "community number\n"
8169 "Do not send outside local AS (well-known community)\n"
8170 "Do not advertise to any peer (well-known community)\n"
8171 "Do not export to next AS (well-known community)\n"
8172 "community number\n"
8173 "Do not send outside local AS (well-known community)\n"
8174 "Do not advertise to any peer (well-known community)\n"
8175 "Do not export to next AS (well-known community)\n"
8176 "community number\n"
8177 "Do not send outside local AS (well-known community)\n"
8178 "Do not advertise to any peer (well-known community)\n"
8179 "Do not export to next AS (well-known community)\n"
8180 "community number\n"
8181 "Do not send outside local AS (well-known community)\n"
8182 "Do not advertise to any peer (well-known community)\n"
8183 "Do not export to next AS (well-known community)\n")
8185 DEFUN (show_bgp_community_exact
,
8186 show_bgp_community_exact_cmd
,
8187 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8190 "Display routes matching the communities\n"
8191 "community number\n"
8192 "Do not send outside local AS (well-known community)\n"
8193 "Do not advertise to any peer (well-known community)\n"
8194 "Do not export to next AS (well-known community)\n"
8195 "Exact match of the communities")
8197 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8200 ALIAS (show_bgp_community_exact
,
8201 show_bgp_ipv6_community_exact_cmd
,
8202 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8206 "Display routes matching the communities\n"
8207 "community number\n"
8208 "Do not send outside local AS (well-known community)\n"
8209 "Do not advertise to any peer (well-known community)\n"
8210 "Do not export to next AS (well-known community)\n"
8211 "Exact match of the communities")
8213 ALIAS (show_bgp_community_exact
,
8214 show_bgp_community2_exact_cmd
,
8215 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8218 "Display routes matching the communities\n"
8219 "community number\n"
8220 "Do not send outside local AS (well-known community)\n"
8221 "Do not advertise to any peer (well-known community)\n"
8222 "Do not export to next AS (well-known community)\n"
8223 "community number\n"
8224 "Do not send outside local AS (well-known community)\n"
8225 "Do not advertise to any peer (well-known community)\n"
8226 "Do not export to next AS (well-known community)\n"
8227 "Exact match of the communities")
8229 ALIAS (show_bgp_community_exact
,
8230 show_bgp_ipv6_community2_exact_cmd
,
8231 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8235 "Display routes matching the communities\n"
8236 "community number\n"
8237 "Do not send outside local AS (well-known community)\n"
8238 "Do not advertise to any peer (well-known community)\n"
8239 "Do not export to next AS (well-known community)\n"
8240 "community number\n"
8241 "Do not send outside local AS (well-known community)\n"
8242 "Do not advertise to any peer (well-known community)\n"
8243 "Do not export to next AS (well-known community)\n"
8244 "Exact match of the communities")
8246 ALIAS (show_bgp_community_exact
,
8247 show_bgp_community3_exact_cmd
,
8248 "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",
8251 "Display routes matching the communities\n"
8252 "community number\n"
8253 "Do not send outside local AS (well-known community)\n"
8254 "Do not advertise to any peer (well-known community)\n"
8255 "Do not export to next AS (well-known community)\n"
8256 "community number\n"
8257 "Do not send outside local AS (well-known community)\n"
8258 "Do not advertise to any peer (well-known community)\n"
8259 "Do not export to next AS (well-known community)\n"
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 "Exact match of the communities")
8266 ALIAS (show_bgp_community_exact
,
8267 show_bgp_ipv6_community3_exact_cmd
,
8268 "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",
8272 "Display routes matching the communities\n"
8273 "community number\n"
8274 "Do not send outside local AS (well-known community)\n"
8275 "Do not advertise to any peer (well-known community)\n"
8276 "Do not export to next AS (well-known community)\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_community4_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) (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 "community number\n"
8306 "Do not send outside local AS (well-known community)\n"
8307 "Do not advertise to any peer (well-known community)\n"
8308 "Do not export to next AS (well-known community)\n"
8309 "Exact match of the communities")
8311 ALIAS (show_bgp_community_exact
,
8312 show_bgp_ipv6_community4_exact_cmd
,
8313 "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",
8317 "Display routes matching the communities\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 "community number\n"
8327 "Do not send outside local AS (well-known community)\n"
8328 "Do not advertise to any peer (well-known community)\n"
8329 "Do not export to next AS (well-known community)\n"
8330 "community number\n"
8331 "Do not send outside local AS (well-known community)\n"
8332 "Do not advertise to any peer (well-known community)\n"
8333 "Do not export to next AS (well-known community)\n"
8334 "Exact match of the communities")
8337 DEFUN (show_ipv6_bgp_community_exact
,
8338 show_ipv6_bgp_community_exact_cmd
,
8339 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8343 "Display routes matching the communities\n"
8344 "community number\n"
8345 "Do not send outside local AS (well-known community)\n"
8346 "Do not advertise to any peer (well-known community)\n"
8347 "Do not export to next AS (well-known community)\n"
8348 "Exact match of the communities")
8350 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8354 ALIAS (show_ipv6_bgp_community_exact
,
8355 show_ipv6_bgp_community2_exact_cmd
,
8356 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8360 "Display routes matching the communities\n"
8361 "community number\n"
8362 "Do not send outside local AS (well-known community)\n"
8363 "Do not advertise to any peer (well-known community)\n"
8364 "Do not export to next AS (well-known community)\n"
8365 "community number\n"
8366 "Do not send outside local AS (well-known community)\n"
8367 "Do not advertise to any peer (well-known community)\n"
8368 "Do not export to next AS (well-known community)\n"
8369 "Exact match of the communities")
8372 ALIAS (show_ipv6_bgp_community_exact
,
8373 show_ipv6_bgp_community3_exact_cmd
,
8374 "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",
8378 "Display routes matching the communities\n"
8379 "community number\n"
8380 "Do not send outside local AS (well-known community)\n"
8381 "Do not advertise to any peer (well-known community)\n"
8382 "Do not export to next AS (well-known community)\n"
8383 "community number\n"
8384 "Do not send outside local AS (well-known community)\n"
8385 "Do not advertise to any peer (well-known community)\n"
8386 "Do not export to next AS (well-known community)\n"
8387 "community number\n"
8388 "Do not send outside local AS (well-known community)\n"
8389 "Do not advertise to any peer (well-known community)\n"
8390 "Do not export to next AS (well-known community)\n"
8391 "Exact match of the communities")
8394 ALIAS (show_ipv6_bgp_community_exact
,
8395 show_ipv6_bgp_community4_exact_cmd
,
8396 "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",
8400 "Display routes matching the communities\n"
8401 "community number\n"
8402 "Do not send outside local AS (well-known community)\n"
8403 "Do not advertise to any peer (well-known community)\n"
8404 "Do not export to next AS (well-known community)\n"
8405 "community number\n"
8406 "Do not send outside local AS (well-known community)\n"
8407 "Do not advertise to any peer (well-known community)\n"
8408 "Do not export to next AS (well-known community)\n"
8409 "community number\n"
8410 "Do not send outside local AS (well-known community)\n"
8411 "Do not advertise to any peer (well-known community)\n"
8412 "Do not export to next AS (well-known community)\n"
8413 "community number\n"
8414 "Do not send outside local AS (well-known community)\n"
8415 "Do not advertise to any peer (well-known community)\n"
8416 "Do not export to next AS (well-known community)\n"
8417 "Exact match of the communities")
8420 DEFUN (show_ipv6_mbgp_community
,
8421 show_ipv6_mbgp_community_cmd
,
8422 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
8426 "Display routes matching the communities\n"
8427 "community number\n"
8428 "Do not send outside local AS (well-known community)\n"
8429 "Do not advertise to any peer (well-known community)\n"
8430 "Do not export to next AS (well-known community)\n")
8432 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
8436 ALIAS (show_ipv6_mbgp_community
,
8437 show_ipv6_mbgp_community2_cmd
,
8438 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8442 "Display routes matching the communities\n"
8443 "community number\n"
8444 "Do not send outside local AS (well-known community)\n"
8445 "Do not advertise to any peer (well-known community)\n"
8446 "Do not export to next AS (well-known community)\n"
8447 "community number\n"
8448 "Do not send outside local AS (well-known community)\n"
8449 "Do not advertise to any peer (well-known community)\n"
8450 "Do not export to next AS (well-known community)\n")
8453 ALIAS (show_ipv6_mbgp_community
,
8454 show_ipv6_mbgp_community3_cmd
,
8455 "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)",
8459 "Display routes matching the communities\n"
8460 "community number\n"
8461 "Do not send outside local AS (well-known community)\n"
8462 "Do not advertise to any peer (well-known community)\n"
8463 "Do not export to next AS (well-known community)\n"
8464 "community number\n"
8465 "Do not send outside local AS (well-known community)\n"
8466 "Do not advertise to any peer (well-known community)\n"
8467 "Do not export to next AS (well-known community)\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")
8474 ALIAS (show_ipv6_mbgp_community
,
8475 show_ipv6_mbgp_community4_cmd
,
8476 "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)",
8480 "Display routes matching the communities\n"
8481 "community number\n"
8482 "Do not send outside local AS (well-known community)\n"
8483 "Do not advertise to any peer (well-known community)\n"
8484 "Do not export to next AS (well-known community)\n"
8485 "community number\n"
8486 "Do not send outside local AS (well-known community)\n"
8487 "Do not advertise to any peer (well-known community)\n"
8488 "Do not export to next AS (well-known community)\n"
8489 "community number\n"
8490 "Do not send outside local AS (well-known community)\n"
8491 "Do not advertise to any peer (well-known community)\n"
8492 "Do not export to next AS (well-known community)\n"
8493 "community number\n"
8494 "Do not send outside local AS (well-known community)\n"
8495 "Do not advertise to any peer (well-known community)\n"
8496 "Do not export to next AS (well-known community)\n")
8499 DEFUN (show_ipv6_mbgp_community_exact
,
8500 show_ipv6_mbgp_community_exact_cmd
,
8501 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8505 "Display routes matching the communities\n"
8506 "community number\n"
8507 "Do not send outside local AS (well-known community)\n"
8508 "Do not advertise to any peer (well-known community)\n"
8509 "Do not export to next AS (well-known community)\n"
8510 "Exact match of the communities")
8512 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
8516 ALIAS (show_ipv6_mbgp_community_exact
,
8517 show_ipv6_mbgp_community2_exact_cmd
,
8518 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8522 "Display routes matching the communities\n"
8523 "community number\n"
8524 "Do not send outside local AS (well-known community)\n"
8525 "Do not advertise to any peer (well-known community)\n"
8526 "Do not export to next AS (well-known community)\n"
8527 "community number\n"
8528 "Do not send outside local AS (well-known community)\n"
8529 "Do not advertise to any peer (well-known community)\n"
8530 "Do not export to next AS (well-known community)\n"
8531 "Exact match of the communities")
8534 ALIAS (show_ipv6_mbgp_community_exact
,
8535 show_ipv6_mbgp_community3_exact_cmd
,
8536 "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",
8540 "Display routes matching the communities\n"
8541 "community number\n"
8542 "Do not send outside local AS (well-known community)\n"
8543 "Do not advertise to any peer (well-known community)\n"
8544 "Do not export to next AS (well-known community)\n"
8545 "community number\n"
8546 "Do not send outside local AS (well-known community)\n"
8547 "Do not advertise to any peer (well-known community)\n"
8548 "Do not export to next AS (well-known community)\n"
8549 "community number\n"
8550 "Do not send outside local AS (well-known community)\n"
8551 "Do not advertise to any peer (well-known community)\n"
8552 "Do not export to next AS (well-known community)\n"
8553 "Exact match of the communities")
8556 ALIAS (show_ipv6_mbgp_community_exact
,
8557 show_ipv6_mbgp_community4_exact_cmd
,
8558 "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",
8562 "Display routes matching the communities\n"
8563 "community number\n"
8564 "Do not send outside local AS (well-known community)\n"
8565 "Do not advertise to any peer (well-known community)\n"
8566 "Do not export to next AS (well-known community)\n"
8567 "community number\n"
8568 "Do not send outside local AS (well-known community)\n"
8569 "Do not advertise to any peer (well-known community)\n"
8570 "Do not export to next AS (well-known community)\n"
8571 "community number\n"
8572 "Do not send outside local AS (well-known community)\n"
8573 "Do not advertise to any peer (well-known community)\n"
8574 "Do not export to next AS (well-known community)\n"
8575 "community number\n"
8576 "Do not send outside local AS (well-known community)\n"
8577 "Do not advertise to any peer (well-known community)\n"
8578 "Do not export to next AS (well-known community)\n"
8579 "Exact match of the communities")
8580 #endif /* HAVE_IPV6 */
8583 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8584 u_int16_t afi
, u_char safi
)
8586 struct community_list
*list
;
8588 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8591 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8596 return bgp_show (vty
, NULL
, afi
, safi
,
8597 (exact
? bgp_show_type_community_list_exact
:
8598 bgp_show_type_community_list
), list
);
8601 DEFUN (show_ip_bgp_community_list
,
8602 show_ip_bgp_community_list_cmd
,
8603 "show ip bgp community-list (<1-500>|WORD)",
8607 "Display routes matching the community-list\n"
8608 "community-list number\n"
8609 "community-list name\n")
8611 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8614 DEFUN (show_ip_bgp_ipv4_community_list
,
8615 show_ip_bgp_ipv4_community_list_cmd
,
8616 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8621 "Address Family modifier\n"
8622 "Address Family modifier\n"
8623 "Display routes matching the community-list\n"
8624 "community-list number\n"
8625 "community-list name\n")
8627 if (strncmp (argv
[0], "m", 1) == 0)
8628 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8630 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8633 DEFUN (show_ip_bgp_community_list_exact
,
8634 show_ip_bgp_community_list_exact_cmd
,
8635 "show ip bgp community-list (<1-500>|WORD) exact-match",
8639 "Display routes matching the community-list\n"
8640 "community-list number\n"
8641 "community-list name\n"
8642 "Exact match of the communities\n")
8644 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8647 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8648 show_ip_bgp_ipv4_community_list_exact_cmd
,
8649 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8654 "Address Family modifier\n"
8655 "Address Family modifier\n"
8656 "Display routes matching the community-list\n"
8657 "community-list number\n"
8658 "community-list name\n"
8659 "Exact match of the communities\n")
8661 if (strncmp (argv
[0], "m", 1) == 0)
8662 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8664 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8668 DEFUN (show_bgp_community_list
,
8669 show_bgp_community_list_cmd
,
8670 "show bgp community-list (<1-500>|WORD)",
8673 "Display routes matching the community-list\n"
8674 "community-list number\n"
8675 "community-list name\n")
8677 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8680 ALIAS (show_bgp_community_list
,
8681 show_bgp_ipv6_community_list_cmd
,
8682 "show bgp ipv6 community-list (<1-500>|WORD)",
8686 "Display routes matching the community-list\n"
8687 "community-list number\n"
8688 "community-list name\n")
8691 DEFUN (show_ipv6_bgp_community_list
,
8692 show_ipv6_bgp_community_list_cmd
,
8693 "show ipv6 bgp community-list WORD",
8697 "Display routes matching the community-list\n"
8698 "community-list name\n")
8700 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8704 DEFUN (show_ipv6_mbgp_community_list
,
8705 show_ipv6_mbgp_community_list_cmd
,
8706 "show ipv6 mbgp community-list WORD",
8710 "Display routes matching the community-list\n"
8711 "community-list name\n")
8713 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8716 DEFUN (show_bgp_community_list_exact
,
8717 show_bgp_community_list_exact_cmd
,
8718 "show bgp community-list (<1-500>|WORD) exact-match",
8721 "Display routes matching the community-list\n"
8722 "community-list number\n"
8723 "community-list name\n"
8724 "Exact match of the communities\n")
8726 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8729 ALIAS (show_bgp_community_list_exact
,
8730 show_bgp_ipv6_community_list_exact_cmd
,
8731 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8735 "Display routes matching the community-list\n"
8736 "community-list number\n"
8737 "community-list name\n"
8738 "Exact match of the communities\n")
8741 DEFUN (show_ipv6_bgp_community_list_exact
,
8742 show_ipv6_bgp_community_list_exact_cmd
,
8743 "show ipv6 bgp community-list WORD exact-match",
8747 "Display routes matching the community-list\n"
8748 "community-list name\n"
8749 "Exact match of the communities\n")
8751 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8755 DEFUN (show_ipv6_mbgp_community_list_exact
,
8756 show_ipv6_mbgp_community_list_exact_cmd
,
8757 "show ipv6 mbgp community-list WORD exact-match",
8761 "Display routes matching the community-list\n"
8762 "community-list name\n"
8763 "Exact match of the communities\n")
8765 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8767 #endif /* HAVE_IPV6 */
8770 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8771 safi_t safi
, enum bgp_show_type type
)
8778 ret
= str2prefix (prefix
, p
);
8781 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8785 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8790 DEFUN (show_ip_bgp_prefix_longer
,
8791 show_ip_bgp_prefix_longer_cmd
,
8792 "show ip bgp A.B.C.D/M longer-prefixes",
8796 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8797 "Display route and more specific routes\n")
8799 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8800 bgp_show_type_prefix_longer
);
8803 DEFUN (show_ip_bgp_flap_prefix_longer
,
8804 show_ip_bgp_flap_prefix_longer_cmd
,
8805 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8809 "Display flap statistics of routes\n"
8810 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8811 "Display route and more specific routes\n")
8813 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8814 bgp_show_type_flap_prefix_longer
);
8817 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8818 show_ip_bgp_ipv4_prefix_longer_cmd
,
8819 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8824 "Address Family modifier\n"
8825 "Address Family modifier\n"
8826 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8827 "Display route and more specific routes\n")
8829 if (strncmp (argv
[0], "m", 1) == 0)
8830 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8831 bgp_show_type_prefix_longer
);
8833 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8834 bgp_show_type_prefix_longer
);
8837 DEFUN (show_ip_bgp_flap_address
,
8838 show_ip_bgp_flap_address_cmd
,
8839 "show ip bgp flap-statistics A.B.C.D",
8843 "Display flap statistics of routes\n"
8844 "Network in the BGP routing table to display\n")
8846 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8847 bgp_show_type_flap_address
);
8850 DEFUN (show_ip_bgp_flap_prefix
,
8851 show_ip_bgp_flap_prefix_cmd
,
8852 "show ip bgp flap-statistics A.B.C.D/M",
8856 "Display flap statistics of routes\n"
8857 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8859 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8860 bgp_show_type_flap_prefix
);
8863 DEFUN (show_bgp_prefix_longer
,
8864 show_bgp_prefix_longer_cmd
,
8865 "show bgp X:X::X:X/M longer-prefixes",
8868 "IPv6 prefix <network>/<length>\n"
8869 "Display route and more specific routes\n")
8871 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8872 bgp_show_type_prefix_longer
);
8875 ALIAS (show_bgp_prefix_longer
,
8876 show_bgp_ipv6_prefix_longer_cmd
,
8877 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8881 "IPv6 prefix <network>/<length>\n"
8882 "Display route and more specific routes\n")
8885 DEFUN (show_ipv6_bgp_prefix_longer
,
8886 show_ipv6_bgp_prefix_longer_cmd
,
8887 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8891 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8892 "Display route and more specific routes\n")
8894 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8895 bgp_show_type_prefix_longer
);
8899 DEFUN (show_ipv6_mbgp_prefix_longer
,
8900 show_ipv6_mbgp_prefix_longer_cmd
,
8901 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8905 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8906 "Display route and more specific routes\n")
8908 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8909 bgp_show_type_prefix_longer
);
8911 #endif /* HAVE_IPV6 */
8913 static struct peer
*
8914 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
8922 /* BGP structure lookup. */
8925 bgp
= bgp_lookup_by_name (view_name
);
8928 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
8934 bgp
= bgp_get_default ();
8937 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8942 /* Get peer sockunion. */
8943 ret
= str2sockunion (ip_str
, &su
);
8946 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
8950 /* Peer structure lookup. */
8951 peer
= peer_lookup (bgp
, &su
);
8954 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
8963 BGP_STATS_MAXBITLEN
= 0,
8967 BGP_STATS_UNAGGREGATEABLE
,
8968 BGP_STATS_MAX_AGGREGATEABLE
,
8969 BGP_STATS_AGGREGATES
,
8971 BGP_STATS_ASPATH_COUNT
,
8972 BGP_STATS_ASPATH_MAXHOPS
,
8973 BGP_STATS_ASPATH_TOTHOPS
,
8974 BGP_STATS_ASPATH_MAXSIZE
,
8975 BGP_STATS_ASPATH_TOTSIZE
,
8976 BGP_STATS_ASN_HIGHEST
,
8980 static const char *table_stats_strs
[] =
8982 [BGP_STATS_PREFIXES
] = "Total Prefixes",
8983 [BGP_STATS_TOTPLEN
] = "Average prefix length",
8984 [BGP_STATS_RIB
] = "Total Advertisements",
8985 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
8986 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
8987 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
8988 [BGP_STATS_SPACE
] = "Address space advertised",
8989 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
8990 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
8991 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
8992 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
8993 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
8994 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
8995 [BGP_STATS_MAX
] = NULL
,
8998 struct bgp_table_stats
9000 struct bgp_table
*table
;
9001 unsigned long long counts
[BGP_STATS_MAX
];
9005 #define TALLY_SIGFIG 100000
9006 static unsigned long
9007 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
9009 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
9010 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
9011 unsigned long ret
= newtot
/ count
;
9013 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
9021 bgp_table_stats_walker (struct thread
*t
)
9023 struct bgp_node
*rn
;
9024 struct bgp_node
*top
;
9025 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
9026 unsigned int space
= 0;
9028 if (!(top
= bgp_table_top (ts
->table
)))
9031 switch (top
->p
.family
)
9034 space
= IPV4_MAX_BITLEN
;
9037 space
= IPV6_MAX_BITLEN
;
9041 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
9043 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
9045 struct bgp_info
*ri
;
9046 struct bgp_node
*prn
= rn
->parent
;
9047 unsigned int rinum
= 0;
9055 ts
->counts
[BGP_STATS_PREFIXES
]++;
9056 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
9059 ts
->counts
[BGP_STATS_AVGPLEN
]
9060 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
9061 ts
->counts
[BGP_STATS_AVGPLEN
],
9065 /* check if the prefix is included by any other announcements */
9066 while (prn
&& !prn
->info
)
9069 if (prn
== NULL
|| prn
== top
)
9071 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
9072 /* announced address space */
9074 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
9077 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
9079 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9082 ts
->counts
[BGP_STATS_RIB
]++;
9085 (CHECK_FLAG (ri
->attr
->flag
,
9086 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
9087 ts
->counts
[BGP_STATS_AGGREGATES
]++;
9090 if (ri
->attr
&& ri
->attr
->aspath
)
9092 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
9093 unsigned int size
= aspath_size (ri
->attr
->aspath
);
9094 as_t highest
= aspath_highest (ri
->attr
->aspath
);
9096 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
9098 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
9099 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
9101 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
9102 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
9104 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
9105 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
9107 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
9108 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9109 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
9111 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
9112 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
9113 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
9116 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
9117 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
9125 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
9127 struct bgp_table_stats ts
;
9130 if (!bgp
->rib
[afi
][safi
])
9132 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
9136 memset (&ts
, 0, sizeof (ts
));
9137 ts
.table
= bgp
->rib
[afi
][safi
];
9138 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
9140 vty_out (vty
, "BGP %s RIB statistics%s%s",
9141 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
9143 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
9145 if (!table_stats_strs
[i
])
9151 case BGP_STATS_ASPATH_AVGHOPS
:
9152 case BGP_STATS_ASPATH_AVGSIZE
:
9153 case BGP_STATS_AVGPLEN
:
9154 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9155 vty_out (vty
, "%12.2f",
9156 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
9159 case BGP_STATS_ASPATH_TOTHOPS
:
9160 case BGP_STATS_ASPATH_TOTSIZE
:
9161 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9162 vty_out (vty
, "%12.2f",
9164 (float)ts
.counts
[i
] /
9165 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
9168 case BGP_STATS_TOTPLEN
:
9169 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9170 vty_out (vty
, "%12.2f",
9172 (float)ts
.counts
[i
] /
9173 (float)ts
.counts
[BGP_STATS_PREFIXES
]
9176 case BGP_STATS_SPACE
:
9177 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9178 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
9179 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
9181 vty_out (vty
, "%30s: ", "\% announced ");
9182 vty_out (vty
, "%12.2f%s",
9183 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
9184 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
9186 vty_out (vty
, "%30s: ", "/8 equivalent ");
9187 vty_out (vty
, "%12.2f%s",
9188 (float)ts
.counts
[BGP_STATS_SPACE
] /
9189 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
9191 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
9193 vty_out (vty
, "%30s: ", "/24 equivalent ");
9194 vty_out (vty
, "%12.2f",
9195 (float)ts
.counts
[BGP_STATS_SPACE
] /
9196 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
9199 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
9200 vty_out (vty
, "%12llu", ts
.counts
[i
]);
9203 vty_out (vty
, "%s", VTY_NEWLINE
);
9209 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
9210 const char *afi_str
, const char *safi_str
)
9217 bgp
= bgp_lookup_by_name (name
);
9219 bgp
= bgp_get_default ();
9223 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
9226 if (strncmp (afi_str
, "ipv", 3) == 0)
9228 if (strncmp (afi_str
, "ipv4", 4) == 0)
9230 else if (strncmp (afi_str
, "ipv6", 4) == 0)
9234 vty_out (vty
, "%% Invalid address family %s%s",
9235 afi_str
, VTY_NEWLINE
);
9238 if (strncmp (safi_str
, "m", 1) == 0)
9239 safi
= SAFI_MULTICAST
;
9240 else if (strncmp (safi_str
, "u", 1) == 0)
9241 safi
= SAFI_UNICAST
;
9242 else if (strncmp (safi_str
, "vpnv4", 5) == 0)
9243 safi
= BGP_SAFI_VPNV4
;
9244 else if (strncmp (safi_str
, "vpnv6", 6) == 0)
9245 safi
= BGP_SAFI_VPNV6
;
9248 vty_out (vty
, "%% Invalid subsequent address family %s%s",
9249 safi_str
, VTY_NEWLINE
);
9255 vty_out (vty
, "%% Invalid address family %s%s",
9256 afi_str
, VTY_NEWLINE
);
9260 if ((afi
== AFI_IP
&& safi
== BGP_SAFI_VPNV6
)
9261 || (afi
== AFI_IP6
&& safi
== BGP_SAFI_VPNV4
))
9263 vty_out (vty
, "%% Invalid subsequent address family %s for %s%s",
9264 afi_str
, safi_str
, VTY_NEWLINE
);
9267 return bgp_table_stats (vty
, bgp
, afi
, safi
);
9270 DEFUN (show_bgp_statistics
,
9271 show_bgp_statistics_cmd
,
9272 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
9277 "Address Family modifier\n"
9278 "Address Family modifier\n"
9279 "BGP RIB advertisement statistics\n")
9281 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9284 ALIAS (show_bgp_statistics
,
9285 show_bgp_statistics_vpnv4_cmd
,
9286 "show bgp (ipv4) (vpnv4) statistics",
9290 "Address Family modifier\n"
9291 "BGP RIB advertisement statistics\n")
9293 DEFUN (show_bgp_statistics_view
,
9294 show_bgp_statistics_view_cmd
,
9295 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
9301 "Address Family modifier\n"
9302 "Address Family modifier\n"
9303 "BGP RIB advertisement statistics\n")
9305 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
9308 ALIAS (show_bgp_statistics_view
,
9309 show_bgp_statistics_view_vpnv4_cmd
,
9310 "show bgp view WORD (ipv4) (vpnv4) statistics",
9315 "Address Family modifier\n"
9316 "BGP RIB advertisement statistics\n")
9328 PCOUNT_PFCNT
, /* the figure we display to users */
9332 static const char *pcount_strs
[] =
9334 [PCOUNT_ADJ_IN
] = "Adj-in",
9335 [PCOUNT_DAMPED
] = "Damped",
9336 [PCOUNT_REMOVED
] = "Removed",
9337 [PCOUNT_HISTORY
] = "History",
9338 [PCOUNT_STALE
] = "Stale",
9339 [PCOUNT_VALID
] = "Valid",
9340 [PCOUNT_ALL
] = "All RIB",
9341 [PCOUNT_COUNTED
] = "PfxCt counted",
9342 [PCOUNT_PFCNT
] = "Useable",
9343 [PCOUNT_MAX
] = NULL
,
9348 unsigned int count
[PCOUNT_MAX
];
9349 const struct peer
*peer
;
9350 const struct bgp_table
*table
;
9354 bgp_peer_count_walker (struct thread
*t
)
9356 struct bgp_node
*rn
;
9357 struct peer_pcounts
*pc
= THREAD_ARG (t
);
9358 const struct peer
*peer
= pc
->peer
;
9360 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
9362 struct bgp_adj_in
*ain
;
9363 struct bgp_info
*ri
;
9365 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9366 if (ain
->peer
== peer
)
9367 pc
->count
[PCOUNT_ADJ_IN
]++;
9369 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9371 char buf
[SU_ADDRSTRLEN
];
9373 if (ri
->peer
!= peer
)
9376 pc
->count
[PCOUNT_ALL
]++;
9378 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
9379 pc
->count
[PCOUNT_DAMPED
]++;
9380 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
9381 pc
->count
[PCOUNT_HISTORY
]++;
9382 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
9383 pc
->count
[PCOUNT_REMOVED
]++;
9384 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
9385 pc
->count
[PCOUNT_STALE
]++;
9386 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
9387 pc
->count
[PCOUNT_VALID
]++;
9388 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9389 pc
->count
[PCOUNT_PFCNT
]++;
9391 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
9393 pc
->count
[PCOUNT_COUNTED
]++;
9394 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9395 plog_warn (peer
->log
,
9396 "%s [pcount] %s/%d is counted but flags 0x%x",
9398 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9399 buf
, SU_ADDRSTRLEN
),
9405 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9406 plog_warn (peer
->log
,
9407 "%s [pcount] %s/%d not counted but flags 0x%x",
9409 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9410 buf
, SU_ADDRSTRLEN
),
9420 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
9422 struct peer_pcounts pcounts
= { .peer
= peer
};
9425 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
9426 || !peer
->bgp
->rib
[afi
][safi
])
9428 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9432 memset (&pcounts
, 0, sizeof(pcounts
));
9433 pcounts
.peer
= peer
;
9434 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
9436 /* in-place call via thread subsystem so as to record execution time
9437 * stats for the thread-walk (i.e. ensure this can't be blamed on
9438 * on just vty_read()).
9440 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
9442 vty_out (vty
, "Prefix counts for %s, %s%s",
9443 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
9444 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
9445 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
9446 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
9448 for (i
= 0; i
< PCOUNT_MAX
; i
++)
9449 vty_out (vty
, "%20s: %-10d%s",
9450 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
9452 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
9454 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
9455 peer
->host
, VTY_NEWLINE
);
9456 vty_out (vty
, "Please report this bug, with the above command output%s",
9463 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
9464 show_ip_bgp_neighbor_prefix_counts_cmd
,
9465 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9469 "Detailed information on TCP and BGP neighbor connections\n"
9470 "Neighbor to display information about\n"
9471 "Neighbor to display information about\n"
9472 "Display detailed prefix count information\n")
9476 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9480 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9483 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
9484 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
9485 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9489 "Detailed information on TCP and BGP neighbor connections\n"
9490 "Neighbor to display information about\n"
9491 "Neighbor to display information about\n"
9492 "Display detailed prefix count information\n")
9496 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9500 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
9503 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
9504 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
9505 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9510 "Address Family modifier\n"
9511 "Address Family modifier\n"
9512 "Detailed information on TCP and BGP neighbor connections\n"
9513 "Neighbor to display information about\n"
9514 "Neighbor to display information about\n"
9515 "Display detailed prefix count information\n")
9519 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9523 if (strncmp (argv
[0], "m", 1) == 0)
9524 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9526 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9529 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9530 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9531 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9536 "Address Family modifier\n"
9537 "Address Family modifier\n"
9538 "Detailed information on TCP and BGP neighbor connections\n"
9539 "Neighbor to display information about\n"
9540 "Neighbor to display information about\n"
9541 "Display detailed prefix count information\n")
9545 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9549 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9554 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9557 struct bgp_table
*table
;
9558 struct bgp_adj_in
*ain
;
9559 struct bgp_adj_out
*adj
;
9560 unsigned long output_count
;
9561 struct bgp_node
*rn
;
9571 table
= bgp
->rib
[afi
][safi
];
9575 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9576 PEER_STATUS_DEFAULT_ORIGINATE
))
9578 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9579 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9580 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9582 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9583 VTY_NEWLINE
, VTY_NEWLINE
);
9587 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9590 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9591 if (ain
->peer
== peer
)
9595 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9596 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9597 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9602 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9607 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9614 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9615 if (adj
->peer
== peer
)
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
);
9626 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9631 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9637 if (output_count
!= 0)
9638 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9639 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9643 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9645 if (! peer
|| ! peer
->afc
[afi
][safi
])
9647 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9651 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9653 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9658 show_adj_route (vty
, peer
, afi
, safi
, in
);
9663 DEFUN (show_ip_bgp_neighbor_advertised_route
,
9664 show_ip_bgp_neighbor_advertised_route_cmd
,
9665 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9669 "Detailed information on TCP and BGP neighbor connections\n"
9670 "Neighbor to display information about\n"
9671 "Neighbor to display information about\n"
9672 "Display the routes advertised to a BGP neighbor\n")
9676 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9680 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9683 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9684 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9685 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9690 "Address Family modifier\n"
9691 "Address Family modifier\n"
9692 "Detailed information on TCP and BGP neighbor connections\n"
9693 "Neighbor to display information about\n"
9694 "Neighbor to display information about\n"
9695 "Display the routes advertised to a BGP neighbor\n")
9699 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9703 if (strncmp (argv
[0], "m", 1) == 0)
9704 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9706 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9710 DEFUN (show_bgp_view_neighbor_advertised_route
,
9711 show_bgp_view_neighbor_advertised_route_cmd
,
9712 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9717 "Detailed information on TCP and BGP neighbor connections\n"
9718 "Neighbor to display information about\n"
9719 "Neighbor to display information about\n"
9720 "Display the routes advertised to a BGP neighbor\n")
9725 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9727 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9732 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9735 ALIAS (show_bgp_view_neighbor_advertised_route
,
9736 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9737 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9743 "Detailed information on TCP and BGP neighbor connections\n"
9744 "Neighbor to display information about\n"
9745 "Neighbor to display information about\n"
9746 "Display the routes advertised to a BGP neighbor\n")
9748 DEFUN (show_bgp_view_neighbor_received_routes
,
9749 show_bgp_view_neighbor_received_routes_cmd
,
9750 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9755 "Detailed information on TCP and BGP neighbor connections\n"
9756 "Neighbor to display information about\n"
9757 "Neighbor to display information about\n"
9758 "Display the received routes from neighbor\n")
9763 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9765 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9770 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
9773 ALIAS (show_bgp_view_neighbor_received_routes
,
9774 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
9775 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9781 "Detailed information on TCP and BGP neighbor connections\n"
9782 "Neighbor to display information about\n"
9783 "Neighbor to display information about\n"
9784 "Display the received routes from neighbor\n")
9786 ALIAS (show_bgp_view_neighbor_advertised_route
,
9787 show_bgp_neighbor_advertised_route_cmd
,
9788 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9791 "Detailed information on TCP and BGP neighbor connections\n"
9792 "Neighbor to display information about\n"
9793 "Neighbor to display information about\n"
9794 "Display the routes advertised to a BGP neighbor\n")
9796 ALIAS (show_bgp_view_neighbor_advertised_route
,
9797 show_bgp_ipv6_neighbor_advertised_route_cmd
,
9798 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9802 "Detailed information on TCP and BGP neighbor connections\n"
9803 "Neighbor to display information about\n"
9804 "Neighbor to display information about\n"
9805 "Display the routes advertised to a BGP neighbor\n")
9808 ALIAS (show_bgp_view_neighbor_advertised_route
,
9809 ipv6_bgp_neighbor_advertised_route_cmd
,
9810 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9814 "Detailed information on TCP and BGP neighbor connections\n"
9815 "Neighbor to display information about\n"
9816 "Neighbor to display information about\n"
9817 "Display the routes advertised to a BGP neighbor\n")
9820 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
9821 ipv6_mbgp_neighbor_advertised_route_cmd
,
9822 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9826 "Detailed information on TCP and BGP neighbor connections\n"
9827 "Neighbor to display information about\n"
9828 "Neighbor to display information about\n"
9829 "Display the routes advertised to a BGP neighbor\n")
9833 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9837 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
9839 #endif /* HAVE_IPV6 */
9841 DEFUN (show_ip_bgp_neighbor_received_routes
,
9842 show_ip_bgp_neighbor_received_routes_cmd
,
9843 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9847 "Detailed information on TCP and BGP neighbor connections\n"
9848 "Neighbor to display information about\n"
9849 "Neighbor to display information about\n"
9850 "Display the received routes from neighbor\n")
9854 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9858 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9861 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
9862 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
9863 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
9868 "Address Family modifier\n"
9869 "Address Family modifier\n"
9870 "Detailed information on TCP and BGP neighbor connections\n"
9871 "Neighbor to display information about\n"
9872 "Neighbor to display information about\n"
9873 "Display the received routes from neighbor\n")
9877 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9881 if (strncmp (argv
[0], "m", 1) == 0)
9882 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
9884 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9887 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
9888 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
9889 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9893 "Detailed information on TCP and BGP neighbor connections\n"
9894 "Neighbor to display information about\n"
9895 "Neighbor to display information about\n"
9896 "Display information received from a BGP neighbor\n"
9897 "Display the prefixlist filter\n")
9900 union sockunion
*su
;
9904 su
= sockunion_str2su (argv
[0]);
9908 peer
= peer_lookup (NULL
, su
);
9912 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9913 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9916 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9917 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9923 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
9924 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
9925 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9930 "Address Family modifier\n"
9931 "Address Family modifier\n"
9932 "Detailed information on TCP and BGP neighbor connections\n"
9933 "Neighbor to display information about\n"
9934 "Neighbor to display information about\n"
9935 "Display information received from a BGP neighbor\n"
9936 "Display the prefixlist filter\n")
9939 union sockunion
*su
;
9943 su
= sockunion_str2su (argv
[1]);
9947 peer
= peer_lookup (NULL
, su
);
9951 if (strncmp (argv
[0], "m", 1) == 0)
9953 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
9954 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9957 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
9958 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9963 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9964 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9967 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9968 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9977 ALIAS (show_bgp_view_neighbor_received_routes
,
9978 show_bgp_neighbor_received_routes_cmd
,
9979 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9982 "Detailed information on TCP and BGP neighbor connections\n"
9983 "Neighbor to display information about\n"
9984 "Neighbor to display information about\n"
9985 "Display the received routes from neighbor\n")
9987 ALIAS (show_bgp_view_neighbor_received_routes
,
9988 show_bgp_ipv6_neighbor_received_routes_cmd
,
9989 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9993 "Detailed information on TCP and BGP neighbor connections\n"
9994 "Neighbor to display information about\n"
9995 "Neighbor to display information about\n"
9996 "Display the received routes from neighbor\n")
9998 DEFUN (show_bgp_neighbor_received_prefix_filter
,
9999 show_bgp_neighbor_received_prefix_filter_cmd
,
10000 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10003 "Detailed information on TCP and BGP neighbor connections\n"
10004 "Neighbor to display information about\n"
10005 "Neighbor to display information about\n"
10006 "Display information received from a BGP neighbor\n"
10007 "Display the prefixlist filter\n")
10010 union sockunion
*su
;
10014 su
= sockunion_str2su (argv
[0]);
10016 return CMD_WARNING
;
10018 peer
= peer_lookup (NULL
, su
);
10020 return CMD_WARNING
;
10022 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10023 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10026 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10027 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10030 return CMD_SUCCESS
;
10033 ALIAS (show_bgp_neighbor_received_prefix_filter
,
10034 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
10035 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10039 "Detailed information on TCP and BGP neighbor connections\n"
10040 "Neighbor to display information about\n"
10041 "Neighbor to display information about\n"
10042 "Display information received from a BGP neighbor\n"
10043 "Display the prefixlist filter\n")
10046 ALIAS (show_bgp_view_neighbor_received_routes
,
10047 ipv6_bgp_neighbor_received_routes_cmd
,
10048 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10052 "Detailed information on TCP and BGP neighbor connections\n"
10053 "Neighbor to display information about\n"
10054 "Neighbor to display information about\n"
10055 "Display the received routes from neighbor\n")
10058 DEFUN (ipv6_mbgp_neighbor_received_routes
,
10059 ipv6_mbgp_neighbor_received_routes_cmd
,
10060 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
10064 "Detailed information on TCP and BGP neighbor connections\n"
10065 "Neighbor to display information about\n"
10066 "Neighbor to display information about\n"
10067 "Display the received routes from neighbor\n")
10071 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10073 return CMD_WARNING
;
10075 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
10078 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
10079 show_bgp_view_neighbor_received_prefix_filter_cmd
,
10080 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10085 "Detailed information on TCP and BGP neighbor connections\n"
10086 "Neighbor to display information about\n"
10087 "Neighbor to display information about\n"
10088 "Display information received from a BGP neighbor\n"
10089 "Display the prefixlist filter\n")
10092 union sockunion
*su
;
10097 /* BGP structure lookup. */
10098 bgp
= bgp_lookup_by_name (argv
[0]);
10101 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10102 return CMD_WARNING
;
10105 su
= sockunion_str2su (argv
[1]);
10107 return CMD_WARNING
;
10109 peer
= peer_lookup (bgp
, su
);
10111 return CMD_WARNING
;
10113 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
10114 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
10117 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
10118 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
10121 return CMD_SUCCESS
;
10124 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
10125 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
10126 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
10132 "Detailed information on TCP and BGP neighbor connections\n"
10133 "Neighbor to display information about\n"
10134 "Neighbor to display information about\n"
10135 "Display information received from a BGP neighbor\n"
10136 "Display the prefixlist filter\n")
10137 #endif /* HAVE_IPV6 */
10140 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
10141 safi_t safi
, enum bgp_show_type type
)
10143 if (! peer
|| ! peer
->afc
[afi
][safi
])
10145 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
10146 return CMD_WARNING
;
10149 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
10152 DEFUN (show_ip_bgp_neighbor_routes
,
10153 show_ip_bgp_neighbor_routes_cmd
,
10154 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
10158 "Detailed information on TCP and BGP neighbor connections\n"
10159 "Neighbor to display information about\n"
10160 "Neighbor to display information about\n"
10161 "Display routes learned from neighbor\n")
10165 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10167 return CMD_WARNING
;
10169 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10170 bgp_show_type_neighbor
);
10173 DEFUN (show_ip_bgp_neighbor_flap
,
10174 show_ip_bgp_neighbor_flap_cmd
,
10175 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10179 "Detailed information on TCP and BGP neighbor connections\n"
10180 "Neighbor to display information about\n"
10181 "Neighbor to display information about\n"
10182 "Display flap statistics of the routes learned from neighbor\n")
10186 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10188 return CMD_WARNING
;
10190 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10191 bgp_show_type_flap_neighbor
);
10194 DEFUN (show_ip_bgp_neighbor_damp
,
10195 show_ip_bgp_neighbor_damp_cmd
,
10196 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10200 "Detailed information on TCP and BGP neighbor connections\n"
10201 "Neighbor to display information about\n"
10202 "Neighbor to display information about\n"
10203 "Display the dampened routes received from neighbor\n")
10207 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10209 return CMD_WARNING
;
10211 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10212 bgp_show_type_damp_neighbor
);
10215 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
10216 show_ip_bgp_ipv4_neighbor_routes_cmd
,
10217 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
10222 "Address Family modifier\n"
10223 "Address Family modifier\n"
10224 "Detailed information on TCP and BGP neighbor connections\n"
10225 "Neighbor to display information about\n"
10226 "Neighbor to display information about\n"
10227 "Display routes learned from neighbor\n")
10231 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
10233 return CMD_WARNING
;
10235 if (strncmp (argv
[0], "m", 1) == 0)
10236 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
10237 bgp_show_type_neighbor
);
10239 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
10240 bgp_show_type_neighbor
);
10243 DEFUN (show_ip_bgp_view_rsclient
,
10244 show_ip_bgp_view_rsclient_cmd
,
10245 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10251 "Information about Route Server Client\n"
10254 struct bgp_table
*table
;
10258 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10260 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10263 return CMD_WARNING
;
10265 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10267 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10269 return CMD_WARNING
;
10272 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10273 PEER_FLAG_RSERVER_CLIENT
))
10275 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10277 return CMD_WARNING
;
10280 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
10282 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10285 ALIAS (show_ip_bgp_view_rsclient
,
10286 show_ip_bgp_rsclient_cmd
,
10287 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
10291 "Information about Route Server Client\n"
10294 DEFUN (show_ip_bgp_view_rsclient_route
,
10295 show_ip_bgp_view_rsclient_route_cmd
,
10296 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10302 "Information about Route Server Client\n"
10304 "Network in the BGP routing table to display\n")
10309 /* BGP structure lookup. */
10312 bgp
= bgp_lookup_by_name (argv
[0]);
10315 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10316 return CMD_WARNING
;
10321 bgp
= bgp_get_default ();
10324 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10325 return CMD_WARNING
;
10330 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10332 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10335 return CMD_WARNING
;
10337 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10339 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10341 return CMD_WARNING
;
10344 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10345 PEER_FLAG_RSERVER_CLIENT
))
10347 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10349 return CMD_WARNING
;
10352 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10353 (argc
== 3) ? argv
[2] : argv
[1],
10354 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
10357 ALIAS (show_ip_bgp_view_rsclient_route
,
10358 show_ip_bgp_rsclient_route_cmd
,
10359 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10363 "Information about Route Server Client\n"
10365 "Network in the BGP routing table to display\n")
10367 DEFUN (show_ip_bgp_view_rsclient_prefix
,
10368 show_ip_bgp_view_rsclient_prefix_cmd
,
10369 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10375 "Information about Route Server Client\n"
10377 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10382 /* BGP structure lookup. */
10385 bgp
= bgp_lookup_by_name (argv
[0]);
10388 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10389 return CMD_WARNING
;
10394 bgp
= bgp_get_default ();
10397 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10398 return CMD_WARNING
;
10403 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10405 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10408 return CMD_WARNING
;
10410 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10412 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10414 return CMD_WARNING
;
10417 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10418 PEER_FLAG_RSERVER_CLIENT
))
10420 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10422 return CMD_WARNING
;
10425 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10426 (argc
== 3) ? argv
[2] : argv
[1],
10427 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
10430 ALIAS (show_ip_bgp_view_rsclient_prefix
,
10431 show_ip_bgp_rsclient_prefix_cmd
,
10432 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10436 "Information about Route Server Client\n"
10438 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10442 DEFUN (show_bgp_view_neighbor_routes
,
10443 show_bgp_view_neighbor_routes_cmd
,
10444 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
10449 "Detailed information on TCP and BGP neighbor connections\n"
10450 "Neighbor to display information about\n"
10451 "Neighbor to display information about\n"
10452 "Display routes learned from neighbor\n")
10457 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10459 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10462 return CMD_WARNING
;
10464 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10465 bgp_show_type_neighbor
);
10468 ALIAS (show_bgp_view_neighbor_routes
,
10469 show_bgp_view_ipv6_neighbor_routes_cmd
,
10470 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10476 "Detailed information on TCP and BGP neighbor connections\n"
10477 "Neighbor to display information about\n"
10478 "Neighbor to display information about\n"
10479 "Display routes learned from neighbor\n")
10481 DEFUN (show_bgp_view_neighbor_damp
,
10482 show_bgp_view_neighbor_damp_cmd
,
10483 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10488 "Detailed information on TCP and BGP neighbor connections\n"
10489 "Neighbor to display information about\n"
10490 "Neighbor to display information about\n"
10491 "Display the dampened routes received from neighbor\n")
10496 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10498 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10501 return CMD_WARNING
;
10503 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10504 bgp_show_type_damp_neighbor
);
10507 ALIAS (show_bgp_view_neighbor_damp
,
10508 show_bgp_view_ipv6_neighbor_damp_cmd
,
10509 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10515 "Detailed information on TCP and BGP neighbor connections\n"
10516 "Neighbor to display information about\n"
10517 "Neighbor to display information about\n"
10518 "Display the dampened routes received from neighbor\n")
10520 DEFUN (show_bgp_view_neighbor_flap
,
10521 show_bgp_view_neighbor_flap_cmd
,
10522 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10527 "Detailed information on TCP and BGP neighbor connections\n"
10528 "Neighbor to display information about\n"
10529 "Neighbor to display information about\n"
10530 "Display flap statistics of the routes learned from neighbor\n")
10535 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10537 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10540 return CMD_WARNING
;
10542 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10543 bgp_show_type_flap_neighbor
);
10546 ALIAS (show_bgp_view_neighbor_flap
,
10547 show_bgp_view_ipv6_neighbor_flap_cmd
,
10548 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10554 "Detailed information on TCP and BGP neighbor connections\n"
10555 "Neighbor to display information about\n"
10556 "Neighbor to display information about\n"
10557 "Display flap statistics of the routes learned from neighbor\n")
10559 ALIAS (show_bgp_view_neighbor_routes
,
10560 show_bgp_neighbor_routes_cmd
,
10561 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
10564 "Detailed information on TCP and BGP neighbor connections\n"
10565 "Neighbor to display information about\n"
10566 "Neighbor to display information about\n"
10567 "Display routes learned from neighbor\n")
10570 ALIAS (show_bgp_view_neighbor_routes
,
10571 show_bgp_ipv6_neighbor_routes_cmd
,
10572 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10576 "Detailed information on TCP and BGP neighbor connections\n"
10577 "Neighbor to display information about\n"
10578 "Neighbor to display information about\n"
10579 "Display routes learned from neighbor\n")
10582 ALIAS (show_bgp_view_neighbor_routes
,
10583 ipv6_bgp_neighbor_routes_cmd
,
10584 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
10588 "Detailed information on TCP and BGP neighbor connections\n"
10589 "Neighbor to display information about\n"
10590 "Neighbor to display information about\n"
10591 "Display routes learned from neighbor\n")
10594 DEFUN (ipv6_mbgp_neighbor_routes
,
10595 ipv6_mbgp_neighbor_routes_cmd
,
10596 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
10600 "Detailed information on TCP and BGP neighbor connections\n"
10601 "Neighbor to display information about\n"
10602 "Neighbor to display information about\n"
10603 "Display routes learned from neighbor\n")
10607 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10609 return CMD_WARNING
;
10611 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
10612 bgp_show_type_neighbor
);
10615 ALIAS (show_bgp_view_neighbor_flap
,
10616 show_bgp_neighbor_flap_cmd
,
10617 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10620 "Detailed information on TCP and BGP neighbor connections\n"
10621 "Neighbor to display information about\n"
10622 "Neighbor to display information about\n"
10623 "Display flap statistics of the routes learned from neighbor\n")
10625 ALIAS (show_bgp_view_neighbor_flap
,
10626 show_bgp_ipv6_neighbor_flap_cmd
,
10627 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10631 "Detailed information on TCP and BGP neighbor connections\n"
10632 "Neighbor to display information about\n"
10633 "Neighbor to display information about\n"
10634 "Display flap statistics of the routes learned from neighbor\n")
10636 ALIAS (show_bgp_view_neighbor_damp
,
10637 show_bgp_neighbor_damp_cmd
,
10638 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10641 "Detailed information on TCP and BGP neighbor connections\n"
10642 "Neighbor to display information about\n"
10643 "Neighbor to display information about\n"
10644 "Display the dampened routes received from neighbor\n")
10646 ALIAS (show_bgp_view_neighbor_damp
,
10647 show_bgp_ipv6_neighbor_damp_cmd
,
10648 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10652 "Detailed information on TCP and BGP neighbor connections\n"
10653 "Neighbor to display information about\n"
10654 "Neighbor to display information about\n"
10655 "Display the dampened routes received from neighbor\n")
10657 DEFUN (show_bgp_view_rsclient
,
10658 show_bgp_view_rsclient_cmd
,
10659 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10664 "Information about Route Server Client\n"
10667 struct bgp_table
*table
;
10671 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10673 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10676 return CMD_WARNING
;
10678 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10680 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10682 return CMD_WARNING
;
10685 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10686 PEER_FLAG_RSERVER_CLIENT
))
10688 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10690 return CMD_WARNING
;
10693 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
10695 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10698 ALIAS (show_bgp_view_rsclient
,
10699 show_bgp_rsclient_cmd
,
10700 "show bgp rsclient (A.B.C.D|X:X::X:X)",
10703 "Information about Route Server Client\n"
10706 DEFUN (show_bgp_view_rsclient_route
,
10707 show_bgp_view_rsclient_route_cmd
,
10708 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10713 "Information about Route Server Client\n"
10715 "Network in the BGP routing table to display\n")
10720 /* BGP structure lookup. */
10723 bgp
= bgp_lookup_by_name (argv
[0]);
10726 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10727 return CMD_WARNING
;
10732 bgp
= bgp_get_default ();
10735 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10736 return CMD_WARNING
;
10741 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10743 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10746 return CMD_WARNING
;
10748 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10750 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10752 return CMD_WARNING
;
10755 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10756 PEER_FLAG_RSERVER_CLIENT
))
10758 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10760 return CMD_WARNING
;
10763 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10764 (argc
== 3) ? argv
[2] : argv
[1],
10765 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
10768 ALIAS (show_bgp_view_rsclient_route
,
10769 show_bgp_rsclient_route_cmd
,
10770 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10773 "Information about Route Server Client\n"
10775 "Network in the BGP routing table to display\n")
10777 DEFUN (show_bgp_view_rsclient_prefix
,
10778 show_bgp_view_rsclient_prefix_cmd
,
10779 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10784 "Information about Route Server Client\n"
10786 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10791 /* BGP structure lookup. */
10794 bgp
= bgp_lookup_by_name (argv
[0]);
10797 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10798 return CMD_WARNING
;
10803 bgp
= bgp_get_default ();
10806 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10807 return CMD_WARNING
;
10812 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10814 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10817 return CMD_WARNING
;
10819 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10821 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10823 return CMD_WARNING
;
10826 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10827 PEER_FLAG_RSERVER_CLIENT
))
10829 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10831 return CMD_WARNING
;
10834 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10835 (argc
== 3) ? argv
[2] : argv
[1],
10836 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
10839 ALIAS (show_bgp_view_rsclient_prefix
,
10840 show_bgp_rsclient_prefix_cmd
,
10841 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10844 "Information about Route Server Client\n"
10846 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10848 #endif /* HAVE_IPV6 */
10850 struct bgp_table
*bgp_distance_table
;
10852 struct bgp_distance
10854 /* Distance value for the IP source prefix. */
10857 /* Name of the access-list to be matched. */
10861 static struct bgp_distance
*
10862 bgp_distance_new ()
10864 struct bgp_distance
*new;
10865 new = XMALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
10866 memset (new, 0, sizeof (struct bgp_distance
));
10871 bgp_distance_free (struct bgp_distance
*bdistance
)
10873 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
10877 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
10878 const char *ip_str
, const char *access_list_str
)
10881 struct prefix_ipv4 p
;
10883 struct bgp_node
*rn
;
10884 struct bgp_distance
*bdistance
;
10886 ret
= str2prefix_ipv4 (ip_str
, &p
);
10889 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10890 return CMD_WARNING
;
10893 distance
= atoi (distance_str
);
10895 /* Get BGP distance node. */
10896 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
10899 bdistance
= rn
->info
;
10900 bgp_unlock_node (rn
);
10904 bdistance
= bgp_distance_new ();
10905 rn
->info
= bdistance
;
10908 /* Set distance value. */
10909 bdistance
->distance
= distance
;
10911 /* Reset access-list configuration. */
10912 if (bdistance
->access_list
)
10914 free (bdistance
->access_list
);
10915 bdistance
->access_list
= NULL
;
10917 if (access_list_str
)
10918 bdistance
->access_list
= strdup (access_list_str
);
10920 return CMD_SUCCESS
;
10924 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
10925 const char *ip_str
, const char *access_list_str
)
10928 struct prefix_ipv4 p
;
10930 struct bgp_node
*rn
;
10931 struct bgp_distance
*bdistance
;
10933 ret
= str2prefix_ipv4 (ip_str
, &p
);
10936 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10937 return CMD_WARNING
;
10940 distance
= atoi (distance_str
);
10942 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
10945 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
10946 return CMD_WARNING
;
10949 bdistance
= rn
->info
;
10951 if (bdistance
->access_list
)
10952 free (bdistance
->access_list
);
10953 bgp_distance_free (bdistance
);
10956 bgp_unlock_node (rn
);
10957 bgp_unlock_node (rn
);
10959 return CMD_SUCCESS
;
10963 bgp_distance_reset ()
10965 struct bgp_node
*rn
;
10966 struct bgp_distance
*bdistance
;
10968 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
10969 if ((bdistance
= rn
->info
) != NULL
)
10971 if (bdistance
->access_list
)
10972 free (bdistance
->access_list
);
10973 bgp_distance_free (bdistance
);
10975 bgp_unlock_node (rn
);
10979 /* Apply BGP information to distance method. */
10981 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
10983 struct bgp_node
*rn
;
10984 struct prefix_ipv4 q
;
10986 struct bgp_distance
*bdistance
;
10987 struct access_list
*alist
;
10988 struct bgp_static
*bgp_static
;
10993 if (p
->family
!= AF_INET
)
10996 peer
= rinfo
->peer
;
10998 if (peer
->su
.sa
.sa_family
!= AF_INET
)
11001 memset (&q
, 0, sizeof (struct prefix_ipv4
));
11002 q
.family
= AF_INET
;
11003 q
.prefix
= peer
->su
.sin
.sin_addr
;
11004 q
.prefixlen
= IPV4_MAX_BITLEN
;
11006 /* Check source address. */
11007 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
11010 bdistance
= rn
->info
;
11011 bgp_unlock_node (rn
);
11013 if (bdistance
->access_list
)
11015 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
11016 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
11017 return bdistance
->distance
;
11020 return bdistance
->distance
;
11023 /* Backdoor check. */
11024 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
11027 bgp_static
= rn
->info
;
11028 bgp_unlock_node (rn
);
11030 if (bgp_static
->backdoor
)
11032 if (bgp
->distance_local
)
11033 return bgp
->distance_local
;
11035 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11039 if (peer_sort (peer
) == BGP_PEER_EBGP
)
11041 if (bgp
->distance_ebgp
)
11042 return bgp
->distance_ebgp
;
11043 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
11047 if (bgp
->distance_ibgp
)
11048 return bgp
->distance_ibgp
;
11049 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
11053 DEFUN (bgp_distance
,
11055 "distance bgp <1-255> <1-255> <1-255>",
11056 "Define an administrative distance\n"
11058 "Distance for routes external to the AS\n"
11059 "Distance for routes internal to the AS\n"
11060 "Distance for local routes\n")
11066 bgp
->distance_ebgp
= atoi (argv
[0]);
11067 bgp
->distance_ibgp
= atoi (argv
[1]);
11068 bgp
->distance_local
= atoi (argv
[2]);
11069 return CMD_SUCCESS
;
11072 DEFUN (no_bgp_distance
,
11073 no_bgp_distance_cmd
,
11074 "no distance bgp <1-255> <1-255> <1-255>",
11076 "Define an administrative distance\n"
11078 "Distance for routes external to the AS\n"
11079 "Distance for routes internal to the AS\n"
11080 "Distance for local routes\n")
11086 bgp
->distance_ebgp
= 0;
11087 bgp
->distance_ibgp
= 0;
11088 bgp
->distance_local
= 0;
11089 return CMD_SUCCESS
;
11092 ALIAS (no_bgp_distance
,
11093 no_bgp_distance2_cmd
,
11096 "Define an administrative distance\n"
11099 DEFUN (bgp_distance_source
,
11100 bgp_distance_source_cmd
,
11101 "distance <1-255> A.B.C.D/M",
11102 "Define an administrative distance\n"
11103 "Administrative distance\n"
11104 "IP source prefix\n")
11106 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
11107 return CMD_SUCCESS
;
11110 DEFUN (no_bgp_distance_source
,
11111 no_bgp_distance_source_cmd
,
11112 "no distance <1-255> A.B.C.D/M",
11114 "Define an administrative distance\n"
11115 "Administrative distance\n"
11116 "IP source prefix\n")
11118 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
11119 return CMD_SUCCESS
;
11122 DEFUN (bgp_distance_source_access_list
,
11123 bgp_distance_source_access_list_cmd
,
11124 "distance <1-255> A.B.C.D/M WORD",
11125 "Define an administrative distance\n"
11126 "Administrative distance\n"
11127 "IP source prefix\n"
11128 "Access list name\n")
11130 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
11131 return CMD_SUCCESS
;
11134 DEFUN (no_bgp_distance_source_access_list
,
11135 no_bgp_distance_source_access_list_cmd
,
11136 "no distance <1-255> A.B.C.D/M WORD",
11138 "Define an administrative distance\n"
11139 "Administrative distance\n"
11140 "IP source prefix\n"
11141 "Access list name\n")
11143 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
11144 return CMD_SUCCESS
;
11147 DEFUN (bgp_damp_set
,
11149 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11150 "BGP Specific commands\n"
11151 "Enable route-flap dampening\n"
11152 "Half-life time for the penalty\n"
11153 "Value to start reusing a route\n"
11154 "Value to start suppressing a route\n"
11155 "Maximum duration to suppress a stable route\n")
11158 int half
= DEFAULT_HALF_LIFE
* 60;
11159 int reuse
= DEFAULT_REUSE
;
11160 int suppress
= DEFAULT_SUPPRESS
;
11161 int max
= 4 * half
;
11165 half
= atoi (argv
[0]) * 60;
11166 reuse
= atoi (argv
[1]);
11167 suppress
= atoi (argv
[2]);
11168 max
= atoi (argv
[3]) * 60;
11170 else if (argc
== 1)
11172 half
= atoi (argv
[0]) * 60;
11177 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
11178 half
, reuse
, suppress
, max
);
11181 ALIAS (bgp_damp_set
,
11183 "bgp dampening <1-45>",
11184 "BGP Specific commands\n"
11185 "Enable route-flap dampening\n"
11186 "Half-life time for the penalty\n")
11188 ALIAS (bgp_damp_set
,
11191 "BGP Specific commands\n"
11192 "Enable route-flap dampening\n")
11194 DEFUN (bgp_damp_unset
,
11195 bgp_damp_unset_cmd
,
11196 "no bgp dampening",
11198 "BGP Specific commands\n"
11199 "Enable route-flap dampening\n")
11204 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
11207 ALIAS (bgp_damp_unset
,
11208 bgp_damp_unset2_cmd
,
11209 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
11211 "BGP Specific commands\n"
11212 "Enable route-flap dampening\n"
11213 "Half-life time for the penalty\n"
11214 "Value to start reusing a route\n"
11215 "Value to start suppressing a route\n"
11216 "Maximum duration to suppress a stable route\n")
11218 DEFUN (show_ip_bgp_dampened_paths
,
11219 show_ip_bgp_dampened_paths_cmd
,
11220 "show ip bgp dampened-paths",
11224 "Display paths suppressed due to dampening\n")
11226 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
11230 DEFUN (show_ip_bgp_flap_statistics
,
11231 show_ip_bgp_flap_statistics_cmd
,
11232 "show ip bgp flap-statistics",
11236 "Display flap statistics of routes\n")
11238 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
11239 bgp_show_type_flap_statistics
, NULL
);
11242 /* Display specified route of BGP table. */
11244 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
11245 const char *ip_str
, afi_t afi
, safi_t safi
,
11246 struct prefix_rd
*prd
, int prefix_check
)
11249 struct prefix match
;
11250 struct bgp_node
*rn
;
11251 struct bgp_node
*rm
;
11252 struct bgp_info
*ri
;
11253 struct bgp_info
*ri_temp
;
11255 struct bgp_table
*table
;
11257 /* BGP structure lookup. */
11260 bgp
= bgp_lookup_by_name (view_name
);
11263 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
11264 return CMD_WARNING
;
11269 bgp
= bgp_get_default ();
11272 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
11273 return CMD_WARNING
;
11277 /* Check IP address argument. */
11278 ret
= str2prefix (ip_str
, &match
);
11281 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
11282 return CMD_WARNING
;
11285 match
.family
= afi2family (afi
);
11287 if (safi
== SAFI_MPLS_VPN
)
11289 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
11291 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
11294 if ((table
= rn
->info
) != NULL
)
11295 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
11296 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
11301 if (ri
->extra
&& ri
->extra
->damp_info
)
11303 ri_temp
= ri
->next
;
11304 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11315 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
11316 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
11321 if (ri
->extra
&& ri
->extra
->damp_info
)
11323 ri_temp
= ri
->next
;
11324 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11333 return CMD_SUCCESS
;
11336 DEFUN (clear_ip_bgp_dampening
,
11337 clear_ip_bgp_dampening_cmd
,
11338 "clear ip bgp dampening",
11342 "Clear route flap dampening information\n")
11344 bgp_damp_info_clean ();
11345 return CMD_SUCCESS
;
11348 DEFUN (clear_ip_bgp_dampening_prefix
,
11349 clear_ip_bgp_dampening_prefix_cmd
,
11350 "clear ip bgp dampening A.B.C.D/M",
11354 "Clear route flap dampening information\n"
11355 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11357 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11358 SAFI_UNICAST
, NULL
, 1);
11361 DEFUN (clear_ip_bgp_dampening_address
,
11362 clear_ip_bgp_dampening_address_cmd
,
11363 "clear ip bgp dampening A.B.C.D",
11367 "Clear route flap dampening information\n"
11368 "Network to clear damping information\n")
11370 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11371 SAFI_UNICAST
, NULL
, 0);
11374 DEFUN (clear_ip_bgp_dampening_address_mask
,
11375 clear_ip_bgp_dampening_address_mask_cmd
,
11376 "clear ip bgp dampening A.B.C.D A.B.C.D",
11380 "Clear route flap dampening information\n"
11381 "Network to clear damping information\n"
11385 char prefix_str
[BUFSIZ
];
11387 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
11390 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
11391 return CMD_WARNING
;
11394 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
11395 SAFI_UNICAST
, NULL
, 0);
11399 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
11400 afi_t afi
, safi_t safi
, int *write
)
11402 struct bgp_node
*prn
;
11403 struct bgp_node
*rn
;
11404 struct bgp_table
*table
;
11406 struct prefix_rd
*prd
;
11407 struct bgp_static
*bgp_static
;
11409 char buf
[SU_ADDRSTRLEN
];
11410 char rdbuf
[RD_ADDRSTRLEN
];
11412 /* Network configuration. */
11413 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
11414 if ((table
= prn
->info
) != NULL
)
11415 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
11416 if ((bgp_static
= rn
->info
) != NULL
)
11419 prd
= (struct prefix_rd
*) &prn
->p
;
11421 /* "address-family" display. */
11422 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11424 /* "network" configuration display. */
11425 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
11426 label
= decode_label (bgp_static
->tag
);
11428 vty_out (vty
, " network %s/%d rd %s tag %d",
11429 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11432 vty_out (vty
, "%s", VTY_NEWLINE
);
11437 /* Configuration of static route announcement and aggregate
11440 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
11441 afi_t afi
, safi_t safi
, int *write
)
11443 struct bgp_node
*rn
;
11445 struct bgp_static
*bgp_static
;
11446 struct bgp_aggregate
*bgp_aggregate
;
11447 char buf
[SU_ADDRSTRLEN
];
11449 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
11450 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
11452 /* Network configuration. */
11453 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11454 if ((bgp_static
= rn
->info
) != NULL
)
11458 /* "address-family" display. */
11459 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11461 /* "network" configuration display. */
11462 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11464 u_int32_t destination
;
11465 struct in_addr netmask
;
11467 destination
= ntohl (p
->u
.prefix4
.s_addr
);
11468 masklen2ip (p
->prefixlen
, &netmask
);
11469 vty_out (vty
, " network %s",
11470 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
11472 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
11473 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
11474 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
11475 || p
->u
.prefix4
.s_addr
== 0)
11477 /* Natural mask is not display. */
11480 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
11484 vty_out (vty
, " network %s/%d",
11485 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11489 if (bgp_static
->rmap
.name
)
11490 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
11493 if (bgp_static
->backdoor
)
11494 vty_out (vty
, " backdoor");
11495 if (bgp_static
->ttl
)
11496 vty_out (vty
, " pathlimit %u", bgp_static
->ttl
);
11499 vty_out (vty
, "%s", VTY_NEWLINE
);
11502 /* Aggregate-address configuration. */
11503 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11504 if ((bgp_aggregate
= rn
->info
) != NULL
)
11508 /* "address-family" display. */
11509 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11511 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11513 struct in_addr netmask
;
11515 masklen2ip (p
->prefixlen
, &netmask
);
11516 vty_out (vty
, " aggregate-address %s %s",
11517 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11518 inet_ntoa (netmask
));
11522 vty_out (vty
, " aggregate-address %s/%d",
11523 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11527 if (bgp_aggregate
->as_set
)
11528 vty_out (vty
, " as-set");
11530 if (bgp_aggregate
->summary_only
)
11531 vty_out (vty
, " summary-only");
11533 vty_out (vty
, "%s", VTY_NEWLINE
);
11540 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
11542 struct bgp_node
*rn
;
11543 struct bgp_distance
*bdistance
;
11545 /* Distance configuration. */
11546 if (bgp
->distance_ebgp
11547 && bgp
->distance_ibgp
11548 && bgp
->distance_local
11549 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
11550 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
11551 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
11552 vty_out (vty
, " distance bgp %d %d %d%s",
11553 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
11556 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
11557 if ((bdistance
= rn
->info
) != NULL
)
11559 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
11560 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
11561 bdistance
->access_list
? bdistance
->access_list
: "",
11568 /* Allocate routing table structure and install commands. */
11572 /* Init BGP distance table. */
11573 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
11575 /* IPv4 BGP commands. */
11576 install_element (BGP_NODE
, &bgp_network_cmd
);
11577 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
11578 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
11579 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
11580 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
11581 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11582 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
11583 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
11584 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
11585 install_element (BGP_NODE
, &bgp_network_ttl_cmd
);
11586 install_element (BGP_NODE
, &bgp_network_mask_ttl_cmd
);
11587 install_element (BGP_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11588 install_element (BGP_NODE
, &bgp_network_backdoor_ttl_cmd
);
11589 install_element (BGP_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11590 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
);
11591 install_element (BGP_NODE
, &no_bgp_network_cmd
);
11592 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
11593 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
11594 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
11595 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
11596 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11597 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
11598 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
11599 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
11600 install_element (BGP_NODE
, &no_bgp_network_ttl_cmd
);
11601 install_element (BGP_NODE
, &no_bgp_network_mask_ttl_cmd
);
11602 install_element (BGP_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11603 install_element (BGP_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11604 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11605 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
);
11607 install_element (BGP_NODE
, &aggregate_address_cmd
);
11608 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
11609 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
11610 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
11611 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
11612 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
11613 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
11614 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11615 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
11616 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11617 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
11618 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
11619 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
11620 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11621 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11622 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
11623 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11624 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11625 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11626 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11628 /* IPv4 unicast configuration. */
11629 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
11630 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
11631 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
11632 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
11633 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
11634 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11635 install_element (BGP_IPV4_NODE
, &bgp_network_ttl_cmd
);
11636 install_element (BGP_IPV4_NODE
, &bgp_network_mask_ttl_cmd
);
11637 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11638 install_element (BGP_IPV4_NODE
, &bgp_network_backdoor_ttl_cmd
);
11639 install_element (BGP_IPV4_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11640 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11641 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
11642 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
11643 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
11644 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
11645 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11646 install_element (BGP_IPV4_NODE
, &no_bgp_network_ttl_cmd
);
11647 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_ttl_cmd
);
11648 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11649 install_element (BGP_IPV4_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11650 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11651 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11652 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
11653 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
11654 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
11655 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
11656 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
11657 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
11658 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
11659 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11660 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
11661 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11662 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
11663 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
11664 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
11665 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11666 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11667 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
11668 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11669 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11670 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11671 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11673 /* IPv4 multicast configuration. */
11674 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
11675 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
11676 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
11677 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
11678 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
11679 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11680 install_element (BGP_IPV4M_NODE
, &bgp_network_ttl_cmd
);
11681 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_ttl_cmd
);
11682 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_ttl_cmd
);
11683 install_element (BGP_IPV4M_NODE
, &bgp_network_backdoor_ttl_cmd
);
11684 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_backdoor_ttl_cmd
);
11685 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11686 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
11687 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
11688 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
11689 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
11690 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
11691 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11692 install_element (BGP_IPV4M_NODE
, &no_bgp_network_ttl_cmd
);
11693 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_ttl_cmd
);
11694 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_ttl_cmd
);
11695 install_element (BGP_IPV4M_NODE
, &no_bgp_network_backdoor_ttl_cmd
);
11696 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_backdoor_ttl_cmd
);
11697 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_backdoor_ttl_cmd
); install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11698 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
11699 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
11700 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
11701 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
11702 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
11703 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
11704 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
11705 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11706 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
11707 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11708 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
11709 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
11710 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
11711 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11712 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11713 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
11714 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11715 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11716 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11717 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11719 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
11720 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
11721 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
11722 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11723 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11724 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11725 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
11726 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11727 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11728 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11729 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
11730 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
11731 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
11732 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
11733 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11734 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
11735 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11736 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
11737 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11738 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
11739 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11740 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
11741 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11742 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
11743 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11744 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
11745 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
11746 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
11747 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
11748 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11749 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11750 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11751 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11752 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
11753 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
11754 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
11755 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
11756 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11757 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11758 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11759 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11760 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
11761 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11762 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11763 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11764 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11765 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11766 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11767 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11768 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11769 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11770 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11771 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11772 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11773 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11774 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11775 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11776 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
11777 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11778 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11779 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11780 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11781 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11782 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11783 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11784 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11785 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11786 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
11787 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11788 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11789 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11790 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11791 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11793 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
11794 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
11795 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
11796 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11797 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11798 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11799 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
11800 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11801 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11802 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11803 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
11804 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
11805 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
11806 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
11807 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11808 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
11809 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11810 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
11811 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11812 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
11813 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11814 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
11815 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11816 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
11817 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11818 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
11819 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
11820 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
11821 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
11822 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11823 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11824 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11825 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11826 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
11827 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
11828 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
11829 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
11830 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11831 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11832 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11833 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11834 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
11835 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11836 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11837 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11838 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11839 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11840 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11841 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11842 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11843 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11844 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11845 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11846 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11847 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11848 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11849 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11850 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
11851 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11852 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11853 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11854 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11855 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11856 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11857 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11858 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11859 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11860 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
11861 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11862 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11863 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11864 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11865 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11867 /* BGP dampening clear commands */
11868 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
11869 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
11870 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
11871 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
11874 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
11875 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
11876 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
11878 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
11880 /* New config IPv6 BGP commands. */
11881 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
11882 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
11883 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_ttl_cmd
);
11884 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
11885 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
11886 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_ttl_cmd
);
11888 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
11889 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
11890 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
11891 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
11893 /* Old config IPv6 BGP commands. */
11894 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
11895 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
11897 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
11898 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
11899 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
11900 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
11902 install_element (VIEW_NODE
, &show_bgp_cmd
);
11903 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
11904 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
11905 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
11906 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
11907 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
11908 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
11909 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
11910 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
11911 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
11912 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
11913 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
11914 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
11915 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
11916 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
11917 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
11918 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
11919 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
11920 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
11921 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
11922 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
11923 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
11924 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
11925 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
11926 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
11927 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11928 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
11929 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11930 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
11931 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11932 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
11933 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11934 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
11935 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
11936 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
11937 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
11938 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
11939 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
11940 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
11941 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
11942 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
11943 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
11944 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
11945 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
11946 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
11947 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
11948 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
11949 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
11950 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
11951 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
11952 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
11953 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
11954 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
11955 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
11956 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
11957 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
11958 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
11959 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
11960 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11961 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
11962 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
11963 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
11964 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
11965 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
11966 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
11967 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11968 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11969 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
11970 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
11971 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
11972 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
11973 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
11974 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
11975 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11977 install_element (ENABLE_NODE
, &show_bgp_cmd
);
11978 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
11979 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
11980 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
11981 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
11982 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
11983 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
11984 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
11985 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
11986 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
11987 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
11988 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
11989 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
11990 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
11991 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
11992 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
11993 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
11994 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
11995 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
11996 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
11997 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
11998 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
11999 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
12000 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
12001 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
12002 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
12003 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
12004 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
12005 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
12006 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
12007 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
12008 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
12009 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
12010 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
12011 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
12012 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
12013 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
12014 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
12015 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
12016 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
12017 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
12018 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
12019 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
12020 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
12021 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
12022 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
12023 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
12024 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
12025 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
12026 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
12027 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
12028 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
12029 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
12030 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
12031 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
12032 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
12033 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
12034 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
12035 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
12036 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
12037 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
12038 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
12039 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
12040 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
12041 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
12042 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
12043 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
12044 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
12045 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
12046 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
12047 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
12048 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
12049 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
12050 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
12053 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
12054 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
12055 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
12056 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
12059 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
12060 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
12061 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
12062 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
12063 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12064 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12065 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
12066 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
12067 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
12068 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
12069 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
12070 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12071 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12072 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12073 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12074 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
12075 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12076 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12077 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
12078 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
12079 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12080 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12081 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12082 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12083 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12084 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
12085 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
12086 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
12087 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
12088 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12089 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12090 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12091 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12092 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12093 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12094 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12097 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
12098 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
12099 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
12100 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
12101 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
12102 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
12103 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
12104 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
12105 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
12106 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
12107 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
12108 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
12109 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
12110 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
12111 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
12112 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
12113 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
12114 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
12115 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
12116 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
12117 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
12118 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
12119 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
12120 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
12121 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
12122 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
12123 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
12124 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
12125 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
12126 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
12127 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
12128 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
12129 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
12130 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
12131 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
12132 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
12135 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12136 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
12137 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12138 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
12141 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12142 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
12143 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12144 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
12147 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12148 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
12149 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12150 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
12151 #endif /* HAVE_IPV6 */
12153 install_element (BGP_NODE
, &bgp_distance_cmd
);
12154 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
12155 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
12156 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
12157 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
12158 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
12159 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
12161 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
12162 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
12163 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
12164 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
12165 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
12166 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
12167 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
12168 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
12169 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
12170 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);