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 /* For modify attribute, copy it to temporary structure. */
888 bgp_attr_dup (attr
, ri
->attr
);
890 /* If local-preference is not set. */
891 if ((peer_sort (peer
) == BGP_PEER_IBGP
892 || peer_sort (peer
) == BGP_PEER_CONFED
)
893 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
895 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
896 attr
->local_pref
= bgp
->default_local_pref
;
899 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
900 if (peer_sort (peer
) == BGP_PEER_EBGP
901 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
903 if (ri
->peer
!= bgp
->peer_self
&& ! transparent
904 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
905 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
909 if (transparent
|| reflect
910 || (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
)
911 && ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
)
913 || (p
->family
== AF_INET6
&&
914 ! IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
915 #endif /* HAVE_IPV6 */
918 /* NEXT-HOP Unchanged. */
920 else if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
921 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
923 || (p
->family
== AF_INET6
&&
924 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
925 #endif /* HAVE_IPV6 */
926 || (peer_sort (peer
) == BGP_PEER_EBGP
927 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0))
929 /* Set IPv4 nexthop. */
930 if (p
->family
== AF_INET
)
932 if (safi
== SAFI_MPLS_VPN
)
933 memcpy (&attr
->extra
->mp_nexthop_global_in
, &peer
->nexthop
.v4
,
936 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
939 /* Set IPv6 nexthop. */
940 if (p
->family
== AF_INET6
)
942 /* IPv6 global nexthop must be included. */
943 memcpy (&attr
->extra
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
945 attr
->extra
->mp_nexthop_len
= 16;
947 #endif /* HAVE_IPV6 */
951 if (p
->family
== AF_INET6
)
953 /* Left nexthop_local unchanged if so configured. */
954 if ( CHECK_FLAG (peer
->af_flags
[afi
][safi
],
955 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
957 if ( IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
) )
958 attr
->extra
->mp_nexthop_len
=32;
960 attr
->extra
->mp_nexthop_len
=16;
963 /* Default nexthop_local treatment for non-RS-Clients */
966 /* Link-local address should not be transit to different peer. */
967 attr
->extra
->mp_nexthop_len
= 16;
969 /* Set link-local address for shared network peer. */
970 if (peer
->shared_network
971 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
973 memcpy (&attr
->extra
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
975 attr
->extra
->mp_nexthop_len
= 32;
978 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
981 attr
->extra
->mp_nexthop_len
= 16;
983 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
984 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
985 attr
->extra
->mp_nexthop_len
= 16;
989 #endif /* HAVE_IPV6 */
991 /* If this is EBGP peer and remove-private-AS is set. */
992 if (peer_sort (peer
) == BGP_PEER_EBGP
993 && peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
994 && aspath_private_as_check (attr
->aspath
))
995 attr
->aspath
= aspath_empty_get ();
997 /* Route map & unsuppress-map apply. */
998 if (ROUTE_MAP_OUT_NAME (filter
)
999 || (ri
->extra
&& ri
->extra
->suppress
) )
1001 struct bgp_info info
;
1002 struct attr dummy_attr
;
1008 /* The route reflector is not allowed to modify the attributes
1009 of the reflected IBGP routes. */
1010 if (peer_sort (from
) == BGP_PEER_IBGP
1011 && peer_sort (peer
) == BGP_PEER_IBGP
)
1013 dummy_attr
.extra
= NULL
;
1014 bgp_attr_dup (&dummy_attr
, attr
);
1015 info
.attr
= &dummy_attr
;
1018 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1020 if (ri
->extra
&& ri
->extra
->suppress
)
1021 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1023 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1025 peer
->rmap_type
= 0;
1027 bgp_attr_extra_free (&dummy_attr
);
1029 if (ret
== RMAP_DENYMATCH
)
1031 bgp_attr_flush (attr
);
1039 bgp_announce_check_rsclient (struct bgp_info
*ri
, struct peer
*rsclient
,
1040 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1043 char buf
[SU_ADDRSTRLEN
];
1044 struct bgp_filter
*filter
;
1045 struct bgp_info info
;
1050 filter
= &rsclient
->filter
[afi
][safi
];
1051 bgp
= rsclient
->bgp
;
1053 #ifdef DISABLE_BGP_ANNOUNCE
1057 /* Do not send back route to sender. */
1058 if (from
== rsclient
)
1061 /* Aggregate-address suppress check. */
1062 if (ri
->extra
&& ri
->extra
->suppress
)
1063 if (! UNSUPPRESS_MAP_NAME (filter
))
1066 /* Default route check. */
1067 if (CHECK_FLAG (rsclient
->af_sflags
[afi
][safi
],
1068 PEER_STATUS_DEFAULT_ORIGINATE
))
1070 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1073 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1075 #endif /* HAVE_IPV6 */
1078 /* If the attribute has originator-id and it is same as remote
1080 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
1082 if (IPV4_ADDR_SAME (&rsclient
->remote_id
,
1083 &ri
->attr
->extra
->originator_id
))
1085 if (BGP_DEBUG (filter
, FILTER
))
1086 zlog (rsclient
->log
, LOG_DEBUG
,
1087 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
1089 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1095 /* ORF prefix-list filter check */
1096 if (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1097 && (CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1098 || CHECK_FLAG (rsclient
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1099 if (rsclient
->orf_plist
[afi
][safi
])
1101 if (prefix_list_apply (rsclient
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1105 /* Output filter check. */
1106 if (bgp_output_filter (rsclient
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
1108 if (BGP_DEBUG (filter
, FILTER
))
1109 zlog (rsclient
->log
, LOG_DEBUG
,
1110 "%s [Update:SEND] %s/%d is filtered",
1112 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1117 #ifdef BGP_SEND_ASPATH_CHECK
1118 /* AS path loop check. */
1119 if (aspath_loop_check (ri
->attr
->aspath
, rsclient
->as
))
1121 if (BGP_DEBUG (filter
, FILTER
))
1122 zlog (rsclient
->log
, LOG_DEBUG
,
1123 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
1124 rsclient
->host
, rsclient
->as
);
1127 #endif /* BGP_SEND_ASPATH_CHECK */
1129 /* For modify attribute, copy it to temporary structure. */
1133 if ((p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
1135 || (p
->family
== AF_INET6
&&
1136 IN6_IS_ADDR_UNSPECIFIED(&attr
->extra
->mp_nexthop_global
))
1137 #endif /* HAVE_IPV6 */
1140 /* Set IPv4 nexthop. */
1141 if (p
->family
== AF_INET
)
1143 if (safi
== SAFI_MPLS_VPN
)
1144 memcpy (&attr
->extra
->mp_nexthop_global_in
, &rsclient
->nexthop
.v4
,
1147 memcpy (&attr
->nexthop
, &rsclient
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
1150 /* Set IPv6 nexthop. */
1151 if (p
->family
== AF_INET6
)
1153 /* IPv6 global nexthop must be included. */
1154 memcpy (&attr
->extra
->mp_nexthop_global
, &rsclient
->nexthop
.v6_global
,
1156 attr
->extra
->mp_nexthop_len
= 16;
1158 #endif /* HAVE_IPV6 */
1162 if (p
->family
== AF_INET6
)
1164 struct attr_extra
*attre
= attr
->extra
;
1166 assert (attr
->extra
);
1168 /* Left nexthop_local unchanged if so configured. */
1169 if ( CHECK_FLAG (rsclient
->af_flags
[afi
][safi
],
1170 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) )
1172 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1173 attre
->mp_nexthop_len
=32;
1175 attre
->mp_nexthop_len
=16;
1178 /* Default nexthop_local treatment for RS-Clients */
1181 /* Announcer and RS-Client are both in the same network */
1182 if (rsclient
->shared_network
&& from
->shared_network
&&
1183 (rsclient
->ifindex
== from
->ifindex
))
1185 if ( IN6_IS_ADDR_LINKLOCAL (&attre
->mp_nexthop_local
) )
1186 attre
->mp_nexthop_len
=32;
1188 attre
->mp_nexthop_len
=16;
1191 /* Set link-local address for shared network peer. */
1192 else if (rsclient
->shared_network
1193 && IN6_IS_ADDR_LINKLOCAL (&rsclient
->nexthop
.v6_local
))
1195 memcpy (&attre
->mp_nexthop_local
, &rsclient
->nexthop
.v6_local
,
1197 attre
->mp_nexthop_len
= 32;
1201 attre
->mp_nexthop_len
= 16;
1205 #endif /* HAVE_IPV6 */
1208 /* If this is EBGP peer and remove-private-AS is set. */
1209 if (peer_sort (rsclient
) == BGP_PEER_EBGP
1210 && peer_af_flag_check (rsclient
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)
1211 && aspath_private_as_check (attr
->aspath
))
1212 attr
->aspath
= aspath_empty_get ();
1214 /* Route map & unsuppress-map apply. */
1215 if (ROUTE_MAP_OUT_NAME (filter
) || (ri
->extra
&& ri
->extra
->suppress
) )
1217 info
.peer
= rsclient
;
1220 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1222 if (ri
->extra
&& ri
->extra
->suppress
)
1223 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1225 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1227 rsclient
->rmap_type
= 0;
1229 if (ret
== RMAP_DENYMATCH
)
1231 bgp_attr_flush (attr
);
1239 struct bgp_info_pair
1241 struct bgp_info
*old
;
1242 struct bgp_info
*new;
1246 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
, struct bgp_info_pair
*result
)
1248 struct bgp_info
*new_select
;
1249 struct bgp_info
*old_select
;
1250 struct bgp_info
*ri
;
1251 struct bgp_info
*ri1
;
1252 struct bgp_info
*ri2
;
1253 struct bgp_info
*nextri
= NULL
;
1255 /* bgp deterministic-med */
1257 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1258 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1260 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1262 if (BGP_INFO_HOLDDOWN (ri1
))
1267 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1269 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1271 if (BGP_INFO_HOLDDOWN (ri2
))
1274 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1275 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1278 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1280 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1284 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1287 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1288 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1291 /* Check old selected route and new selected route. */
1294 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1296 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1299 if (BGP_INFO_HOLDDOWN (ri
))
1301 /* reap REMOVED routes, if needs be
1302 * selected route must stay for a while longer though
1304 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1305 && (ri
!= old_select
))
1306 bgp_info_reap (rn
, ri
);
1311 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1312 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1314 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1317 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1318 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_SELECTED
);
1320 if (bgp_info_cmp (bgp
, ri
, new_select
))
1324 result
->old
= old_select
;
1325 result
->new = new_select
;
1331 bgp_process_announce_selected (struct peer
*peer
, struct bgp_info
*selected
,
1332 struct bgp_node
*rn
, struct attr
*attr
, afi_t afi
, safi_t safi
)
1338 /* Announce route to Established peer. */
1339 if (peer
->status
!= Established
)
1342 /* Address family configuration check. */
1343 if (! peer
->afc_nego
[afi
][safi
])
1346 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1347 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
1348 PEER_STATUS_ORF_WAIT_REFRESH
))
1351 switch (rn
->table
->type
)
1353 case BGP_TABLE_MAIN
:
1354 /* Announcement to peer->conf. If the route is filtered,
1356 if (selected
&& bgp_announce_check (selected
, peer
, p
, attr
, afi
, safi
))
1357 bgp_adj_out_set (rn
, peer
, p
, attr
, afi
, safi
, selected
);
1359 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1361 case BGP_TABLE_RSCLIENT
:
1362 /* Announcement to peer->conf. If the route is filtered,
1364 if (selected
&& bgp_announce_check_rsclient
1365 (selected
, peer
, p
, attr
, afi
, safi
))
1366 bgp_adj_out_set (rn
, peer
, p
, attr
, afi
, safi
, selected
);
1368 bgp_adj_out_unset (rn
, peer
, p
, afi
, safi
);
1374 struct bgp_process_queue
1377 struct bgp_node
*rn
;
1382 static wq_item_status
1383 bgp_process_rsclient (struct work_queue
*wq
, void *data
)
1385 struct bgp_process_queue
*pq
= data
;
1386 struct bgp
*bgp
= pq
->bgp
;
1387 struct bgp_node
*rn
= pq
->rn
;
1388 afi_t afi
= pq
->afi
;
1389 safi_t safi
= pq
->safi
;
1390 struct bgp_info
*new_select
;
1391 struct bgp_info
*old_select
;
1392 struct bgp_info_pair old_and_new
;
1394 struct listnode
*node
, *nnode
;
1395 struct peer
*rsclient
= rn
->table
->owner
;
1397 memset (&attr
, 0, sizeof (struct attr
));
1398 /* Best path selection. */
1399 bgp_best_selection (bgp
, rn
, &old_and_new
);
1400 new_select
= old_and_new
.new;
1401 old_select
= old_and_new
.old
;
1403 if (CHECK_FLAG (rsclient
->sflags
, PEER_STATUS_GROUP
))
1405 for (ALL_LIST_ELEMENTS (rsclient
->group
->peer
, node
, nnode
, rsclient
))
1407 /* Nothing to do. */
1408 if (old_select
&& old_select
== new_select
)
1409 if (!CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1413 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1416 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1417 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1420 bgp_process_announce_selected (rsclient
, new_select
, rn
, &attr
,
1427 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1430 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1431 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1433 bgp_process_announce_selected (rsclient
, new_select
, rn
,
1437 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1438 bgp_info_reap (rn
, old_select
);
1440 bgp_attr_extra_free (&attr
);
1442 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1446 static wq_item_status
1447 bgp_process_main (struct work_queue
*wq
, void *data
)
1449 struct bgp_process_queue
*pq
= data
;
1450 struct bgp
*bgp
= pq
->bgp
;
1451 struct bgp_node
*rn
= pq
->rn
;
1452 afi_t afi
= pq
->afi
;
1453 safi_t safi
= pq
->safi
;
1454 struct prefix
*p
= &rn
->p
;
1455 struct bgp_info
*new_select
;
1456 struct bgp_info
*old_select
;
1457 struct bgp_info_pair old_and_new
;
1458 struct listnode
*node
, *nnode
;
1462 memset (&attr
, 0, sizeof (struct attr
));
1464 /* Best path selection. */
1465 bgp_best_selection (bgp
, rn
, &old_and_new
);
1466 old_select
= old_and_new
.old
;
1467 new_select
= old_and_new
.new;
1469 /* Nothing to do. */
1470 if (old_select
&& old_select
== new_select
)
1472 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1474 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1475 bgp_zebra_announce (p
, old_select
, bgp
);
1477 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1483 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1486 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1487 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1491 /* Check each BGP peer. */
1492 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
1494 bgp_process_announce_selected (peer
, new_select
, rn
, &attr
, afi
, safi
);
1498 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&&
1499 ! bgp_option_check (BGP_OPT_NO_FIB
))
1502 && new_select
->type
== ZEBRA_ROUTE_BGP
1503 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1504 bgp_zebra_announce (p
, new_select
, bgp
);
1507 /* Withdraw the route from the kernel. */
1509 && old_select
->type
== ZEBRA_ROUTE_BGP
1510 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1511 bgp_zebra_withdraw (p
, old_select
);
1515 /* Reap old select bgp_info, it it has been removed */
1516 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1517 bgp_info_reap (rn
, old_select
);
1519 bgp_attr_extra_free (&attr
);
1521 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1526 bgp_processq_del (struct work_queue
*wq
, void *data
)
1528 struct bgp_process_queue
*pq
= data
;
1530 bgp_unlock_node (pq
->rn
);
1531 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1535 bgp_process_queue_init (void)
1537 bm
->process_main_queue
1538 = work_queue_new (bm
->master
, "process_main_queue");
1539 bm
->process_rsclient_queue
1540 = work_queue_new (bm
->master
, "process_rsclient_queue");
1542 if ( !(bm
->process_main_queue
&& bm
->process_rsclient_queue
) )
1544 zlog_err ("%s: Failed to allocate work queue", __func__
);
1548 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1549 bm
->process_rsclient_queue
->spec
.workfunc
= &bgp_process_rsclient
;
1550 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1551 bm
->process_rsclient_queue
->spec
.del_item_data
1552 = bm
->process_main_queue
->spec
.del_item_data
;
1553 bm
->process_main_queue
->spec
.max_retries
1554 = bm
->process_main_queue
->spec
.max_retries
= 0;
1555 bm
->process_rsclient_queue
->spec
.hold
1556 = bm
->process_main_queue
->spec
.hold
= 50;
1560 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1562 struct bgp_process_queue
*pqnode
;
1564 /* already scheduled for processing? */
1565 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1568 if ( (bm
->process_main_queue
== NULL
) ||
1569 (bm
->process_rsclient_queue
== NULL
) )
1570 bgp_process_queue_init ();
1572 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1573 sizeof (struct bgp_process_queue
));
1577 pqnode
->rn
= bgp_lock_node (rn
); /* unlocked by bgp_processq_del */
1580 pqnode
->safi
= safi
;
1582 switch (rn
->table
->type
)
1584 case BGP_TABLE_MAIN
:
1585 work_queue_add (bm
->process_main_queue
, pqnode
);
1587 case BGP_TABLE_RSCLIENT
:
1588 work_queue_add (bm
->process_rsclient_queue
, pqnode
);
1596 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1600 peer
= THREAD_ARG (thread
);
1601 peer
->t_pmax_restart
= NULL
;
1603 if (BGP_DEBUG (events
, EVENTS
))
1604 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1613 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1614 safi_t safi
, int always
)
1616 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1619 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1621 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1625 zlog (peer
->log
, LOG_INFO
,
1626 "%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1627 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1628 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1629 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1631 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1637 if (safi
== SAFI_MPLS_VPN
)
1638 safi
= BGP_SAFI_VPNV4
;
1640 ndata
[0] = (afi
>> 8);
1643 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1644 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1645 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1646 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1648 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1649 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1650 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1653 /* restart timer start */
1654 if (peer
->pmax_restart
[afi
][safi
])
1656 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1658 if (BGP_DEBUG (events
, EVENTS
))
1659 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
1660 peer
->host
, peer
->v_pmax_restart
);
1662 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
1663 peer
->v_pmax_restart
);
1669 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1671 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
1673 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
1677 zlog (peer
->log
, LOG_INFO
,
1678 "%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
1679 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
1680 peer
->pmax
[afi
][safi
]);
1681 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1684 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
1688 /* Unconditionally remove the route from the RIB, without taking
1689 * damping into consideration (eg, because the session went down)
1692 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1693 afi_t afi
, safi_t safi
)
1695 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1697 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1698 bgp_info_delete (rn
, ri
); /* keep historical info */
1700 bgp_process (peer
->bgp
, rn
, afi
, safi
);
1704 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
1705 afi_t afi
, safi_t safi
)
1707 int status
= BGP_DAMP_NONE
;
1709 /* apply dampening, if result is suppressed, we'll be retaining
1710 * the bgp_info in the RIB for historical reference.
1712 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
1713 && peer_sort (peer
) == BGP_PEER_EBGP
)
1714 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
1715 == BGP_DAMP_SUPPRESSED
)
1717 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
1721 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1725 bgp_update_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1726 struct attr
*attr
, struct peer
*peer
, struct prefix
*p
, int type
,
1727 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
)
1729 struct bgp_node
*rn
;
1731 struct attr new_attr
= { 0 };
1732 struct attr
*attr_new
;
1733 struct attr
*attr_new2
;
1734 struct bgp_info
*ri
;
1735 struct bgp_info
*new;
1737 char buf
[SU_ADDRSTRLEN
];
1739 //memset (new_attr, 0, sizeof (struct attr));
1741 /* Do not insert announces from a rsclient into its own 'bgp_table'. */
1742 if (peer
== rsclient
)
1746 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1748 /* Check previously received route. */
1749 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1750 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1753 /* AS path loop check. */
1754 if (aspath_loop_check (attr
->aspath
, rsclient
->as
) > peer
->allowas_in
[afi
][safi
])
1756 reason
= "as-path contains our own AS;";
1760 /* Route reflector originator ID check. */
1761 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1762 && IPV4_ADDR_SAME (&rsclient
->remote_id
, &attr
->extra
->originator_id
))
1764 reason
= "originator is us;";
1768 bgp_attr_dup (&new_attr
, attr
);
1770 /* Apply export policy. */
1771 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
) &&
1772 bgp_export_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1774 reason
= "export-policy;";
1778 attr_new2
= bgp_attr_intern (&new_attr
);
1780 /* Apply import policy. */
1781 if (bgp_import_modifier (rsclient
, peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1783 bgp_attr_unintern (attr_new2
);
1785 reason
= "import-policy;";
1789 attr_new
= bgp_attr_intern (&new_attr
);
1790 bgp_attr_unintern (attr_new2
);
1792 /* IPv4 unicast next hop check. */
1793 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1795 /* Next hop must not be 0.0.0.0 nor Class E address. */
1796 if (new_attr
.nexthop
.s_addr
== 0
1797 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1799 bgp_attr_unintern (attr_new
);
1801 reason
= "martian next-hop;";
1806 /* new_attr isn't passed to any functions after here */
1807 bgp_attr_extra_free (&new_attr
);
1809 /* If the update is implicit withdraw. */
1812 ri
->uptime
= time (NULL
);
1814 /* Same attribute comes in. */
1815 if (!CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
)
1816 && attrhash_cmp (ri
->attr
, attr_new
))
1819 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1821 if (BGP_DEBUG (update
, UPDATE_IN
))
1822 zlog (peer
->log
, LOG_DEBUG
,
1823 "%s rcvd %s/%d for RS-client %s...duplicate ignored",
1825 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1826 p
->prefixlen
, rsclient
->host
);
1828 bgp_unlock_node (rn
);
1829 bgp_attr_unintern (attr_new
);
1834 /* Withdraw/Announce before we fully processed the withdraw */
1835 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
1836 bgp_info_restore (rn
, ri
);
1838 /* Received Logging. */
1839 if (BGP_DEBUG (update
, UPDATE_IN
))
1840 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1842 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1843 p
->prefixlen
, rsclient
->host
);
1845 /* The attribute is changed. */
1846 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
1848 /* Update to new attribute. */
1849 bgp_attr_unintern (ri
->attr
);
1850 ri
->attr
= attr_new
;
1852 /* Update MPLS tag. */
1853 if (safi
== SAFI_MPLS_VPN
)
1854 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
1856 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
1858 /* Process change. */
1859 bgp_process (bgp
, rn
, afi
, safi
);
1860 bgp_unlock_node (rn
);
1865 /* Received Logging. */
1866 if (BGP_DEBUG (update
, UPDATE_IN
))
1868 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d for RS-client %s",
1870 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1871 p
->prefixlen
, rsclient
->host
);
1874 /* Make new BGP info. */
1875 new = bgp_info_new ();
1877 new->sub_type
= sub_type
;
1879 new->attr
= attr_new
;
1880 new->uptime
= time (NULL
);
1882 /* Update MPLS tag. */
1883 if (safi
== SAFI_MPLS_VPN
)
1884 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
1886 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
1888 /* Register new BGP information. */
1889 bgp_info_add (rn
, new);
1891 /* route_node_get lock */
1892 bgp_unlock_node (rn
);
1894 /* Process change. */
1895 bgp_process (bgp
, rn
, afi
, safi
);
1897 bgp_attr_extra_free (&new_attr
);
1903 /* This BGP update is filtered. Log the reason then update BGP entry. */
1904 if (BGP_DEBUG (update
, UPDATE_IN
))
1905 zlog (peer
->log
, LOG_DEBUG
,
1906 "%s rcvd UPDATE about %s/%d -- DENIED for RS-client %s due to: %s",
1908 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1909 p
->prefixlen
, rsclient
->host
, reason
);
1912 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
1914 bgp_unlock_node (rn
);
1917 bgp_attr_extra_free (&new_attr
);
1923 bgp_withdraw_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
,
1924 struct peer
*peer
, struct prefix
*p
, int type
, int sub_type
,
1925 struct prefix_rd
*prd
, u_char
*tag
)
1927 struct bgp_node
*rn
;
1928 struct bgp_info
*ri
;
1929 char buf
[SU_ADDRSTRLEN
];
1931 if (rsclient
== peer
)
1934 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1936 /* Lookup withdrawn route. */
1937 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1938 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1941 /* Withdraw specified route from routing table. */
1942 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1943 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
1944 else if (BGP_DEBUG (update
, UPDATE_IN
))
1945 zlog (peer
->log
, LOG_DEBUG
,
1946 "%s Can't find the route %s/%d", peer
->host
,
1947 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1950 /* Unlock bgp_node_get() lock. */
1951 bgp_unlock_node (rn
);
1955 bgp_update_main (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1956 afi_t afi
, safi_t safi
, int type
, int sub_type
,
1957 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
1960 int aspath_loop_count
= 0;
1961 struct bgp_node
*rn
;
1963 struct attr new_attr
= { 0 };
1964 struct attr
*attr_new
;
1965 struct bgp_info
*ri
;
1966 struct bgp_info
*new;
1968 char buf
[SU_ADDRSTRLEN
];
1971 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
1973 /* When peer's soft reconfiguration enabled. Record input packet in
1975 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
1976 && peer
!= bgp
->peer_self
&& ! soft_reconfig
)
1977 bgp_adj_in_set (rn
, peer
, attr
);
1979 /* Check previously received route. */
1980 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1981 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1984 /* AS path local-as loop check. */
1985 if (peer
->change_local_as
)
1987 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
1988 aspath_loop_count
= 1;
1990 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
1992 reason
= "as-path contains our own AS;";
1997 /* AS path loop check. */
1998 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
1999 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2000 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2001 > peer
->allowas_in
[afi
][safi
]))
2003 reason
= "as-path contains our own AS;";
2007 /* Route reflector originator ID check. */
2008 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2009 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2011 reason
= "originator is us;";
2015 /* Route reflector cluster ID check. */
2016 if (bgp_cluster_filter (peer
, attr
))
2018 reason
= "reflected from the same cluster;";
2022 /* Apply incoming filter. */
2023 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2029 /* Apply incoming route-map. */
2030 bgp_attr_dup (&new_attr
, attr
);
2032 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
2034 reason
= "route-map;";
2038 /* IPv4 unicast next hop check. */
2039 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2041 /* If the peer is EBGP and nexthop is not on connected route,
2043 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1
2044 && ! bgp_nexthop_check_ebgp (afi
, &new_attr
)
2045 && ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
2047 reason
= "non-connected next-hop;";
2051 /* Next hop must not be 0.0.0.0 nor Class E address. Next hop
2052 must not be my own address. */
2053 if (bgp_nexthop_self (afi
, &new_attr
)
2054 || new_attr
.nexthop
.s_addr
== 0
2055 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
2057 reason
= "martian next-hop;";
2062 attr_new
= bgp_attr_intern (&new_attr
);
2064 /* If the update is implicit withdraw. */
2067 ri
->uptime
= time (NULL
);
2069 /* Same attribute comes in. */
2070 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2071 && attrhash_cmp (ri
->attr
, attr_new
))
2073 bgp_info_unset_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2075 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2076 && peer_sort (peer
) == BGP_PEER_EBGP
2077 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2079 if (BGP_DEBUG (update
, UPDATE_IN
))
2080 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2082 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2085 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2087 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2088 bgp_process (bgp
, rn
, afi
, safi
);
2091 else /* Duplicate - odd */
2093 if (BGP_DEBUG (update
, UPDATE_IN
))
2094 zlog (peer
->log
, LOG_DEBUG
,
2095 "%s rcvd %s/%d...duplicate ignored",
2097 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2100 /* graceful restart STALE flag unset. */
2101 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2103 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2104 bgp_process (bgp
, rn
, afi
, safi
);
2108 bgp_unlock_node (rn
);
2109 bgp_attr_unintern (attr_new
);
2110 bgp_attr_extra_free (&new_attr
);
2115 /* Withdraw/Announce before we fully processed the withdraw */
2116 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2118 if (BGP_DEBUG (update
, UPDATE_IN
))
2119 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d, flapped quicker than processing",
2121 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2123 bgp_info_restore (rn
, ri
);
2126 /* Received Logging. */
2127 if (BGP_DEBUG (update
, UPDATE_IN
))
2128 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2130 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2133 /* graceful restart STALE flag unset. */
2134 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2135 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2137 /* The attribute is changed. */
2138 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2140 /* implicit withdraw, decrement aggregate and pcount here.
2141 * only if update is accepted, they'll increment below.
2143 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2145 /* Update bgp route dampening information. */
2146 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2147 && peer_sort (peer
) == BGP_PEER_EBGP
)
2149 /* This is implicit withdraw so we should update dampening
2151 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2152 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2155 /* Update to new attribute. */
2156 bgp_attr_unintern (ri
->attr
);
2157 ri
->attr
= attr_new
;
2159 /* Update MPLS tag. */
2160 if (safi
== SAFI_MPLS_VPN
)
2161 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2163 /* Update bgp route dampening information. */
2164 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2165 && peer_sort (peer
) == BGP_PEER_EBGP
)
2167 /* Now we do normal update dampening. */
2168 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2169 if (ret
== BGP_DAMP_SUPPRESSED
)
2171 bgp_unlock_node (rn
);
2172 bgp_attr_extra_free (&new_attr
);
2177 /* Nexthop reachability check. */
2178 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2179 && safi
== SAFI_UNICAST
2180 && (peer_sort (peer
) == BGP_PEER_IBGP
2181 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2182 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2184 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
2185 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2187 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2190 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2192 /* Process change. */
2193 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2195 bgp_process (bgp
, rn
, afi
, safi
);
2196 bgp_unlock_node (rn
);
2197 bgp_attr_extra_free (&new_attr
);
2202 /* Received Logging. */
2203 if (BGP_DEBUG (update
, UPDATE_IN
))
2205 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd %s/%d",
2207 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2211 /* Make new BGP info. */
2212 new = bgp_info_new ();
2214 new->sub_type
= sub_type
;
2216 new->attr
= attr_new
;
2217 new->uptime
= time (NULL
);
2219 /* Update MPLS tag. */
2220 if (safi
== SAFI_MPLS_VPN
)
2221 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2223 /* Nexthop reachability check. */
2224 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
2225 && safi
== SAFI_UNICAST
2226 && (peer_sort (peer
) == BGP_PEER_IBGP
2227 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
2228 || CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)))
2230 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
2231 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2233 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2236 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2238 /* Increment prefix */
2239 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2241 /* Register new BGP information. */
2242 bgp_info_add (rn
, new);
2244 /* route_node_get lock */
2245 bgp_unlock_node (rn
);
2247 bgp_attr_extra_free (&new_attr
);
2249 /* If maximum prefix count is configured and current prefix
2251 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2254 /* Process change. */
2255 bgp_process (bgp
, rn
, afi
, safi
);
2259 /* This BGP update is filtered. Log the reason then update BGP
2262 if (BGP_DEBUG (update
, UPDATE_IN
))
2263 zlog (peer
->log
, LOG_DEBUG
,
2264 "%s rcvd UPDATE about %s/%d -- DENIED due to: %s",
2266 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2267 p
->prefixlen
, reason
);
2270 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2272 bgp_unlock_node (rn
);
2274 bgp_attr_extra_free (&new_attr
);
2280 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2281 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2282 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2284 struct peer
*rsclient
;
2285 struct listnode
*node
, *nnode
;
2289 ret
= bgp_update_main (peer
, p
, attr
, afi
, safi
, type
, sub_type
, prd
, tag
,
2294 /* Process the update for each RS-client. */
2295 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2297 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2298 bgp_update_rsclient (rsclient
, afi
, safi
, attr
, peer
, p
, type
,
2299 sub_type
, prd
, tag
);
2306 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
2307 afi_t afi
, safi_t safi
, int type
, int sub_type
,
2308 struct prefix_rd
*prd
, u_char
*tag
)
2311 char buf
[SU_ADDRSTRLEN
];
2312 struct bgp_node
*rn
;
2313 struct bgp_info
*ri
;
2314 struct peer
*rsclient
;
2315 struct listnode
*node
, *nnode
;
2319 /* Process the withdraw for each RS-client. */
2320 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
2322 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2323 bgp_withdraw_rsclient (rsclient
, afi
, safi
, peer
, p
, type
, sub_type
, prd
, tag
);
2327 if (BGP_DEBUG (update
, UPDATE_IN
))
2328 zlog (peer
->log
, LOG_DEBUG
, "%s rcvd UPDATE about %s/%d -- withdrawn",
2330 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2334 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2336 /* If peer is soft reconfiguration enabled. Record input packet for
2337 further calculation. */
2338 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2339 && peer
!= bgp
->peer_self
)
2340 bgp_adj_in_unset (rn
, peer
);
2342 /* Lookup withdrawn route. */
2343 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2344 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
2347 /* Withdraw specified route from routing table. */
2348 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2349 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2350 else if (BGP_DEBUG (update
, UPDATE_IN
))
2351 zlog (peer
->log
, LOG_DEBUG
,
2352 "%s Can't find the route %s/%d", peer
->host
,
2353 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2356 /* Unlock bgp_node_get() lock. */
2357 bgp_unlock_node (rn
);
2363 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2367 struct aspath
*aspath
= { 0 };
2369 struct bgp_info binfo
;
2371 int ret
= RMAP_DENYMATCH
;
2373 if (!(afi
== AFI_IP
|| afi
== AFI_IP6
))
2377 from
= bgp
->peer_self
;
2379 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
2380 aspath
= attr
.aspath
;
2381 attr
.local_pref
= bgp
->default_local_pref
;
2382 memcpy (&attr
.nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
2385 str2prefix ("0.0.0.0/0", &p
);
2387 else if (afi
== AFI_IP6
)
2389 struct attr_extra
*ae
;
2392 ae
= bgp_attr_extra_get (&attr
);
2395 str2prefix ("::/0", &p
);
2397 /* IPv6 global nexthop must be included. */
2398 memcpy (&ae
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
2400 ae
->mp_nexthop_len
= 16;
2402 /* If the peer is on shared nextwork and we have link-local
2404 if (peer
->shared_network
2405 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
2407 memcpy (&ae
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
2409 ae
->mp_nexthop_len
= 32;
2412 #endif /* HAVE_IPV6 */
2414 if (peer
->default_rmap
[afi
][safi
].name
)
2416 binfo
.peer
= bgp
->peer_self
;
2419 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_DEFAULT
);
2421 ret
= route_map_apply (peer
->default_rmap
[afi
][safi
].map
, &p
,
2424 bgp
->peer_self
->rmap_type
= 0;
2426 if (ret
== RMAP_DENYMATCH
)
2428 bgp_attr_flush (&attr
);
2435 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
))
2436 bgp_default_withdraw_send (peer
, afi
, safi
);
2437 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2441 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_DEFAULT_ORIGINATE
);
2442 bgp_default_update_send (peer
, &attr
, afi
, safi
, from
);
2445 bgp_attr_extra_free (&attr
);
2446 aspath_unintern (aspath
);
2450 bgp_announce_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2451 struct bgp_table
*table
, int rsclient
)
2453 struct bgp_node
*rn
;
2454 struct bgp_info
*ri
;
2457 memset (&attr
, 0, sizeof (struct attr
));
2460 table
= (rsclient
) ? peer
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2462 if (safi
!= SAFI_MPLS_VPN
2463 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
2464 bgp_default_originate (peer
, afi
, safi
, 0);
2466 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next(rn
))
2467 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2468 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= peer
)
2471 (bgp_announce_check_rsclient (ri
, peer
, &rn
->p
, &attr
, afi
, safi
))
2472 : (bgp_announce_check (ri
, peer
, &rn
->p
, &attr
, afi
, safi
)))
2473 bgp_adj_out_set (rn
, peer
, &rn
->p
, &attr
, afi
, safi
, ri
);
2475 bgp_adj_out_unset (rn
, peer
, &rn
->p
, afi
, safi
);
2477 bgp_attr_extra_free (&attr
);
2482 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2484 struct bgp_node
*rn
;
2485 struct bgp_table
*table
;
2487 if (peer
->status
!= Established
)
2490 if (! peer
->afc_nego
[afi
][safi
])
2493 /* First update is deferred until ORF or ROUTE-REFRESH is received */
2494 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
2497 if (safi
!= SAFI_MPLS_VPN
)
2498 bgp_announce_table (peer
, afi
, safi
, NULL
, 0);
2500 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2501 rn
= bgp_route_next(rn
))
2502 if ((table
= (rn
->info
)) != NULL
)
2503 bgp_announce_table (peer
, afi
, safi
, table
, 0);
2505 if (CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2506 bgp_announce_table (peer
, afi
, safi
, NULL
, 1);
2510 bgp_announce_route_all (struct peer
*peer
)
2515 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2516 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2517 bgp_announce_route (peer
, afi
, safi
);
2521 bgp_soft_reconfig_table_rsclient (struct peer
*rsclient
, afi_t afi
,
2522 safi_t safi
, struct bgp_table
*table
)
2524 struct bgp_node
*rn
;
2525 struct bgp_adj_in
*ain
;
2528 table
= rsclient
->bgp
->rib
[afi
][safi
];
2530 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2531 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2533 bgp_update_rsclient (rsclient
, afi
, safi
, ain
->attr
, ain
->peer
,
2534 &rn
->p
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
2539 bgp_soft_reconfig_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
2541 struct bgp_table
*table
;
2542 struct bgp_node
*rn
;
2544 if (safi
!= SAFI_MPLS_VPN
)
2545 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, NULL
);
2548 for (rn
= bgp_table_top (rsclient
->bgp
->rib
[afi
][safi
]); rn
;
2549 rn
= bgp_route_next (rn
))
2550 if ((table
= rn
->info
) != NULL
)
2551 bgp_soft_reconfig_table_rsclient (rsclient
, afi
, safi
, table
);
2555 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2556 struct bgp_table
*table
)
2559 struct bgp_node
*rn
;
2560 struct bgp_adj_in
*ain
;
2563 table
= peer
->bgp
->rib
[afi
][safi
];
2565 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2566 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2568 if (ain
->peer
== peer
)
2570 ret
= bgp_update (peer
, &rn
->p
, ain
->attr
, afi
, safi
,
2571 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2575 bgp_unlock_node (rn
);
2584 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2586 struct bgp_node
*rn
;
2587 struct bgp_table
*table
;
2589 if (peer
->status
!= Established
)
2592 if (safi
!= SAFI_MPLS_VPN
)
2593 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
);
2595 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2596 rn
= bgp_route_next (rn
))
2597 if ((table
= rn
->info
) != NULL
)
2598 bgp_soft_reconfig_table (peer
, afi
, safi
, table
);
2601 static wq_item_status
2602 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2604 struct bgp_node
*rn
= data
;
2605 struct peer
*peer
= wq
->spec
.data
;
2606 struct bgp_info
*ri
;
2607 afi_t afi
= rn
->table
->afi
;
2608 safi_t safi
= rn
->table
->safi
;
2610 assert (rn
&& peer
);
2612 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2613 if (ri
->peer
== peer
)
2615 /* graceful restart STALE flag set. */
2616 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2617 && peer
->nsf
[afi
][safi
]
2618 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2619 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2620 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2622 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2629 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2631 struct bgp_node
*rn
= data
;
2633 bgp_unlock_node (rn
);
2637 bgp_clear_node_complete (struct work_queue
*wq
)
2639 struct peer
*peer
= wq
->spec
.data
;
2641 peer_unlock (peer
); /* bgp_clear_node_complete */
2643 /* Tickle FSM to start moving again */
2644 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2648 bgp_clear_node_queue_init (struct peer
*peer
)
2650 #define CLEAR_QUEUE_NAME_LEN 26 /* "clear 2001:123:123:123::1" */
2651 char wname
[CLEAR_QUEUE_NAME_LEN
];
2653 snprintf (wname
, CLEAR_QUEUE_NAME_LEN
, "clear %s", peer
->host
);
2654 #undef CLEAR_QUEUE_NAME_LEN
2656 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2658 zlog_err ("%s: Failed to allocate work queue", __func__
);
2661 peer
->clear_node_queue
->spec
.hold
= 10;
2662 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2663 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2664 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2665 peer
->clear_node_queue
->spec
.max_retries
= 0;
2667 /* we only 'lock' this peer reference when the queue is actually active */
2668 peer
->clear_node_queue
->spec
.data
= peer
;
2672 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2673 struct bgp_table
*table
, struct peer
*rsclient
)
2675 struct bgp_node
*rn
;
2679 table
= (rsclient
) ? rsclient
->rib
[afi
][safi
] : peer
->bgp
->rib
[afi
][safi
];
2681 /* If still no table => afi/safi isn't configured at all or smth. */
2685 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2687 struct bgp_info
*ri
;
2688 struct bgp_adj_in
*ain
;
2689 struct bgp_adj_out
*aout
;
2691 if (rn
->info
== NULL
)
2694 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2695 * queued for every clearing peer, regardless of whether it is
2696 * relevant to the peer at hand.
2698 * Overview: There are 3 different indices which need to be
2699 * scrubbed, potentially, when a peer is removed:
2701 * 1 peer's routes visible via the RIB (ie accepted routes)
2702 * 2 peer's routes visible by the (optional) peer's adj-in index
2703 * 3 other routes visible by the peer's adj-out index
2705 * 3 there is no hurry in scrubbing, once the struct peer is
2706 * removed from bgp->peer, we could just GC such deleted peer's
2707 * adj-outs at our leisure.
2709 * 1 and 2 must be 'scrubbed' in some way, at least made
2710 * invisible via RIB index before peer session is allowed to be
2711 * brought back up. So one needs to know when such a 'search' is
2716 * - there'd be a single global queue or a single RIB walker
2717 * - rather than tracking which route_nodes still need to be
2718 * examined on a peer basis, we'd track which peers still
2721 * Given that our per-peer prefix-counts now should be reliable,
2722 * this may actually be achievable. It doesn't seem to be a huge
2723 * problem at this time,
2725 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2726 if (ri
->peer
== peer
)
2728 bgp_lock_node (rn
); /* unlocked: bgp_clear_node_queue_del */
2729 work_queue_add (peer
->clear_node_queue
, rn
);
2732 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2733 if (ain
->peer
== peer
)
2735 bgp_adj_in_remove (rn
, ain
);
2736 bgp_unlock_node (rn
);
2739 for (aout
= rn
->adj_out
; aout
; aout
= aout
->next
)
2740 if (aout
->peer
== peer
)
2742 bgp_adj_out_remove (rn
, aout
, peer
, afi
, safi
);
2743 bgp_unlock_node (rn
);
2751 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2753 struct bgp_node
*rn
;
2754 struct bgp_table
*table
;
2755 struct peer
*rsclient
;
2756 struct listnode
*node
, *nnode
;
2758 if (peer
->clear_node_queue
== NULL
)
2759 bgp_clear_node_queue_init (peer
);
2761 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2762 * Idle until it receives a Clearing_Completed event. This protects
2763 * against peers which flap faster than we can we clear, which could
2766 * a) race with routes from the new session being installed before
2767 * clear_route_node visits the node (to delete the route of that
2769 * b) resource exhaustion, clear_route_node likely leads to an entry
2770 * on the process_main queue. Fast-flapping could cause that queue
2773 if (!peer
->clear_node_queue
->thread
)
2774 peer_lock (peer
); /* bgp_clear_node_complete */
2776 if (safi
!= SAFI_MPLS_VPN
)
2777 bgp_clear_route_table (peer
, afi
, safi
, NULL
, NULL
);
2779 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2780 rn
= bgp_route_next (rn
))
2781 if ((table
= rn
->info
) != NULL
)
2782 bgp_clear_route_table (peer
, afi
, safi
, table
, NULL
);
2784 for (ALL_LIST_ELEMENTS (peer
->bgp
->rsclient
, node
, nnode
, rsclient
))
2786 if (CHECK_FLAG(rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
2787 bgp_clear_route_table (peer
, afi
, safi
, NULL
, rsclient
);
2790 /* If no routes were cleared, nothing was added to workqueue, the
2791 * completion function won't be run by workqueue code - call it here.
2792 * XXX: Actually, this assumption doesn't hold, see
2793 * bgp_clear_route_table(), we queue all non-empty nodes.
2795 * Additionally, there is a presumption in FSM that clearing is only
2796 * really needed if peer state is Established - peers in
2797 * pre-Established states shouldn't have any route-update state
2798 * associated with them (in or out).
2800 * We still can get here in pre-Established though, through
2801 * peer_delete -> bgp_fsm_change_status, so this is a useful sanity
2802 * check to ensure the assumption above holds.
2804 * At some future point, this check could be move to the top of the
2805 * function, and do a quick early-return when state is
2806 * pre-Established, avoiding above list and table scans. Once we're
2809 if (!peer
->clear_node_queue
->thread
)
2810 bgp_clear_node_complete (peer
->clear_node_queue
);
2813 /* clearing queue scheduled. Normal if in Established state
2814 * (and about to transition out of it), but otherwise...
2816 if (peer
->status
!= Established
)
2818 plog_err (peer
->log
, "%s [Error] State %s is not Established,"
2819 " but routes were cleared - bug!",
2820 peer
->host
, LOOKUP (bgp_status_msg
, peer
->status
));
2821 assert (peer
->status
== Established
);
2827 bgp_clear_route_all (struct peer
*peer
)
2832 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2833 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2834 bgp_clear_route (peer
, afi
, safi
);
2838 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2840 struct bgp_table
*table
;
2841 struct bgp_node
*rn
;
2842 struct bgp_adj_in
*ain
;
2844 table
= peer
->bgp
->rib
[afi
][safi
];
2846 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2847 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2848 if (ain
->peer
== peer
)
2850 bgp_adj_in_remove (rn
, ain
);
2851 bgp_unlock_node (rn
);
2857 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2859 struct bgp_node
*rn
;
2860 struct bgp_info
*ri
;
2861 struct bgp_table
*table
;
2863 table
= peer
->bgp
->rib
[afi
][safi
];
2865 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2867 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2868 if (ri
->peer
== peer
)
2870 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2871 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2877 /* Delete all kernel routes. */
2879 bgp_cleanup_routes ()
2882 struct listnode
*node
, *nnode
;
2883 struct bgp_node
*rn
;
2884 struct bgp_table
*table
;
2885 struct bgp_info
*ri
;
2887 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
2889 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
2891 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2892 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2893 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2894 && ri
->type
== ZEBRA_ROUTE_BGP
2895 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2896 bgp_zebra_withdraw (&rn
->p
, ri
);
2898 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
2900 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2901 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2902 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
2903 && ri
->type
== ZEBRA_ROUTE_BGP
2904 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
2905 bgp_zebra_withdraw (&rn
->p
, ri
);
2913 bgp_zclient_reset ();
2914 access_list_reset ();
2915 prefix_list_reset ();
2918 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
2921 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
2929 /* Check peer status. */
2930 if (peer
->status
!= Established
)
2934 lim
= pnt
+ packet
->length
;
2936 for (; pnt
< lim
; pnt
+= psize
)
2938 /* Clear prefix structure. */
2939 memset (&p
, 0, sizeof (struct prefix
));
2941 /* Fetch prefix length. */
2942 p
.prefixlen
= *pnt
++;
2943 p
.family
= afi2family (packet
->afi
);
2945 /* Already checked in nlri_sanity_check(). We do double check
2947 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
2948 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
2951 /* Packet size overflow check. */
2952 psize
= PSIZE (p
.prefixlen
);
2954 /* When packet overflow occur return immediately. */
2955 if (pnt
+ psize
> lim
)
2958 /* Fetch prefix from NLRI packet. */
2959 memcpy (&p
.u
.prefix
, pnt
, psize
);
2961 /* Check address. */
2962 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
2964 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
2967 * From draft-ietf-idr-bgp4-22, Section 6.3:
2968 * If a BGP router receives an UPDATE message with a
2969 * semantically incorrect NLRI field, in which a prefix is
2970 * semantically incorrect (eg. an unexpected multicast IP
2971 * address), it should ignore the prefix.
2973 zlog (peer
->log
, LOG_ERR
,
2974 "IPv4 unicast NLRI is multicast address %s",
2975 inet_ntoa (p
.u
.prefix4
));
2982 /* Check address. */
2983 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
2985 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
2989 zlog (peer
->log
, LOG_WARNING
,
2990 "IPv6 link-local NLRI received %s ignore this NLRI",
2991 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
2996 #endif /* HAVE_IPV6 */
2998 /* Normal process. */
3000 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3001 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3003 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
3004 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3006 /* Address family configuration mismatch or maximum-prefix count
3012 /* Packet length consistency check. */
3019 /* NLRI encode syntax check routine. */
3021 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
,
3030 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3031 syntactic validity. If the field is syntactically incorrect,
3032 then the Error Subcode is set to Invalid Network Field. */
3038 /* Prefix length check. */
3039 if ((afi
== AFI_IP
&& prefixlen
> 32)
3040 || (afi
== AFI_IP6
&& prefixlen
> 128))
3042 plog_err (peer
->log
,
3043 "%s [Error] Update packet error (wrong prefix length %d)",
3044 peer
->host
, prefixlen
);
3045 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3046 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3050 /* Packet size overflow check. */
3051 psize
= PSIZE (prefixlen
);
3053 if (pnt
+ psize
> end
)
3055 plog_err (peer
->log
,
3056 "%s [Error] Update packet error"
3057 " (prefix data overflow prefix size is %d)",
3059 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3060 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3067 /* Packet length consistency check. */
3070 plog_err (peer
->log
,
3071 "%s [Error] Update packet error"
3072 " (prefix length mismatch with total length)",
3074 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3075 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3081 static struct bgp_static
*
3084 struct bgp_static
*new;
3085 new = XMALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3086 memset (new, 0, sizeof (struct bgp_static
));
3091 bgp_static_free (struct bgp_static
*bgp_static
)
3093 if (bgp_static
->rmap
.name
)
3094 free (bgp_static
->rmap
.name
);
3095 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3099 bgp_static_withdraw_rsclient (struct bgp
*bgp
, struct peer
*rsclient
,
3100 struct prefix
*p
, afi_t afi
, safi_t safi
)
3102 struct bgp_node
*rn
;
3103 struct bgp_info
*ri
;
3105 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3107 /* Check selected route and self inserted route. */
3108 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3109 if (ri
->peer
== bgp
->peer_self
3110 && ri
->type
== ZEBRA_ROUTE_BGP
3111 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3114 /* Withdraw static BGP route from routing table. */
3117 bgp_info_delete (rn
, ri
);
3118 bgp_process (bgp
, rn
, afi
, safi
);
3121 /* Unlock bgp_node_lookup. */
3122 bgp_unlock_node (rn
);
3126 bgp_static_update_rsclient (struct peer
*rsclient
, struct prefix
*p
,
3127 struct bgp_static
*bgp_static
,
3128 afi_t afi
, safi_t safi
)
3130 struct bgp_node
*rn
;
3131 struct bgp_info
*ri
;
3132 struct bgp_info
*new;
3133 struct bgp_info info
;
3134 struct attr
*attr_new
;
3135 struct attr attr
= {0 };
3136 struct attr new_attr
= { .extra
= 0 };
3139 char buf
[SU_ADDRSTRLEN
];
3141 bgp
= rsclient
->bgp
;
3143 assert (bgp_static
);
3147 rn
= bgp_afi_node_get (rsclient
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3149 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3151 attr
.nexthop
= bgp_static
->igpnexthop
;
3152 attr
.med
= bgp_static
->igpmetric
;
3153 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3155 /* Apply network route-map for export to this rsclient. */
3156 if (bgp_static
->rmap
.name
)
3158 struct attr attr_tmp
= attr
;
3159 info
.peer
= rsclient
;
3160 info
.attr
= &attr_tmp
;
3162 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_EXPORT
);
3163 SET_FLAG (rsclient
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3165 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3167 rsclient
->rmap_type
= 0;
3169 if (ret
== RMAP_DENYMATCH
)
3171 /* Free uninterned attribute. */
3172 bgp_attr_flush (&attr_tmp
);
3174 /* Unintern original. */
3175 aspath_unintern (attr
.aspath
);
3176 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3177 bgp_attr_extra_free (&attr
);
3181 attr_new
= bgp_attr_intern (&attr_tmp
);
3184 attr_new
= bgp_attr_intern (&attr
);
3186 new_attr
= *attr_new
;
3188 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3190 if (bgp_import_modifier (rsclient
, bgp
->peer_self
, p
, &new_attr
, afi
, safi
)
3193 /* This BGP update is filtered. Log the reason then update BGP entry. */
3194 if (BGP_DEBUG (update
, UPDATE_IN
))
3195 zlog (rsclient
->log
, LOG_DEBUG
,
3196 "Static UPDATE about %s/%d -- DENIED for RS-client %s due to: import-policy",
3197 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
3198 p
->prefixlen
, rsclient
->host
);
3200 bgp
->peer_self
->rmap_type
= 0;
3202 bgp_attr_unintern (attr_new
);
3203 aspath_unintern (attr
.aspath
);
3204 bgp_attr_extra_free (&attr
);
3206 bgp_static_withdraw_rsclient (bgp
, rsclient
, p
, afi
, safi
);
3211 bgp
->peer_self
->rmap_type
= 0;
3213 bgp_attr_unintern (attr_new
);
3214 attr_new
= bgp_attr_intern (&new_attr
);
3216 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3217 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3218 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3223 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3224 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3226 bgp_unlock_node (rn
);
3227 bgp_attr_unintern (attr_new
);
3228 aspath_unintern (attr
.aspath
);
3229 bgp_attr_extra_free (&attr
);
3234 /* The attribute is changed. */
3235 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3237 /* Rewrite BGP route information. */
3238 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3239 bgp_info_restore(rn
, ri
);
3240 bgp_attr_unintern (ri
->attr
);
3241 ri
->attr
= attr_new
;
3242 ri
->uptime
= time (NULL
);
3244 /* Process change. */
3245 bgp_process (bgp
, rn
, afi
, safi
);
3246 bgp_unlock_node (rn
);
3247 aspath_unintern (attr
.aspath
);
3248 bgp_attr_extra_free (&attr
);
3253 /* Make new BGP info. */
3254 new = bgp_info_new ();
3255 new->type
= ZEBRA_ROUTE_BGP
;
3256 new->sub_type
= BGP_ROUTE_STATIC
;
3257 new->peer
= bgp
->peer_self
;
3258 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3259 new->attr
= attr_new
;
3260 new->uptime
= time (NULL
);
3262 /* Register new BGP information. */
3263 bgp_info_add (rn
, new);
3265 /* route_node_get lock */
3266 bgp_unlock_node (rn
);
3268 /* Process change. */
3269 bgp_process (bgp
, rn
, afi
, safi
);
3271 /* Unintern original. */
3272 aspath_unintern (attr
.aspath
);
3273 bgp_attr_extra_free (&attr
);
3277 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3278 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3280 struct bgp_node
*rn
;
3281 struct bgp_info
*ri
;
3282 struct bgp_info
*new;
3283 struct bgp_info info
;
3284 struct attr attr
= { 0 };
3285 struct attr
*attr_new
;
3288 assert (bgp_static
);
3292 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3294 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3296 attr
.nexthop
= bgp_static
->igpnexthop
;
3297 attr
.med
= bgp_static
->igpmetric
;
3298 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3300 /* Apply route-map. */
3301 if (bgp_static
->rmap
.name
)
3303 struct attr attr_tmp
= attr
;
3304 info
.peer
= bgp
->peer_self
;
3305 info
.attr
= &attr_tmp
;
3307 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3309 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3311 bgp
->peer_self
->rmap_type
= 0;
3313 if (ret
== RMAP_DENYMATCH
)
3315 /* Free uninterned attribute. */
3316 bgp_attr_flush (&attr_tmp
);
3318 /* Unintern original. */
3319 aspath_unintern (attr
.aspath
);
3320 bgp_attr_extra_free (&attr
);
3321 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3324 attr_new
= bgp_attr_intern (&attr_tmp
);
3327 attr_new
= bgp_attr_intern (&attr
);
3329 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3330 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3331 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3336 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3337 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3339 bgp_unlock_node (rn
);
3340 bgp_attr_unintern (attr_new
);
3341 aspath_unintern (attr
.aspath
);
3342 bgp_attr_extra_free (&attr
);
3347 /* The attribute is changed. */
3348 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3350 /* Rewrite BGP route information. */
3351 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3352 bgp_info_restore(rn
, ri
);
3354 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3355 bgp_attr_unintern (ri
->attr
);
3356 ri
->attr
= attr_new
;
3357 ri
->uptime
= time (NULL
);
3359 /* Process change. */
3360 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3361 bgp_process (bgp
, rn
, afi
, safi
);
3362 bgp_unlock_node (rn
);
3363 aspath_unintern (attr
.aspath
);
3364 bgp_attr_extra_free (&attr
);
3369 /* Make new BGP info. */
3370 new = bgp_info_new ();
3371 new->type
= ZEBRA_ROUTE_BGP
;
3372 new->sub_type
= BGP_ROUTE_STATIC
;
3373 new->peer
= bgp
->peer_self
;
3374 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3375 new->attr
= attr_new
;
3376 new->uptime
= time (NULL
);
3378 /* Aggregate address increment. */
3379 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3381 /* Register new BGP information. */
3382 bgp_info_add (rn
, new);
3384 /* route_node_get lock */
3385 bgp_unlock_node (rn
);
3387 /* Process change. */
3388 bgp_process (bgp
, rn
, afi
, safi
);
3390 /* Unintern original. */
3391 aspath_unintern (attr
.aspath
);
3392 bgp_attr_extra_free (&attr
);
3396 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3397 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3399 struct peer
*rsclient
;
3400 struct listnode
*node
, *nnode
;
3402 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3404 for (ALL_LIST_ELEMENTS (bgp
->rsclient
, node
, nnode
, rsclient
))
3406 if (CHECK_FLAG (rsclient
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
3407 bgp_static_update_rsclient (rsclient
, p
, bgp_static
, afi
, safi
);
3412 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3413 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3415 struct bgp_node
*rn
;
3416 struct bgp_info
*new;
3418 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3420 /* Make new BGP info. */
3421 new = bgp_info_new ();
3422 new->type
= ZEBRA_ROUTE_BGP
;
3423 new->sub_type
= BGP_ROUTE_STATIC
;
3424 new->peer
= bgp
->peer_self
;
3425 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
3426 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3427 new->uptime
= time (NULL
);
3428 new->extra
= bgp_info_extra_new();
3429 memcpy (new->extra
->tag
, tag
, 3);
3431 /* Aggregate address increment. */
3432 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3434 /* Register new BGP information. */
3435 bgp_info_add (rn
, new);
3437 /* route_node_get lock */
3438 bgp_unlock_node (rn
);
3440 /* Process change. */
3441 bgp_process (bgp
, rn
, afi
, safi
);
3445 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3448 struct bgp_node
*rn
;
3449 struct bgp_info
*ri
;
3451 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3453 /* Check selected route and self inserted route. */
3454 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3455 if (ri
->peer
== bgp
->peer_self
3456 && ri
->type
== ZEBRA_ROUTE_BGP
3457 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3460 /* Withdraw static BGP route from routing table. */
3463 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3464 bgp_info_delete (rn
, ri
);
3465 bgp_process (bgp
, rn
, afi
, safi
);
3468 /* Unlock bgp_node_lookup. */
3469 bgp_unlock_node (rn
);
3473 bgp_check_local_routes_rsclient (struct peer
*rsclient
, afi_t afi
, safi_t safi
)
3475 struct bgp_static
*bgp_static
;
3477 struct bgp_node
*rn
;
3480 bgp
= rsclient
->bgp
;
3482 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3483 if ((bgp_static
= rn
->info
) != NULL
)
3487 bgp_static_update_rsclient (rsclient
, p
, bgp_static
,
3493 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
3494 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
3496 struct bgp_node
*rn
;
3497 struct bgp_info
*ri
;
3499 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3501 /* Check selected route and self inserted route. */
3502 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3503 if (ri
->peer
== bgp
->peer_self
3504 && ri
->type
== ZEBRA_ROUTE_BGP
3505 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3508 /* Withdraw static BGP route from routing table. */
3511 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3512 bgp_info_delete (rn
, ri
);
3513 bgp_process (bgp
, rn
, afi
, safi
);
3516 /* Unlock bgp_node_lookup. */
3517 bgp_unlock_node (rn
);
3520 /* Configure static BGP network. When user don't run zebra, static
3521 route should be installed as valid. */
3523 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3524 u_int16_t afi
, u_char safi
, const char *rmap
, int backdoor
)
3528 struct bgp_static
*bgp_static
;
3529 struct bgp_node
*rn
;
3530 int need_update
= 0;
3532 /* Convert IP prefix string to struct prefix. */
3533 ret
= str2prefix (ip_str
, &p
);
3536 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3540 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3542 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3546 #endif /* HAVE_IPV6 */
3550 /* Set BGP static route configuration. */
3551 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3555 /* Configuration change. */
3556 bgp_static
= rn
->info
;
3558 /* Check previous routes are installed into BGP. */
3559 if (! bgp_static
->backdoor
&& bgp_static
->valid
)
3562 bgp_static
->backdoor
= backdoor
;
3565 if (bgp_static
->rmap
.name
)
3566 free (bgp_static
->rmap
.name
);
3567 bgp_static
->rmap
.name
= strdup (rmap
);
3568 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3572 if (bgp_static
->rmap
.name
)
3573 free (bgp_static
->rmap
.name
);
3574 bgp_static
->rmap
.name
= NULL
;
3575 bgp_static
->rmap
.map
= NULL
;
3576 bgp_static
->valid
= 0;
3578 bgp_unlock_node (rn
);
3582 /* New configuration. */
3583 bgp_static
= bgp_static_new ();
3584 bgp_static
->backdoor
= backdoor
;
3585 bgp_static
->valid
= 0;
3586 bgp_static
->igpmetric
= 0;
3587 bgp_static
->igpnexthop
.s_addr
= 0;
3590 if (bgp_static
->rmap
.name
)
3591 free (bgp_static
->rmap
.name
);
3592 bgp_static
->rmap
.name
= strdup (rmap
);
3593 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3595 rn
->info
= bgp_static
;
3598 /* If BGP scan is not enabled, we should install this route here. */
3599 if (! bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3601 bgp_static
->valid
= 1;
3604 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3606 if (! bgp_static
->backdoor
)
3607 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3613 /* Configure static BGP network. */
3615 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3616 u_int16_t afi
, u_char safi
)
3620 struct bgp_static
*bgp_static
;
3621 struct bgp_node
*rn
;
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 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3644 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3649 bgp_static
= rn
->info
;
3651 /* Update BGP RIB. */
3652 if (! bgp_static
->backdoor
)
3653 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3655 /* Clear configuration. */
3656 bgp_static_free (bgp_static
);
3658 bgp_unlock_node (rn
);
3659 bgp_unlock_node (rn
);
3664 /* Called from bgp_delete(). Delete all static routes from the BGP
3667 bgp_static_delete (struct bgp
*bgp
)
3671 struct bgp_node
*rn
;
3672 struct bgp_node
*rm
;
3673 struct bgp_table
*table
;
3674 struct bgp_static
*bgp_static
;
3676 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3677 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3678 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3679 if (rn
->info
!= NULL
)
3681 if (safi
== SAFI_MPLS_VPN
)
3685 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3687 bgp_static
= rn
->info
;
3688 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3689 AFI_IP
, SAFI_MPLS_VPN
,
3690 (struct prefix_rd
*)&rn
->p
,
3692 bgp_static_free (bgp_static
);
3694 bgp_unlock_node (rn
);
3699 bgp_static
= rn
->info
;
3700 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3701 bgp_static_free (bgp_static
);
3703 bgp_unlock_node (rn
);
3709 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3710 const char *tag_str
)
3714 struct prefix_rd prd
;
3716 struct bgp_node
*prn
;
3717 struct bgp_node
*rn
;
3718 struct bgp_table
*table
;
3719 struct bgp_static
*bgp_static
;
3724 ret
= str2prefix (ip_str
, &p
);
3727 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3732 ret
= str2prefix_rd (rd_str
, &prd
);
3735 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3739 ret
= str2tag (tag_str
, tag
);
3742 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3746 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3747 (struct prefix
*)&prd
);
3748 if (prn
->info
== NULL
)
3749 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3751 bgp_unlock_node (prn
);
3754 rn
= bgp_node_get (table
, &p
);
3758 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3759 bgp_unlock_node (rn
);
3763 /* New configuration. */
3764 bgp_static
= bgp_static_new ();
3765 bgp_static
->valid
= 1;
3766 memcpy (bgp_static
->tag
, tag
, 3);
3767 rn
->info
= bgp_static
;
3769 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3775 /* Configure static BGP network. */
3777 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3778 const char *rd_str
, const char *tag_str
)
3783 struct prefix_rd prd
;
3784 struct bgp_node
*prn
;
3785 struct bgp_node
*rn
;
3786 struct bgp_table
*table
;
3787 struct bgp_static
*bgp_static
;
3792 /* Convert IP prefix string to struct prefix. */
3793 ret
= str2prefix (ip_str
, &p
);
3796 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3801 ret
= str2prefix_rd (rd_str
, &prd
);
3804 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3808 ret
= str2tag (tag_str
, tag
);
3811 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3815 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3816 (struct prefix
*)&prd
);
3817 if (prn
->info
== NULL
)
3818 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3820 bgp_unlock_node (prn
);
3823 rn
= bgp_node_lookup (table
, &p
);
3827 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3829 bgp_static
= rn
->info
;
3830 bgp_static_free (bgp_static
);
3832 bgp_unlock_node (rn
);
3833 bgp_unlock_node (rn
);
3836 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3843 "network A.B.C.D/M",
3844 "Specify a network to announce via BGP\n"
3845 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3847 return bgp_static_set (vty
, vty
->index
, argv
[0],
3848 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3851 DEFUN (bgp_network_route_map
,
3852 bgp_network_route_map_cmd
,
3853 "network A.B.C.D/M route-map WORD",
3854 "Specify a network to announce via BGP\n"
3855 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3856 "Route-map to modify the attributes\n"
3857 "Name of the route map\n")
3859 return bgp_static_set (vty
, vty
->index
, argv
[0],
3860 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3863 DEFUN (bgp_network_backdoor
,
3864 bgp_network_backdoor_cmd
,
3865 "network A.B.C.D/M backdoor",
3866 "Specify a network to announce via BGP\n"
3867 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3868 "Specify a BGP backdoor route\n")
3870 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
3873 DEFUN (bgp_network_mask
,
3874 bgp_network_mask_cmd
,
3875 "network A.B.C.D mask A.B.C.D",
3876 "Specify a network to announce via BGP\n"
3882 char prefix_str
[BUFSIZ
];
3884 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3887 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3891 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3892 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3895 DEFUN (bgp_network_mask_route_map
,
3896 bgp_network_mask_route_map_cmd
,
3897 "network A.B.C.D mask A.B.C.D route-map WORD",
3898 "Specify a network to announce via BGP\n"
3902 "Route-map to modify the attributes\n"
3903 "Name of the route map\n")
3906 char prefix_str
[BUFSIZ
];
3908 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3911 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3915 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3916 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
3919 DEFUN (bgp_network_mask_backdoor
,
3920 bgp_network_mask_backdoor_cmd
,
3921 "network A.B.C.D mask A.B.C.D backdoor",
3922 "Specify a network to announce via BGP\n"
3926 "Specify a BGP backdoor route\n")
3929 char prefix_str
[BUFSIZ
];
3931 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3934 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3938 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
, NULL
, 1);
3941 DEFUN (bgp_network_mask_natural
,
3942 bgp_network_mask_natural_cmd
,
3944 "Specify a network to announce via BGP\n"
3948 char prefix_str
[BUFSIZ
];
3950 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3953 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3957 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3958 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3961 DEFUN (bgp_network_mask_natural_route_map
,
3962 bgp_network_mask_natural_route_map_cmd
,
3963 "network A.B.C.D route-map WORD",
3964 "Specify a network to announce via BGP\n"
3966 "Route-map to modify the attributes\n"
3967 "Name of the route map\n")
3970 char prefix_str
[BUFSIZ
];
3972 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3975 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3979 return bgp_static_set (vty
, vty
->index
, prefix_str
,
3980 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3983 DEFUN (bgp_network_mask_natural_backdoor
,
3984 bgp_network_mask_natural_backdoor_cmd
,
3985 "network A.B.C.D backdoor",
3986 "Specify a network to announce via BGP\n"
3988 "Specify a BGP backdoor route\n")
3991 char prefix_str
[BUFSIZ
];
3993 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
3996 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4000 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
, NULL
, 1);
4003 DEFUN (no_bgp_network
,
4005 "no network A.B.C.D/M",
4007 "Specify a network to announce via BGP\n"
4008 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4010 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4011 bgp_node_safi (vty
));
4014 ALIAS (no_bgp_network
,
4015 no_bgp_network_route_map_cmd
,
4016 "no network A.B.C.D/M route-map WORD",
4018 "Specify a network to announce via BGP\n"
4019 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4020 "Route-map to modify the attributes\n"
4021 "Name of the route map\n")
4023 ALIAS (no_bgp_network
,
4024 no_bgp_network_backdoor_cmd
,
4025 "no network A.B.C.D/M backdoor",
4027 "Specify a network to announce via BGP\n"
4028 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4029 "Specify a BGP backdoor route\n")
4031 DEFUN (no_bgp_network_mask
,
4032 no_bgp_network_mask_cmd
,
4033 "no network A.B.C.D mask A.B.C.D",
4035 "Specify a network to announce via BGP\n"
4041 char prefix_str
[BUFSIZ
];
4043 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4046 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4050 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4051 bgp_node_safi (vty
));
4054 ALIAS (no_bgp_network_mask
,
4055 no_bgp_network_mask_route_map_cmd
,
4056 "no network A.B.C.D mask A.B.C.D route-map WORD",
4058 "Specify a network to announce via BGP\n"
4062 "Route-map to modify the attributes\n"
4063 "Name of the route map\n")
4065 ALIAS (no_bgp_network_mask
,
4066 no_bgp_network_mask_backdoor_cmd
,
4067 "no network A.B.C.D mask A.B.C.D backdoor",
4069 "Specify a network to announce via BGP\n"
4073 "Specify a BGP backdoor route\n")
4075 DEFUN (no_bgp_network_mask_natural
,
4076 no_bgp_network_mask_natural_cmd
,
4077 "no network A.B.C.D",
4079 "Specify a network to announce via BGP\n"
4083 char prefix_str
[BUFSIZ
];
4085 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4088 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4092 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4093 bgp_node_safi (vty
));
4096 ALIAS (no_bgp_network_mask_natural
,
4097 no_bgp_network_mask_natural_route_map_cmd
,
4098 "no network A.B.C.D route-map WORD",
4100 "Specify a network to announce via BGP\n"
4102 "Route-map to modify the attributes\n"
4103 "Name of the route map\n")
4105 ALIAS (no_bgp_network_mask_natural
,
4106 no_bgp_network_mask_natural_backdoor_cmd
,
4107 "no network A.B.C.D backdoor",
4109 "Specify a network to announce via BGP\n"
4111 "Specify a BGP backdoor route\n")
4114 DEFUN (ipv6_bgp_network
,
4115 ipv6_bgp_network_cmd
,
4116 "network X:X::X:X/M",
4117 "Specify a network to announce via BGP\n"
4118 "IPv6 prefix <network>/<length>\n")
4120 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
4123 DEFUN (ipv6_bgp_network_route_map
,
4124 ipv6_bgp_network_route_map_cmd
,
4125 "network X:X::X:X/M route-map WORD",
4126 "Specify a network to announce via BGP\n"
4127 "IPv6 prefix <network>/<length>\n"
4128 "Route-map to modify the attributes\n"
4129 "Name of the route map\n")
4131 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4132 bgp_node_safi (vty
), argv
[1], 0);
4135 DEFUN (no_ipv6_bgp_network
,
4136 no_ipv6_bgp_network_cmd
,
4137 "no network X:X::X:X/M",
4139 "Specify a network to announce via BGP\n"
4140 "IPv6 prefix <network>/<length>\n")
4142 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
4145 ALIAS (no_ipv6_bgp_network
,
4146 no_ipv6_bgp_network_route_map_cmd
,
4147 "no network X:X::X:X/M route-map WORD",
4149 "Specify a network to announce via BGP\n"
4150 "IPv6 prefix <network>/<length>\n"
4151 "Route-map to modify the attributes\n"
4152 "Name of the route map\n")
4154 ALIAS (ipv6_bgp_network
,
4155 old_ipv6_bgp_network_cmd
,
4156 "ipv6 bgp network X:X::X:X/M",
4159 "Specify a network to announce via BGP\n"
4160 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4162 ALIAS (no_ipv6_bgp_network
,
4163 old_no_ipv6_bgp_network_cmd
,
4164 "no ipv6 bgp network X:X::X:X/M",
4168 "Specify a network to announce via BGP\n"
4169 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4170 #endif /* HAVE_IPV6 */
4172 /* Aggreagete address:
4174 advertise-map Set condition to advertise attribute
4175 as-set Generate AS set path information
4176 attribute-map Set attributes of aggregate
4177 route-map Set parameters of aggregate
4178 summary-only Filter more specific routes from updates
4179 suppress-map Conditionally filter more specific routes from updates
4182 struct bgp_aggregate
4184 /* Summary-only flag. */
4185 u_char summary_only
;
4187 /* AS set generation. */
4190 /* Route-map for aggregated route. */
4191 struct route_map
*map
;
4193 /* Suppress-count. */
4194 unsigned long count
;
4196 /* SAFI configuration. */
4200 static struct bgp_aggregate
*
4201 bgp_aggregate_new ()
4203 struct bgp_aggregate
*new;
4204 new = XMALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4205 memset (new, 0, sizeof (struct bgp_aggregate
));
4210 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4212 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4216 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4217 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4218 struct bgp_aggregate
*aggregate
)
4220 struct bgp_table
*table
;
4221 struct bgp_node
*top
;
4222 struct bgp_node
*rn
;
4224 struct aspath
*aspath
= NULL
;
4225 struct aspath
*asmerge
= NULL
;
4226 struct community
*community
= NULL
;
4227 struct community
*commerge
= NULL
;
4228 struct in_addr nexthop
;
4230 struct bgp_info
*ri
;
4231 struct bgp_info
*new;
4233 unsigned long match
= 0;
4235 /* Record adding route's nexthop and med. */
4238 nexthop
= rinew
->attr
->nexthop
;
4239 med
= rinew
->attr
->med
;
4242 /* ORIGIN attribute: If at least one route among routes that are
4243 aggregated has ORIGIN with the value INCOMPLETE, then the
4244 aggregated route must have the ORIGIN attribute with the value
4245 INCOMPLETE. Otherwise, if at least one route among routes that
4246 are aggregated has ORIGIN with the value EGP, then the aggregated
4247 route must have the origin attribute with the value EGP. In all
4248 other case the value of the ORIGIN attribute of the aggregated
4249 route is INTERNAL. */
4250 origin
= BGP_ORIGIN_IGP
;
4252 table
= bgp
->rib
[afi
][safi
];
4254 top
= bgp_node_get (table
, p
);
4255 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4256 if (rn
->p
.prefixlen
> p
->prefixlen
)
4260 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4262 if (BGP_INFO_HOLDDOWN (ri
))
4265 if (del
&& ri
== del
)
4268 if (! rinew
&& first
)
4270 nexthop
= ri
->attr
->nexthop
;
4271 med
= ri
->attr
->med
;
4275 #ifdef AGGREGATE_NEXTHOP_CHECK
4276 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4277 || ri
->attr
->med
!= med
)
4280 aspath_free (aspath
);
4282 community_free (community
);
4283 bgp_unlock_node (rn
);
4284 bgp_unlock_node (top
);
4287 #endif /* AGGREGATE_NEXTHOP_CHECK */
4289 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4291 if (aggregate
->summary_only
)
4293 (bgp_info_extra_get (ri
))->suppress
++;
4294 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4300 if (aggregate
->as_set
)
4302 if (origin
< ri
->attr
->origin
)
4303 origin
= ri
->attr
->origin
;
4307 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4308 aspath_free (aspath
);
4312 aspath
= aspath_dup (ri
->attr
->aspath
);
4314 if (ri
->attr
->community
)
4318 commerge
= community_merge (community
,
4319 ri
->attr
->community
);
4320 community
= community_uniq_sort (commerge
);
4321 community_free (commerge
);
4324 community
= community_dup (ri
->attr
->community
);
4330 bgp_process (bgp
, rn
, afi
, safi
);
4332 bgp_unlock_node (top
);
4338 if (aggregate
->summary_only
)
4339 (bgp_info_extra_get (rinew
))->suppress
++;
4341 if (aggregate
->as_set
)
4343 if (origin
< rinew
->attr
->origin
)
4344 origin
= rinew
->attr
->origin
;
4348 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4349 aspath_free (aspath
);
4353 aspath
= aspath_dup (rinew
->attr
->aspath
);
4355 if (rinew
->attr
->community
)
4359 commerge
= community_merge (community
,
4360 rinew
->attr
->community
);
4361 community
= community_uniq_sort (commerge
);
4362 community_free (commerge
);
4365 community
= community_dup (rinew
->attr
->community
);
4370 if (aggregate
->count
> 0)
4372 rn
= bgp_node_get (table
, p
);
4373 new = bgp_info_new ();
4374 new->type
= ZEBRA_ROUTE_BGP
;
4375 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4376 new->peer
= bgp
->peer_self
;
4377 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4378 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4379 new->uptime
= time (NULL
);
4381 bgp_info_add (rn
, new);
4382 bgp_unlock_node (rn
);
4383 bgp_process (bgp
, rn
, afi
, safi
);
4388 aspath_free (aspath
);
4390 community_free (community
);
4394 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4395 struct bgp_aggregate
*);
4398 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4399 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4401 struct bgp_node
*child
;
4402 struct bgp_node
*rn
;
4403 struct bgp_aggregate
*aggregate
;
4405 /* MPLS-VPN aggregation is not yet supported. */
4406 if (safi
== SAFI_MPLS_VPN
)
4409 if (p
->prefixlen
== 0)
4412 if (BGP_INFO_HOLDDOWN (ri
))
4415 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4417 /* Aggregate address configuration check. */
4418 for (rn
= child
; rn
; rn
= rn
->parent
)
4419 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4421 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4422 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4424 bgp_unlock_node (child
);
4428 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4429 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4431 struct bgp_node
*child
;
4432 struct bgp_node
*rn
;
4433 struct bgp_aggregate
*aggregate
;
4435 /* MPLS-VPN aggregation is not yet supported. */
4436 if (safi
== SAFI_MPLS_VPN
)
4439 if (p
->prefixlen
== 0)
4442 child
= bgp_node_get (bgp
->aggregate
[afi
][safi
], p
);
4444 /* Aggregate address configuration check. */
4445 for (rn
= child
; rn
; rn
= rn
->parent
)
4446 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4448 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4449 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4451 bgp_unlock_node (child
);
4455 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4456 struct bgp_aggregate
*aggregate
)
4458 struct bgp_table
*table
;
4459 struct bgp_node
*top
;
4460 struct bgp_node
*rn
;
4461 struct bgp_info
*new;
4462 struct bgp_info
*ri
;
4463 unsigned long match
;
4464 u_char origin
= BGP_ORIGIN_IGP
;
4465 struct aspath
*aspath
= NULL
;
4466 struct aspath
*asmerge
= NULL
;
4467 struct community
*community
= NULL
;
4468 struct community
*commerge
= NULL
;
4470 table
= bgp
->rib
[afi
][safi
];
4473 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4475 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4478 /* If routes exists below this node, generate aggregate routes. */
4479 top
= bgp_node_get (table
, p
);
4480 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4481 if (rn
->p
.prefixlen
> p
->prefixlen
)
4485 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4487 if (BGP_INFO_HOLDDOWN (ri
))
4490 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4492 /* summary-only aggregate route suppress aggregated
4493 route announcement. */
4494 if (aggregate
->summary_only
)
4496 (bgp_info_extra_get (ri
))->suppress
++;
4497 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4500 /* as-set aggregate route generate origin, as path,
4501 community aggregation. */
4502 if (aggregate
->as_set
)
4504 if (origin
< ri
->attr
->origin
)
4505 origin
= ri
->attr
->origin
;
4509 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4510 aspath_free (aspath
);
4514 aspath
= aspath_dup (ri
->attr
->aspath
);
4516 if (ri
->attr
->community
)
4520 commerge
= community_merge (community
,
4521 ri
->attr
->community
);
4522 community
= community_uniq_sort (commerge
);
4523 community_free (commerge
);
4526 community
= community_dup (ri
->attr
->community
);
4533 /* If this node is suppressed, process the change. */
4535 bgp_process (bgp
, rn
, afi
, safi
);
4537 bgp_unlock_node (top
);
4539 /* Add aggregate route to BGP table. */
4540 if (aggregate
->count
)
4542 rn
= bgp_node_get (table
, p
);
4544 new = bgp_info_new ();
4545 new->type
= ZEBRA_ROUTE_BGP
;
4546 new->sub_type
= BGP_ROUTE_AGGREGATE
;
4547 new->peer
= bgp
->peer_self
;
4548 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4549 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
4550 new->uptime
= time (NULL
);
4552 bgp_info_add (rn
, new);
4553 bgp_unlock_node (rn
);
4555 /* Process change. */
4556 bgp_process (bgp
, rn
, afi
, safi
);
4561 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4562 safi_t safi
, struct bgp_aggregate
*aggregate
)
4564 struct bgp_table
*table
;
4565 struct bgp_node
*top
;
4566 struct bgp_node
*rn
;
4567 struct bgp_info
*ri
;
4568 unsigned long match
;
4570 table
= bgp
->rib
[afi
][safi
];
4572 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4574 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4577 /* If routes exists below this node, generate aggregate routes. */
4578 top
= bgp_node_get (table
, p
);
4579 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4580 if (rn
->p
.prefixlen
> p
->prefixlen
)
4584 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4586 if (BGP_INFO_HOLDDOWN (ri
))
4589 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4591 if (aggregate
->summary_only
&& ri
->extra
)
4593 ri
->extra
->suppress
--;
4595 if (ri
->extra
->suppress
== 0)
4597 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4605 /* If this node was suppressed, process the change. */
4607 bgp_process (bgp
, rn
, afi
, safi
);
4609 bgp_unlock_node (top
);
4611 /* Delete aggregate route from BGP table. */
4612 rn
= bgp_node_get (table
, p
);
4614 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4615 if (ri
->peer
== bgp
->peer_self
4616 && ri
->type
== ZEBRA_ROUTE_BGP
4617 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4620 /* Withdraw static BGP route from routing table. */
4623 bgp_info_delete (rn
, ri
);
4624 bgp_process (bgp
, rn
, afi
, safi
);
4627 /* Unlock bgp_node_lookup. */
4628 bgp_unlock_node (rn
);
4631 /* Aggregate route attribute. */
4632 #define AGGREGATE_SUMMARY_ONLY 1
4633 #define AGGREGATE_AS_SET 1
4636 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4637 afi_t afi
, safi_t safi
,
4638 u_char summary_only
, u_char as_set
)
4642 struct bgp_node
*rn
;
4644 struct bgp_aggregate
*aggregate
;
4646 /* Convert string to prefix structure. */
4647 ret
= str2prefix (prefix_str
, &p
);
4650 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4655 /* Get BGP structure. */
4658 /* Old configuration check. */
4659 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4663 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4664 bgp_unlock_node (rn
);
4668 /* Make aggregate address structure. */
4669 aggregate
= bgp_aggregate_new ();
4670 aggregate
->summary_only
= summary_only
;
4671 aggregate
->as_set
= as_set
;
4672 aggregate
->safi
= safi
;
4673 rn
->info
= aggregate
;
4675 /* Aggregate address insert into BGP routing table. */
4676 if (safi
& SAFI_UNICAST
)
4677 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4678 if (safi
& SAFI_MULTICAST
)
4679 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4685 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4686 afi_t afi
, safi_t safi
)
4690 struct bgp_node
*rn
;
4692 struct bgp_aggregate
*aggregate
;
4694 /* Convert string to prefix structure. */
4695 ret
= str2prefix (prefix_str
, &p
);
4698 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4703 /* Get BGP structure. */
4706 /* Old configuration check. */
4707 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4710 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4715 aggregate
= rn
->info
;
4716 if (aggregate
->safi
& SAFI_UNICAST
)
4717 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4718 if (aggregate
->safi
& SAFI_MULTICAST
)
4719 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4721 /* Unlock aggregate address configuration. */
4723 bgp_aggregate_free (aggregate
);
4724 bgp_unlock_node (rn
);
4725 bgp_unlock_node (rn
);
4730 DEFUN (aggregate_address
,
4731 aggregate_address_cmd
,
4732 "aggregate-address A.B.C.D/M",
4733 "Configure BGP aggregate entries\n"
4734 "Aggregate prefix\n")
4736 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4739 DEFUN (aggregate_address_mask
,
4740 aggregate_address_mask_cmd
,
4741 "aggregate-address A.B.C.D A.B.C.D",
4742 "Configure BGP aggregate entries\n"
4743 "Aggregate address\n"
4747 char prefix_str
[BUFSIZ
];
4749 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4753 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4757 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4761 DEFUN (aggregate_address_summary_only
,
4762 aggregate_address_summary_only_cmd
,
4763 "aggregate-address A.B.C.D/M summary-only",
4764 "Configure BGP aggregate entries\n"
4765 "Aggregate prefix\n"
4766 "Filter more specific routes from updates\n")
4768 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4769 AGGREGATE_SUMMARY_ONLY
, 0);
4772 DEFUN (aggregate_address_mask_summary_only
,
4773 aggregate_address_mask_summary_only_cmd
,
4774 "aggregate-address A.B.C.D A.B.C.D summary-only",
4775 "Configure BGP aggregate entries\n"
4776 "Aggregate address\n"
4778 "Filter more specific routes from updates\n")
4781 char prefix_str
[BUFSIZ
];
4783 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4787 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4791 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4792 AGGREGATE_SUMMARY_ONLY
, 0);
4795 DEFUN (aggregate_address_as_set
,
4796 aggregate_address_as_set_cmd
,
4797 "aggregate-address A.B.C.D/M as-set",
4798 "Configure BGP aggregate entries\n"
4799 "Aggregate prefix\n"
4800 "Generate AS set path information\n")
4802 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4803 0, AGGREGATE_AS_SET
);
4806 DEFUN (aggregate_address_mask_as_set
,
4807 aggregate_address_mask_as_set_cmd
,
4808 "aggregate-address A.B.C.D A.B.C.D as-set",
4809 "Configure BGP aggregate entries\n"
4810 "Aggregate address\n"
4812 "Generate AS set path information\n")
4815 char prefix_str
[BUFSIZ
];
4817 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4821 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4825 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4826 0, AGGREGATE_AS_SET
);
4830 DEFUN (aggregate_address_as_set_summary
,
4831 aggregate_address_as_set_summary_cmd
,
4832 "aggregate-address A.B.C.D/M as-set summary-only",
4833 "Configure BGP aggregate entries\n"
4834 "Aggregate prefix\n"
4835 "Generate AS set path information\n"
4836 "Filter more specific routes from updates\n")
4838 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4839 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
4842 ALIAS (aggregate_address_as_set_summary
,
4843 aggregate_address_summary_as_set_cmd
,
4844 "aggregate-address A.B.C.D/M summary-only as-set",
4845 "Configure BGP aggregate entries\n"
4846 "Aggregate prefix\n"
4847 "Filter more specific routes from updates\n"
4848 "Generate AS set path information\n")
4850 DEFUN (aggregate_address_mask_as_set_summary
,
4851 aggregate_address_mask_as_set_summary_cmd
,
4852 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4853 "Configure BGP aggregate entries\n"
4854 "Aggregate address\n"
4856 "Generate AS set path information\n"
4857 "Filter more specific routes from updates\n")
4860 char prefix_str
[BUFSIZ
];
4862 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4866 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4870 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4871 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
4874 ALIAS (aggregate_address_mask_as_set_summary
,
4875 aggregate_address_mask_summary_as_set_cmd
,
4876 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4877 "Configure BGP aggregate entries\n"
4878 "Aggregate address\n"
4880 "Filter more specific routes from updates\n"
4881 "Generate AS set path information\n")
4883 DEFUN (no_aggregate_address
,
4884 no_aggregate_address_cmd
,
4885 "no aggregate-address A.B.C.D/M",
4887 "Configure BGP aggregate entries\n"
4888 "Aggregate prefix\n")
4890 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
4893 ALIAS (no_aggregate_address
,
4894 no_aggregate_address_summary_only_cmd
,
4895 "no aggregate-address A.B.C.D/M summary-only",
4897 "Configure BGP aggregate entries\n"
4898 "Aggregate prefix\n"
4899 "Filter more specific routes from updates\n")
4901 ALIAS (no_aggregate_address
,
4902 no_aggregate_address_as_set_cmd
,
4903 "no aggregate-address A.B.C.D/M as-set",
4905 "Configure BGP aggregate entries\n"
4906 "Aggregate prefix\n"
4907 "Generate AS set path information\n")
4909 ALIAS (no_aggregate_address
,
4910 no_aggregate_address_as_set_summary_cmd
,
4911 "no aggregate-address A.B.C.D/M as-set summary-only",
4913 "Configure BGP aggregate entries\n"
4914 "Aggregate prefix\n"
4915 "Generate AS set path information\n"
4916 "Filter more specific routes from updates\n")
4918 ALIAS (no_aggregate_address
,
4919 no_aggregate_address_summary_as_set_cmd
,
4920 "no aggregate-address A.B.C.D/M summary-only as-set",
4922 "Configure BGP aggregate entries\n"
4923 "Aggregate prefix\n"
4924 "Filter more specific routes from updates\n"
4925 "Generate AS set path information\n")
4927 DEFUN (no_aggregate_address_mask
,
4928 no_aggregate_address_mask_cmd
,
4929 "no aggregate-address A.B.C.D A.B.C.D",
4931 "Configure BGP aggregate entries\n"
4932 "Aggregate address\n"
4936 char prefix_str
[BUFSIZ
];
4938 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4942 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4946 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
4949 ALIAS (no_aggregate_address_mask
,
4950 no_aggregate_address_mask_summary_only_cmd
,
4951 "no aggregate-address A.B.C.D A.B.C.D summary-only",
4953 "Configure BGP aggregate entries\n"
4954 "Aggregate address\n"
4956 "Filter more specific routes from updates\n")
4958 ALIAS (no_aggregate_address_mask
,
4959 no_aggregate_address_mask_as_set_cmd
,
4960 "no aggregate-address A.B.C.D A.B.C.D as-set",
4962 "Configure BGP aggregate entries\n"
4963 "Aggregate address\n"
4965 "Generate AS set path information\n")
4967 ALIAS (no_aggregate_address_mask
,
4968 no_aggregate_address_mask_as_set_summary_cmd
,
4969 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
4971 "Configure BGP aggregate entries\n"
4972 "Aggregate address\n"
4974 "Generate AS set path information\n"
4975 "Filter more specific routes from updates\n")
4977 ALIAS (no_aggregate_address_mask
,
4978 no_aggregate_address_mask_summary_as_set_cmd
,
4979 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
4981 "Configure BGP aggregate entries\n"
4982 "Aggregate address\n"
4984 "Filter more specific routes from updates\n"
4985 "Generate AS set path information\n")
4988 DEFUN (ipv6_aggregate_address
,
4989 ipv6_aggregate_address_cmd
,
4990 "aggregate-address X:X::X:X/M",
4991 "Configure BGP aggregate entries\n"
4992 "Aggregate prefix\n")
4994 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
4997 DEFUN (ipv6_aggregate_address_summary_only
,
4998 ipv6_aggregate_address_summary_only_cmd
,
4999 "aggregate-address X:X::X:X/M summary-only",
5000 "Configure BGP aggregate entries\n"
5001 "Aggregate prefix\n"
5002 "Filter more specific routes from updates\n")
5004 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5005 AGGREGATE_SUMMARY_ONLY
, 0);
5008 DEFUN (no_ipv6_aggregate_address
,
5009 no_ipv6_aggregate_address_cmd
,
5010 "no aggregate-address X:X::X:X/M",
5012 "Configure BGP aggregate entries\n"
5013 "Aggregate prefix\n")
5015 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5018 DEFUN (no_ipv6_aggregate_address_summary_only
,
5019 no_ipv6_aggregate_address_summary_only_cmd
,
5020 "no aggregate-address X:X::X:X/M summary-only",
5022 "Configure BGP aggregate entries\n"
5023 "Aggregate prefix\n"
5024 "Filter more specific routes from updates\n")
5026 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5029 ALIAS (ipv6_aggregate_address
,
5030 old_ipv6_aggregate_address_cmd
,
5031 "ipv6 bgp aggregate-address X:X::X:X/M",
5034 "Configure BGP aggregate entries\n"
5035 "Aggregate prefix\n")
5037 ALIAS (ipv6_aggregate_address_summary_only
,
5038 old_ipv6_aggregate_address_summary_only_cmd
,
5039 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5042 "Configure BGP aggregate entries\n"
5043 "Aggregate prefix\n"
5044 "Filter more specific routes from updates\n")
5046 ALIAS (no_ipv6_aggregate_address
,
5047 old_no_ipv6_aggregate_address_cmd
,
5048 "no ipv6 bgp aggregate-address X:X::X:X/M",
5052 "Configure BGP aggregate entries\n"
5053 "Aggregate prefix\n")
5055 ALIAS (no_ipv6_aggregate_address_summary_only
,
5056 old_no_ipv6_aggregate_address_summary_only_cmd
,
5057 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5061 "Configure BGP aggregate entries\n"
5062 "Aggregate prefix\n"
5063 "Filter more specific routes from updates\n")
5064 #endif /* HAVE_IPV6 */
5066 /* Redistribute route treatment. */
5068 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
5069 u_int32_t metric
, u_char type
)
5072 struct listnode
*node
, *nnode
;
5073 struct bgp_info
*new;
5074 struct bgp_info
*bi
;
5075 struct bgp_info info
;
5076 struct bgp_node
*bn
;
5077 struct attr attr
= { 0 };
5078 struct attr attr_new
= { 0 };
5079 struct attr
*new_attr
;
5083 /* Make default attribute. */
5084 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5086 attr
.nexthop
= *nexthop
;
5089 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5091 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5093 afi
= family2afi (p
->family
);
5095 if (bgp
->redist
[afi
][type
])
5097 /* Copy attribute for modification. */
5098 bgp_attr_dup (&attr_new
, &attr
);
5100 if (bgp
->redist_metric_flag
[afi
][type
])
5101 attr_new
.med
= bgp
->redist_metric
[afi
][type
];
5103 /* Apply route-map. */
5104 if (bgp
->rmap
[afi
][type
].map
)
5106 info
.peer
= bgp
->peer_self
;
5107 info
.attr
= &attr_new
;
5109 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5111 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
5114 bgp
->peer_self
->rmap_type
= 0;
5116 if (ret
== RMAP_DENYMATCH
)
5118 /* Free uninterned attribute. */
5119 bgp_attr_flush (&attr_new
);
5120 bgp_attr_extra_free (&attr_new
);
5122 /* Unintern original. */
5123 aspath_unintern (attr
.aspath
);
5124 bgp_attr_extra_free (&attr
);
5125 bgp_redistribute_delete (p
, type
);
5130 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5131 afi
, SAFI_UNICAST
, p
, NULL
);
5133 new_attr
= bgp_attr_intern (&attr_new
);
5134 bgp_attr_extra_free (&attr_new
);
5136 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5137 if (bi
->peer
== bgp
->peer_self
5138 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5143 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5144 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5146 bgp_attr_unintern (new_attr
);
5147 aspath_unintern (attr
.aspath
);
5148 bgp_attr_extra_free (&attr
);
5149 bgp_unlock_node (bn
);
5154 /* The attribute is changed. */
5155 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5157 /* Rewrite BGP route information. */
5158 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5159 bgp_info_restore(bn
, bi
);
5161 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5162 bgp_attr_unintern (bi
->attr
);
5163 bi
->attr
= new_attr
;
5164 bi
->uptime
= time (NULL
);
5166 /* Process change. */
5167 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5168 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5169 bgp_unlock_node (bn
);
5170 aspath_unintern (attr
.aspath
);
5171 bgp_attr_extra_free (&attr
);
5176 new = bgp_info_new ();
5178 new->sub_type
= BGP_ROUTE_REDISTRIBUTE
;
5179 new->peer
= bgp
->peer_self
;
5180 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5181 new->attr
= new_attr
;
5182 new->uptime
= time (NULL
);
5184 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5185 bgp_info_add (bn
, new);
5186 bgp_unlock_node (bn
);
5187 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5191 /* Unintern original. */
5192 aspath_unintern (attr
.aspath
);
5193 bgp_attr_extra_free (&attr
);
5197 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
5200 struct listnode
*node
, *nnode
;
5202 struct bgp_node
*rn
;
5203 struct bgp_info
*ri
;
5205 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5207 afi
= family2afi (p
->family
);
5209 if (bgp
->redist
[afi
][type
])
5211 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5213 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5214 if (ri
->peer
== bgp
->peer_self
5215 && ri
->type
== type
)
5220 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5221 bgp_info_delete (rn
, ri
);
5222 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5224 bgp_unlock_node (rn
);
5229 /* Withdraw specified route type's route. */
5231 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
5233 struct bgp_node
*rn
;
5234 struct bgp_info
*ri
;
5235 struct bgp_table
*table
;
5237 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5239 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5241 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5242 if (ri
->peer
== bgp
->peer_self
5243 && ri
->type
== type
)
5248 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5249 bgp_info_delete (rn
, ri
);
5250 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5255 /* Static function to display route. */
5257 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5260 u_int32_t destination
;
5263 if (p
->family
== AF_INET
)
5265 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5266 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5268 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5269 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5270 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5271 || p
->u
.prefix4
.s_addr
== 0)
5273 /* When mask is natural, mask is not displayed. */
5276 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5279 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5284 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5286 vty_out (vty
, "%*s", len
, " ");
5289 enum bgp_display_type
5294 /* Print the short form route status for a bgp_info */
5296 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
)
5298 /* Route status display. */
5299 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5301 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5303 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5305 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5311 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5313 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5315 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5320 /* Internal route. */
5321 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5327 /* called from terminal list command */
5329 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5330 struct bgp_info
*binfo
, int display
, safi_t safi
)
5334 /* short status lead text */
5335 route_vty_short_status_out (vty
, binfo
);
5337 /* print prefix and mask */
5339 route_vty_out_route (p
, vty
);
5341 vty_out (vty
, "%*s", 17, " ");
5343 /* Print attribute */
5347 if (p
->family
== AF_INET
)
5349 if (safi
== SAFI_MPLS_VPN
)
5350 vty_out (vty
, "%-16s",
5351 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5353 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5356 else if (p
->family
== AF_INET6
)
5361 len
= vty_out (vty
, "%s",
5362 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5366 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5368 vty_out (vty
, "%*s", len
, " ");
5370 #endif /* HAVE_IPV6 */
5372 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5373 vty_out (vty
, "%10d", attr
->med
);
5377 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5378 vty_out (vty
, "%7d", attr
->local_pref
);
5382 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5386 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5389 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5391 vty_out (vty
, "%s", VTY_NEWLINE
);
5394 /* called from terminal list command */
5396 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
5397 struct attr
*attr
, safi_t safi
)
5399 /* Route status display. */
5404 /* print prefix and mask */
5405 route_vty_out_route (p
, vty
);
5407 /* Print attribute */
5410 if (p
->family
== AF_INET
)
5412 if (safi
== SAFI_MPLS_VPN
)
5413 vty_out (vty
, "%-16s",
5414 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5416 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5419 else if (p
->family
== AF_INET6
)
5424 assert (attr
->extra
);
5426 len
= vty_out (vty
, "%s",
5427 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5431 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5433 vty_out (vty
, "%*s", len
, " ");
5435 #endif /* HAVE_IPV6 */
5437 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5438 vty_out (vty
, "%10d", attr
->med
);
5442 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5443 vty_out (vty
, "%7d", attr
->local_pref
);
5447 vty_out (vty
, "%7d ", (attr
->extra
? attr
->extra
->weight
: 0));
5451 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5454 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5457 vty_out (vty
, "%s", VTY_NEWLINE
);
5461 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5462 struct bgp_info
*binfo
, int display
, safi_t safi
)
5465 u_int32_t label
= 0;
5470 /* short status lead text */
5471 route_vty_short_status_out (vty
, binfo
);
5473 /* print prefix and mask */
5475 route_vty_out_route (p
, vty
);
5477 vty_out (vty
, "%*s", 17, " ");
5479 /* Print attribute */
5483 if (p
->family
== AF_INET
)
5485 if (safi
== SAFI_MPLS_VPN
)
5486 vty_out (vty
, "%-16s",
5487 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5489 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5492 else if (p
->family
== AF_INET6
)
5494 assert (attr
->extra
);
5497 if (attr
->extra
->mp_nexthop_len
== 16)
5499 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5501 else if (attr
->extra
->mp_nexthop_len
== 32)
5502 vty_out (vty
, "%s(%s)",
5503 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5505 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5509 #endif /* HAVE_IPV6 */
5512 label
= decode_label (binfo
->extra
->tag
);
5514 vty_out (vty
, "notag/%d", label
);
5516 vty_out (vty
, "%s", VTY_NEWLINE
);
5519 /* dampening route */
5521 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5522 struct bgp_info
*binfo
, int display
, safi_t safi
)
5527 /* short status lead text */
5528 route_vty_short_status_out (vty
, binfo
);
5530 /* print prefix and mask */
5532 route_vty_out_route (p
, vty
);
5534 vty_out (vty
, "%*s", 17, " ");
5536 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5539 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
5541 vty_out (vty
, "%*s", len
, " ");
5543 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
));
5545 /* Print attribute */
5551 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5554 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5556 vty_out (vty
, "%s", VTY_NEWLINE
);
5559 #define BGP_UPTIME_LEN 25
5563 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
,
5564 struct bgp_info
*binfo
, int display
, safi_t safi
)
5567 struct bgp_damp_info
*bdi
;
5568 char timebuf
[BGP_UPTIME_LEN
];
5574 bdi
= binfo
->extra
->damp_info
;
5576 /* short status lead text */
5577 route_vty_short_status_out (vty
, binfo
);
5579 /* print prefix and mask */
5581 route_vty_out_route (p
, vty
);
5583 vty_out (vty
, "%*s", 17, " ");
5585 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
5588 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
5590 vty_out (vty
, "%*s", len
, " ");
5592 len
= vty_out (vty
, "%d", bdi
->flap
);
5597 vty_out (vty
, "%*s ", len
, " ");
5599 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
5600 timebuf
, BGP_UPTIME_LEN
));
5602 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
5603 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5604 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
));
5606 vty_out (vty
, "%*s ", 8, " ");
5608 /* Print attribute */
5614 aspath_print_vty (vty
, "%s ", attr
->aspath
);
5617 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5619 vty_out (vty
, "%s", VTY_NEWLINE
);
5623 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
5624 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
5626 char buf
[INET6_ADDRSTRLEN
];
5629 int sockunion_vty_out (struct vty
*, union sockunion
*);
5635 /* Line1 display AS-path, Aggregator */
5639 if (aspath_count_hops (attr
->aspath
) == 0)
5640 vty_out (vty
, "Local");
5642 aspath_print_vty (vty
, "%s", attr
->aspath
);
5645 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5646 vty_out (vty
, ", (removed)");
5647 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5648 vty_out (vty
, ", (stale)");
5649 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
5650 vty_out (vty
, ", (aggregated by %d %s)",
5651 attr
->extra
->aggregator_as
,
5652 inet_ntoa (attr
->extra
->aggregator_addr
));
5653 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
5654 vty_out (vty
, ", (Received from a RR-client)");
5655 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
5656 vty_out (vty
, ", (Received from a RS-client)");
5657 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5658 vty_out (vty
, ", (history entry)");
5659 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5660 vty_out (vty
, ", (suppressed due to dampening)");
5661 vty_out (vty
, "%s", VTY_NEWLINE
);
5663 /* Line2 display Next-hop, Neighbor, Router-id */
5664 if (p
->family
== AF_INET
)
5666 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
5667 inet_ntoa (attr
->extra
->mp_nexthop_global_in
) :
5668 inet_ntoa (attr
->nexthop
));
5673 assert (attr
->extra
);
5674 vty_out (vty
, " %s",
5675 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5676 buf
, INET6_ADDRSTRLEN
));
5678 #endif /* HAVE_IPV6 */
5680 if (binfo
->peer
== bgp
->peer_self
)
5682 vty_out (vty
, " from %s ",
5683 p
->family
== AF_INET
? "0.0.0.0" : "::");
5684 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
5688 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
5689 vty_out (vty
, " (inaccessible)");
5690 else if (binfo
->extra
&& binfo
->extra
->igpmetric
)
5691 vty_out (vty
, " (metric %d)", binfo
->extra
->igpmetric
);
5692 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
5693 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5694 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
5696 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
5698 vty_out (vty
, "%s", VTY_NEWLINE
);
5701 /* display nexthop local */
5702 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== 32)
5704 vty_out (vty
, " (%s)%s",
5705 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5706 buf
, INET6_ADDRSTRLEN
),
5709 #endif /* HAVE_IPV6 */
5711 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
5712 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
5714 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
5715 vty_out (vty
, ", metric %d", attr
->med
);
5717 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
5718 vty_out (vty
, ", localpref %d", attr
->local_pref
);
5720 vty_out (vty
, ", localpref %d", bgp
->default_local_pref
);
5722 if (attr
->extra
&& attr
->extra
->weight
!= 0)
5723 vty_out (vty
, ", weight %d", attr
->extra
->weight
);
5725 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5726 vty_out (vty
, ", valid");
5728 if (binfo
->peer
!= bgp
->peer_self
)
5730 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
5731 vty_out (vty
, ", internal");
5733 vty_out (vty
, ", %s",
5734 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
5736 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
5737 vty_out (vty
, ", aggregated, local");
5738 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
5739 vty_out (vty
, ", sourced");
5741 vty_out (vty
, ", sourced, local");
5743 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5744 vty_out (vty
, ", atomic-aggregate");
5746 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5747 vty_out (vty
, ", best");
5749 vty_out (vty
, "%s", VTY_NEWLINE
);
5751 /* Line 4 display Community */
5752 if (attr
->community
)
5753 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
5756 /* Line 5 display Extended-community */
5757 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
5758 vty_out (vty
, " Extended Community: %s%s",
5759 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
5761 /* Line 6 display Originator, Cluster-id */
5762 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
5763 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
5765 assert (attr
->extra
);
5766 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
5767 vty_out (vty
, " Originator: %s",
5768 inet_ntoa (attr
->extra
->originator_id
));
5770 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
5773 vty_out (vty
, ", Cluster list: ");
5774 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
5775 vty_out (vty
, "%s ",
5776 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
5778 vty_out (vty
, "%s", VTY_NEWLINE
);
5781 if (binfo
->extra
&& binfo
->extra
->damp_info
)
5782 bgp_damp_info_vty (vty
, binfo
);
5784 /* Line 7 display Uptime */
5785 vty_out (vty
, " Last update: %s", ctime (&binfo
->uptime
));
5787 vty_out (vty
, "%s", VTY_NEWLINE
);
5790 #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"
5791 #define BGP_SHOW_OCODE_HEADER "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s"
5792 #define BGP_SHOW_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
5793 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
5794 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
5798 bgp_show_type_normal
,
5799 bgp_show_type_regexp
,
5800 bgp_show_type_prefix_list
,
5801 bgp_show_type_filter_list
,
5802 bgp_show_type_route_map
,
5803 bgp_show_type_neighbor
,
5804 bgp_show_type_cidr_only
,
5805 bgp_show_type_prefix_longer
,
5806 bgp_show_type_community_all
,
5807 bgp_show_type_community
,
5808 bgp_show_type_community_exact
,
5809 bgp_show_type_community_list
,
5810 bgp_show_type_community_list_exact
,
5811 bgp_show_type_flap_statistics
,
5812 bgp_show_type_flap_address
,
5813 bgp_show_type_flap_prefix
,
5814 bgp_show_type_flap_cidr_only
,
5815 bgp_show_type_flap_regexp
,
5816 bgp_show_type_flap_filter_list
,
5817 bgp_show_type_flap_prefix_list
,
5818 bgp_show_type_flap_prefix_longer
,
5819 bgp_show_type_flap_route_map
,
5820 bgp_show_type_flap_neighbor
,
5821 bgp_show_type_dampend_paths
,
5822 bgp_show_type_damp_neighbor
5826 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
5827 enum bgp_show_type type
, void *output_arg
)
5829 struct bgp_info
*ri
;
5830 struct bgp_node
*rn
;
5833 unsigned long output_count
;
5835 /* This is first entry point, so reset total line. */
5838 /* Start processing of routes. */
5839 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5840 if (rn
->info
!= NULL
)
5844 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5846 if (type
== bgp_show_type_flap_statistics
5847 || type
== bgp_show_type_flap_address
5848 || type
== bgp_show_type_flap_prefix
5849 || type
== bgp_show_type_flap_cidr_only
5850 || type
== bgp_show_type_flap_regexp
5851 || type
== bgp_show_type_flap_filter_list
5852 || type
== bgp_show_type_flap_prefix_list
5853 || type
== bgp_show_type_flap_prefix_longer
5854 || type
== bgp_show_type_flap_route_map
5855 || type
== bgp_show_type_flap_neighbor
5856 || type
== bgp_show_type_dampend_paths
5857 || type
== bgp_show_type_damp_neighbor
)
5859 if (!(ri
->extra
&& ri
->extra
->damp_info
))
5862 if (type
== bgp_show_type_regexp
5863 || type
== bgp_show_type_flap_regexp
)
5865 regex_t
*regex
= output_arg
;
5867 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
5870 if (type
== bgp_show_type_prefix_list
5871 || type
== bgp_show_type_flap_prefix_list
)
5873 struct prefix_list
*plist
= output_arg
;
5875 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
5878 if (type
== bgp_show_type_filter_list
5879 || type
== bgp_show_type_flap_filter_list
)
5881 struct as_list
*as_list
= output_arg
;
5883 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
5886 if (type
== bgp_show_type_route_map
5887 || type
== bgp_show_type_flap_route_map
)
5889 struct route_map
*rmap
= output_arg
;
5890 struct bgp_info binfo
;
5891 struct attr dummy_attr
;
5894 bgp_attr_dup (&dummy_attr
, ri
->attr
);
5895 binfo
.peer
= ri
->peer
;
5896 binfo
.attr
= &dummy_attr
;
5898 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
5900 bgp_attr_extra_free (&dummy_attr
);
5902 if (ret
== RMAP_DENYMATCH
)
5905 if (type
== bgp_show_type_neighbor
5906 || type
== bgp_show_type_flap_neighbor
5907 || type
== bgp_show_type_damp_neighbor
)
5909 union sockunion
*su
= output_arg
;
5911 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
5914 if (type
== bgp_show_type_cidr_only
5915 || type
== bgp_show_type_flap_cidr_only
)
5917 u_int32_t destination
;
5919 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
5920 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
5922 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
5924 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
5927 if (type
== bgp_show_type_prefix_longer
5928 || type
== bgp_show_type_flap_prefix_longer
)
5930 struct prefix
*p
= output_arg
;
5932 if (! prefix_match (p
, &rn
->p
))
5935 if (type
== bgp_show_type_community_all
)
5937 if (! ri
->attr
->community
)
5940 if (type
== bgp_show_type_community
)
5942 struct community
*com
= output_arg
;
5944 if (! ri
->attr
->community
||
5945 ! community_match (ri
->attr
->community
, com
))
5948 if (type
== bgp_show_type_community_exact
)
5950 struct community
*com
= output_arg
;
5952 if (! ri
->attr
->community
||
5953 ! community_cmp (ri
->attr
->community
, com
))
5956 if (type
== bgp_show_type_community_list
)
5958 struct community_list
*list
= output_arg
;
5960 if (! community_list_match (ri
->attr
->community
, list
))
5963 if (type
== bgp_show_type_community_list_exact
)
5965 struct community_list
*list
= output_arg
;
5967 if (! community_list_exact_match (ri
->attr
->community
, list
))
5970 if (type
== bgp_show_type_flap_address
5971 || type
== bgp_show_type_flap_prefix
)
5973 struct prefix
*p
= output_arg
;
5975 if (! prefix_match (&rn
->p
, p
))
5978 if (type
== bgp_show_type_flap_prefix
)
5979 if (p
->prefixlen
!= rn
->p
.prefixlen
)
5982 if (type
== bgp_show_type_dampend_paths
5983 || type
== bgp_show_type_damp_neighbor
)
5985 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
5986 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
5992 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (*router_id
), VTY_NEWLINE
);
5993 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
5994 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
5995 if (type
== bgp_show_type_dampend_paths
5996 || type
== bgp_show_type_damp_neighbor
)
5997 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
5998 else if (type
== bgp_show_type_flap_statistics
5999 || type
== bgp_show_type_flap_address
6000 || type
== bgp_show_type_flap_prefix
6001 || type
== bgp_show_type_flap_cidr_only
6002 || type
== bgp_show_type_flap_regexp
6003 || type
== bgp_show_type_flap_filter_list
6004 || type
== bgp_show_type_flap_prefix_list
6005 || type
== bgp_show_type_flap_prefix_longer
6006 || type
== bgp_show_type_flap_route_map
6007 || type
== bgp_show_type_flap_neighbor
)
6008 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
6010 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
6014 if (type
== bgp_show_type_dampend_paths
6015 || type
== bgp_show_type_damp_neighbor
)
6016 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6017 else if (type
== bgp_show_type_flap_statistics
6018 || type
== bgp_show_type_flap_address
6019 || type
== bgp_show_type_flap_prefix
6020 || type
== bgp_show_type_flap_cidr_only
6021 || type
== bgp_show_type_flap_regexp
6022 || type
== bgp_show_type_flap_filter_list
6023 || type
== bgp_show_type_flap_prefix_list
6024 || type
== bgp_show_type_flap_prefix_longer
6025 || type
== bgp_show_type_flap_route_map
6026 || type
== bgp_show_type_flap_neighbor
)
6027 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6029 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
6036 /* No route is displayed */
6037 if (output_count
== 0)
6039 if (type
== bgp_show_type_normal
)
6040 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
6043 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6044 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6050 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
6051 enum bgp_show_type type
, void *output_arg
)
6053 struct bgp_table
*table
;
6056 bgp
= bgp_get_default ();
6061 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6066 table
= bgp
->rib
[afi
][safi
];
6068 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
);
6071 /* Header of detailed BGP route information */
6073 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
6074 struct bgp_node
*rn
,
6075 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
)
6077 struct bgp_info
*ri
;
6080 struct listnode
*node
, *nnode
;
6081 char buf1
[INET6_ADDRSTRLEN
];
6082 char buf2
[INET6_ADDRSTRLEN
];
6087 int no_advertise
= 0;
6092 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
6093 (safi
== SAFI_MPLS_VPN
?
6094 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
6095 safi
== SAFI_MPLS_VPN
? ":" : "",
6096 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
6097 p
->prefixlen
, VTY_NEWLINE
);
6099 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6102 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
6105 if (ri
->extra
&& ri
->extra
->suppress
)
6107 if (ri
->attr
->community
!= NULL
)
6109 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
6111 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
6113 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
6119 vty_out (vty
, "Paths: (%d available", count
);
6122 vty_out (vty
, ", best #%d", best
);
6123 if (safi
== SAFI_UNICAST
)
6124 vty_out (vty
, ", table Default-IP-Routing-Table");
6127 vty_out (vty
, ", no best path");
6129 vty_out (vty
, ", not advertised to any peer");
6131 vty_out (vty
, ", not advertised to EBGP peer");
6133 vty_out (vty
, ", not advertised outside local AS");
6135 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
6136 vty_out (vty
, ")%s", VTY_NEWLINE
);
6138 /* advertised peer */
6139 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6141 if (bgp_adj_out_lookup (peer
, p
, afi
, safi
, rn
))
6144 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
6145 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6150 vty_out (vty
, " Not advertised to any peer");
6151 vty_out (vty
, "%s", VTY_NEWLINE
);
6154 /* Display specified route of BGP table. */
6156 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
6157 struct bgp_table
*rib
, const char *ip_str
,
6158 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6164 struct prefix match
;
6165 struct bgp_node
*rn
;
6166 struct bgp_node
*rm
;
6167 struct bgp_info
*ri
;
6168 struct bgp_table
*table
;
6170 /* Check IP address argument. */
6171 ret
= str2prefix (ip_str
, &match
);
6174 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
6178 match
.family
= afi2family (afi
);
6180 if (safi
== SAFI_MPLS_VPN
)
6182 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
6184 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
6187 if ((table
= rn
->info
) != NULL
)
6191 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
6193 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
6196 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
6200 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
6201 AFI_IP
, SAFI_MPLS_VPN
);
6206 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
);
6216 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
6218 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
6220 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6224 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
);
6228 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
);
6236 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
6243 /* Display specified route of Main RIB */
6245 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
6246 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
6251 /* BGP structure lookup. */
6254 bgp
= bgp_lookup_by_name (view_name
);
6257 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
6263 bgp
= bgp_get_default ();
6266 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
6271 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
6272 afi
, safi
, prd
, prefix_check
);
6275 /* BGP route print out function. */
6283 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6286 DEFUN (show_ip_bgp_ipv4
,
6287 show_ip_bgp_ipv4_cmd
,
6288 "show ip bgp ipv4 (unicast|multicast)",
6293 "Address Family modifier\n"
6294 "Address Family modifier\n")
6296 if (strncmp (argv
[0], "m", 1) == 0)
6297 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
6300 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6303 DEFUN (show_ip_bgp_route
,
6304 show_ip_bgp_route_cmd
,
6305 "show ip bgp A.B.C.D",
6309 "Network in the BGP routing table to display\n")
6311 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6314 DEFUN (show_ip_bgp_ipv4_route
,
6315 show_ip_bgp_ipv4_route_cmd
,
6316 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
6321 "Address Family modifier\n"
6322 "Address Family modifier\n"
6323 "Network in the BGP routing table to display\n")
6325 if (strncmp (argv
[0], "m", 1) == 0)
6326 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0);
6328 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6331 DEFUN (show_ip_bgp_vpnv4_all_route
,
6332 show_ip_bgp_vpnv4_all_route_cmd
,
6333 "show ip bgp vpnv4 all A.B.C.D",
6337 "Display VPNv4 NLRI specific information\n"
6338 "Display information about all VPNv4 NLRIs\n"
6339 "Network in the BGP routing table to display\n")
6341 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0);
6344 DEFUN (show_ip_bgp_vpnv4_rd_route
,
6345 show_ip_bgp_vpnv4_rd_route_cmd
,
6346 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D",
6350 "Display VPNv4 NLRI specific information\n"
6351 "Display information for a route distinguisher\n"
6352 "VPN Route Distinguisher\n"
6353 "Network in the BGP routing table to display\n")
6356 struct prefix_rd prd
;
6358 ret
= str2prefix_rd (argv
[0], &prd
);
6361 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6364 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0);
6367 DEFUN (show_ip_bgp_prefix
,
6368 show_ip_bgp_prefix_cmd
,
6369 "show ip bgp A.B.C.D/M",
6373 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6375 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6378 DEFUN (show_ip_bgp_ipv4_prefix
,
6379 show_ip_bgp_ipv4_prefix_cmd
,
6380 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
6385 "Address Family modifier\n"
6386 "Address Family modifier\n"
6387 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6389 if (strncmp (argv
[0], "m", 1) == 0)
6390 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1);
6392 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6395 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
6396 show_ip_bgp_vpnv4_all_prefix_cmd
,
6397 "show ip bgp vpnv4 all A.B.C.D/M",
6401 "Display VPNv4 NLRI specific information\n"
6402 "Display information about all VPNv4 NLRIs\n"
6403 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6405 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1);
6408 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
6409 show_ip_bgp_vpnv4_rd_prefix_cmd
,
6410 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M",
6414 "Display VPNv4 NLRI specific information\n"
6415 "Display information for a route distinguisher\n"
6416 "VPN Route Distinguisher\n"
6417 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6420 struct prefix_rd prd
;
6422 ret
= str2prefix_rd (argv
[0], &prd
);
6425 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
6428 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 1);
6431 DEFUN (show_ip_bgp_view
,
6432 show_ip_bgp_view_cmd
,
6433 "show ip bgp view WORD",
6442 /* BGP structure lookup. */
6443 bgp
= bgp_lookup_by_name (argv
[0]);
6446 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6450 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6453 DEFUN (show_ip_bgp_view_route
,
6454 show_ip_bgp_view_route_cmd
,
6455 "show ip bgp view WORD A.B.C.D",
6461 "Network in the BGP routing table to display\n")
6463 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0);
6466 DEFUN (show_ip_bgp_view_prefix
,
6467 show_ip_bgp_view_prefix_cmd
,
6468 "show ip bgp view WORD A.B.C.D/M",
6474 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
6476 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1);
6486 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6498 DEFUN (show_ipv6_bgp
,
6505 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
6509 DEFUN (show_bgp_route
,
6511 "show bgp X:X::X:X",
6514 "Network in the BGP routing table to display\n")
6516 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6519 ALIAS (show_bgp_route
,
6520 show_bgp_ipv6_route_cmd
,
6521 "show bgp ipv6 X:X::X:X",
6525 "Network in the BGP routing table to display\n")
6528 DEFUN (show_ipv6_bgp_route
,
6529 show_ipv6_bgp_route_cmd
,
6530 "show ipv6 bgp X:X::X:X",
6534 "Network in the BGP routing table to display\n")
6536 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6539 DEFUN (show_bgp_prefix
,
6540 show_bgp_prefix_cmd
,
6541 "show bgp X:X::X:X/M",
6544 "IPv6 prefix <network>/<length>\n")
6546 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6549 ALIAS (show_bgp_prefix
,
6550 show_bgp_ipv6_prefix_cmd
,
6551 "show bgp ipv6 X:X::X:X/M",
6555 "IPv6 prefix <network>/<length>\n")
6558 DEFUN (show_ipv6_bgp_prefix
,
6559 show_ipv6_bgp_prefix_cmd
,
6560 "show ipv6 bgp X:X::X:X/M",
6564 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6566 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6569 DEFUN (show_bgp_view
,
6571 "show bgp view WORD",
6579 /* BGP structure lookup. */
6580 bgp
= bgp_lookup_by_name (argv
[0]);
6583 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
6587 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
);
6590 ALIAS (show_bgp_view
,
6591 show_bgp_view_ipv6_cmd
,
6592 "show bgp view WORD ipv6",
6599 DEFUN (show_bgp_view_route
,
6600 show_bgp_view_route_cmd
,
6601 "show bgp view WORD X:X::X:X",
6606 "Network in the BGP routing table to display\n")
6608 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
6611 ALIAS (show_bgp_view_route
,
6612 show_bgp_view_ipv6_route_cmd
,
6613 "show bgp view WORD ipv6 X:X::X:X",
6619 "Network in the BGP routing table to display\n")
6621 DEFUN (show_bgp_view_prefix
,
6622 show_bgp_view_prefix_cmd
,
6623 "show bgp view WORD X:X::X:X/M",
6628 "IPv6 prefix <network>/<length>\n")
6630 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
6633 ALIAS (show_bgp_view_prefix
,
6634 show_bgp_view_ipv6_prefix_cmd
,
6635 "show bgp view WORD ipv6 X:X::X:X/M",
6641 "IPv6 prefix <network>/<length>\n")
6644 DEFUN (show_ipv6_mbgp
,
6651 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
6656 DEFUN (show_ipv6_mbgp_route
,
6657 show_ipv6_mbgp_route_cmd
,
6658 "show ipv6 mbgp X:X::X:X",
6662 "Network in the MBGP routing table to display\n")
6664 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0);
6668 DEFUN (show_ipv6_mbgp_prefix
,
6669 show_ipv6_mbgp_prefix_cmd
,
6670 "show ipv6 mbgp X:X::X:X/M",
6674 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
6676 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1);
6682 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
6683 safi_t safi
, enum bgp_show_type type
)
6693 b
= buffer_new (1024);
6694 for (i
= 0; i
< argc
; i
++)
6697 buffer_putc (b
, ' ');
6700 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
6705 buffer_putstr (b
, argv
[i
]);
6707 buffer_putc (b
, '\0');
6709 regstr
= buffer_getstr (b
);
6712 regex
= bgp_regcomp (regstr
);
6713 XFREE(MTYPE_TMP
, regstr
);
6716 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
6721 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
);
6722 bgp_regex_free (regex
);
6726 DEFUN (show_ip_bgp_regexp
,
6727 show_ip_bgp_regexp_cmd
,
6728 "show ip bgp regexp .LINE",
6732 "Display routes matching the AS path regular expression\n"
6733 "A regular-expression to match the BGP AS paths\n")
6735 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6736 bgp_show_type_regexp
);
6739 DEFUN (show_ip_bgp_flap_regexp
,
6740 show_ip_bgp_flap_regexp_cmd
,
6741 "show ip bgp flap-statistics regexp .LINE",
6745 "Display flap statistics of routes\n"
6746 "Display routes matching the AS path regular expression\n"
6747 "A regular-expression to match the BGP AS paths\n")
6749 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6750 bgp_show_type_flap_regexp
);
6753 DEFUN (show_ip_bgp_ipv4_regexp
,
6754 show_ip_bgp_ipv4_regexp_cmd
,
6755 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
6760 "Address Family modifier\n"
6761 "Address Family modifier\n"
6762 "Display routes matching the AS path regular expression\n"
6763 "A regular-expression to match the BGP AS paths\n")
6765 if (strncmp (argv
[0], "m", 1) == 0)
6766 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
6767 bgp_show_type_regexp
);
6769 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
6770 bgp_show_type_regexp
);
6774 DEFUN (show_bgp_regexp
,
6775 show_bgp_regexp_cmd
,
6776 "show bgp regexp .LINE",
6779 "Display routes matching the AS path regular expression\n"
6780 "A regular-expression to match the BGP AS paths\n")
6782 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
6783 bgp_show_type_regexp
);
6786 ALIAS (show_bgp_regexp
,
6787 show_bgp_ipv6_regexp_cmd
,
6788 "show bgp ipv6 regexp .LINE",
6792 "Display routes matching the AS path regular expression\n"
6793 "A regular-expression to match the BGP AS paths\n")
6796 DEFUN (show_ipv6_bgp_regexp
,
6797 show_ipv6_bgp_regexp_cmd
,
6798 "show ipv6 bgp regexp .LINE",
6802 "Display routes matching the AS path regular expression\n"
6803 "A regular-expression to match the BGP AS paths\n")
6805 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
6806 bgp_show_type_regexp
);
6810 DEFUN (show_ipv6_mbgp_regexp
,
6811 show_ipv6_mbgp_regexp_cmd
,
6812 "show ipv6 mbgp regexp .LINE",
6816 "Display routes matching the AS path regular expression\n"
6817 "A regular-expression to match the MBGP AS paths\n")
6819 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
6820 bgp_show_type_regexp
);
6822 #endif /* HAVE_IPV6 */
6825 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
6826 safi_t safi
, enum bgp_show_type type
)
6828 struct prefix_list
*plist
;
6830 plist
= prefix_list_lookup (afi
, prefix_list_str
);
6833 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
6834 prefix_list_str
, VTY_NEWLINE
);
6838 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
);
6841 DEFUN (show_ip_bgp_prefix_list
,
6842 show_ip_bgp_prefix_list_cmd
,
6843 "show ip bgp prefix-list WORD",
6847 "Display routes conforming to the prefix-list\n"
6848 "IP prefix-list name\n")
6850 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6851 bgp_show_type_prefix_list
);
6854 DEFUN (show_ip_bgp_flap_prefix_list
,
6855 show_ip_bgp_flap_prefix_list_cmd
,
6856 "show ip bgp flap-statistics prefix-list WORD",
6860 "Display flap statistics of routes\n"
6861 "Display routes conforming to the prefix-list\n"
6862 "IP prefix-list name\n")
6864 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6865 bgp_show_type_flap_prefix_list
);
6868 DEFUN (show_ip_bgp_ipv4_prefix_list
,
6869 show_ip_bgp_ipv4_prefix_list_cmd
,
6870 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
6875 "Address Family modifier\n"
6876 "Address Family modifier\n"
6877 "Display routes conforming to the prefix-list\n"
6878 "IP prefix-list name\n")
6880 if (strncmp (argv
[0], "m", 1) == 0)
6881 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
6882 bgp_show_type_prefix_list
);
6884 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
6885 bgp_show_type_prefix_list
);
6889 DEFUN (show_bgp_prefix_list
,
6890 show_bgp_prefix_list_cmd
,
6891 "show bgp prefix-list WORD",
6894 "Display routes conforming to the prefix-list\n"
6895 "IPv6 prefix-list name\n")
6897 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6898 bgp_show_type_prefix_list
);
6901 ALIAS (show_bgp_prefix_list
,
6902 show_bgp_ipv6_prefix_list_cmd
,
6903 "show bgp ipv6 prefix-list WORD",
6907 "Display routes conforming to the prefix-list\n"
6908 "IPv6 prefix-list name\n")
6911 DEFUN (show_ipv6_bgp_prefix_list
,
6912 show_ipv6_bgp_prefix_list_cmd
,
6913 "show ipv6 bgp prefix-list WORD",
6917 "Display routes matching the prefix-list\n"
6918 "IPv6 prefix-list name\n")
6920 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
6921 bgp_show_type_prefix_list
);
6925 DEFUN (show_ipv6_mbgp_prefix_list
,
6926 show_ipv6_mbgp_prefix_list_cmd
,
6927 "show ipv6 mbgp prefix-list WORD",
6931 "Display routes matching the prefix-list\n"
6932 "IPv6 prefix-list name\n")
6934 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
6935 bgp_show_type_prefix_list
);
6937 #endif /* HAVE_IPV6 */
6940 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
6941 safi_t safi
, enum bgp_show_type type
)
6943 struct as_list
*as_list
;
6945 as_list
= as_list_lookup (filter
);
6946 if (as_list
== NULL
)
6948 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
6952 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
);
6955 DEFUN (show_ip_bgp_filter_list
,
6956 show_ip_bgp_filter_list_cmd
,
6957 "show ip bgp filter-list WORD",
6961 "Display routes conforming to the filter-list\n"
6962 "Regular expression access list name\n")
6964 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6965 bgp_show_type_filter_list
);
6968 DEFUN (show_ip_bgp_flap_filter_list
,
6969 show_ip_bgp_flap_filter_list_cmd
,
6970 "show ip bgp flap-statistics filter-list WORD",
6974 "Display flap statistics of routes\n"
6975 "Display routes conforming to the filter-list\n"
6976 "Regular expression access list name\n")
6978 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
6979 bgp_show_type_flap_filter_list
);
6982 DEFUN (show_ip_bgp_ipv4_filter_list
,
6983 show_ip_bgp_ipv4_filter_list_cmd
,
6984 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
6989 "Address Family modifier\n"
6990 "Address Family modifier\n"
6991 "Display routes conforming to the filter-list\n"
6992 "Regular expression access list name\n")
6994 if (strncmp (argv
[0], "m", 1) == 0)
6995 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
6996 bgp_show_type_filter_list
);
6998 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
6999 bgp_show_type_filter_list
);
7003 DEFUN (show_bgp_filter_list
,
7004 show_bgp_filter_list_cmd
,
7005 "show bgp filter-list WORD",
7008 "Display routes conforming to the filter-list\n"
7009 "Regular expression access list name\n")
7011 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7012 bgp_show_type_filter_list
);
7015 ALIAS (show_bgp_filter_list
,
7016 show_bgp_ipv6_filter_list_cmd
,
7017 "show bgp ipv6 filter-list WORD",
7021 "Display routes conforming to the filter-list\n"
7022 "Regular expression access list name\n")
7025 DEFUN (show_ipv6_bgp_filter_list
,
7026 show_ipv6_bgp_filter_list_cmd
,
7027 "show ipv6 bgp filter-list WORD",
7031 "Display routes conforming to the filter-list\n"
7032 "Regular expression access list name\n")
7034 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7035 bgp_show_type_filter_list
);
7039 DEFUN (show_ipv6_mbgp_filter_list
,
7040 show_ipv6_mbgp_filter_list_cmd
,
7041 "show ipv6 mbgp filter-list WORD",
7045 "Display routes conforming to the filter-list\n"
7046 "Regular expression access list name\n")
7048 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
7049 bgp_show_type_filter_list
);
7051 #endif /* HAVE_IPV6 */
7054 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
7055 safi_t safi
, enum bgp_show_type type
)
7057 struct route_map
*rmap
;
7059 rmap
= route_map_lookup_by_name (rmap_str
);
7062 vty_out (vty
, "%% %s is not a valid route-map name%s",
7063 rmap_str
, VTY_NEWLINE
);
7067 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
);
7070 DEFUN (show_ip_bgp_route_map
,
7071 show_ip_bgp_route_map_cmd
,
7072 "show ip bgp route-map WORD",
7076 "Display routes matching the route-map\n"
7077 "A route-map to match on\n")
7079 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7080 bgp_show_type_route_map
);
7083 DEFUN (show_ip_bgp_flap_route_map
,
7084 show_ip_bgp_flap_route_map_cmd
,
7085 "show ip bgp flap-statistics route-map WORD",
7089 "Display flap statistics of routes\n"
7090 "Display routes matching the route-map\n"
7091 "A route-map to match on\n")
7093 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
7094 bgp_show_type_flap_route_map
);
7097 DEFUN (show_ip_bgp_ipv4_route_map
,
7098 show_ip_bgp_ipv4_route_map_cmd
,
7099 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
7104 "Address Family modifier\n"
7105 "Address Family modifier\n"
7106 "Display routes matching the route-map\n"
7107 "A route-map to match on\n")
7109 if (strncmp (argv
[0], "m", 1) == 0)
7110 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
7111 bgp_show_type_route_map
);
7113 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
7114 bgp_show_type_route_map
);
7117 DEFUN (show_bgp_route_map
,
7118 show_bgp_route_map_cmd
,
7119 "show bgp route-map WORD",
7122 "Display routes matching the route-map\n"
7123 "A route-map to match on\n")
7125 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
7126 bgp_show_type_route_map
);
7129 ALIAS (show_bgp_route_map
,
7130 show_bgp_ipv6_route_map_cmd
,
7131 "show bgp ipv6 route-map WORD",
7135 "Display routes matching the route-map\n"
7136 "A route-map to match on\n")
7138 DEFUN (show_ip_bgp_cidr_only
,
7139 show_ip_bgp_cidr_only_cmd
,
7140 "show ip bgp cidr-only",
7144 "Display only routes with non-natural netmasks\n")
7146 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7147 bgp_show_type_cidr_only
, NULL
);
7150 DEFUN (show_ip_bgp_flap_cidr_only
,
7151 show_ip_bgp_flap_cidr_only_cmd
,
7152 "show ip bgp flap-statistics cidr-only",
7156 "Display flap statistics of routes\n"
7157 "Display only routes with non-natural netmasks\n")
7159 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7160 bgp_show_type_flap_cidr_only
, NULL
);
7163 DEFUN (show_ip_bgp_ipv4_cidr_only
,
7164 show_ip_bgp_ipv4_cidr_only_cmd
,
7165 "show ip bgp ipv4 (unicast|multicast) cidr-only",
7170 "Address Family modifier\n"
7171 "Address Family modifier\n"
7172 "Display only routes with non-natural netmasks\n")
7174 if (strncmp (argv
[0], "m", 1) == 0)
7175 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7176 bgp_show_type_cidr_only
, NULL
);
7178 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7179 bgp_show_type_cidr_only
, NULL
);
7182 DEFUN (show_ip_bgp_community_all
,
7183 show_ip_bgp_community_all_cmd
,
7184 "show ip bgp community",
7188 "Display routes matching the communities\n")
7190 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7191 bgp_show_type_community_all
, NULL
);
7194 DEFUN (show_ip_bgp_ipv4_community_all
,
7195 show_ip_bgp_ipv4_community_all_cmd
,
7196 "show ip bgp ipv4 (unicast|multicast) community",
7201 "Address Family modifier\n"
7202 "Address Family modifier\n"
7203 "Display routes matching the communities\n")
7205 if (strncmp (argv
[0], "m", 1) == 0)
7206 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
7207 bgp_show_type_community_all
, NULL
);
7209 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
7210 bgp_show_type_community_all
, NULL
);
7214 DEFUN (show_bgp_community_all
,
7215 show_bgp_community_all_cmd
,
7216 "show bgp community",
7219 "Display routes matching the communities\n")
7221 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7222 bgp_show_type_community_all
, NULL
);
7225 ALIAS (show_bgp_community_all
,
7226 show_bgp_ipv6_community_all_cmd
,
7227 "show bgp ipv6 community",
7231 "Display routes matching the communities\n")
7234 DEFUN (show_ipv6_bgp_community_all
,
7235 show_ipv6_bgp_community_all_cmd
,
7236 "show ipv6 bgp community",
7240 "Display routes matching the communities\n")
7242 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
7243 bgp_show_type_community_all
, NULL
);
7247 DEFUN (show_ipv6_mbgp_community_all
,
7248 show_ipv6_mbgp_community_all_cmd
,
7249 "show ipv6 mbgp community",
7253 "Display routes matching the communities\n")
7255 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
7256 bgp_show_type_community_all
, NULL
);
7258 #endif /* HAVE_IPV6 */
7261 bgp_show_community (struct vty
*vty
, int argc
, const char **argv
, int exact
,
7262 u_int16_t afi
, u_char safi
)
7264 struct community
*com
;
7270 b
= buffer_new (1024);
7271 for (i
= 0; i
< argc
; i
++)
7274 buffer_putc (b
, ' ');
7277 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
7282 buffer_putstr (b
, argv
[i
]);
7284 buffer_putc (b
, '\0');
7286 str
= buffer_getstr (b
);
7289 com
= community_str2com (str
);
7290 XFREE (MTYPE_TMP
, str
);
7293 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
7297 return bgp_show (vty
, NULL
, afi
, safi
,
7298 (exact
? bgp_show_type_community_exact
:
7299 bgp_show_type_community
), com
);
7302 DEFUN (show_ip_bgp_community
,
7303 show_ip_bgp_community_cmd
,
7304 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
7308 "Display routes matching the communities\n"
7309 "community number\n"
7310 "Do not send outside local AS (well-known community)\n"
7311 "Do not advertise to any peer (well-known community)\n"
7312 "Do not export to next AS (well-known community)\n")
7314 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7317 ALIAS (show_ip_bgp_community
,
7318 show_ip_bgp_community2_cmd
,
7319 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7323 "Display routes matching the communities\n"
7324 "community number\n"
7325 "Do not send outside local AS (well-known community)\n"
7326 "Do not advertise to any peer (well-known community)\n"
7327 "Do not export to next AS (well-known community)\n"
7328 "community number\n"
7329 "Do not send outside local AS (well-known community)\n"
7330 "Do not advertise to any peer (well-known community)\n"
7331 "Do not export to next AS (well-known community)\n")
7333 ALIAS (show_ip_bgp_community
,
7334 show_ip_bgp_community3_cmd
,
7335 "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)",
7339 "Display routes matching the communities\n"
7340 "community number\n"
7341 "Do not send outside local AS (well-known community)\n"
7342 "Do not advertise to any peer (well-known community)\n"
7343 "Do not export to next AS (well-known community)\n"
7344 "community number\n"
7345 "Do not send outside local AS (well-known community)\n"
7346 "Do not advertise to any peer (well-known community)\n"
7347 "Do not export to next AS (well-known community)\n"
7348 "community number\n"
7349 "Do not send outside local AS (well-known community)\n"
7350 "Do not advertise to any peer (well-known community)\n"
7351 "Do not export to next AS (well-known community)\n")
7353 ALIAS (show_ip_bgp_community
,
7354 show_ip_bgp_community4_cmd
,
7355 "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)",
7359 "Display routes matching the communities\n"
7360 "community number\n"
7361 "Do not send outside local AS (well-known community)\n"
7362 "Do not advertise to any peer (well-known community)\n"
7363 "Do not export to next AS (well-known community)\n"
7364 "community number\n"
7365 "Do not send outside local AS (well-known community)\n"
7366 "Do not advertise to any peer (well-known community)\n"
7367 "Do not export to next AS (well-known community)\n"
7368 "community number\n"
7369 "Do not send outside local AS (well-known community)\n"
7370 "Do not advertise to any peer (well-known community)\n"
7371 "Do not export to next AS (well-known community)\n"
7372 "community number\n"
7373 "Do not send outside local AS (well-known community)\n"
7374 "Do not advertise to any peer (well-known community)\n"
7375 "Do not export to next AS (well-known community)\n")
7377 DEFUN (show_ip_bgp_ipv4_community
,
7378 show_ip_bgp_ipv4_community_cmd
,
7379 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
7384 "Address Family modifier\n"
7385 "Address Family modifier\n"
7386 "Display routes matching the communities\n"
7387 "community number\n"
7388 "Do not send outside local AS (well-known community)\n"
7389 "Do not advertise to any peer (well-known community)\n"
7390 "Do not export to next AS (well-known community)\n")
7392 if (strncmp (argv
[0], "m", 1) == 0)
7393 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
7395 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
7398 ALIAS (show_ip_bgp_ipv4_community
,
7399 show_ip_bgp_ipv4_community2_cmd
,
7400 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7405 "Address Family modifier\n"
7406 "Address Family modifier\n"
7407 "Display routes matching the communities\n"
7408 "community number\n"
7409 "Do not send outside local AS (well-known community)\n"
7410 "Do not advertise to any peer (well-known community)\n"
7411 "Do not export to next AS (well-known community)\n"
7412 "community number\n"
7413 "Do not send outside local AS (well-known community)\n"
7414 "Do not advertise to any peer (well-known community)\n"
7415 "Do not export to next AS (well-known community)\n")
7417 ALIAS (show_ip_bgp_ipv4_community
,
7418 show_ip_bgp_ipv4_community3_cmd
,
7419 "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)",
7424 "Address Family modifier\n"
7425 "Address Family modifier\n"
7426 "Display routes matching the communities\n"
7427 "community number\n"
7428 "Do not send outside local AS (well-known community)\n"
7429 "Do not advertise to any peer (well-known community)\n"
7430 "Do not export to next AS (well-known community)\n"
7431 "community number\n"
7432 "Do not send outside local AS (well-known community)\n"
7433 "Do not advertise to any peer (well-known community)\n"
7434 "Do not export to next AS (well-known community)\n"
7435 "community number\n"
7436 "Do not send outside local AS (well-known community)\n"
7437 "Do not advertise to any peer (well-known community)\n"
7438 "Do not export to next AS (well-known community)\n")
7440 ALIAS (show_ip_bgp_ipv4_community
,
7441 show_ip_bgp_ipv4_community4_cmd
,
7442 "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)",
7447 "Address Family modifier\n"
7448 "Address Family modifier\n"
7449 "Display routes matching the communities\n"
7450 "community number\n"
7451 "Do not send outside local AS (well-known community)\n"
7452 "Do not advertise to any peer (well-known community)\n"
7453 "Do not export to next AS (well-known community)\n"
7454 "community number\n"
7455 "Do not send outside local AS (well-known community)\n"
7456 "Do not advertise to any peer (well-known community)\n"
7457 "Do not export to next AS (well-known community)\n"
7458 "community number\n"
7459 "Do not send outside local AS (well-known community)\n"
7460 "Do not advertise to any peer (well-known community)\n"
7461 "Do not export to next AS (well-known community)\n"
7462 "community number\n"
7463 "Do not send outside local AS (well-known community)\n"
7464 "Do not advertise to any peer (well-known community)\n"
7465 "Do not export to next AS (well-known community)\n")
7467 DEFUN (show_ip_bgp_community_exact
,
7468 show_ip_bgp_community_exact_cmd
,
7469 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7473 "Display routes matching the communities\n"
7474 "community number\n"
7475 "Do not send outside local AS (well-known community)\n"
7476 "Do not advertise to any peer (well-known community)\n"
7477 "Do not export to next AS (well-known community)\n"
7478 "Exact match of the communities")
7480 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7483 ALIAS (show_ip_bgp_community_exact
,
7484 show_ip_bgp_community2_exact_cmd
,
7485 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7489 "Display routes matching the communities\n"
7490 "community number\n"
7491 "Do not send outside local AS (well-known community)\n"
7492 "Do not advertise to any peer (well-known community)\n"
7493 "Do not export to next AS (well-known community)\n"
7494 "community number\n"
7495 "Do not send outside local AS (well-known community)\n"
7496 "Do not advertise to any peer (well-known community)\n"
7497 "Do not export to next AS (well-known community)\n"
7498 "Exact match of the communities")
7500 ALIAS (show_ip_bgp_community_exact
,
7501 show_ip_bgp_community3_exact_cmd
,
7502 "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",
7506 "Display routes matching the communities\n"
7507 "community number\n"
7508 "Do not send outside local AS (well-known community)\n"
7509 "Do not advertise to any peer (well-known community)\n"
7510 "Do not export to next AS (well-known community)\n"
7511 "community number\n"
7512 "Do not send outside local AS (well-known community)\n"
7513 "Do not advertise to any peer (well-known community)\n"
7514 "Do not export to next AS (well-known community)\n"
7515 "community number\n"
7516 "Do not send outside local AS (well-known community)\n"
7517 "Do not advertise to any peer (well-known community)\n"
7518 "Do not export to next AS (well-known community)\n"
7519 "Exact match of the communities")
7521 ALIAS (show_ip_bgp_community_exact
,
7522 show_ip_bgp_community4_exact_cmd
,
7523 "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",
7527 "Display routes matching the communities\n"
7528 "community number\n"
7529 "Do not send outside local AS (well-known community)\n"
7530 "Do not advertise to any peer (well-known community)\n"
7531 "Do not export to next AS (well-known community)\n"
7532 "community number\n"
7533 "Do not send outside local AS (well-known community)\n"
7534 "Do not advertise to any peer (well-known community)\n"
7535 "Do not export to next AS (well-known community)\n"
7536 "community number\n"
7537 "Do not send outside local AS (well-known community)\n"
7538 "Do not advertise to any peer (well-known community)\n"
7539 "Do not export to next AS (well-known community)\n"
7540 "community number\n"
7541 "Do not send outside local AS (well-known community)\n"
7542 "Do not advertise to any peer (well-known community)\n"
7543 "Do not export to next AS (well-known community)\n"
7544 "Exact match of the communities")
7546 DEFUN (show_ip_bgp_ipv4_community_exact
,
7547 show_ip_bgp_ipv4_community_exact_cmd
,
7548 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7553 "Address Family modifier\n"
7554 "Address Family modifier\n"
7555 "Display routes matching the communities\n"
7556 "community number\n"
7557 "Do not send outside local AS (well-known community)\n"
7558 "Do not advertise to any peer (well-known community)\n"
7559 "Do not export to next AS (well-known community)\n"
7560 "Exact match of the communities")
7562 if (strncmp (argv
[0], "m", 1) == 0)
7563 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
7565 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
7568 ALIAS (show_ip_bgp_ipv4_community_exact
,
7569 show_ip_bgp_ipv4_community2_exact_cmd
,
7570 "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",
7575 "Address Family modifier\n"
7576 "Address Family modifier\n"
7577 "Display routes matching the communities\n"
7578 "community number\n"
7579 "Do not send outside local AS (well-known community)\n"
7580 "Do not advertise to any peer (well-known community)\n"
7581 "Do not export to next AS (well-known community)\n"
7582 "community number\n"
7583 "Do not send outside local AS (well-known community)\n"
7584 "Do not advertise to any peer (well-known community)\n"
7585 "Do not export to next AS (well-known community)\n"
7586 "Exact match of the communities")
7588 ALIAS (show_ip_bgp_ipv4_community_exact
,
7589 show_ip_bgp_ipv4_community3_exact_cmd
,
7590 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7595 "Address Family modifier\n"
7596 "Address Family modifier\n"
7597 "Display routes matching the communities\n"
7598 "community number\n"
7599 "Do not send outside local AS (well-known community)\n"
7600 "Do not advertise to any peer (well-known community)\n"
7601 "Do not export to next AS (well-known community)\n"
7602 "community number\n"
7603 "Do not send outside local AS (well-known community)\n"
7604 "Do not advertise to any peer (well-known community)\n"
7605 "Do not export to next AS (well-known community)\n"
7606 "community number\n"
7607 "Do not send outside local AS (well-known community)\n"
7608 "Do not advertise to any peer (well-known community)\n"
7609 "Do not export to next AS (well-known community)\n"
7610 "Exact match of the communities")
7612 ALIAS (show_ip_bgp_ipv4_community_exact
,
7613 show_ip_bgp_ipv4_community4_exact_cmd
,
7614 "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",
7619 "Address Family modifier\n"
7620 "Address Family modifier\n"
7621 "Display routes matching the communities\n"
7622 "community number\n"
7623 "Do not send outside local AS (well-known community)\n"
7624 "Do not advertise to any peer (well-known community)\n"
7625 "Do not export to next AS (well-known community)\n"
7626 "community number\n"
7627 "Do not send outside local AS (well-known community)\n"
7628 "Do not advertise to any peer (well-known community)\n"
7629 "Do not export to next AS (well-known community)\n"
7630 "community number\n"
7631 "Do not send outside local AS (well-known community)\n"
7632 "Do not advertise to any peer (well-known community)\n"
7633 "Do not export to next AS (well-known community)\n"
7634 "community number\n"
7635 "Do not send outside local AS (well-known community)\n"
7636 "Do not advertise to any peer (well-known community)\n"
7637 "Do not export to next AS (well-known community)\n"
7638 "Exact match of the communities")
7641 DEFUN (show_bgp_community
,
7642 show_bgp_community_cmd
,
7643 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
7646 "Display routes matching the communities\n"
7647 "community number\n"
7648 "Do not send outside local AS (well-known community)\n"
7649 "Do not advertise to any peer (well-known community)\n"
7650 "Do not export to next AS (well-known community)\n")
7652 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7655 ALIAS (show_bgp_community
,
7656 show_bgp_ipv6_community_cmd
,
7657 "show bgp ipv6 community (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")
7667 ALIAS (show_bgp_community
,
7668 show_bgp_community2_cmd
,
7669 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7672 "Display routes matching the communities\n"
7673 "community number\n"
7674 "Do not send outside local AS (well-known community)\n"
7675 "Do not advertise to any peer (well-known community)\n"
7676 "Do not export to next AS (well-known community)\n"
7677 "community number\n"
7678 "Do not send outside local AS (well-known community)\n"
7679 "Do not advertise to any peer (well-known community)\n"
7680 "Do not export to next AS (well-known community)\n")
7682 ALIAS (show_bgp_community
,
7683 show_bgp_ipv6_community2_cmd
,
7684 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7688 "Display routes matching the communities\n"
7689 "community number\n"
7690 "Do not send outside local AS (well-known community)\n"
7691 "Do not advertise to any peer (well-known community)\n"
7692 "Do not export to next AS (well-known community)\n"
7693 "community number\n"
7694 "Do not send outside local AS (well-known community)\n"
7695 "Do not advertise to any peer (well-known community)\n"
7696 "Do not export to next AS (well-known community)\n")
7698 ALIAS (show_bgp_community
,
7699 show_bgp_community3_cmd
,
7700 "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)",
7703 "Display routes matching the communities\n"
7704 "community number\n"
7705 "Do not send outside local AS (well-known community)\n"
7706 "Do not advertise to any peer (well-known community)\n"
7707 "Do not export to next AS (well-known community)\n"
7708 "community number\n"
7709 "Do not send outside local AS (well-known community)\n"
7710 "Do not advertise to any peer (well-known community)\n"
7711 "Do not export to next AS (well-known community)\n"
7712 "community number\n"
7713 "Do not send outside local AS (well-known community)\n"
7714 "Do not advertise to any peer (well-known community)\n"
7715 "Do not export to next AS (well-known community)\n")
7717 ALIAS (show_bgp_community
,
7718 show_bgp_ipv6_community3_cmd
,
7719 "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)",
7723 "Display routes matching the communities\n"
7724 "community number\n"
7725 "Do not send outside local AS (well-known community)\n"
7726 "Do not advertise to any peer (well-known community)\n"
7727 "Do not export to next AS (well-known community)\n"
7728 "community number\n"
7729 "Do not send outside local AS (well-known community)\n"
7730 "Do not advertise to any peer (well-known community)\n"
7731 "Do not export to next AS (well-known community)\n"
7732 "community number\n"
7733 "Do not send outside local AS (well-known community)\n"
7734 "Do not advertise to any peer (well-known community)\n"
7735 "Do not export to next AS (well-known community)\n")
7737 ALIAS (show_bgp_community
,
7738 show_bgp_community4_cmd
,
7739 "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)",
7742 "Display routes matching the communities\n"
7743 "community number\n"
7744 "Do not send outside local AS (well-known community)\n"
7745 "Do not advertise to any peer (well-known community)\n"
7746 "Do not export to next AS (well-known community)\n"
7747 "community number\n"
7748 "Do not send outside local AS (well-known community)\n"
7749 "Do not advertise to any peer (well-known community)\n"
7750 "Do not export to next AS (well-known community)\n"
7751 "community number\n"
7752 "Do not send outside local AS (well-known community)\n"
7753 "Do not advertise to any peer (well-known community)\n"
7754 "Do not export to next AS (well-known community)\n"
7755 "community number\n"
7756 "Do not send outside local AS (well-known community)\n"
7757 "Do not advertise to any peer (well-known community)\n"
7758 "Do not export to next AS (well-known community)\n")
7760 ALIAS (show_bgp_community
,
7761 show_bgp_ipv6_community4_cmd
,
7762 "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)",
7766 "Display routes matching the communities\n"
7767 "community number\n"
7768 "Do not send outside local AS (well-known community)\n"
7769 "Do not advertise to any peer (well-known community)\n"
7770 "Do not export to next AS (well-known community)\n"
7771 "community number\n"
7772 "Do not send outside local AS (well-known community)\n"
7773 "Do not advertise to any peer (well-known community)\n"
7774 "Do not export to next AS (well-known community)\n"
7775 "community number\n"
7776 "Do not send outside local AS (well-known community)\n"
7777 "Do not advertise to any peer (well-known community)\n"
7778 "Do not export to next AS (well-known community)\n"
7779 "community number\n"
7780 "Do not send outside local AS (well-known community)\n"
7781 "Do not advertise to any peer (well-known community)\n"
7782 "Do not export to next AS (well-known community)\n")
7785 DEFUN (show_ipv6_bgp_community
,
7786 show_ipv6_bgp_community_cmd
,
7787 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
7791 "Display routes matching the communities\n"
7792 "community number\n"
7793 "Do not send outside local AS (well-known community)\n"
7794 "Do not advertise to any peer (well-known community)\n"
7795 "Do not export to next AS (well-known community)\n")
7797 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
7801 ALIAS (show_ipv6_bgp_community
,
7802 show_ipv6_bgp_community2_cmd
,
7803 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
7807 "Display routes matching the communities\n"
7808 "community number\n"
7809 "Do not send outside local AS (well-known community)\n"
7810 "Do not advertise to any peer (well-known community)\n"
7811 "Do not export to next AS (well-known community)\n"
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")
7818 ALIAS (show_ipv6_bgp_community
,
7819 show_ipv6_bgp_community3_cmd
,
7820 "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)",
7824 "Display routes matching the communities\n"
7825 "community number\n"
7826 "Do not send outside local AS (well-known community)\n"
7827 "Do not advertise to any peer (well-known community)\n"
7828 "Do not export to next AS (well-known community)\n"
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")
7839 ALIAS (show_ipv6_bgp_community
,
7840 show_ipv6_bgp_community4_cmd
,
7841 "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)",
7845 "Display routes matching the communities\n"
7846 "community number\n"
7847 "Do not send outside local AS (well-known community)\n"
7848 "Do not advertise to any peer (well-known community)\n"
7849 "Do not export to next AS (well-known community)\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")
7863 DEFUN (show_bgp_community_exact
,
7864 show_bgp_community_exact_cmd
,
7865 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7868 "Display routes matching the communities\n"
7869 "community number\n"
7870 "Do not send outside local AS (well-known community)\n"
7871 "Do not advertise to any peer (well-known community)\n"
7872 "Do not export to next AS (well-known community)\n"
7873 "Exact match of the communities")
7875 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
7878 ALIAS (show_bgp_community_exact
,
7879 show_bgp_ipv6_community_exact_cmd
,
7880 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
7884 "Display routes matching the communities\n"
7885 "community number\n"
7886 "Do not send outside local AS (well-known community)\n"
7887 "Do not advertise to any peer (well-known community)\n"
7888 "Do not export to next AS (well-known community)\n"
7889 "Exact match of the communities")
7891 ALIAS (show_bgp_community_exact
,
7892 show_bgp_community2_exact_cmd
,
7893 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7896 "Display routes matching the communities\n"
7897 "community number\n"
7898 "Do not send outside local AS (well-known community)\n"
7899 "Do not advertise to any peer (well-known community)\n"
7900 "Do not export to next AS (well-known community)\n"
7901 "community number\n"
7902 "Do not send outside local AS (well-known community)\n"
7903 "Do not advertise to any peer (well-known community)\n"
7904 "Do not export to next AS (well-known community)\n"
7905 "Exact match of the communities")
7907 ALIAS (show_bgp_community_exact
,
7908 show_bgp_ipv6_community2_exact_cmd
,
7909 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
7913 "Display routes matching the communities\n"
7914 "community number\n"
7915 "Do not send outside local AS (well-known community)\n"
7916 "Do not advertise to any peer (well-known community)\n"
7917 "Do not export to next AS (well-known community)\n"
7918 "community number\n"
7919 "Do not send outside local AS (well-known community)\n"
7920 "Do not advertise to any peer (well-known community)\n"
7921 "Do not export to next AS (well-known community)\n"
7922 "Exact match of the communities")
7924 ALIAS (show_bgp_community_exact
,
7925 show_bgp_community3_exact_cmd
,
7926 "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",
7929 "Display routes matching the communities\n"
7930 "community number\n"
7931 "Do not send outside local AS (well-known community)\n"
7932 "Do not advertise to any peer (well-known community)\n"
7933 "Do not export to next AS (well-known community)\n"
7934 "community number\n"
7935 "Do not send outside local AS (well-known community)\n"
7936 "Do not advertise to any peer (well-known community)\n"
7937 "Do not export to next AS (well-known community)\n"
7938 "community number\n"
7939 "Do not send outside local AS (well-known community)\n"
7940 "Do not advertise to any peer (well-known community)\n"
7941 "Do not export to next AS (well-known community)\n"
7942 "Exact match of the communities")
7944 ALIAS (show_bgp_community_exact
,
7945 show_bgp_ipv6_community3_exact_cmd
,
7946 "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",
7950 "Display routes matching the communities\n"
7951 "community number\n"
7952 "Do not send outside local AS (well-known community)\n"
7953 "Do not advertise to any peer (well-known community)\n"
7954 "Do not export to next AS (well-known community)\n"
7955 "community number\n"
7956 "Do not send outside local AS (well-known community)\n"
7957 "Do not advertise to any peer (well-known community)\n"
7958 "Do not export to next AS (well-known community)\n"
7959 "community number\n"
7960 "Do not send outside local AS (well-known community)\n"
7961 "Do not advertise to any peer (well-known community)\n"
7962 "Do not export to next AS (well-known community)\n"
7963 "Exact match of the communities")
7965 ALIAS (show_bgp_community_exact
,
7966 show_bgp_community4_exact_cmd
,
7967 "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",
7970 "Display routes matching the communities\n"
7971 "community number\n"
7972 "Do not send outside local AS (well-known community)\n"
7973 "Do not advertise to any peer (well-known community)\n"
7974 "Do not export to next AS (well-known community)\n"
7975 "community number\n"
7976 "Do not send outside local AS (well-known community)\n"
7977 "Do not advertise to any peer (well-known community)\n"
7978 "Do not export to next AS (well-known community)\n"
7979 "community number\n"
7980 "Do not send outside local AS (well-known community)\n"
7981 "Do not advertise to any peer (well-known community)\n"
7982 "Do not export to next AS (well-known community)\n"
7983 "community number\n"
7984 "Do not send outside local AS (well-known community)\n"
7985 "Do not advertise to any peer (well-known community)\n"
7986 "Do not export to next AS (well-known community)\n"
7987 "Exact match of the communities")
7989 ALIAS (show_bgp_community_exact
,
7990 show_bgp_ipv6_community4_exact_cmd
,
7991 "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",
7995 "Display routes matching the communities\n"
7996 "community number\n"
7997 "Do not send outside local AS (well-known community)\n"
7998 "Do not advertise to any peer (well-known community)\n"
7999 "Do not export to next AS (well-known community)\n"
8000 "community number\n"
8001 "Do not send outside local AS (well-known community)\n"
8002 "Do not advertise to any peer (well-known community)\n"
8003 "Do not export to next AS (well-known community)\n"
8004 "community number\n"
8005 "Do not send outside local AS (well-known community)\n"
8006 "Do not advertise to any peer (well-known community)\n"
8007 "Do not export to next AS (well-known community)\n"
8008 "community number\n"
8009 "Do not send outside local AS (well-known community)\n"
8010 "Do not advertise to any peer (well-known community)\n"
8011 "Do not export to next AS (well-known community)\n"
8012 "Exact match of the communities")
8015 DEFUN (show_ipv6_bgp_community_exact
,
8016 show_ipv6_bgp_community_exact_cmd
,
8017 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8021 "Display routes matching the communities\n"
8022 "community number\n"
8023 "Do not send outside local AS (well-known community)\n"
8024 "Do not advertise to any peer (well-known community)\n"
8025 "Do not export to next AS (well-known community)\n"
8026 "Exact match of the communities")
8028 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
8032 ALIAS (show_ipv6_bgp_community_exact
,
8033 show_ipv6_bgp_community2_exact_cmd
,
8034 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8038 "Display routes matching the communities\n"
8039 "community number\n"
8040 "Do not send outside local AS (well-known community)\n"
8041 "Do not advertise to any peer (well-known community)\n"
8042 "Do not export to next AS (well-known community)\n"
8043 "community number\n"
8044 "Do not send outside local AS (well-known community)\n"
8045 "Do not advertise to any peer (well-known community)\n"
8046 "Do not export to next AS (well-known community)\n"
8047 "Exact match of the communities")
8050 ALIAS (show_ipv6_bgp_community_exact
,
8051 show_ipv6_bgp_community3_exact_cmd
,
8052 "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",
8056 "Display routes matching the communities\n"
8057 "community number\n"
8058 "Do not send outside local AS (well-known community)\n"
8059 "Do not advertise to any peer (well-known community)\n"
8060 "Do not export to next AS (well-known community)\n"
8061 "community number\n"
8062 "Do not send outside local AS (well-known community)\n"
8063 "Do not advertise to any peer (well-known community)\n"
8064 "Do not export to next AS (well-known community)\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 "Exact match of the communities")
8072 ALIAS (show_ipv6_bgp_community_exact
,
8073 show_ipv6_bgp_community4_exact_cmd
,
8074 "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",
8078 "Display routes matching the communities\n"
8079 "community number\n"
8080 "Do not send outside local AS (well-known community)\n"
8081 "Do not advertise to any peer (well-known community)\n"
8082 "Do not export to next AS (well-known community)\n"
8083 "community number\n"
8084 "Do not send outside local AS (well-known community)\n"
8085 "Do not advertise to any peer (well-known community)\n"
8086 "Do not export to next AS (well-known community)\n"
8087 "community number\n"
8088 "Do not send outside local AS (well-known community)\n"
8089 "Do not advertise to any peer (well-known community)\n"
8090 "Do not export to next AS (well-known community)\n"
8091 "community number\n"
8092 "Do not send outside local AS (well-known community)\n"
8093 "Do not advertise to any peer (well-known community)\n"
8094 "Do not export to next AS (well-known community)\n"
8095 "Exact match of the communities")
8098 DEFUN (show_ipv6_mbgp_community
,
8099 show_ipv6_mbgp_community_cmd
,
8100 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
8104 "Display routes matching the communities\n"
8105 "community number\n"
8106 "Do not send outside local AS (well-known community)\n"
8107 "Do not advertise to any peer (well-known community)\n"
8108 "Do not export to next AS (well-known community)\n")
8110 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
8114 ALIAS (show_ipv6_mbgp_community
,
8115 show_ipv6_mbgp_community2_cmd
,
8116 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8120 "Display routes matching the communities\n"
8121 "community number\n"
8122 "Do not send outside local AS (well-known community)\n"
8123 "Do not advertise to any peer (well-known community)\n"
8124 "Do not export to next AS (well-known community)\n"
8125 "community number\n"
8126 "Do not send outside local AS (well-known community)\n"
8127 "Do not advertise to any peer (well-known community)\n"
8128 "Do not export to next AS (well-known community)\n")
8131 ALIAS (show_ipv6_mbgp_community
,
8132 show_ipv6_mbgp_community3_cmd
,
8133 "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)",
8137 "Display routes matching the communities\n"
8138 "community number\n"
8139 "Do not send outside local AS (well-known community)\n"
8140 "Do not advertise to any peer (well-known community)\n"
8141 "Do not export to next AS (well-known community)\n"
8142 "community number\n"
8143 "Do not send outside local AS (well-known community)\n"
8144 "Do not advertise to any peer (well-known community)\n"
8145 "Do not export to next AS (well-known community)\n"
8146 "community number\n"
8147 "Do not send outside local AS (well-known community)\n"
8148 "Do not advertise to any peer (well-known community)\n"
8149 "Do not export to next AS (well-known community)\n")
8152 ALIAS (show_ipv6_mbgp_community
,
8153 show_ipv6_mbgp_community4_cmd
,
8154 "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)",
8158 "Display routes matching the communities\n"
8159 "community number\n"
8160 "Do not send outside local AS (well-known community)\n"
8161 "Do not advertise to any peer (well-known community)\n"
8162 "Do not export to next AS (well-known community)\n"
8163 "community number\n"
8164 "Do not send outside local AS (well-known community)\n"
8165 "Do not advertise to any peer (well-known community)\n"
8166 "Do not export to next AS (well-known community)\n"
8167 "community number\n"
8168 "Do not send outside local AS (well-known community)\n"
8169 "Do not advertise to any peer (well-known community)\n"
8170 "Do not export to next AS (well-known community)\n"
8171 "community number\n"
8172 "Do not send outside local AS (well-known community)\n"
8173 "Do not advertise to any peer (well-known community)\n"
8174 "Do not export to next AS (well-known community)\n")
8177 DEFUN (show_ipv6_mbgp_community_exact
,
8178 show_ipv6_mbgp_community_exact_cmd
,
8179 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
8183 "Display routes matching the communities\n"
8184 "community number\n"
8185 "Do not send outside local AS (well-known community)\n"
8186 "Do not advertise to any peer (well-known community)\n"
8187 "Do not export to next AS (well-known community)\n"
8188 "Exact match of the communities")
8190 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
8194 ALIAS (show_ipv6_mbgp_community_exact
,
8195 show_ipv6_mbgp_community2_exact_cmd
,
8196 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
8200 "Display routes matching the communities\n"
8201 "community number\n"
8202 "Do not send outside local AS (well-known community)\n"
8203 "Do not advertise to any peer (well-known community)\n"
8204 "Do not export to next AS (well-known community)\n"
8205 "community number\n"
8206 "Do not send outside local AS (well-known community)\n"
8207 "Do not advertise to any peer (well-known community)\n"
8208 "Do not export to next AS (well-known community)\n"
8209 "Exact match of the communities")
8212 ALIAS (show_ipv6_mbgp_community_exact
,
8213 show_ipv6_mbgp_community3_exact_cmd
,
8214 "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",
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 "community number\n"
8228 "Do not send outside local AS (well-known community)\n"
8229 "Do not advertise to any peer (well-known community)\n"
8230 "Do not export to next AS (well-known community)\n"
8231 "Exact match of the communities")
8234 ALIAS (show_ipv6_mbgp_community_exact
,
8235 show_ipv6_mbgp_community4_exact_cmd
,
8236 "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",
8240 "Display routes matching the communities\n"
8241 "community number\n"
8242 "Do not send outside local AS (well-known community)\n"
8243 "Do not advertise to any peer (well-known community)\n"
8244 "Do not export to next AS (well-known community)\n"
8245 "community number\n"
8246 "Do not send outside local AS (well-known community)\n"
8247 "Do not advertise to any peer (well-known community)\n"
8248 "Do not export to next AS (well-known community)\n"
8249 "community number\n"
8250 "Do not send outside local AS (well-known community)\n"
8251 "Do not advertise to any peer (well-known community)\n"
8252 "Do not export to next AS (well-known community)\n"
8253 "community number\n"
8254 "Do not send outside local AS (well-known community)\n"
8255 "Do not advertise to any peer (well-known community)\n"
8256 "Do not export to next AS (well-known community)\n"
8257 "Exact match of the communities")
8258 #endif /* HAVE_IPV6 */
8261 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
8262 u_int16_t afi
, u_char safi
)
8264 struct community_list
*list
;
8266 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
8269 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
8274 return bgp_show (vty
, NULL
, afi
, safi
,
8275 (exact
? bgp_show_type_community_list_exact
:
8276 bgp_show_type_community_list
), list
);
8279 DEFUN (show_ip_bgp_community_list
,
8280 show_ip_bgp_community_list_cmd
,
8281 "show ip bgp community-list (<1-500>|WORD)",
8285 "Display routes matching the community-list\n"
8286 "community-list number\n"
8287 "community-list name\n")
8289 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
8292 DEFUN (show_ip_bgp_ipv4_community_list
,
8293 show_ip_bgp_ipv4_community_list_cmd
,
8294 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
8299 "Address Family modifier\n"
8300 "Address Family modifier\n"
8301 "Display routes matching the community-list\n"
8302 "community-list number\n"
8303 "community-list name\n")
8305 if (strncmp (argv
[0], "m", 1) == 0)
8306 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
8308 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
8311 DEFUN (show_ip_bgp_community_list_exact
,
8312 show_ip_bgp_community_list_exact_cmd
,
8313 "show ip bgp community-list (<1-500>|WORD) exact-match",
8317 "Display routes matching the community-list\n"
8318 "community-list number\n"
8319 "community-list name\n"
8320 "Exact match of the communities\n")
8322 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
8325 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
8326 show_ip_bgp_ipv4_community_list_exact_cmd
,
8327 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
8332 "Address Family modifier\n"
8333 "Address Family modifier\n"
8334 "Display routes matching the community-list\n"
8335 "community-list number\n"
8336 "community-list name\n"
8337 "Exact match of the communities\n")
8339 if (strncmp (argv
[0], "m", 1) == 0)
8340 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
8342 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
8346 DEFUN (show_bgp_community_list
,
8347 show_bgp_community_list_cmd
,
8348 "show bgp community-list (<1-500>|WORD)",
8351 "Display routes matching the community-list\n"
8352 "community-list number\n"
8353 "community-list name\n")
8355 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8358 ALIAS (show_bgp_community_list
,
8359 show_bgp_ipv6_community_list_cmd
,
8360 "show bgp ipv6 community-list (<1-500>|WORD)",
8364 "Display routes matching the community-list\n"
8365 "community-list number\n"
8366 "community-list name\n")
8369 DEFUN (show_ipv6_bgp_community_list
,
8370 show_ipv6_bgp_community_list_cmd
,
8371 "show ipv6 bgp community-list WORD",
8375 "Display routes matching the community-list\n"
8376 "community-list name\n")
8378 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
8382 DEFUN (show_ipv6_mbgp_community_list
,
8383 show_ipv6_mbgp_community_list_cmd
,
8384 "show ipv6 mbgp community-list WORD",
8388 "Display routes matching the community-list\n"
8389 "community-list name\n")
8391 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
8394 DEFUN (show_bgp_community_list_exact
,
8395 show_bgp_community_list_exact_cmd
,
8396 "show bgp community-list (<1-500>|WORD) exact-match",
8399 "Display routes matching the community-list\n"
8400 "community-list number\n"
8401 "community-list name\n"
8402 "Exact match of the communities\n")
8404 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8407 ALIAS (show_bgp_community_list_exact
,
8408 show_bgp_ipv6_community_list_exact_cmd
,
8409 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
8413 "Display routes matching the community-list\n"
8414 "community-list number\n"
8415 "community-list name\n"
8416 "Exact match of the communities\n")
8419 DEFUN (show_ipv6_bgp_community_list_exact
,
8420 show_ipv6_bgp_community_list_exact_cmd
,
8421 "show ipv6 bgp community-list WORD exact-match",
8425 "Display routes matching the community-list\n"
8426 "community-list name\n"
8427 "Exact match of the communities\n")
8429 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
8433 DEFUN (show_ipv6_mbgp_community_list_exact
,
8434 show_ipv6_mbgp_community_list_exact_cmd
,
8435 "show ipv6 mbgp community-list WORD exact-match",
8439 "Display routes matching the community-list\n"
8440 "community-list name\n"
8441 "Exact match of the communities\n")
8443 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
8445 #endif /* HAVE_IPV6 */
8448 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
8449 safi_t safi
, enum bgp_show_type type
)
8456 ret
= str2prefix (prefix
, p
);
8459 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
8463 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
);
8468 DEFUN (show_ip_bgp_prefix_longer
,
8469 show_ip_bgp_prefix_longer_cmd
,
8470 "show ip bgp A.B.C.D/M longer-prefixes",
8474 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8475 "Display route and more specific routes\n")
8477 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8478 bgp_show_type_prefix_longer
);
8481 DEFUN (show_ip_bgp_flap_prefix_longer
,
8482 show_ip_bgp_flap_prefix_longer_cmd
,
8483 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
8487 "Display flap statistics of routes\n"
8488 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8489 "Display route and more specific routes\n")
8491 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8492 bgp_show_type_flap_prefix_longer
);
8495 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
8496 show_ip_bgp_ipv4_prefix_longer_cmd
,
8497 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
8502 "Address Family modifier\n"
8503 "Address Family modifier\n"
8504 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8505 "Display route and more specific routes\n")
8507 if (strncmp (argv
[0], "m", 1) == 0)
8508 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8509 bgp_show_type_prefix_longer
);
8511 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8512 bgp_show_type_prefix_longer
);
8515 DEFUN (show_ip_bgp_flap_address
,
8516 show_ip_bgp_flap_address_cmd
,
8517 "show ip bgp flap-statistics A.B.C.D",
8521 "Display flap statistics of routes\n"
8522 "Network in the BGP routing table to display\n")
8524 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8525 bgp_show_type_flap_address
);
8528 DEFUN (show_ip_bgp_flap_prefix
,
8529 show_ip_bgp_flap_prefix_cmd
,
8530 "show ip bgp flap-statistics A.B.C.D/M",
8534 "Display flap statistics of routes\n"
8535 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8537 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8538 bgp_show_type_flap_prefix
);
8541 DEFUN (show_bgp_prefix_longer
,
8542 show_bgp_prefix_longer_cmd
,
8543 "show bgp X:X::X:X/M longer-prefixes",
8546 "IPv6 prefix <network>/<length>\n"
8547 "Display route and more specific routes\n")
8549 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8550 bgp_show_type_prefix_longer
);
8553 ALIAS (show_bgp_prefix_longer
,
8554 show_bgp_ipv6_prefix_longer_cmd
,
8555 "show bgp ipv6 X:X::X:X/M longer-prefixes",
8559 "IPv6 prefix <network>/<length>\n"
8560 "Display route and more specific routes\n")
8563 DEFUN (show_ipv6_bgp_prefix_longer
,
8564 show_ipv6_bgp_prefix_longer_cmd
,
8565 "show ipv6 bgp X:X::X:X/M longer-prefixes",
8569 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8570 "Display route and more specific routes\n")
8572 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8573 bgp_show_type_prefix_longer
);
8577 DEFUN (show_ipv6_mbgp_prefix_longer
,
8578 show_ipv6_mbgp_prefix_longer_cmd
,
8579 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
8583 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8584 "Display route and more specific routes\n")
8586 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8587 bgp_show_type_prefix_longer
);
8589 #endif /* HAVE_IPV6 */
8591 static struct peer
*
8592 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
8600 /* BGP structure lookup. */
8603 bgp
= bgp_lookup_by_name (view_name
);
8606 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
8612 bgp
= bgp_get_default ();
8615 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8620 /* Get peer sockunion. */
8621 ret
= str2sockunion (ip_str
, &su
);
8624 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
8628 /* Peer structure lookup. */
8629 peer
= peer_lookup (bgp
, &su
);
8632 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
8641 BGP_STATS_MAXBITLEN
= 0,
8645 BGP_STATS_UNAGGREGATEABLE
,
8646 BGP_STATS_MAX_AGGREGATEABLE
,
8647 BGP_STATS_AGGREGATES
,
8649 BGP_STATS_ASPATH_COUNT
,
8650 BGP_STATS_ASPATH_MAXHOPS
,
8651 BGP_STATS_ASPATH_TOTHOPS
,
8652 BGP_STATS_ASPATH_MAXSIZE
,
8653 BGP_STATS_ASPATH_TOTSIZE
,
8654 BGP_STATS_ASN_HIGHEST
,
8658 static const char *table_stats_strs
[] =
8660 [BGP_STATS_PREFIXES
] = "Total Prefixes",
8661 [BGP_STATS_TOTPLEN
] = "Average prefix length",
8662 [BGP_STATS_RIB
] = "Total Advertisements",
8663 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
8664 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
8665 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
8666 [BGP_STATS_SPACE
] = "Address space advertised",
8667 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
8668 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
8669 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
8670 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
8671 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
8672 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
8673 [BGP_STATS_MAX
] = NULL
,
8676 struct bgp_table_stats
8678 struct bgp_table
*table
;
8679 unsigned long long counts
[BGP_STATS_MAX
];
8683 #define TALLY_SIGFIG 100000
8684 static unsigned long
8685 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
8687 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
8688 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
8689 unsigned long ret
= newtot
/ count
;
8691 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
8699 bgp_table_stats_walker (struct thread
*t
)
8701 struct bgp_node
*rn
;
8702 struct bgp_node
*top
;
8703 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
8704 unsigned int space
= 0;
8706 if (!(top
= bgp_table_top (ts
->table
)))
8709 switch (top
->p
.family
)
8712 space
= IPV4_MAX_BITLEN
;
8715 space
= IPV6_MAX_BITLEN
;
8719 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
8721 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
8723 struct bgp_info
*ri
;
8724 struct bgp_node
*prn
= rn
->parent
;
8725 unsigned int rinum
= 0;
8733 ts
->counts
[BGP_STATS_PREFIXES
]++;
8734 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
8737 ts
->counts
[BGP_STATS_AVGPLEN
]
8738 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
8739 ts
->counts
[BGP_STATS_AVGPLEN
],
8743 /* check if the prefix is included by any other announcements */
8744 while (prn
&& !prn
->info
)
8747 if (prn
== NULL
|| prn
== top
)
8749 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
8750 /* announced address space */
8752 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
8755 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
8757 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8760 ts
->counts
[BGP_STATS_RIB
]++;
8763 (CHECK_FLAG (ri
->attr
->flag
,
8764 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
8765 ts
->counts
[BGP_STATS_AGGREGATES
]++;
8768 if (ri
->attr
&& ri
->attr
->aspath
)
8770 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
8771 unsigned int size
= aspath_size (ri
->attr
->aspath
);
8772 as_t highest
= aspath_highest (ri
->attr
->aspath
);
8774 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
8776 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
8777 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
8779 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
8780 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
8782 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
8783 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
8785 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
8786 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
8787 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
8789 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
8790 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
8791 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
8794 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
8795 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
8803 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
8805 struct bgp_table_stats ts
;
8808 if (!bgp
->rib
[afi
][safi
])
8810 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
8814 memset (&ts
, 0, sizeof (ts
));
8815 ts
.table
= bgp
->rib
[afi
][safi
];
8816 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
8818 vty_out (vty
, "BGP %s RIB statistics%s%s",
8819 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
8821 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
8823 if (!table_stats_strs
[i
])
8829 case BGP_STATS_ASPATH_AVGHOPS
:
8830 case BGP_STATS_ASPATH_AVGSIZE
:
8831 case BGP_STATS_AVGPLEN
:
8832 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8833 vty_out (vty
, "%12.2f",
8834 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
8837 case BGP_STATS_ASPATH_TOTHOPS
:
8838 case BGP_STATS_ASPATH_TOTSIZE
:
8839 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8840 vty_out (vty
, "%12.2f",
8842 (float)ts
.counts
[i
] /
8843 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
8846 case BGP_STATS_TOTPLEN
:
8847 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8848 vty_out (vty
, "%12.2f",
8850 (float)ts
.counts
[i
] /
8851 (float)ts
.counts
[BGP_STATS_PREFIXES
]
8854 case BGP_STATS_SPACE
:
8855 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8856 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
8857 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
8859 vty_out (vty
, "%30s: ", "\% announced ");
8860 vty_out (vty
, "%12.2f%s",
8861 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
8862 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
8864 vty_out (vty
, "%30s: ", "/8 equivalent ");
8865 vty_out (vty
, "%12.2f%s",
8866 (float)ts
.counts
[BGP_STATS_SPACE
] /
8867 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
8869 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
8871 vty_out (vty
, "%30s: ", "/24 equivalent ");
8872 vty_out (vty
, "%12.2f",
8873 (float)ts
.counts
[BGP_STATS_SPACE
] /
8874 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
8877 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
8878 vty_out (vty
, "%12llu", ts
.counts
[i
]);
8881 vty_out (vty
, "%s", VTY_NEWLINE
);
8887 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
8888 const char *afi_str
, const char *safi_str
)
8895 bgp
= bgp_lookup_by_name (name
);
8897 bgp
= bgp_get_default ();
8901 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
8904 if (strncmp (afi_str
, "ipv", 3) == 0)
8906 if (strncmp (afi_str
, "ipv4", 4) == 0)
8908 else if (strncmp (afi_str
, "ipv6", 4) == 0)
8912 vty_out (vty
, "%% Invalid address family %s%s",
8913 afi_str
, VTY_NEWLINE
);
8916 if (strncmp (safi_str
, "m", 1) == 0)
8917 safi
= SAFI_MULTICAST
;
8918 else if (strncmp (safi_str
, "u", 1) == 0)
8919 safi
= SAFI_UNICAST
;
8920 else if (strncmp (safi_str
, "vpnv4", 5) == 0)
8921 safi
= BGP_SAFI_VPNV4
;
8922 else if (strncmp (safi_str
, "vpnv6", 6) == 0)
8923 safi
= BGP_SAFI_VPNV6
;
8926 vty_out (vty
, "%% Invalid subsequent address family %s%s",
8927 safi_str
, VTY_NEWLINE
);
8933 vty_out (vty
, "%% Invalid address family %s%s",
8934 afi_str
, VTY_NEWLINE
);
8938 if ((afi
== AFI_IP
&& safi
== BGP_SAFI_VPNV6
)
8939 || (afi
== AFI_IP6
&& safi
== BGP_SAFI_VPNV4
))
8941 vty_out (vty
, "%% Invalid subsequent address family %s for %s%s",
8942 afi_str
, safi_str
, VTY_NEWLINE
);
8945 return bgp_table_stats (vty
, bgp
, afi
, safi
);
8948 DEFUN (show_bgp_statistics
,
8949 show_bgp_statistics_cmd
,
8950 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
8955 "Address Family modifier\n"
8956 "Address Family modifier\n"
8957 "BGP RIB advertisement statistics\n")
8959 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
8962 ALIAS (show_bgp_statistics
,
8963 show_bgp_statistics_vpnv4_cmd
,
8964 "show bgp (ipv4) (vpnv4) statistics",
8968 "Address Family modifier\n"
8969 "BGP RIB advertisement statistics\n")
8971 DEFUN (show_bgp_statistics_view
,
8972 show_bgp_statistics_view_cmd
,
8973 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
8979 "Address Family modifier\n"
8980 "Address Family modifier\n"
8981 "BGP RIB advertisement statistics\n")
8983 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
8986 ALIAS (show_bgp_statistics_view
,
8987 show_bgp_statistics_view_vpnv4_cmd
,
8988 "show bgp view WORD (ipv4) (vpnv4) statistics",
8993 "Address Family modifier\n"
8994 "BGP RIB advertisement statistics\n")
9006 PCOUNT_PFCNT
, /* the figure we display to users */
9010 static const char *pcount_strs
[] =
9012 [PCOUNT_ADJ_IN
] = "Adj-in",
9013 [PCOUNT_DAMPED
] = "Damped",
9014 [PCOUNT_REMOVED
] = "Removed",
9015 [PCOUNT_HISTORY
] = "History",
9016 [PCOUNT_STALE
] = "Stale",
9017 [PCOUNT_VALID
] = "Valid",
9018 [PCOUNT_ALL
] = "All RIB",
9019 [PCOUNT_COUNTED
] = "PfxCt counted",
9020 [PCOUNT_PFCNT
] = "Useable",
9021 [PCOUNT_MAX
] = NULL
,
9026 unsigned int count
[PCOUNT_MAX
];
9027 const struct peer
*peer
;
9028 const struct bgp_table
*table
;
9032 bgp_peer_count_walker (struct thread
*t
)
9034 struct bgp_node
*rn
;
9035 struct peer_pcounts
*pc
= THREAD_ARG (t
);
9036 const struct peer
*peer
= pc
->peer
;
9038 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
9040 struct bgp_adj_in
*ain
;
9041 struct bgp_info
*ri
;
9043 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9044 if (ain
->peer
== peer
)
9045 pc
->count
[PCOUNT_ADJ_IN
]++;
9047 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
9049 char buf
[SU_ADDRSTRLEN
];
9051 if (ri
->peer
!= peer
)
9054 pc
->count
[PCOUNT_ALL
]++;
9056 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
9057 pc
->count
[PCOUNT_DAMPED
]++;
9058 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
9059 pc
->count
[PCOUNT_HISTORY
]++;
9060 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
9061 pc
->count
[PCOUNT_REMOVED
]++;
9062 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
9063 pc
->count
[PCOUNT_STALE
]++;
9064 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
9065 pc
->count
[PCOUNT_VALID
]++;
9066 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9067 pc
->count
[PCOUNT_PFCNT
]++;
9069 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
9071 pc
->count
[PCOUNT_COUNTED
]++;
9072 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9073 plog_warn (peer
->log
,
9074 "%s [pcount] %s/%d is counted but flags 0x%x",
9076 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9077 buf
, SU_ADDRSTRLEN
),
9083 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
9084 plog_warn (peer
->log
,
9085 "%s [pcount] %s/%d not counted but flags 0x%x",
9087 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
9088 buf
, SU_ADDRSTRLEN
),
9098 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
)
9100 struct peer_pcounts pcounts
= { .peer
= peer
};
9103 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
9104 || !peer
->bgp
->rib
[afi
][safi
])
9106 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9110 memset (&pcounts
, 0, sizeof(pcounts
));
9111 pcounts
.peer
= peer
;
9112 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
9114 /* in-place call via thread subsystem so as to record execution time
9115 * stats for the thread-walk (i.e. ensure this can't be blamed on
9116 * on just vty_read()).
9118 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
9120 vty_out (vty
, "Prefix counts for %s, %s%s",
9121 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
9122 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
9123 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
9124 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
9126 for (i
= 0; i
< PCOUNT_MAX
; i
++)
9127 vty_out (vty
, "%20s: %-10d%s",
9128 pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
9130 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
9132 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
9133 peer
->host
, VTY_NEWLINE
);
9134 vty_out (vty
, "Please report this bug, with the above command output%s",
9141 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
9142 show_ip_bgp_neighbor_prefix_counts_cmd
,
9143 "show ip bgp neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9147 "Detailed information on TCP and BGP neighbor connections\n"
9148 "Neighbor to display information about\n"
9149 "Neighbor to display information about\n"
9150 "Display detailed prefix count information\n")
9154 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9158 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9161 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
9162 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
9163 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9167 "Detailed information on TCP and BGP neighbor connections\n"
9168 "Neighbor to display information about\n"
9169 "Neighbor to display information about\n"
9170 "Display detailed prefix count information\n")
9174 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9178 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
);
9181 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
9182 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
9183 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9188 "Address Family modifier\n"
9189 "Address Family modifier\n"
9190 "Detailed information on TCP and BGP neighbor connections\n"
9191 "Neighbor to display information about\n"
9192 "Neighbor to display information about\n"
9193 "Display detailed prefix count information\n")
9197 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9201 if (strncmp (argv
[0], "m", 1) == 0)
9202 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
);
9204 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
);
9207 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
9208 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
9209 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X) prefix-counts",
9214 "Address Family modifier\n"
9215 "Address Family modifier\n"
9216 "Detailed information on TCP and BGP neighbor connections\n"
9217 "Neighbor to display information about\n"
9218 "Neighbor to display information about\n"
9219 "Display detailed prefix count information\n")
9223 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9227 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
);
9232 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
9235 struct bgp_table
*table
;
9236 struct bgp_adj_in
*ain
;
9237 struct bgp_adj_out
*adj
;
9238 unsigned long output_count
;
9239 struct bgp_node
*rn
;
9249 table
= bgp
->rib
[afi
][safi
];
9253 if (! in
&& CHECK_FLAG (peer
->af_sflags
[afi
][safi
],
9254 PEER_STATUS_DEFAULT_ORIGINATE
))
9256 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9257 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9258 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9260 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
9261 VTY_NEWLINE
, VTY_NEWLINE
);
9265 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
9268 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
9269 if (ain
->peer
== peer
)
9273 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9274 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9275 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9280 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9285 route_vty_out_tmp (vty
, &rn
->p
, ain
->attr
, safi
);
9292 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
9293 if (adj
->peer
== peer
)
9297 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
9298 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9299 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
9304 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
9309 route_vty_out_tmp (vty
, &rn
->p
, adj
->attr
, safi
);
9315 if (output_count
!= 0)
9316 vty_out (vty
, "%sTotal number of prefixes %ld%s",
9317 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
9321 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, int in
)
9323 if (! peer
|| ! peer
->afc
[afi
][safi
])
9325 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9329 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9331 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
9336 show_adj_route (vty
, peer
, afi
, safi
, in
);
9341 DEFUN (show_ip_bgp_neighbor_advertised_route
,
9342 show_ip_bgp_neighbor_advertised_route_cmd
,
9343 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9347 "Detailed information on TCP and BGP neighbor connections\n"
9348 "Neighbor to display information about\n"
9349 "Neighbor to display information about\n"
9350 "Display the routes advertised to a BGP neighbor\n")
9354 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9358 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9361 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
9362 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
9363 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9368 "Address Family modifier\n"
9369 "Address Family modifier\n"
9370 "Detailed information on TCP and BGP neighbor connections\n"
9371 "Neighbor to display information about\n"
9372 "Neighbor to display information about\n"
9373 "Display the routes advertised to a BGP neighbor\n")
9377 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9381 if (strncmp (argv
[0], "m", 1) == 0)
9382 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0);
9384 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0);
9388 DEFUN (show_bgp_view_neighbor_advertised_route
,
9389 show_bgp_view_neighbor_advertised_route_cmd
,
9390 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9395 "Detailed information on TCP and BGP neighbor connections\n"
9396 "Neighbor to display information about\n"
9397 "Neighbor to display information about\n"
9398 "Display the routes advertised to a BGP neighbor\n")
9403 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9405 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9410 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0);
9413 ALIAS (show_bgp_view_neighbor_advertised_route
,
9414 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
9415 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9421 "Detailed information on TCP and BGP neighbor connections\n"
9422 "Neighbor to display information about\n"
9423 "Neighbor to display information about\n"
9424 "Display the routes advertised to a BGP neighbor\n")
9426 DEFUN (show_bgp_view_neighbor_received_routes
,
9427 show_bgp_view_neighbor_received_routes_cmd
,
9428 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
9433 "Detailed information on TCP and BGP neighbor connections\n"
9434 "Neighbor to display information about\n"
9435 "Neighbor to display information about\n"
9436 "Display the received routes from neighbor\n")
9441 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9443 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9448 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1);
9451 ALIAS (show_bgp_view_neighbor_received_routes
,
9452 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
9453 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9459 "Detailed information on TCP and BGP neighbor connections\n"
9460 "Neighbor to display information about\n"
9461 "Neighbor to display information about\n"
9462 "Display the received routes from neighbor\n")
9464 ALIAS (show_bgp_view_neighbor_advertised_route
,
9465 show_bgp_neighbor_advertised_route_cmd
,
9466 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
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 the routes advertised to a BGP neighbor\n")
9474 ALIAS (show_bgp_view_neighbor_advertised_route
,
9475 show_bgp_ipv6_neighbor_advertised_route_cmd
,
9476 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9480 "Detailed information on TCP and BGP neighbor connections\n"
9481 "Neighbor to display information about\n"
9482 "Neighbor to display information about\n"
9483 "Display the routes advertised to a BGP neighbor\n")
9486 ALIAS (show_bgp_view_neighbor_advertised_route
,
9487 ipv6_bgp_neighbor_advertised_route_cmd
,
9488 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9492 "Detailed information on TCP and BGP neighbor connections\n"
9493 "Neighbor to display information about\n"
9494 "Neighbor to display information about\n"
9495 "Display the routes advertised to a BGP neighbor\n")
9498 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
9499 ipv6_mbgp_neighbor_advertised_route_cmd
,
9500 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
9504 "Detailed information on TCP and BGP neighbor connections\n"
9505 "Neighbor to display information about\n"
9506 "Neighbor to display information about\n"
9507 "Display the routes advertised to a BGP neighbor\n")
9511 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9515 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0);
9517 #endif /* HAVE_IPV6 */
9519 DEFUN (show_ip_bgp_neighbor_received_routes
,
9520 show_ip_bgp_neighbor_received_routes_cmd
,
9521 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9525 "Detailed information on TCP and BGP neighbor connections\n"
9526 "Neighbor to display information about\n"
9527 "Neighbor to display information about\n"
9528 "Display the received routes from neighbor\n")
9532 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9536 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9539 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
9540 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
9541 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
9546 "Address Family modifier\n"
9547 "Address Family modifier\n"
9548 "Detailed information on TCP and BGP neighbor connections\n"
9549 "Neighbor to display information about\n"
9550 "Neighbor to display information about\n"
9551 "Display the received routes from neighbor\n")
9555 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9559 if (strncmp (argv
[0], "m", 1) == 0)
9560 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1);
9562 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1);
9565 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
9566 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
9567 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9571 "Detailed information on TCP and BGP neighbor connections\n"
9572 "Neighbor to display information about\n"
9573 "Neighbor to display information about\n"
9574 "Display information received from a BGP neighbor\n"
9575 "Display the prefixlist filter\n")
9578 union sockunion
*su
;
9582 su
= sockunion_str2su (argv
[0]);
9586 peer
= peer_lookup (NULL
, su
);
9590 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9591 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9594 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9595 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9601 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
9602 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
9603 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9608 "Address Family modifier\n"
9609 "Address Family modifier\n"
9610 "Detailed information on TCP and BGP neighbor connections\n"
9611 "Neighbor to display information about\n"
9612 "Neighbor to display information about\n"
9613 "Display information received from a BGP neighbor\n"
9614 "Display the prefixlist filter\n")
9617 union sockunion
*su
;
9621 su
= sockunion_str2su (argv
[1]);
9625 peer
= peer_lookup (NULL
, su
);
9629 if (strncmp (argv
[0], "m", 1) == 0)
9631 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
9632 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9635 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
9636 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9641 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
9642 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
);
9645 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
9646 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
);
9655 ALIAS (show_bgp_view_neighbor_received_routes
,
9656 show_bgp_neighbor_received_routes_cmd
,
9657 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9660 "Detailed information on TCP and BGP neighbor connections\n"
9661 "Neighbor to display information about\n"
9662 "Neighbor to display information about\n"
9663 "Display the received routes from neighbor\n")
9665 ALIAS (show_bgp_view_neighbor_received_routes
,
9666 show_bgp_ipv6_neighbor_received_routes_cmd
,
9667 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
9671 "Detailed information on TCP and BGP neighbor connections\n"
9672 "Neighbor to display information about\n"
9673 "Neighbor to display information about\n"
9674 "Display the received routes from neighbor\n")
9676 DEFUN (show_bgp_neighbor_received_prefix_filter
,
9677 show_bgp_neighbor_received_prefix_filter_cmd
,
9678 "show bgp neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9681 "Detailed information on TCP and BGP neighbor connections\n"
9682 "Neighbor to display information about\n"
9683 "Neighbor to display information about\n"
9684 "Display information received from a BGP neighbor\n"
9685 "Display the prefixlist filter\n")
9688 union sockunion
*su
;
9692 su
= sockunion_str2su (argv
[0]);
9696 peer
= peer_lookup (NULL
, su
);
9700 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
9701 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
9704 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
9705 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
9711 ALIAS (show_bgp_neighbor_received_prefix_filter
,
9712 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
9713 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
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 information received from a BGP neighbor\n"
9721 "Display the prefixlist filter\n")
9724 ALIAS (show_bgp_view_neighbor_received_routes
,
9725 ipv6_bgp_neighbor_received_routes_cmd
,
9726 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9730 "Detailed information on TCP and BGP neighbor connections\n"
9731 "Neighbor to display information about\n"
9732 "Neighbor to display information about\n"
9733 "Display the received routes from neighbor\n")
9736 DEFUN (ipv6_mbgp_neighbor_received_routes
,
9737 ipv6_mbgp_neighbor_received_routes_cmd
,
9738 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
9742 "Detailed information on TCP and BGP neighbor connections\n"
9743 "Neighbor to display information about\n"
9744 "Neighbor to display information about\n"
9745 "Display the received routes from neighbor\n")
9749 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9753 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1);
9756 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
9757 show_bgp_view_neighbor_received_prefix_filter_cmd
,
9758 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9763 "Detailed information on TCP and BGP neighbor connections\n"
9764 "Neighbor to display information about\n"
9765 "Neighbor to display information about\n"
9766 "Display information received from a BGP neighbor\n"
9767 "Display the prefixlist filter\n")
9770 union sockunion
*su
;
9775 /* BGP structure lookup. */
9776 bgp
= bgp_lookup_by_name (argv
[0]);
9779 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9783 su
= sockunion_str2su (argv
[1]);
9787 peer
= peer_lookup (bgp
, su
);
9791 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
9792 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
);
9795 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
9796 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
);
9802 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
9803 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
9804 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received prefix-filter",
9810 "Detailed information on TCP and BGP neighbor connections\n"
9811 "Neighbor to display information about\n"
9812 "Neighbor to display information about\n"
9813 "Display information received from a BGP neighbor\n"
9814 "Display the prefixlist filter\n")
9815 #endif /* HAVE_IPV6 */
9818 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
9819 safi_t safi
, enum bgp_show_type type
)
9821 if (! peer
|| ! peer
->afc
[afi
][safi
])
9823 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
9827 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
);
9830 DEFUN (show_ip_bgp_neighbor_routes
,
9831 show_ip_bgp_neighbor_routes_cmd
,
9832 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
9836 "Detailed information on TCP and BGP neighbor connections\n"
9837 "Neighbor to display information about\n"
9838 "Neighbor to display information about\n"
9839 "Display routes learned from neighbor\n")
9843 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9847 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9848 bgp_show_type_neighbor
);
9851 DEFUN (show_ip_bgp_neighbor_flap
,
9852 show_ip_bgp_neighbor_flap_cmd
,
9853 "show ip bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
9857 "Detailed information on TCP and BGP neighbor connections\n"
9858 "Neighbor to display information about\n"
9859 "Neighbor to display information about\n"
9860 "Display flap statistics of the routes learned from neighbor\n")
9864 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9868 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9869 bgp_show_type_flap_neighbor
);
9872 DEFUN (show_ip_bgp_neighbor_damp
,
9873 show_ip_bgp_neighbor_damp_cmd
,
9874 "show ip bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
9878 "Detailed information on TCP and BGP neighbor connections\n"
9879 "Neighbor to display information about\n"
9880 "Neighbor to display information about\n"
9881 "Display the dampened routes received from neighbor\n")
9885 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9889 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9890 bgp_show_type_damp_neighbor
);
9893 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
9894 show_ip_bgp_ipv4_neighbor_routes_cmd
,
9895 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
9900 "Address Family modifier\n"
9901 "Address Family modifier\n"
9902 "Detailed information on TCP and BGP neighbor connections\n"
9903 "Neighbor to display information about\n"
9904 "Neighbor to display information about\n"
9905 "Display routes learned from neighbor\n")
9909 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1]);
9913 if (strncmp (argv
[0], "m", 1) == 0)
9914 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
9915 bgp_show_type_neighbor
);
9917 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
9918 bgp_show_type_neighbor
);
9921 DEFUN (show_ip_bgp_view_rsclient
,
9922 show_ip_bgp_view_rsclient_cmd
,
9923 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
9929 "Information about Route Server Client\n"
9932 struct bgp_table
*table
;
9936 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
9938 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
9943 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
9945 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
9950 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
9951 PEER_FLAG_RSERVER_CLIENT
))
9953 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
9958 table
= peer
->rib
[AFI_IP
][SAFI_UNICAST
];
9960 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
9963 ALIAS (show_ip_bgp_view_rsclient
,
9964 show_ip_bgp_rsclient_cmd
,
9965 "show ip bgp rsclient (A.B.C.D|X:X::X:X)",
9969 "Information about Route Server Client\n"
9972 DEFUN (show_ip_bgp_view_rsclient_route
,
9973 show_ip_bgp_view_rsclient_route_cmd
,
9974 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
9980 "Information about Route Server Client\n"
9982 "Network in the BGP routing table to display\n")
9987 /* BGP structure lookup. */
9990 bgp
= bgp_lookup_by_name (argv
[0]);
9993 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9999 bgp
= bgp_get_default ();
10002 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10003 return CMD_WARNING
;
10008 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10010 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10013 return CMD_WARNING
;
10015 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10017 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10019 return CMD_WARNING
;
10022 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10023 PEER_FLAG_RSERVER_CLIENT
))
10025 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10027 return CMD_WARNING
;
10030 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10031 (argc
== 3) ? argv
[2] : argv
[1],
10032 AFI_IP
, SAFI_UNICAST
, NULL
, 0);
10035 ALIAS (show_ip_bgp_view_rsclient_route
,
10036 show_ip_bgp_rsclient_route_cmd
,
10037 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D",
10041 "Information about Route Server Client\n"
10043 "Network in the BGP routing table to display\n")
10045 DEFUN (show_ip_bgp_view_rsclient_prefix
,
10046 show_ip_bgp_view_rsclient_prefix_cmd
,
10047 "show ip bgp view WORD rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10053 "Information about Route Server Client\n"
10055 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10060 /* BGP structure lookup. */
10063 bgp
= bgp_lookup_by_name (argv
[0]);
10066 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10067 return CMD_WARNING
;
10072 bgp
= bgp_get_default ();
10075 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10076 return CMD_WARNING
;
10081 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10083 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10086 return CMD_WARNING
;
10088 if (! peer
->afc
[AFI_IP
][SAFI_UNICAST
])
10090 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10092 return CMD_WARNING
;
10095 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
],
10096 PEER_FLAG_RSERVER_CLIENT
))
10098 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10100 return CMD_WARNING
;
10103 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP
][SAFI_UNICAST
],
10104 (argc
== 3) ? argv
[2] : argv
[1],
10105 AFI_IP
, SAFI_UNICAST
, NULL
, 1);
10108 ALIAS (show_ip_bgp_view_rsclient_prefix
,
10109 show_ip_bgp_rsclient_prefix_cmd
,
10110 "show ip bgp rsclient (A.B.C.D|X:X::X:X) A.B.C.D/M",
10114 "Information about Route Server Client\n"
10116 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10120 DEFUN (show_bgp_view_neighbor_routes
,
10121 show_bgp_view_neighbor_routes_cmd
,
10122 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
10127 "Detailed information on TCP and BGP neighbor connections\n"
10128 "Neighbor to display information about\n"
10129 "Neighbor to display information about\n"
10130 "Display routes learned from neighbor\n")
10135 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10137 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10140 return CMD_WARNING
;
10142 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10143 bgp_show_type_neighbor
);
10146 ALIAS (show_bgp_view_neighbor_routes
,
10147 show_bgp_view_ipv6_neighbor_routes_cmd
,
10148 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10154 "Detailed information on TCP and BGP neighbor connections\n"
10155 "Neighbor to display information about\n"
10156 "Neighbor to display information about\n"
10157 "Display routes learned from neighbor\n")
10159 DEFUN (show_bgp_view_neighbor_damp
,
10160 show_bgp_view_neighbor_damp_cmd
,
10161 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10166 "Detailed information on TCP and BGP neighbor connections\n"
10167 "Neighbor to display information about\n"
10168 "Neighbor to display information about\n"
10169 "Display the dampened routes received from neighbor\n")
10174 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10176 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10179 return CMD_WARNING
;
10181 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10182 bgp_show_type_damp_neighbor
);
10185 ALIAS (show_bgp_view_neighbor_damp
,
10186 show_bgp_view_ipv6_neighbor_damp_cmd
,
10187 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10193 "Detailed information on TCP and BGP neighbor connections\n"
10194 "Neighbor to display information about\n"
10195 "Neighbor to display information about\n"
10196 "Display the dampened routes received from neighbor\n")
10198 DEFUN (show_bgp_view_neighbor_flap
,
10199 show_bgp_view_neighbor_flap_cmd
,
10200 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10205 "Detailed information on TCP and BGP neighbor connections\n"
10206 "Neighbor to display information about\n"
10207 "Neighbor to display information about\n"
10208 "Display flap statistics of the routes learned from neighbor\n")
10213 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10215 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10218 return CMD_WARNING
;
10220 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
10221 bgp_show_type_flap_neighbor
);
10224 ALIAS (show_bgp_view_neighbor_flap
,
10225 show_bgp_view_ipv6_neighbor_flap_cmd
,
10226 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10232 "Detailed information on TCP and BGP neighbor connections\n"
10233 "Neighbor to display information about\n"
10234 "Neighbor to display information about\n"
10235 "Display flap statistics of the routes learned from neighbor\n")
10237 ALIAS (show_bgp_view_neighbor_routes
,
10238 show_bgp_neighbor_routes_cmd
,
10239 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
10242 "Detailed information on TCP and BGP neighbor connections\n"
10243 "Neighbor to display information about\n"
10244 "Neighbor to display information about\n"
10245 "Display routes learned from neighbor\n")
10248 ALIAS (show_bgp_view_neighbor_routes
,
10249 show_bgp_ipv6_neighbor_routes_cmd
,
10250 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
10254 "Detailed information on TCP and BGP neighbor connections\n"
10255 "Neighbor to display information about\n"
10256 "Neighbor to display information about\n"
10257 "Display routes learned from neighbor\n")
10260 ALIAS (show_bgp_view_neighbor_routes
,
10261 ipv6_bgp_neighbor_routes_cmd
,
10262 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
10266 "Detailed information on TCP and BGP neighbor connections\n"
10267 "Neighbor to display information about\n"
10268 "Neighbor to display information about\n"
10269 "Display routes learned from neighbor\n")
10272 DEFUN (ipv6_mbgp_neighbor_routes
,
10273 ipv6_mbgp_neighbor_routes_cmd
,
10274 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
10278 "Detailed information on TCP and BGP neighbor connections\n"
10279 "Neighbor to display information about\n"
10280 "Neighbor to display information about\n"
10281 "Display routes learned from neighbor\n")
10285 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10287 return CMD_WARNING
;
10289 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
10290 bgp_show_type_neighbor
);
10293 ALIAS (show_bgp_view_neighbor_flap
,
10294 show_bgp_neighbor_flap_cmd
,
10295 "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10298 "Detailed information on TCP and BGP neighbor connections\n"
10299 "Neighbor to display information about\n"
10300 "Neighbor to display information about\n"
10301 "Display flap statistics of the routes learned from neighbor\n")
10303 ALIAS (show_bgp_view_neighbor_flap
,
10304 show_bgp_ipv6_neighbor_flap_cmd
,
10305 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
10309 "Detailed information on TCP and BGP neighbor connections\n"
10310 "Neighbor to display information about\n"
10311 "Neighbor to display information about\n"
10312 "Display flap statistics of the routes learned from neighbor\n")
10314 ALIAS (show_bgp_view_neighbor_damp
,
10315 show_bgp_neighbor_damp_cmd
,
10316 "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10319 "Detailed information on TCP and BGP neighbor connections\n"
10320 "Neighbor to display information about\n"
10321 "Neighbor to display information about\n"
10322 "Display the dampened routes received from neighbor\n")
10324 ALIAS (show_bgp_view_neighbor_damp
,
10325 show_bgp_ipv6_neighbor_damp_cmd
,
10326 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
10330 "Detailed information on TCP and BGP neighbor connections\n"
10331 "Neighbor to display information about\n"
10332 "Neighbor to display information about\n"
10333 "Display the dampened routes received from neighbor\n")
10335 DEFUN (show_bgp_view_rsclient
,
10336 show_bgp_view_rsclient_cmd
,
10337 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X)",
10342 "Information about Route Server Client\n"
10345 struct bgp_table
*table
;
10349 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10351 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10354 return CMD_WARNING
;
10356 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10358 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10360 return CMD_WARNING
;
10363 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10364 PEER_FLAG_RSERVER_CLIENT
))
10366 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10368 return CMD_WARNING
;
10371 table
= peer
->rib
[AFI_IP6
][SAFI_UNICAST
];
10373 return bgp_show_table (vty
, table
, &peer
->remote_id
, bgp_show_type_normal
, NULL
);
10376 ALIAS (show_bgp_view_rsclient
,
10377 show_bgp_rsclient_cmd
,
10378 "show bgp rsclient (A.B.C.D|X:X::X:X)",
10381 "Information about Route Server Client\n"
10384 DEFUN (show_bgp_view_rsclient_route
,
10385 show_bgp_view_rsclient_route_cmd
,
10386 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10391 "Information about Route Server Client\n"
10393 "Network in the BGP routing table to display\n")
10398 /* BGP structure lookup. */
10401 bgp
= bgp_lookup_by_name (argv
[0]);
10404 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10405 return CMD_WARNING
;
10410 bgp
= bgp_get_default ();
10413 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10414 return CMD_WARNING
;
10419 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10421 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10424 return CMD_WARNING
;
10426 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10428 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10430 return CMD_WARNING
;
10433 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10434 PEER_FLAG_RSERVER_CLIENT
))
10436 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10438 return CMD_WARNING
;
10441 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10442 (argc
== 3) ? argv
[2] : argv
[1],
10443 AFI_IP6
, SAFI_UNICAST
, NULL
, 0);
10446 ALIAS (show_bgp_view_rsclient_route
,
10447 show_bgp_rsclient_route_cmd
,
10448 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X",
10451 "Information about Route Server Client\n"
10453 "Network in the BGP routing table to display\n")
10455 DEFUN (show_bgp_view_rsclient_prefix
,
10456 show_bgp_view_rsclient_prefix_cmd
,
10457 "show bgp view WORD rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10462 "Information about Route Server Client\n"
10464 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10469 /* BGP structure lookup. */
10472 bgp
= bgp_lookup_by_name (argv
[0]);
10475 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
10476 return CMD_WARNING
;
10481 bgp
= bgp_get_default ();
10484 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10485 return CMD_WARNING
;
10490 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1]);
10492 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0]);
10495 return CMD_WARNING
;
10497 if (! peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
10499 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
10501 return CMD_WARNING
;
10504 if ( ! CHECK_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
10505 PEER_FLAG_RSERVER_CLIENT
))
10507 vty_out (vty
, "%% Neighbor is not a Route-Server client%s",
10509 return CMD_WARNING
;
10512 return bgp_show_route_in_table (vty
, bgp
, peer
->rib
[AFI_IP6
][SAFI_UNICAST
],
10513 (argc
== 3) ? argv
[2] : argv
[1],
10514 AFI_IP6
, SAFI_UNICAST
, NULL
, 1);
10517 ALIAS (show_bgp_view_rsclient_prefix
,
10518 show_bgp_rsclient_prefix_cmd
,
10519 "show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M",
10522 "Information about Route Server Client\n"
10524 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
10526 #endif /* HAVE_IPV6 */
10528 struct bgp_table
*bgp_distance_table
;
10530 struct bgp_distance
10532 /* Distance value for the IP source prefix. */
10535 /* Name of the access-list to be matched. */
10539 static struct bgp_distance
*
10540 bgp_distance_new ()
10542 struct bgp_distance
*new;
10543 new = XMALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
10544 memset (new, 0, sizeof (struct bgp_distance
));
10549 bgp_distance_free (struct bgp_distance
*bdistance
)
10551 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
10555 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
10556 const char *ip_str
, const char *access_list_str
)
10559 struct prefix_ipv4 p
;
10561 struct bgp_node
*rn
;
10562 struct bgp_distance
*bdistance
;
10564 ret
= str2prefix_ipv4 (ip_str
, &p
);
10567 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10568 return CMD_WARNING
;
10571 distance
= atoi (distance_str
);
10573 /* Get BGP distance node. */
10574 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
10577 bdistance
= rn
->info
;
10578 bgp_unlock_node (rn
);
10582 bdistance
= bgp_distance_new ();
10583 rn
->info
= bdistance
;
10586 /* Set distance value. */
10587 bdistance
->distance
= distance
;
10589 /* Reset access-list configuration. */
10590 if (bdistance
->access_list
)
10592 free (bdistance
->access_list
);
10593 bdistance
->access_list
= NULL
;
10595 if (access_list_str
)
10596 bdistance
->access_list
= strdup (access_list_str
);
10598 return CMD_SUCCESS
;
10602 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
10603 const char *ip_str
, const char *access_list_str
)
10606 struct prefix_ipv4 p
;
10608 struct bgp_node
*rn
;
10609 struct bgp_distance
*bdistance
;
10611 ret
= str2prefix_ipv4 (ip_str
, &p
);
10614 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
10615 return CMD_WARNING
;
10618 distance
= atoi (distance_str
);
10620 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
10623 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
10624 return CMD_WARNING
;
10627 bdistance
= rn
->info
;
10629 if (bdistance
->access_list
)
10630 free (bdistance
->access_list
);
10631 bgp_distance_free (bdistance
);
10634 bgp_unlock_node (rn
);
10635 bgp_unlock_node (rn
);
10637 return CMD_SUCCESS
;
10641 bgp_distance_reset ()
10643 struct bgp_node
*rn
;
10644 struct bgp_distance
*bdistance
;
10646 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
10647 if ((bdistance
= rn
->info
) != NULL
)
10649 if (bdistance
->access_list
)
10650 free (bdistance
->access_list
);
10651 bgp_distance_free (bdistance
);
10653 bgp_unlock_node (rn
);
10657 /* Apply BGP information to distance method. */
10659 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
10661 struct bgp_node
*rn
;
10662 struct prefix_ipv4 q
;
10664 struct bgp_distance
*bdistance
;
10665 struct access_list
*alist
;
10666 struct bgp_static
*bgp_static
;
10671 if (p
->family
!= AF_INET
)
10674 peer
= rinfo
->peer
;
10676 if (peer
->su
.sa
.sa_family
!= AF_INET
)
10679 memset (&q
, 0, sizeof (struct prefix_ipv4
));
10680 q
.family
= AF_INET
;
10681 q
.prefix
= peer
->su
.sin
.sin_addr
;
10682 q
.prefixlen
= IPV4_MAX_BITLEN
;
10684 /* Check source address. */
10685 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
10688 bdistance
= rn
->info
;
10689 bgp_unlock_node (rn
);
10691 if (bdistance
->access_list
)
10693 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
10694 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
10695 return bdistance
->distance
;
10698 return bdistance
->distance
;
10701 /* Backdoor check. */
10702 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
10705 bgp_static
= rn
->info
;
10706 bgp_unlock_node (rn
);
10708 if (bgp_static
->backdoor
)
10710 if (bgp
->distance_local
)
10711 return bgp
->distance_local
;
10713 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
10717 if (peer_sort (peer
) == BGP_PEER_EBGP
)
10719 if (bgp
->distance_ebgp
)
10720 return bgp
->distance_ebgp
;
10721 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
10725 if (bgp
->distance_ibgp
)
10726 return bgp
->distance_ibgp
;
10727 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
10731 DEFUN (bgp_distance
,
10733 "distance bgp <1-255> <1-255> <1-255>",
10734 "Define an administrative distance\n"
10736 "Distance for routes external to the AS\n"
10737 "Distance for routes internal to the AS\n"
10738 "Distance for local routes\n")
10744 bgp
->distance_ebgp
= atoi (argv
[0]);
10745 bgp
->distance_ibgp
= atoi (argv
[1]);
10746 bgp
->distance_local
= atoi (argv
[2]);
10747 return CMD_SUCCESS
;
10750 DEFUN (no_bgp_distance
,
10751 no_bgp_distance_cmd
,
10752 "no distance bgp <1-255> <1-255> <1-255>",
10754 "Define an administrative distance\n"
10756 "Distance for routes external to the AS\n"
10757 "Distance for routes internal to the AS\n"
10758 "Distance for local routes\n")
10764 bgp
->distance_ebgp
= 0;
10765 bgp
->distance_ibgp
= 0;
10766 bgp
->distance_local
= 0;
10767 return CMD_SUCCESS
;
10770 ALIAS (no_bgp_distance
,
10771 no_bgp_distance2_cmd
,
10774 "Define an administrative distance\n"
10777 DEFUN (bgp_distance_source
,
10778 bgp_distance_source_cmd
,
10779 "distance <1-255> A.B.C.D/M",
10780 "Define an administrative distance\n"
10781 "Administrative distance\n"
10782 "IP source prefix\n")
10784 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
10785 return CMD_SUCCESS
;
10788 DEFUN (no_bgp_distance_source
,
10789 no_bgp_distance_source_cmd
,
10790 "no distance <1-255> A.B.C.D/M",
10792 "Define an administrative distance\n"
10793 "Administrative distance\n"
10794 "IP source prefix\n")
10796 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
10797 return CMD_SUCCESS
;
10800 DEFUN (bgp_distance_source_access_list
,
10801 bgp_distance_source_access_list_cmd
,
10802 "distance <1-255> A.B.C.D/M WORD",
10803 "Define an administrative distance\n"
10804 "Administrative distance\n"
10805 "IP source prefix\n"
10806 "Access list name\n")
10808 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
10809 return CMD_SUCCESS
;
10812 DEFUN (no_bgp_distance_source_access_list
,
10813 no_bgp_distance_source_access_list_cmd
,
10814 "no distance <1-255> A.B.C.D/M WORD",
10816 "Define an administrative distance\n"
10817 "Administrative distance\n"
10818 "IP source prefix\n"
10819 "Access list name\n")
10821 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
10822 return CMD_SUCCESS
;
10825 DEFUN (bgp_damp_set
,
10827 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
10828 "BGP Specific commands\n"
10829 "Enable route-flap dampening\n"
10830 "Half-life time for the penalty\n"
10831 "Value to start reusing a route\n"
10832 "Value to start suppressing a route\n"
10833 "Maximum duration to suppress a stable route\n")
10836 int half
= DEFAULT_HALF_LIFE
* 60;
10837 int reuse
= DEFAULT_REUSE
;
10838 int suppress
= DEFAULT_SUPPRESS
;
10839 int max
= 4 * half
;
10843 half
= atoi (argv
[0]) * 60;
10844 reuse
= atoi (argv
[1]);
10845 suppress
= atoi (argv
[2]);
10846 max
= atoi (argv
[3]) * 60;
10848 else if (argc
== 1)
10850 half
= atoi (argv
[0]) * 60;
10855 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
10856 half
, reuse
, suppress
, max
);
10859 ALIAS (bgp_damp_set
,
10861 "bgp dampening <1-45>",
10862 "BGP Specific commands\n"
10863 "Enable route-flap dampening\n"
10864 "Half-life time for the penalty\n")
10866 ALIAS (bgp_damp_set
,
10869 "BGP Specific commands\n"
10870 "Enable route-flap dampening\n")
10872 DEFUN (bgp_damp_unset
,
10873 bgp_damp_unset_cmd
,
10874 "no bgp dampening",
10876 "BGP Specific commands\n"
10877 "Enable route-flap dampening\n")
10882 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
10885 ALIAS (bgp_damp_unset
,
10886 bgp_damp_unset2_cmd
,
10887 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
10889 "BGP Specific commands\n"
10890 "Enable route-flap dampening\n"
10891 "Half-life time for the penalty\n"
10892 "Value to start reusing a route\n"
10893 "Value to start suppressing a route\n"
10894 "Maximum duration to suppress a stable route\n")
10896 DEFUN (show_ip_bgp_dampened_paths
,
10897 show_ip_bgp_dampened_paths_cmd
,
10898 "show ip bgp dampened-paths",
10902 "Display paths suppressed due to dampening\n")
10904 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
10908 DEFUN (show_ip_bgp_flap_statistics
,
10909 show_ip_bgp_flap_statistics_cmd
,
10910 "show ip bgp flap-statistics",
10914 "Display flap statistics of routes\n")
10916 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10917 bgp_show_type_flap_statistics
, NULL
);
10920 /* Display specified route of BGP table. */
10922 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
10923 const char *ip_str
, afi_t afi
, safi_t safi
,
10924 struct prefix_rd
*prd
, int prefix_check
)
10927 struct prefix match
;
10928 struct bgp_node
*rn
;
10929 struct bgp_node
*rm
;
10930 struct bgp_info
*ri
;
10931 struct bgp_info
*ri_temp
;
10933 struct bgp_table
*table
;
10935 /* BGP structure lookup. */
10938 bgp
= bgp_lookup_by_name (view_name
);
10941 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
10942 return CMD_WARNING
;
10947 bgp
= bgp_get_default ();
10950 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
10951 return CMD_WARNING
;
10955 /* Check IP address argument. */
10956 ret
= str2prefix (ip_str
, &match
);
10959 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
10960 return CMD_WARNING
;
10963 match
.family
= afi2family (afi
);
10965 if (safi
== SAFI_MPLS_VPN
)
10967 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
10969 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
10972 if ((table
= rn
->info
) != NULL
)
10973 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
10974 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
10979 if (ri
->extra
&& ri
->extra
->damp_info
)
10981 ri_temp
= ri
->next
;
10982 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
10993 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
10994 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
10999 if (ri
->extra
&& ri
->extra
->damp_info
)
11001 ri_temp
= ri
->next
;
11002 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
11011 return CMD_SUCCESS
;
11014 DEFUN (clear_ip_bgp_dampening
,
11015 clear_ip_bgp_dampening_cmd
,
11016 "clear ip bgp dampening",
11020 "Clear route flap dampening information\n")
11022 bgp_damp_info_clean ();
11023 return CMD_SUCCESS
;
11026 DEFUN (clear_ip_bgp_dampening_prefix
,
11027 clear_ip_bgp_dampening_prefix_cmd
,
11028 "clear ip bgp dampening A.B.C.D/M",
11032 "Clear route flap dampening information\n"
11033 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11035 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11036 SAFI_UNICAST
, NULL
, 1);
11039 DEFUN (clear_ip_bgp_dampening_address
,
11040 clear_ip_bgp_dampening_address_cmd
,
11041 "clear ip bgp dampening A.B.C.D",
11045 "Clear route flap dampening information\n"
11046 "Network to clear damping information\n")
11048 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
11049 SAFI_UNICAST
, NULL
, 0);
11052 DEFUN (clear_ip_bgp_dampening_address_mask
,
11053 clear_ip_bgp_dampening_address_mask_cmd
,
11054 "clear ip bgp dampening A.B.C.D A.B.C.D",
11058 "Clear route flap dampening information\n"
11059 "Network to clear damping information\n"
11063 char prefix_str
[BUFSIZ
];
11065 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
11068 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
11069 return CMD_WARNING
;
11072 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
11073 SAFI_UNICAST
, NULL
, 0);
11077 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
11078 afi_t afi
, safi_t safi
, int *write
)
11080 struct bgp_node
*prn
;
11081 struct bgp_node
*rn
;
11082 struct bgp_table
*table
;
11084 struct prefix_rd
*prd
;
11085 struct bgp_static
*bgp_static
;
11087 char buf
[SU_ADDRSTRLEN
];
11088 char rdbuf
[RD_ADDRSTRLEN
];
11090 /* Network configuration. */
11091 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
11092 if ((table
= prn
->info
) != NULL
)
11093 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
11094 if ((bgp_static
= rn
->info
) != NULL
)
11097 prd
= (struct prefix_rd
*) &prn
->p
;
11099 /* "address-family" display. */
11100 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11102 /* "network" configuration display. */
11103 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
11104 label
= decode_label (bgp_static
->tag
);
11106 vty_out (vty
, " network %s/%d rd %s tag %d",
11107 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11110 vty_out (vty
, "%s", VTY_NEWLINE
);
11115 /* Configuration of static route announcement and aggregate
11118 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
11119 afi_t afi
, safi_t safi
, int *write
)
11121 struct bgp_node
*rn
;
11123 struct bgp_static
*bgp_static
;
11124 struct bgp_aggregate
*bgp_aggregate
;
11125 char buf
[SU_ADDRSTRLEN
];
11127 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
11128 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
11130 /* Network configuration. */
11131 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11132 if ((bgp_static
= rn
->info
) != NULL
)
11136 /* "address-family" display. */
11137 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11139 /* "network" configuration display. */
11140 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11142 u_int32_t destination
;
11143 struct in_addr netmask
;
11145 destination
= ntohl (p
->u
.prefix4
.s_addr
);
11146 masklen2ip (p
->prefixlen
, &netmask
);
11147 vty_out (vty
, " network %s",
11148 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
11150 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
11151 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
11152 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
11153 || p
->u
.prefix4
.s_addr
== 0)
11155 /* Natural mask is not display. */
11158 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
11162 vty_out (vty
, " network %s/%d",
11163 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11167 if (bgp_static
->rmap
.name
)
11168 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
11169 else if (bgp_static
->backdoor
)
11170 vty_out (vty
, " backdoor");
11172 vty_out (vty
, "%s", VTY_NEWLINE
);
11175 /* Aggregate-address configuration. */
11176 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
11177 if ((bgp_aggregate
= rn
->info
) != NULL
)
11181 /* "address-family" display. */
11182 bgp_config_write_family_header (vty
, afi
, safi
, write
);
11184 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
11186 struct in_addr netmask
;
11188 masklen2ip (p
->prefixlen
, &netmask
);
11189 vty_out (vty
, " aggregate-address %s %s",
11190 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11191 inet_ntoa (netmask
));
11195 vty_out (vty
, " aggregate-address %s/%d",
11196 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
11200 if (bgp_aggregate
->as_set
)
11201 vty_out (vty
, " as-set");
11203 if (bgp_aggregate
->summary_only
)
11204 vty_out (vty
, " summary-only");
11206 vty_out (vty
, "%s", VTY_NEWLINE
);
11213 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
11215 struct bgp_node
*rn
;
11216 struct bgp_distance
*bdistance
;
11218 /* Distance configuration. */
11219 if (bgp
->distance_ebgp
11220 && bgp
->distance_ibgp
11221 && bgp
->distance_local
11222 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
11223 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
11224 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
11225 vty_out (vty
, " distance bgp %d %d %d%s",
11226 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
11229 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
11230 if ((bdistance
= rn
->info
) != NULL
)
11232 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
11233 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
11234 bdistance
->access_list
? bdistance
->access_list
: "",
11241 /* Allocate routing table structure and install commands. */
11245 /* Init BGP distance table. */
11246 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
11248 /* IPv4 BGP commands. */
11249 install_element (BGP_NODE
, &bgp_network_cmd
);
11250 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
11251 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
11252 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
11253 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
11254 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11255 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
11256 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
11257 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
11258 install_element (BGP_NODE
, &no_bgp_network_cmd
);
11259 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
11260 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
11261 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
11262 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
11263 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11264 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
11265 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
11266 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
11268 install_element (BGP_NODE
, &aggregate_address_cmd
);
11269 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
11270 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
11271 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
11272 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
11273 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
11274 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
11275 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11276 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
11277 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11278 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
11279 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
11280 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
11281 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11282 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11283 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
11284 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11285 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11286 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11287 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11289 /* IPv4 unicast configuration. */
11290 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
11291 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
11292 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
11293 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
11294 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
11295 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11296 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
11297 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
11298 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
11299 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
11300 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
11301 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11302 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
11303 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
11304 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
11305 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
11306 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
11307 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
11308 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
11309 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11310 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
11311 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11312 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
11313 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
11314 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
11315 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11316 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11317 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
11318 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11319 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11320 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11321 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11323 /* IPv4 multicast configuration. */
11324 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
11325 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
11326 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
11327 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
11328 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
11329 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
11330 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
11331 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
11332 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
11333 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
11334 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
11335 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
11336 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
11337 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
11338 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
11339 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
11340 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
11341 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
11342 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
11343 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
11344 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
11345 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
11346 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
11347 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
11348 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
11349 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
11350 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
11351 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
11352 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
11353 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
11354 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
11355 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
11357 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
11358 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
11359 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
11360 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11361 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11362 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11363 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
11364 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11365 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11366 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11367 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
11368 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
11369 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
11370 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
11371 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11372 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
11373 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11374 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
11375 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11376 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
11377 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11378 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
11379 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11380 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
11381 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11382 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
11383 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
11384 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
11385 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
11386 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11387 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11388 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11389 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11390 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
11391 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
11392 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
11393 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
11394 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11395 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11396 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11397 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11398 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
11399 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11400 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11401 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11402 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11403 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11404 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11405 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11406 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11407 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11408 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11409 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11410 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11411 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11412 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11413 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11414 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
11415 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11416 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11417 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11418 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11419 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11420 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11421 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11422 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11423 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11424 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_cmd
);
11425 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11426 install_element (VIEW_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11427 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11428 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11429 install_element (VIEW_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11431 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
11432 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
11433 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
11434 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
11435 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
11436 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
11437 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
11438 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
11439 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
11440 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
11441 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
11442 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
11443 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
11444 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
11445 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
11446 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
11447 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
11448 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
11449 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
11450 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
11451 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
11452 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
11453 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
11454 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
11455 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
11456 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
11457 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
11458 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
11459 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
11460 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
11461 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
11462 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
11463 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
11464 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
11465 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
11466 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
11467 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
11468 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
11469 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
11470 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
11471 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
11472 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
11473 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
11474 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
11475 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
11476 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
11477 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
11478 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
11479 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
11480 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
11481 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
11482 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
11483 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
11484 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
11485 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
11486 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
11487 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
11488 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
11489 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
11490 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
11491 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
11492 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
11493 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
11494 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
11495 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
11496 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
11497 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
11498 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_cmd
);
11499 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_route_cmd
);
11500 install_element (ENABLE_NODE
, &show_ip_bgp_rsclient_prefix_cmd
);
11501 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_cmd
);
11502 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_route_cmd
);
11503 install_element (ENABLE_NODE
, &show_ip_bgp_view_rsclient_prefix_cmd
);
11505 /* BGP dampening clear commands */
11506 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
11507 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
11508 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
11509 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
11512 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
11513 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
11514 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
11516 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
11518 /* New config IPv6 BGP commands. */
11519 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
11520 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
11521 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
11522 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
11524 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
11525 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
11526 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
11527 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
11529 /* Old config IPv6 BGP commands. */
11530 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
11531 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
11533 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
11534 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
11535 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
11536 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
11538 install_element (VIEW_NODE
, &show_bgp_cmd
);
11539 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
11540 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
11541 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
11542 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
11543 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
11544 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
11545 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
11546 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
11547 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
11548 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
11549 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
11550 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
11551 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
11552 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
11553 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
11554 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
11555 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
11556 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
11557 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
11558 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
11559 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
11560 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
11561 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
11562 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
11563 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11564 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
11565 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11566 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
11567 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11568 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
11569 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11570 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
11571 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
11572 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
11573 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
11574 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
11575 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
11576 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
11577 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
11578 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
11579 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
11580 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
11581 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
11582 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
11583 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
11584 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
11585 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
11586 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
11587 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
11588 install_element (VIEW_NODE
, &show_bgp_rsclient_cmd
);
11589 install_element (VIEW_NODE
, &show_bgp_rsclient_route_cmd
);
11590 install_element (VIEW_NODE
, &show_bgp_rsclient_prefix_cmd
);
11591 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
11592 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
11593 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
11594 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
11595 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
11596 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11597 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
11598 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
11599 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
11600 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
11601 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
11602 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
11603 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11604 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11605 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
11606 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
11607 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
11608 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
11609 install_element (VIEW_NODE
, &show_bgp_view_rsclient_cmd
);
11610 install_element (VIEW_NODE
, &show_bgp_view_rsclient_route_cmd
);
11611 install_element (VIEW_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11613 install_element (ENABLE_NODE
, &show_bgp_cmd
);
11614 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
11615 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
11616 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
11617 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
11618 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
11619 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
11620 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
11621 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
11622 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
11623 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
11624 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
11625 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
11626 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
11627 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
11628 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
11629 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
11630 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
11631 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
11632 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
11633 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
11634 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
11635 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
11636 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
11637 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
11638 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
11639 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
11640 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
11641 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
11642 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
11643 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
11644 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
11645 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
11646 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
11647 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
11648 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
11649 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
11650 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
11651 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
11652 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
11653 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
11654 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
11655 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
11656 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
11657 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
11658 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
11659 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
11660 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
11661 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
11662 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
11663 install_element (ENABLE_NODE
, &show_bgp_rsclient_cmd
);
11664 install_element (ENABLE_NODE
, &show_bgp_rsclient_route_cmd
);
11665 install_element (ENABLE_NODE
, &show_bgp_rsclient_prefix_cmd
);
11666 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
11667 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
11668 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
11669 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
11670 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
11671 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
11672 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
11673 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
11674 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
11675 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
11676 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
11677 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
11678 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
11679 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
11680 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
11681 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
11682 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
11683 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
11684 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_cmd
);
11685 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_route_cmd
);
11686 install_element (ENABLE_NODE
, &show_bgp_view_rsclient_prefix_cmd
);
11689 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
11690 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
11691 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
11692 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
11695 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
11696 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
11697 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
11698 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
11699 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
11700 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
11701 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
11702 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
11703 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
11704 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
11705 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
11706 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
11707 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
11708 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
11709 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
11710 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
11711 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
11712 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
11713 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
11714 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
11715 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
11716 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
11717 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
11718 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
11719 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
11720 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
11721 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
11722 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
11723 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
11724 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
11725 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
11726 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
11727 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
11728 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
11729 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
11730 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
11733 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
11734 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
11735 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
11736 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
11737 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
11738 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
11739 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
11740 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
11741 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
11742 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
11743 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
11744 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
11745 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
11746 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
11747 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
11748 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
11749 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
11750 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
11751 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
11752 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
11753 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
11754 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
11755 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
11756 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
11757 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
11758 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
11759 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
11760 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
11761 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
11762 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
11763 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
11764 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
11765 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
11766 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
11767 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
11768 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
11771 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
11772 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
11773 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
11774 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
11777 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
11778 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
11779 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
11780 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
11783 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
11784 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
11785 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
11786 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
11787 #endif /* HAVE_IPV6 */
11789 install_element (BGP_NODE
, &bgp_distance_cmd
);
11790 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
11791 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
11792 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
11793 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
11794 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
11795 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
11797 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
11798 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
11799 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
11800 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
11801 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
11802 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
11803 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
11804 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
11805 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
11806 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);