1 /* Route object related function for route server.
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
35 #include "sockunion.h"
39 #include "bgpd/bgpd.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_clist.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_ecommunity.h"
47 #include "bgpd/bgp_packet.h"
48 #include "bgpd/bgp_regex.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"
56 void bgp_zebra_announce (struct prefix
*, struct bgp_info
*, struct bgp
*);
57 void bgp_zebra_withdraw (struct prefix
*, struct bgp_info
*);
59 /* Static annoucement peer. */
60 struct peer
*peer_self
;
62 /* Extern from bgp_dump.c */
63 extern char *bgp_origin_str
[];
64 extern char *bgp_origin_long_str
[];
67 bgp_route_node_get (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct prefix
*p
,
68 struct prefix_rd
*prd
)
70 struct route_node
*rn
;
71 struct route_table
*table
;
73 if (safi
== SAFI_MPLS_VPN
)
75 rn
= route_node_get (bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
78 rn
->info
= route_table_init ();
80 route_unlock_node (rn
);
84 table
= bgp
->rib
[afi
][safi
];
86 return route_node_get (table
, p
);
89 /* Allocate new bgp info structure. */
95 new = XMALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
96 memset (new, 0, sizeof (struct bgp_info
));
101 /* Free bgp route information. */
103 bgp_info_free (struct bgp_info
*br
)
105 if (br
->bgp_damp_info
)
106 br
->bgp_damp_info
->bgp_info
= NULL
;
108 bgp_attr_unintern (br
->attr
);
109 XFREE (MTYPE_BGP_ROUTE
, br
);
112 /* Add bgp route infomation to routing table node. */
114 bgp_info_add (struct bgp_info
**rp
, struct bgp_info
*ri
)
123 /* Delete rib from rib list. */
125 bgp_info_delete (struct bgp_info
**rp
, struct bgp_info
*ri
)
128 ri
->next
->prev
= ri
->prev
;
131 ri
->prev
->next
= ri
->next
;
136 /* Get MED value. If MED value is missing and "bgp bestpath
137 missing-as-worst" is specified, treat it as the worst value. */
139 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
141 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
145 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_MED_MISSING_AS_WORST
))
152 /* Compare two bgp route entity. br is preferable then return 1. */
154 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
)
157 u_int32_t exist_pref
;
160 struct in_addr new_id
;
161 struct in_addr exist_id
;
164 int internal_as_route
= 0;
165 int confed_as_route
= 0;
174 /* 1. Weight check. */
175 if (new->attr
->weight
> exist
->attr
->weight
)
177 if (new->attr
->weight
< exist
->attr
->weight
)
180 /* 2. Local preference check. */
181 if (new->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
182 new_pref
= new->attr
->local_pref
;
184 new_pref
= bgp
->default_local_pref
;
186 if (exist
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
187 exist_pref
= exist
->attr
->local_pref
;
189 exist_pref
= bgp
->default_local_pref
;
191 if (new_pref
> exist_pref
)
193 if (new_pref
< exist_pref
)
196 /* 3. Local route check. */
197 if (new->type
== ZEBRA_ROUTE_CONNECT
)
199 if (exist
->type
== ZEBRA_ROUTE_CONNECT
)
202 if (new->type
== ZEBRA_ROUTE_STATIC
)
204 if (exist
->type
== ZEBRA_ROUTE_STATIC
)
207 if (new->sub_type
== BGP_ROUTE_STATIC
)
209 if (exist
->sub_type
== BGP_ROUTE_STATIC
)
212 if (new->sub_type
== BGP_ROUTE_AGGREGATE
)
214 if (exist
->sub_type
== BGP_ROUTE_AGGREGATE
)
217 /* 4. AS path length check. */
218 if (! CHECK_FLAG (bgp
->config
, BGP_CONFIG_ASPATH_IGNORE
))
220 if (new->attr
->aspath
->count
< exist
->attr
->aspath
->count
)
222 if (new->attr
->aspath
->count
> exist
->attr
->aspath
->count
)
226 /* 5. Origin check. */
227 if (new->attr
->origin
< exist
->attr
->origin
)
229 if (new->attr
->origin
> exist
->attr
->origin
)
233 internal_as_route
= (new->attr
->aspath
->length
== 0
234 && exist
->attr
->aspath
->length
== 0);
235 confed_as_route
= (new->attr
->aspath
->length
> 0
236 && exist
->attr
->aspath
->length
> 0
237 && new->attr
->aspath
->count
== 0
238 && exist
->attr
->aspath
->count
== 0);
240 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_ALWAYS_COMPARE_MED
)
241 || (CHECK_FLAG (bgp
->config
, BGP_CONFIG_MED_CONFED
)
243 || aspath_cmp_left (new->attr
->aspath
, exist
->attr
->aspath
)
244 || aspath_cmp_left_confed (new->attr
->aspath
, exist
->attr
->aspath
)
245 || internal_as_route
)
247 new_med
= bgp_med_value (new->attr
, bgp
);
248 exist_med
= bgp_med_value (exist
->attr
, bgp
);
250 if (new_med
< exist_med
)
252 if (new_med
> exist_med
)
256 /* 7. Peer type check. */
257 if (peer_sort (new->peer
) == BGP_PEER_EBGP
258 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
)
260 if (peer_sort (new->peer
) == BGP_PEER_EBGP
261 && peer_sort (exist
->peer
) == BGP_PEER_CONFED
)
263 if (peer_sort (new->peer
) == BGP_PEER_IBGP
264 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
266 if (peer_sort (new->peer
) == BGP_PEER_CONFED
267 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
270 /* 8. IGP metric check. */
271 if (new->igpmetric
< exist
->igpmetric
)
273 if (new->igpmetric
> exist
->igpmetric
)
276 /* 9. Maximum path check. */
278 /* 10. If both paths are external, prefer the path that was received
279 first (the oldest one). This step minimizes route-flap, since a
280 newer path won't displace an older one, even if it was the
281 preferred route based on the additional decision criteria below. */
282 if (! CHECK_FLAG (bgp
->config
, BGP_CONFIG_COMPARE_ROUTER_ID
)
283 && peer_sort (new->peer
) == BGP_PEER_EBGP
284 && peer_sort (exist
->peer
) == BGP_PEER_EBGP
)
286 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
288 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
292 /* 11. Rourter-ID comparision. */
293 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
294 new_id
.s_addr
= new->attr
->originator_id
.s_addr
;
296 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
297 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
298 exist_id
.s_addr
= exist
->attr
->originator_id
.s_addr
;
300 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
302 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
304 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
307 /* 12. Cluster length comparision. */
308 if (new->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
309 new_cluster
= new->attr
->cluster
->length
;
312 if (exist
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
313 exist_cluster
= exist
->attr
->cluster
->length
;
317 if (new_cluster
< exist_cluster
)
319 if (new_cluster
> exist_cluster
)
322 /* 13. Neighbor address comparision. */
323 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
334 bgp_input_filter (struct peer_conf
*conf
, struct prefix
*p
, struct attr
*attr
,
335 afi_t afi
, safi_t safi
)
337 struct bgp_filter
*filter
;
339 filter
= &conf
->filter
[afi
][safi
];
341 if (DISTRIBUTE_IN_NAME (filter
))
342 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
345 if (PREFIX_LIST_IN_NAME (filter
))
346 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
349 if (FILTER_LIST_IN_NAME (filter
))
350 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
353 return FILTER_PERMIT
;
357 bgp_output_filter (struct peer_conf
*conf
, struct prefix
*p
, struct attr
*attr
,
358 afi_t afi
, safi_t safi
)
360 struct bgp_filter
*filter
;
362 filter
= &conf
->filter
[afi
][safi
];
364 if (DISTRIBUTE_OUT_NAME (filter
))
365 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
368 if (PREFIX_LIST_OUT_NAME (filter
))
369 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
372 if (FILTER_LIST_OUT_NAME (filter
))
373 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
376 return FILTER_PERMIT
;
379 /* If community attribute includes no_export then return 1. */
381 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
385 /* NO_ADVERTISE check. */
386 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
389 /* NO_EXPORT check. */
390 if (peer_sort (peer
) == BGP_PEER_EBGP
&&
391 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
394 /* NO_EXPORT_SUBCONFED check. */
395 if (peer_sort (peer
) == BGP_PEER_EBGP
396 || peer_sort (peer
) == BGP_PEER_CONFED
)
397 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
404 bgp_cluster_filter (struct peer_conf
*conf
, struct attr
*attr
)
406 struct in_addr cluster_id
;
408 /* Route reflection loop check. */
411 if (conf
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
412 cluster_id
= conf
->bgp
->cluster
;
414 cluster_id
= conf
->bgp
->id
;
416 if (cluster_loop_check (attr
->cluster
, cluster_id
))
422 /* Delete all kernel routes. */
428 struct route_node
*rn
;
429 struct route_table
*table
;
432 LIST_LOOP (bgp_list
, bgp
, nn
)
434 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
436 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
437 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
438 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
439 && ri
->type
== ZEBRA_ROUTE_BGP
440 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
441 bgp_zebra_withdraw (&rn
->p
, ri
);
443 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
445 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
446 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
447 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
448 && ri
->type
== ZEBRA_ROUTE_BGP
449 && ri
->sub_type
== BGP_ROUTE_NORMAL
)
450 bgp_zebra_withdraw (&rn
->p
, ri
);
458 bgp_zclient_reset ();
459 access_list_reset ();
460 prefix_list_reset ();
463 /* Apply filters and return interned struct attr. */
465 bgp_input_modifier (struct peer
*peer
, struct peer_conf
*conf
,
466 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
468 struct bgp_filter
*filter
;
469 struct bgp_info info
;
470 route_map_result_t ret
;
472 filter
= &conf
->filter
[afi
][safi
];
474 /* Apply default weight value. */
475 attr
->weight
= peer
->weight
;
477 /* Route map apply. */
478 if (ROUTE_MAP_IN_NAME (filter
))
480 /* Duplicate current value to new strucutre for modification. */
484 /* Apply BGP route map to the attribute. */
485 ret
= route_map_apply (ROUTE_MAP_IN (filter
), p
, RMAP_BGP
, &info
);
486 if (ret
== RMAP_DENYMATCH
)
488 /* Free newly generated AS path and community by route-map. */
489 bgp_attr_flush (attr
);
496 /* Set a route to Adj-RIBs-In or Adj-RIBs-Out. In case of attr is
497 NULL, it only store prefix information. */
499 bgp_adj_set (struct route_table
*table
, struct prefix
*p
, struct attr
*attr
,
500 struct prefix_rd
*prd
, safi_t safi
)
502 struct route_node
*rn
;
507 if (safi
== SAFI_MPLS_VPN
)
509 rn
= route_node_get (table
, (struct prefix
*)prd
);
510 if (rn
->info
== NULL
)
511 rn
->info
= route_table_init ();
513 route_unlock_node (rn
);
518 rn
= route_node_get (table
, p
);
522 bgp_attr_unintern (rn
->info
);
523 route_unlock_node (rn
);
527 rn
->info
= bgp_attr_intern (attr
);
534 /* Unset a route from Adj-RIBs-In or Adj-RIBs-Out. If bgp_adj_set()
535 only store prefix information, this function detect it and properly
538 bgp_adj_unset (struct route_table
*table
, struct prefix
*p
,
539 struct prefix_rd
*prd
, safi_t safi
)
541 struct route_node
*rn
;
546 if (safi
== SAFI_MPLS_VPN
)
548 rn
= route_node_lookup (table
, (struct prefix
*)prd
);
554 rn
= route_node_lookup (table
, p
);
559 bgp_attr_unintern (rn
->info
);
561 route_unlock_node (rn
);
562 route_unlock_node (rn
);
566 /* Check the prefix is in Adj-RIBs-In or Adj-RIBs-Out. */
568 bgp_adj_lookup (struct route_table
*table
, struct prefix
*p
,
569 struct prefix_rd
*prd
, safi_t safi
)
571 struct route_node
*rn
;
572 struct route_node
*rm
;
579 if (safi
== SAFI_MPLS_VPN
)
581 rn
= route_node_lookup (table
, (struct prefix
*) prd
);
587 rm
= route_node_lookup (table
, p
);
591 route_unlock_node (rm
);
594 route_unlock_node (rn
);
599 /* Clear entire table. */
601 bgp_adj_clear (struct route_table
*table
, safi_t safi
)
603 struct route_node
*rn
;
608 if (safi
== SAFI_MPLS_VPN
)
610 struct route_table
*pt
;
611 struct route_node
*rm
;
613 for (rm
= route_top(table
); rm
; rm
= route_next (rm
))
614 if ((pt
= rm
->info
) != NULL
)
616 for (rn
= route_top (pt
); rn
; rn
= route_next (rn
))
620 bgp_attr_unintern (rn
->info
);
622 route_unlock_node (rn
);
628 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
632 bgp_attr_unintern (rn
->info
);
634 route_unlock_node (rn
);
639 bgp_announce_check (struct bgp_info
*ri
, struct peer_conf
*conf
,
640 struct prefix
*p
, struct attr
*attr
, afi_t afi
, safi_t safi
)
643 char buf
[SU_ADDRSTRLEN
];
644 struct bgp_filter
*filter
;
645 struct bgp_info info
;
649 struct attr dummy_attr
;
654 filter
= &conf
->filter
[afi
][safi
];
657 #ifdef DISABLE_BGP_ANNOUNCE
661 /* Do not send back route to sender. */
665 /* Aggregate-address suppress check. */
669 /* If community is not disabled check the no-export and local. */
670 if (bgp_community_filter (peer
, ri
->attr
))
673 /* If the attribute has originator-id and it is same as remote
675 if (ri
->attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
))
677 if (IPV4_ADDR_SAME (&peer
->remote_id
, &ri
->attr
->originator_id
))
679 if (BGP_DEBUG (filter
, FILTER
))
680 zlog (peer
->log
, LOG_INFO
,
681 "%s [Update:SEND] %s/%d originator-id is same as remote router-id",
683 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
689 /* Output filter check. */
690 if (bgp_output_filter (conf
, p
, ri
->attr
, afi
, safi
) == FILTER_DENY
)
692 if (BGP_DEBUG (filter
, FILTER
))
693 zlog (peer
->log
, LOG_INFO
,
694 "%s [Update:SEND] %s/%d is filtered",
696 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
701 /* Default route check. */
702 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
703 && ! (CHECK_FLAG (peer
->flags
, PEER_FLAG_DEFAULT_ORIGINATE
)))
705 if (BGP_DEBUG (filter
, FILTER
))
706 zlog (peer
->log
, LOG_INFO
,
707 "%s [Update:SEND] default route announcement is suppressed",
712 if (p
->family
== AF_INET6
&& p
->prefixlen
== 0
713 && ! (CHECK_FLAG (peer
->flags
, PEER_FLAG_DEFAULT_ORIGINATE
)))
715 if (BGP_DEBUG (filter
, FILTER
))
716 zlog (peer
->log
, LOG_INFO
,
717 "%s [Update:SEND] IPv6 default route announcement is suppressed",
721 #endif /* HAVE_IPV6 */
723 #ifdef BGP_SEND_ASPATH_CHECK
724 /* AS path loop check. */
725 if (aspath_loop_check (ri
->attr
->aspath
, peer
->as
))
727 if (BGP_DEBUG (filter
, FILTER
))
728 zlog (peer
->log
, LOG_INFO
,
729 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
730 peer
->host
, peer
->as
);
733 #endif /* BGP_SEND_ASPATH_CHECK */
735 /* If we're a CONFED we need to loop check the CONFED ID too */
736 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
738 if (aspath_loop_check(ri
->attr
->aspath
, bgp
->confederation_id
))
740 if (BGP_DEBUG (filter
, FILTER
))
741 zlog (peer
->log
, LOG_INFO
,
742 "%s [Update:SEND] suppress announcement to peer AS %d is AS path.",
744 bgp
->confederation_id
);
749 /* IBGP reflection check. */
750 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
752 /* A route from a Client peer. */
753 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
755 /* Reflect to all the Non-Client peers and also to the
756 Client peers other than the originator. Originator check
757 is already done. So there is noting to do. */
758 /* no bgp client-to-client reflection check. */
759 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_NO_CLIENT_TO_CLIENT
))
760 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
765 /* A route from a Non-client peer. Reflect to all other
767 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
772 /* For modify attribute, copy it to temporary structure. */
775 /* If local-preference is not set. */
776 if ((peer_sort (peer
) == BGP_PEER_IBGP
777 || peer_sort (peer
) == BGP_PEER_CONFED
)
778 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
780 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
781 attr
->local_pref
= bgp
->default_local_pref
;
784 /* Transparency check. */
785 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
786 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
791 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
794 /* Route Server Clients are transparent MED.
795 So there is noting to do. */
799 if (peer_sort (peer
) == BGP_PEER_EBGP
800 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
)
801 && ri
->peer
!= peer_self
)
802 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
806 if (transparent
|| CHECK_FLAG (peer
->flags
, PEER_FLAG_TRANSPARENT_NEXTHOP
))
808 /* Route Server Clients are transparent NEXT-HOP.
809 So there is noting to do. */
811 else if (! (peer_sort (from
) == BGP_PEER_IBGP
812 && peer_sort (peer
) == BGP_PEER_IBGP
))
814 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
815 || (p
->family
== AF_INET
&& attr
->nexthop
.s_addr
== 0)
817 || (p
->family
== AF_INET6
&& ri
->peer
== peer_self
)
818 #endif /* HAVE_IPV6 */
819 || ((peer_sort (peer
) == BGP_PEER_EBGP
820 && bgp_multiaccess_check_v4 (attr
->nexthop
, peer
->host
) == 0)))
822 /* Set IPv4 nexthop. */
823 if (safi
== SAFI_MPLS_VPN
)
824 memcpy (&attr
->mp_nexthop_global_in
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
826 memcpy (&attr
->nexthop
, &peer
->nexthop
.v4
, IPV4_MAX_BYTELEN
);
829 /* Set IPv6 nexthop. */
830 if (p
->family
== AF_INET6
)
832 /* IPv6 global nexthop must be included. */
833 memcpy (&attr
->mp_nexthop_global
, &peer
->nexthop
.v6_global
,
835 attr
->mp_nexthop_len
= 16;
837 /* If the peer is on shared nextwork and we have link-local
839 if (peer
->shared_network
840 && !IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
842 memcpy (&attr
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
844 attr
->mp_nexthop_len
= 32;
847 #endif /* HAVE_IPV6 */
852 if (p
->family
== AF_INET6
)
854 /* Link-local address should not be transit to different peer. */
855 attr
->mp_nexthop_len
= 16;
857 /* Set link-local address for shared network peer. */
858 if (peer
->shared_network
859 && ! IN6_IS_ADDR_UNSPECIFIED (&peer
->nexthop
.v6_local
))
861 memcpy (&attr
->mp_nexthop_local
, &peer
->nexthop
.v6_local
,
863 attr
->mp_nexthop_len
= 32;
866 #endif /* HAVE_IPV6 */
871 /* If bgpd act as BGP-4+ route-reflector, do not send link-local
873 if (peer_sort (from
) == BGP_PEER_IBGP
&& peer_sort (peer
) == BGP_PEER_IBGP
)
874 attr
->mp_nexthop_len
= 16;
876 /* If BGP-4+ link-local nexthop is not link-local nexthop. */
877 if (! IN6_IS_ADDR_LINKLOCAL (&peer
->nexthop
.v6_local
))
878 attr
->mp_nexthop_len
= 16;
879 #endif /* HAVE_IPV6 */
881 /* Route map apply. */
882 if (ROUTE_MAP_OUT_NAME (filter
))
887 /* The route reflector is not allowed to modify the attributes
888 of the reflected IBGP routes. */
889 if (peer_sort (from
) == BGP_PEER_IBGP
890 && peer_sort (peer
) == BGP_PEER_IBGP
)
893 info
.attr
= &dummy_attr
;
896 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
897 if (ret
== RMAP_DENYMATCH
)
899 bgp_attr_flush (attr
);
906 /* Announce selected routes to the conf->peer. */
908 bgp_announce_rib (struct peer_conf
*conf
, afi_t afi
, safi_t safi
)
910 struct route_node
*rn
;
914 for (rn
= route_top (conf
->bgp
->rib
[afi
][safi
]); rn
; rn
= route_next(rn
))
915 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
917 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
918 && ri
->peer
!= conf
->peer
)
919 if (bgp_announce_check (ri
, conf
, &rn
->p
, &attr
, afi
, safi
))
921 bgp_update_send (conf
, conf
->peer
, &rn
->p
, &attr
, afi
, safi
,
922 ri
->peer
, NULL
, NULL
);
923 bgp_adj_set (conf
->peer
->adj_out
[afi
][safi
], &rn
->p
, &attr
,
930 bgp_announce_rib_vpnv4 (struct peer_conf
*conf
, afi_t afi
, safi_t safi
)
932 struct route_node
*rn
;
933 struct route_node
*rm
;
934 struct route_table
*table
;
938 for (rn
= route_top (conf
->bgp
->rib
[afi
][safi
]); rn
; rn
= route_next(rn
))
939 if ((table
= (rn
->info
)) != NULL
)
941 for (rm
= route_top (table
); rm
; rm
= route_next (rm
))
942 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
944 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
945 && ri
->peer
!= conf
->peer
)
946 if (bgp_announce_check ((struct bgp_info
*)ri
, conf
,
947 &rm
->p
, &attr
, afi
, safi
))
949 bgp_update_send (conf
, conf
->peer
, &rm
->p
, &attr
,
951 (struct prefix_rd
*) &rn
->p
, ri
->tag
);
952 bgp_adj_set (conf
->peer
->adj_out
[afi
][safi
], &rm
->p
,
953 &attr
, (struct prefix_rd
*)&rn
->p
, safi
);
959 /* Refresh routes conf->peer. */
961 bgp_refresh_rib (struct peer_conf
*conf
, afi_t afi
, safi_t safi
)
963 struct route_node
*rn
;
967 for (rn
= route_top (conf
->bgp
->rib
[afi
][safi
]); rn
; rn
= route_next(rn
))
968 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
969 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
) && ri
->peer
!= conf
->peer
)
971 if (bgp_announce_check (ri
, conf
, &rn
->p
, &attr
, afi
, safi
))
973 bgp_update_send (conf
, conf
->peer
, &rn
->p
, &attr
, afi
, safi
,
974 ri
->peer
, NULL
, NULL
);
975 bgp_adj_set (conf
->peer
->adj_out
[afi
][safi
], &rn
->p
, &attr
,
980 /* Send withdraw to the peer */
981 if (bgp_adj_lookup (conf
->peer
->adj_out
[afi
][safi
], &rn
->p
,
984 bgp_withdraw_send (conf
->peer
, &rn
->p
, afi
, safi
, NULL
,
986 bgp_adj_unset (conf
->peer
->adj_out
[afi
][safi
], &rn
->p
, NULL
,
993 /* Refresh routes conf->peer. */
995 bgp_refresh_rib_vpnv4 (struct peer_conf
*conf
, afi_t afi
, safi_t safi
)
997 struct route_node
*rn
;
998 struct route_node
*rm
;
999 struct route_table
*table
;
1000 struct bgp_info
*ri
;
1003 for (rn
= route_top (conf
->bgp
->rib
[afi
][safi
]); rn
; rn
= route_next(rn
))
1004 if ((table
= rn
->info
) != NULL
)
1006 for (rm
= route_top (table
); rm
; rm
= route_next (rm
))
1007 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
1008 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
1009 && ri
->peer
!= conf
->peer
)
1011 if (bgp_announce_check ((struct bgp_info
*)ri
, conf
, &rm
->p
,
1014 bgp_update_send (conf
, conf
->peer
, &rm
->p
, &attr
,
1015 afi
, safi
, ri
->peer
,
1016 (struct prefix_rd
*) &rn
->p
, ri
->tag
);
1017 bgp_adj_set (conf
->peer
->adj_out
[afi
][safi
], &rm
->p
,
1018 &attr
, (struct prefix_rd
*) &rn
->p
, safi
);
1022 /* Send withdraw to the peer */
1023 if (bgp_adj_lookup (conf
->peer
->adj_out
[afi
][safi
], &rm
->p
,
1024 (struct prefix_rd
*) &rn
->p
, safi
))
1026 bgp_withdraw_send (conf
->peer
, &rm
->p
, afi
, safi
,
1027 (struct prefix_rd
*) &rn
->p
, ri
->tag
);
1028 bgp_adj_unset (conf
->peer
->adj_out
[afi
][safi
],
1029 &rm
->p
, (struct prefix_rd
*) &rn
->p
, safi
);
1036 /* Announce current routing table to the peer when peer gets
1039 bgp_announce_table (struct peer
*peer
)
1041 struct listnode
*nn
;
1042 struct peer_conf
*conf
;
1044 LIST_LOOP (peer
->conf
, conf
, nn
)
1046 if (conf
->peer
->afc_nego
[AFI_IP
][SAFI_UNICAST
])
1047 bgp_announce_rib (conf
, AFI_IP
, SAFI_UNICAST
);
1048 if (conf
->peer
->afc_nego
[AFI_IP
][SAFI_MULTICAST
])
1049 bgp_announce_rib (conf
, AFI_IP
, SAFI_MULTICAST
);
1050 if (conf
->peer
->afc_nego
[AFI_IP6
][SAFI_UNICAST
])
1051 bgp_announce_rib (conf
, AFI_IP6
, SAFI_UNICAST
);
1052 if (conf
->peer
->afc_nego
[AFI_IP6
][SAFI_MULTICAST
])
1053 bgp_announce_rib (conf
, AFI_IP6
, SAFI_MULTICAST
);
1056 if (conf
->peer
->afc_nego
[AFI_IP
][SAFI_MPLS_VPN
])
1057 bgp_announce_rib_vpnv4 (conf
, AFI_IP
, SAFI_MPLS_VPN
);
1061 /* Announce current routing table to the peer when peer gets
1064 bgp_refresh_table (struct peer
*peer
, afi_t afi
, safi_t safi
)
1066 struct listnode
*nn
;
1067 struct peer_conf
*conf
;
1069 LIST_LOOP (peer
->conf
, conf
, nn
)
1071 if (conf
->peer
->afc_nego
[afi
][safi
])
1073 if (safi
== SAFI_MPLS_VPN
)
1074 bgp_refresh_rib_vpnv4 (conf
, afi
, safi
);
1076 bgp_refresh_rib (conf
, afi
, safi
);
1081 /* Process changed routing entry. */
1083 bgp_process (struct bgp
*bgp
, struct route_node
*rn
, afi_t afi
, safi_t safi
,
1084 struct bgp_info
*del
, struct prefix_rd
*prd
, u_char
*tag
)
1087 struct bgp_info
*ri
;
1088 struct bgp_info
*new_select
;
1089 struct bgp_info
*old_select
;
1090 struct listnode
*nn
;
1091 struct peer_conf
*conf_to
;
1092 struct peer
*peer_to
;
1094 struct bgp_info
*ri1
;
1095 struct bgp_info
*ri2
;
1099 /* bgp deterministic-med */
1101 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_DETERMINISTIC_MED
))
1102 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1104 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1106 if (BGP_INFO_HOLDDOWN (ri1
))
1111 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1113 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1115 if (BGP_INFO_HOLDDOWN (ri2
))
1118 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1119 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1122 if (bgp_info_cmp (bgp
, ri2
, new_select
))
1124 UNSET_FLAG (new_select
->flags
, BGP_INFO_DMED_SELECTED
);
1128 SET_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
);
1131 SET_FLAG (new_select
->flags
, BGP_INFO_DMED_CHECK
);
1132 SET_FLAG (new_select
->flags
, BGP_INFO_DMED_SELECTED
);
1135 /* Check old selected route and new selected route. */
1138 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1140 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1143 if (BGP_INFO_HOLDDOWN (ri
))
1146 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_DETERMINISTIC_MED
)
1147 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1149 UNSET_FLAG (ri
->flags
, BGP_INFO_DMED_CHECK
);
1152 UNSET_FLAG (ri
->flags
, BGP_INFO_DMED_CHECK
);
1153 UNSET_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
);
1155 if (bgp_info_cmp (bgp
, ri
, new_select
))
1159 /* Nothing to do. */
1160 if (old_select
&& old_select
== new_select
)
1162 if (! CHECK_FLAG (old_select
->flags
, BGP_INFO_ATTR_CHANGED
))
1164 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
))
1165 bgp_zebra_announce (p
, old_select
, bgp
);
1171 UNSET_FLAG (old_select
->flags
, BGP_INFO_SELECTED
);
1174 SET_FLAG (new_select
->flags
, BGP_INFO_SELECTED
);
1175 UNSET_FLAG (new_select
->flags
, BGP_INFO_ATTR_CHANGED
);
1178 /* Check each BGP peer. */
1179 LIST_LOOP (bgp
->peer_conf
, conf_to
, nn
)
1181 peer_to
= conf_to
->peer
;
1183 /* Announce route to Established peer. */
1184 if (peer_to
->status
!= Established
)
1187 /* Address family configuration check. */
1188 if (! conf_to
->peer
->afc_nego
[afi
][safi
])
1191 /* Announcement to peer->conf. If the route is filtered,
1194 && bgp_announce_check (new_select
, conf_to
, p
, &attr
, afi
, safi
))
1196 /* Send update to the peer. */
1197 bgp_update_send (conf_to
, peer_to
, p
, &attr
, afi
, safi
,
1198 new_select
->peer
, prd
, tag
);
1199 bgp_adj_set (peer_to
->adj_out
[afi
][safi
], p
, &attr
, prd
, safi
);
1203 /* Send withdraw to the peer */
1204 if (bgp_adj_lookup (peer_to
->adj_out
[afi
][safi
], p
, prd
, safi
))
1206 bgp_withdraw_send (peer_to
, p
, afi
, safi
, prd
, tag
);
1207 bgp_adj_unset (peer_to
->adj_out
[afi
][safi
], p
, prd
, safi
);
1213 if (safi
== SAFI_UNICAST
&& ! bgp
->name
&& ! no_kernel_mode
)
1216 && new_select
->type
== ZEBRA_ROUTE_BGP
1217 && new_select
->sub_type
== BGP_ROUTE_NORMAL
)
1218 bgp_zebra_announce (p
, new_select
, bgp
);
1221 /* In case of selected route is deleted check the pointer. */
1223 && del
&& CHECK_FLAG (del
->flags
, BGP_INFO_SELECTED
))
1226 /* Withdraw the route from the kernel. */
1228 && old_select
->type
== ZEBRA_ROUTE_BGP
1229 && old_select
->sub_type
== BGP_ROUTE_NORMAL
)
1230 bgp_zebra_withdraw (p
, old_select
);
1236 /* maximum-prefix check. */
1238 bgp_maximum_prefix_overflow (struct peer_conf
*conf
, afi_t afi
, safi_t safi
)
1242 if (conf
->pmax
[afi
][safi
]
1243 && conf
->pcount
[afi
][safi
] >= conf
->pmax
[afi
][safi
])
1246 zlog (peer
->log
, LOG_INFO
,
1247 "MAXPFXEXCEED: No. of prefix received from %s (afi %d): %ld exceed limit %ld",
1248 peer
->host
, afi
, conf
->pcount
[afi
][safi
], conf
->pmax
[afi
][safi
]);
1249 if (! conf
->pmax_warning
[afi
][safi
])
1251 BGP_EVENT_ADD (peer
, BGP_Stop
);
1252 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1260 bgp_implicit_withdraw (struct peer_conf
*conf
, struct bgp
*bgp
,
1261 struct prefix
*p
, struct bgp_info
*ri
,
1262 struct route_node
*rn
, afi_t afi
, safi_t safi
)
1264 conf
->pcount
[afi
][safi
]--;
1265 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
1266 bgp_info_delete ((struct bgp_info
**) &rn
->info
, ri
);
1268 route_unlock_node (rn
);
1271 /* Generic function for update BGP information. This function only
1272 update routing table information. To announce change we have to
1273 call bgp_process(). */
1275 bgp_update (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1276 afi_t afi
, safi_t safi
, int type
, int sub_type
,
1277 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
1279 struct listnode
*nn
;
1280 struct route_node
*rn
;
1282 struct peer_conf
*conf
;
1283 struct attr new_attr
;
1284 struct bgp_info
*ri
;
1285 struct bgp_info
*new;
1286 char buf
[SU_ADDRSTRLEN
];
1287 int bgp_damp_update (struct bgp_info
*);
1289 /* Check this route's origin is not static/aggregate/redistributed
1291 if (peer
!= peer_self
&& ! soft_reconfig
)
1293 /* If peer is soft reconfiguration enabled. Record input packet for
1294 further calculation. */
1295 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
1296 bgp_adj_set (peer
->adj_in
[afi
][safi
], p
, attr
, prd
, safi
);
1299 /* Kick each configuration BGP instance. */
1300 LIST_LOOP (peer
->conf
, conf
, nn
)
1305 rn
= bgp_route_node_get (bgp
, afi
, safi
, p
, prd
);
1307 /* Check selected route and self inserted route. */
1308 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1309 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1312 /* Aspath loop check. */
1313 if (aspath_loop_check (attr
->aspath
, bgp
->as
)
1314 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
1315 && aspath_loop_check(attr
->aspath
, bgp
->confederation_id
)))
1317 /* If the update is implicit withdraw. */
1319 bgp_implicit_withdraw (conf
, bgp
, p
, ri
, rn
, afi
, safi
);
1321 if (BGP_DEBUG (update
, UPDATE_IN
))
1322 zlog (peer
->log
, LOG_INFO
,
1323 "%s rcvd UPDATE about %s/%d -- DENIED due to: as-path contains our own AS;",
1325 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1327 /* Process change. */
1328 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1329 route_unlock_node (rn
);
1333 /* Route reflector originator ID check. */
1334 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
1335 && IPV4_ADDR_SAME (&bgp
->id
, &attr
->originator_id
))
1337 /* If the update is implicit withdraw. */
1339 bgp_implicit_withdraw (conf
, bgp
, p
, ri
, rn
, afi
, safi
);
1341 if (BGP_DEBUG (update
, UPDATE_IN
))
1342 zlog (peer
->log
, LOG_INFO
,
1343 "%s rcvd UPDATE about %s/%d -- DENIED due to: originator is us;",
1345 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1347 /* Process change. */
1348 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1349 route_unlock_node (rn
);
1353 /* Route reflector cluster ID check. */
1354 if (bgp_cluster_filter (conf
, attr
))
1356 /* If the update is implicit withdraw. */
1358 bgp_implicit_withdraw (conf
, bgp
, p
, ri
, rn
, afi
, safi
);
1360 if (BGP_DEBUG (update
, UPDATE_IN
))
1361 zlog (peer
->log
, LOG_INFO
,
1362 "%s rcvd UPDATE about %s/%d -- DENIED due to: reflected from the same cluster;",
1364 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1366 /* Process change. */
1367 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1368 route_unlock_node (rn
);
1372 /* Apply input filter and route-map. Filter and route-map
1373 application logging is also don in the function. */
1374 if (bgp_input_filter (conf
, p
, attr
, afi
, safi
) == FILTER_DENY
)
1376 /* If the update is implicit withdraw. */
1378 bgp_implicit_withdraw (conf
, bgp
, p
, ri
, rn
, afi
, safi
);
1380 if (BGP_DEBUG (update
, UPDATE_IN
))
1382 zlog (peer
->log
, LOG_INFO
,
1383 "%s rcvd UPDATE about %s/%d -- DENIED due to: filter;",
1385 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1388 /* Process change. */
1389 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1390 route_unlock_node (rn
);
1394 /* Apply input route-map. */
1397 if (bgp_input_modifier (peer
, conf
, p
, &new_attr
, afi
, safi
) == RMAP_DENY
)
1399 /* If the update is implicit withdraw. */
1401 bgp_implicit_withdraw (conf
, bgp
, p
, ri
, rn
, afi
, safi
);
1403 if (BGP_DEBUG (update
, UPDATE_IN
))
1405 zlog (peer
->log
, LOG_INFO
,
1406 "%s rcvd UPDATE about %s/%d -- DENIED due to: route-map;",
1408 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1411 /* Process change. */
1412 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1413 route_unlock_node (rn
);
1417 /* If the peer is EBGP and nexthop is not on connected route,
1419 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
1420 && peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
== 1)
1422 if (! bgp_nexthop_check_ebgp (afi
, &new_attr
))
1424 /* Debug information. */
1425 if (BGP_DEBUG (update
, UPDATE_IN
))
1427 zlog (peer
->log
, LOG_INFO
,
1428 "%s rcvd UPDATE about %s/%d -- DENIED due to: non-connected next-hop;",
1430 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1434 /* Perform implicit withdraw. */
1436 bgp_implicit_withdraw (conf
, bgp
, p
, ri
, rn
, afi
, safi
);
1438 /* Process change. */
1439 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1440 route_unlock_node (rn
);
1445 /* Check nexthop. */
1446 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
1448 if (bgp_nexthop_self (afi
, &new_attr
)
1449 || new_attr
.nexthop
.s_addr
== 0
1450 || ntohl (new_attr
.nexthop
.s_addr
) >= 0xe0000000)
1452 /* Debug information. */
1453 if (BGP_DEBUG (update
, UPDATE_IN
))
1455 zlog (peer
->log
, LOG_INFO
,
1456 "%s rcvd UPDATE about %s/%d -- DENIED due to: martian next-hop;",
1458 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1462 /* Perform implicit withdraw. */
1464 bgp_implicit_withdraw (conf
, bgp
, p
, ri
, rn
, afi
, safi
);
1466 /* Process change. */
1467 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1468 route_unlock_node (rn
);
1473 /* If the update is implicit withdraw. */
1476 /* Update BGP flap dampening information. */
1477 if (ri
->bgp_damp_info
)
1478 bgp_damp_update (ri
);
1480 /* Same attribute comes in. */
1481 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
)
1482 && attrhash_cmp (ri
->attr
, &new_attr
))
1484 UNSET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
1486 if (BGP_DEBUG (update
, UPDATE_IN
))
1487 zlog (peer
->log
, LOG_INFO
,
1488 "%s rcvd %s/%d...duplicate ignored",
1490 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1493 ri
->uptime
= time (NULL
);
1494 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1495 route_unlock_node (rn
);
1500 /* Received Logging. */
1501 if (BGP_DEBUG (update
, UPDATE_IN
))
1502 zlog (peer
->log
, LOG_INFO
, "%s rcvd %s/%d",
1504 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1507 /* The attribute is changed. */
1508 SET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
1510 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1512 UNSET_FLAG (ri
->flags
, BGP_INFO_HISTORY
);
1513 conf
->pcount
[afi
][safi
]++;
1516 /* Rewrite BGP route information. */
1517 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
1518 bgp_attr_unintern (ri
->attr
);
1519 ri
->attr
= bgp_attr_intern (&new_attr
);
1520 ri
->uptime
= time (NULL
);
1522 /* Update MPLS tag. */
1523 if (safi
== SAFI_MPLS_VPN
)
1524 memcpy (ri
->tag
, tag
, 3);
1526 /* Nexthop reachability check. */
1527 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
1528 && safi
== SAFI_UNICAST
1529 && (peer_sort (peer
) == BGP_PEER_IBGP
||
1530 (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)))
1532 if (bgp_nexthop_lookup (afi
, peer
, ri
, NULL
, NULL
))
1533 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
1535 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
1538 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
1540 /* Process change. */
1541 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
1542 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1543 route_unlock_node (rn
);
1547 /* Received Logging. */
1548 if (BGP_DEBUG (update
, UPDATE_IN
))
1550 zlog (peer
->log
, LOG_INFO
, "%s rcvd %s/%d",
1552 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1556 /* Increment prefix counter */
1557 conf
->pcount
[afi
][safi
]++;
1559 /* Make new BGP info. */
1560 new = bgp_info_new ();
1562 new->sub_type
= sub_type
;
1564 new->attr
= bgp_attr_intern (&new_attr
);
1565 new->uptime
= time (NULL
);
1567 /* Update MPLS tag. */
1568 if (safi
== SAFI_MPLS_VPN
)
1569 memcpy (new->tag
, tag
, 3);
1571 /* Nexthop reachability check. */
1572 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
1573 && safi
== SAFI_UNICAST
1574 && (peer_sort (peer
) == BGP_PEER_IBGP
1575 || (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)))
1577 if (bgp_nexthop_lookup (afi
, peer
, new, NULL
, NULL
))
1578 SET_FLAG (new->flags
, BGP_INFO_VALID
);
1580 UNSET_FLAG (new->flags
, BGP_INFO_VALID
);
1583 SET_FLAG (new->flags
, BGP_INFO_VALID
);
1585 /* Aggregate address increment. */
1586 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
1588 /* Register new BGP information. */
1589 bgp_info_add ((struct bgp_info
**) &rn
->info
, new);
1591 /* If maximum prefix count is configured and current prefix
1593 if (! conf
->pmax_warning
[afi
][safi
])
1594 if (bgp_maximum_prefix_overflow (conf
, afi
, safi
))
1597 /* Process change. */
1598 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
1603 /* Generic function for withdraw BGP information */
1605 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1606 int afi
, int safi
, int type
, int sub_type
, struct prefix_rd
*prd
,
1609 struct peer_conf
*conf
;
1610 struct listnode
*nn
;
1612 char buf
[SU_ADDRSTRLEN
];
1613 struct route_node
*rn
;
1614 struct bgp_info
*ri
;
1615 int bgp_damp_withdraw(struct bgp_info
*);
1618 if (peer
!= peer_self
)
1620 /* If peer is soft reconfiguration enabled. Record input packet for
1621 further calculation. */
1622 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
1623 bgp_adj_unset (peer
->adj_in
[afi
][safi
], p
, prd
, safi
);
1626 LIST_LOOP (peer
->conf
, conf
, nn
)
1631 if (BGP_DEBUG (update
, UPDATE_IN
))
1632 zlog (peer
->log
, LOG_INFO
, "%s rcvd UPDATE about %s/%d -- withdrawn",
1633 peer
->host
, inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1637 rn
= bgp_route_node_get (bgp
, afi
, safi
, p
, prd
);
1639 /* Check selected route and self inserted route. */
1640 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1641 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
)
1644 /* Withdraw specified route from routing table. */
1645 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
1647 status
= BGP_DAMP_DISABLED
;
1649 if (peer_sort (peer
) != BGP_PEER_IBGP
1650 && peer_sort (peer
) != BGP_PEER_CONFED
)
1652 status
= bgp_damp_withdraw (ri
);
1654 if (status
== BGP_DAMP_CONTINUE
1655 || status
== BGP_DAMP_DISCONTINUE
)
1657 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
1658 bgp_process (bgp
, rn
, afi
, safi
, ri
, prd
, tag
);
1659 conf
->pcount
[afi
][safi
]--;
1663 if (status
== BGP_DAMP_DISABLED
)
1665 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
1666 bgp_info_delete ((struct bgp_info
**) &rn
->info
, ri
);
1667 bgp_process (bgp
, rn
, afi
, safi
, ri
, prd
, tag
);
1669 route_unlock_node (rn
);
1671 /* Prefix count updates. */
1672 conf
->pcount
[afi
][safi
]--;
1677 if (BGP_DEBUG (update
, UPDATE_IN
))
1678 zlog (peer
->log
, LOG_INFO
,
1679 "%s Can't find the route %s/%d", peer
->host
,
1680 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1684 /* Unlock route_node_get() lock. */
1685 route_unlock_node (rn
);
1690 /* Parser of NLRI octet stream. Withdraw NLRI is recognized by NULL
1693 nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
1701 /* Check peer status. */
1702 if (peer
->status
!= Established
)
1706 lim
= pnt
+ packet
->length
;
1708 for (; pnt
< lim
; pnt
+= psize
)
1710 /* Clear prefix structure. */
1711 memset (&p
, 0, sizeof (struct prefix
));
1713 /* Fetch prefix length. */
1714 p
.prefixlen
= *pnt
++;
1715 p
.family
= afi2family (packet
->afi
);
1717 /* Already checked in nlri_sanity_check(). We do double check
1719 if ((packet
->afi
== AFI_IP
&& p
.prefixlen
> 32)
1720 || (packet
->afi
== AFI_IP6
&& p
.prefixlen
> 128))
1723 /* Packet size overflow check. */
1724 psize
= PSIZE (p
.prefixlen
);
1726 /* When packet overflow occur return immediately. */
1727 if (pnt
+ psize
> lim
)
1730 /* Fetch prefix from NLRI packet. */
1731 memcpy (&p
.u
.prefix
, pnt
, psize
);
1733 /* Check address. */
1734 if (packet
->afi
== AFI_IP
&& packet
->safi
== SAFI_UNICAST
)
1736 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
1738 zlog (peer
->log
, LOG_ERR
,
1739 "IPv4 unicast NLRI is multicast address %s",
1740 inet_ntoa (p
.u
.prefix4
));
1741 bgp_notify_send (peer
,
1742 BGP_NOTIFY_UPDATE_ERR
,
1743 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
1749 /* Check address. */
1750 if (packet
->afi
== AFI_IP6
&& packet
->safi
== SAFI_UNICAST
)
1752 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
1756 zlog (peer
->log
, LOG_WARNING
,
1757 "IPv6 link-local NLRI received %s ignore this NLRI",
1758 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
1763 #endif /* HAVE_IPV6 */
1765 /* Translate update. Convert unicast update to multicast update. */
1766 if (packet
->safi
== SAFI_UNICAST
&& peer
->translate_update
)
1769 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, SAFI_MULTICAST
,
1770 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
1772 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, SAFI_MULTICAST
,
1773 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
1778 /* Do not process unicast update when translate update is
1779 only to multicast. */
1780 if (packet
->safi
== SAFI_UNICAST
1781 && peer
->translate_update
== SAFI_MULTICAST
)
1784 /* Normal process. */
1786 ret
= bgp_update (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
1787 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
1789 ret
= bgp_withdraw (peer
, &p
, attr
, packet
->afi
, packet
->safi
,
1790 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
1792 /* Address family configuration mismatch or maximum-prefix count
1798 /* Packet length consistency check. */
1805 /* NLRI encode syntax check routine. */
1807 nlri_sanity_check (struct peer
*peer
, int afi
, u_char
*pnt
, bgp_size_t length
)
1815 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
1816 syntactic validity. If the field is syntactically incorrect,
1817 then the Error Subcode is set to Invalid Network Field. */
1823 /* Prefix length check. */
1824 if ((afi
== AFI_IP
&& prefixlen
> 32)
1825 || (afi
== AFI_IP6
&& prefixlen
> 128))
1827 plog_err (peer
->log
,
1828 "%s [Error] Update packet error (wrong prefix length %d)",
1829 peer
->host
, prefixlen
);
1830 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
1831 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
1835 /* Packet size overflow check. */
1836 psize
= PSIZE (prefixlen
);
1838 if (pnt
+ psize
> end
)
1840 plog_err (peer
->log
,
1841 "%s [Error] Update packet error"
1842 " (prefix data overflow prefix size is %d)",
1844 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
1845 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
1852 /* Packet length consistency check. */
1855 plog_err (peer
->log
,
1856 "%s [Error] Update packet error"
1857 " (prefix length mismatch with total length)",
1859 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
1860 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
1866 /* Soft reconfiguration for input. */
1868 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
1871 struct route_node
*rn
;
1874 for (rn
= route_top (peer
->adj_in
[afi
][safi
]); rn
; rn
= route_next (rn
))
1875 if ((attr
= rn
->info
) != NULL
)
1877 ret
= bgp_update (peer
, &rn
->p
, attr
, afi
, safi
,
1878 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
1881 /* Address family configuration mismatch or maximum-prefix count
1885 route_unlock_node (rn
);
1891 /* Remove all routes from the peer. */
1893 bgp_route_clear_with_afi (struct peer
*peer
, struct bgp
*bgp
, afi_t afi
,
1896 struct route_node
*rn
;
1897 struct bgp_info
*ri
;
1898 struct bgp_info
*next
;
1900 for (rn
= route_top (bgp
->rib
[afi
][safi
]); rn
; rn
= route_next (rn
))
1901 for (ri
= rn
->info
; ri
; ri
= next
)
1905 if (ri
->peer
== peer
)
1907 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
1908 bgp_info_delete ((struct bgp_info
**) &rn
->info
, ri
);
1909 bgp_process (bgp
, rn
, afi
, safi
, ri
, NULL
, NULL
);
1911 route_unlock_node (rn
);
1917 bgp_route_clear_with_afi_vpnv4 (struct peer
*peer
, struct bgp
*bgp
, afi_t afi
,
1920 struct route_node
*rn
;
1921 struct route_node
*rm
;
1922 struct route_table
*table
;
1923 struct bgp_info
*ri
;
1924 struct bgp_info
*next
;
1926 for (rn
= route_top (bgp
->rib
[afi
][safi
]); rn
; rn
= route_next (rn
))
1927 if ((table
= (rn
->info
)) != NULL
)
1929 for (rm
= route_top (table
); rm
; rm
= route_next (rm
))
1930 for (ri
= rm
->info
; ri
; ri
= next
)
1934 if (ri
->peer
== peer
)
1936 bgp_aggregate_decrement (bgp
, &rm
->p
, (struct bgp_info
*)ri
,
1938 bgp_info_delete ((struct bgp_info
**) &rm
->info
,
1939 (struct bgp_info
*)ri
);
1940 bgp_process (bgp
, rm
, afi
, safi
, (struct bgp_info
*)ri
,
1941 (struct prefix_rd
*)&rn
->p
, ri
->tag
);
1942 bgp_info_free ((struct bgp_info
*)ri
);
1943 route_unlock_node (rm
);
1949 /* Remove all routes from the peer. */
1951 bgp_route_clear (struct peer
*peer
)
1953 struct listnode
*nn
;
1954 struct peer_conf
*conf
;
1956 /* Clear BGP routes. */
1957 LIST_LOOP (peer
->conf
, conf
, nn
)
1959 bgp_route_clear_with_afi (peer
, conf
->bgp
, AFI_IP
, SAFI_UNICAST
);
1960 bgp_route_clear_with_afi (peer
, conf
->bgp
, AFI_IP
, SAFI_MULTICAST
);
1961 bgp_route_clear_with_afi (peer
, conf
->bgp
, AFI_IP6
, SAFI_UNICAST
);
1962 bgp_route_clear_with_afi (peer
, conf
->bgp
, AFI_IP6
, SAFI_MULTICAST
);
1963 bgp_route_clear_with_afi_vpnv4 (peer
, conf
->bgp
, AFI_IP
, SAFI_MPLS_VPN
);
1965 /* Clear prefix counter. */
1966 conf
->pcount
[AFI_IP
][SAFI_UNICAST
] = 0;
1967 conf
->pcount
[AFI_IP
][SAFI_MULTICAST
] = 0;
1968 conf
->pcount
[AFI_IP
][SAFI_MPLS_VPN
] = 0;
1969 conf
->pcount
[AFI_IP6
][SAFI_UNICAST
] = 0;
1970 conf
->pcount
[AFI_IP6
][SAFI_MULTICAST
] = 0;
1973 /* Clear Adj-RIB-In information. */
1974 bgp_adj_clear (peer
->adj_in
[AFI_IP
][SAFI_UNICAST
], SAFI_UNICAST
);
1975 bgp_adj_clear (peer
->adj_in
[AFI_IP
][SAFI_MULTICAST
], SAFI_MULTICAST
);
1976 bgp_adj_clear (peer
->adj_in
[AFI_IP6
][SAFI_UNICAST
], SAFI_UNICAST
);
1977 bgp_adj_clear (peer
->adj_in
[AFI_IP6
][SAFI_MULTICAST
], SAFI_MULTICAST
);
1979 /* Clear Adj-RIB-Out information. */
1980 bgp_adj_clear (peer
->adj_out
[AFI_IP
][SAFI_UNICAST
], SAFI_UNICAST
);
1981 bgp_adj_clear (peer
->adj_out
[AFI_IP
][SAFI_MULTICAST
], SAFI_MULTICAST
);
1982 bgp_adj_clear (peer
->adj_out
[AFI_IP
][SAFI_MPLS_VPN
], SAFI_MPLS_VPN
);
1983 bgp_adj_clear (peer
->adj_out
[AFI_IP6
][SAFI_UNICAST
], SAFI_UNICAST
);
1984 bgp_adj_clear (peer
->adj_out
[AFI_IP6
][SAFI_MULTICAST
], SAFI_MULTICAST
);
1990 struct bgp_static
*new;
1991 new = XMALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
1992 memset (new, 0, sizeof (struct bgp_static
));
1997 bgp_static_free (struct bgp_static
*bgp_static
)
1999 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
2003 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
2006 struct route_node
*rn
;
2007 struct bgp_info
*new;
2008 u_int32_t igpmetric
;
2010 rn
= bgp_route_node_get (bgp
, afi
, safi
, p
, NULL
);
2012 /* Make new BGP info. */
2013 new = bgp_info_new ();
2014 new->type
= ZEBRA_ROUTE_BGP
;
2015 new->sub_type
= BGP_ROUTE_STATIC
;
2016 new->peer
= peer_self
;
2017 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
2018 && CHECK_FLAG (bgp
->config
, BGP_CONFIG_IMPORT_CHECK
))
2020 if (bgp_import_check (p
, &igpmetric
))
2021 SET_FLAG (new->flags
, BGP_INFO_VALID
);
2023 UNSET_FLAG (new->flags
, BGP_INFO_VALID
);
2026 SET_FLAG (new->flags
, BGP_INFO_VALID
);
2027 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
2028 new->uptime
= time (NULL
);
2030 /* Aggregate address increment. */
2031 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2033 /* Register new BGP information. */
2034 bgp_info_add ((struct bgp_info
**) &rn
->info
, new);
2036 /* Process change. */
2037 bgp_process (bgp
, rn
, afi
, safi
, NULL
, NULL
, NULL
);
2041 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
2042 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
2044 struct route_node
*rn
;
2045 struct bgp_info
*new;
2047 rn
= bgp_route_node_get (bgp
, afi
, safi
, p
, prd
);
2049 /* Make new BGP info. */
2050 new = bgp_info_new ();
2051 new->type
= ZEBRA_ROUTE_BGP
;
2052 new->sub_type
= BGP_ROUTE_STATIC
;
2053 new->peer
= peer_self
;
2054 new->attr
= bgp_attr_default_intern (BGP_ORIGIN_IGP
);
2055 SET_FLAG (new->flags
, BGP_INFO_VALID
);
2056 new->uptime
= time (NULL
);
2057 memcpy (new->tag
, tag
, 3);
2059 /* Aggregate address increment. */
2060 bgp_aggregate_increment (bgp
, p
, (struct bgp_info
*) new, afi
, safi
);
2062 /* Register new BGP information. */
2063 bgp_info_add ((struct bgp_info
**) &rn
->info
, (struct bgp_info
*) new);
2065 /* Process change. */
2066 bgp_process (bgp
, rn
, afi
, safi
, NULL
, prd
, tag
);
2070 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
2073 struct route_node
*rn
;
2074 struct bgp_info
*ri
;
2076 rn
= bgp_route_node_get (bgp
, afi
, safi
, p
, NULL
);
2078 /* Check selected route and self inserted route. */
2079 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2080 if (ri
->peer
== peer_self
2081 && ri
->type
== ZEBRA_ROUTE_BGP
2082 && ri
->sub_type
== BGP_ROUTE_STATIC
)
2085 /* Withdraw static BGP route from routing table. */
2088 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2089 bgp_info_delete ((struct bgp_info
**) &rn
->info
, ri
);
2090 bgp_process (bgp
, rn
, afi
, safi
, ri
, NULL
, NULL
);
2092 route_unlock_node (rn
);
2095 /* Unlock route_node_lookup. */
2096 route_unlock_node (rn
);
2100 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, u_int16_t afi
,
2101 u_char safi
, struct prefix_rd
*prd
, u_char
*tag
)
2103 struct route_node
*rn
;
2104 struct bgp_info
*ri
;
2106 rn
= bgp_route_node_get (bgp
, afi
, safi
, p
, prd
);
2108 /* Check selected route and self inserted route. */
2109 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2110 if (ri
->peer
== peer_self
2111 && ri
->type
== ZEBRA_ROUTE_BGP
2112 && ri
->sub_type
== BGP_ROUTE_STATIC
)
2115 /* Withdraw static BGP route from routing table. */
2118 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2119 bgp_info_delete ((struct bgp_info
**) &rn
->info
, ri
);
2120 bgp_process (bgp
, rn
, afi
, safi
, ri
, prd
, tag
);
2122 route_unlock_node (rn
);
2125 /* Unlock route_node_lookup. */
2126 route_unlock_node (rn
);
2129 /* Configure static BGP network. */
2131 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, char *ip_str
, u_int16_t afi
,
2132 u_char safi
, int backdoor
)
2136 struct bgp_static
*bgp_static
;
2137 struct route_node
*rn
;
2139 /* Convert IP prefix string to struct prefix. */
2140 ret
= str2prefix (ip_str
, &p
);
2143 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
2147 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
2149 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
2153 #endif /* HAVE_IPV6 */
2157 /* Set BGP static route configuration. */
2158 rn
= route_node_get (bgp
->route
[afi
][safi
], &p
);
2162 /* Configuration change. */
2163 bgp_static
= rn
->info
;
2167 if (bgp_static
->backdoor
)
2168 bgp_static_update (bgp
, &p
, afi
, safi
);
2172 if (! bgp_static
->backdoor
)
2173 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
2175 bgp_static
->backdoor
= backdoor
;
2176 route_unlock_node (rn
);
2180 /* New configuration. */
2181 bgp_static
= bgp_static_new ();
2182 bgp_static
->backdoor
= backdoor
;
2183 bgp_static
->valid
= 1;
2184 rn
->info
= bgp_static
;
2187 bgp_static_update (bgp
, &p
, afi
, safi
);
2193 /* Configure static BGP network. */
2195 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, char *ip_str
,
2196 u_int16_t afi
, u_char safi
)
2200 struct bgp_static
*bgp_static
;
2201 struct route_node
*rn
;
2203 /* Convert IP prefix string to struct prefix. */
2204 ret
= str2prefix (ip_str
, &p
);
2207 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
2211 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
2213 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
2217 #endif /* HAVE_IPV6 */
2221 rn
= route_node_lookup (bgp
->route
[afi
][safi
], &p
);
2224 vty_out (vty
, "%% Can't find specified static route configuration.%s",
2229 bgp_static
= rn
->info
;
2231 /* Update BGP RIB. */
2232 if (! bgp_static
->backdoor
)
2233 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
2235 /* Clear configuration. */
2236 bgp_static_free (bgp_static
);
2238 route_unlock_node (rn
);
2239 route_unlock_node (rn
);
2244 /* Called from bgp_delete(). Delete all static routes from the BGP
2247 bgp_static_delete (struct bgp
*bgp
)
2251 struct route_node
*rn
;
2252 struct route_node
*rm
;
2253 struct route_table
*table
;
2254 struct bgp_static
*bgp_static
;
2256 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2257 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2258 for (rn
= route_top (bgp
->route
[afi
][safi
]); rn
; rn
= route_next (rn
))
2259 if (rn
->info
!= NULL
)
2261 if (safi
== SAFI_MPLS_VPN
)
2265 for (rm
= route_top (table
); rm
; rm
= route_next (rm
))
2267 bgp_static
= rn
->info
;
2268 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
2269 AFI_IP
, SAFI_MPLS_VPN
,
2270 (struct prefix_rd
*)&rn
->p
,
2272 bgp_static_free (bgp_static
);
2274 route_unlock_node (rn
);
2279 bgp_static
= rn
->info
;
2280 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
2281 bgp_static_free (bgp_static
);
2283 route_unlock_node (rn
);
2289 bgp_static_set_vpnv4 (struct vty
*vty
, char *ip_str
, char *rd_str
,
2294 struct prefix_rd prd
;
2296 struct route_node
*prn
;
2297 struct route_node
*rn
;
2298 struct route_table
*table
;
2299 struct bgp_static
*bgp_static
;
2304 ret
= str2prefix (ip_str
, &p
);
2307 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
2312 ret
= str2prefix_rd (rd_str
, &prd
);
2315 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
2319 ret
= str2tag (tag_str
, tag
);
2322 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
2326 prn
= route_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
2327 (struct prefix
*)&prd
);
2328 if (prn
->info
== NULL
)
2329 prn
->info
= route_table_init ();
2331 route_unlock_node (prn
);
2334 rn
= route_node_get (table
, &p
);
2338 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
2339 route_unlock_node (rn
);
2343 /* New configuration. */
2344 bgp_static
= bgp_static_new ();
2345 bgp_static
->valid
= 1;
2346 memcpy (bgp_static
->tag
, tag
, 3);
2347 rn
->info
= bgp_static
;
2349 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
2355 /* Configure static BGP network. */
2357 bgp_static_unset_vpnv4 (struct vty
*vty
, char *ip_str
, char *rd_str
,
2363 struct prefix_rd prd
;
2364 struct route_node
*prn
;
2365 struct route_node
*rn
;
2366 struct route_table
*table
;
2367 struct bgp_static
*bgp_static
;
2372 /* Convert IP prefix string to struct prefix. */
2373 ret
= str2prefix (ip_str
, &p
);
2376 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
2381 ret
= str2prefix_rd (rd_str
, &prd
);
2384 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
2388 ret
= str2tag (tag_str
, tag
);
2391 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
2395 prn
= route_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
2396 (struct prefix
*)&prd
);
2397 if (prn
->info
== NULL
)
2398 prn
->info
= route_table_init ();
2400 route_unlock_node (prn
);
2403 rn
= route_node_lookup (table
, &p
);
2407 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
2409 bgp_static
= rn
->info
;
2410 bgp_static_free (bgp_static
);
2412 route_unlock_node (rn
);
2413 route_unlock_node (rn
);
2416 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
2422 bgp_node_afi (struct vty
*vty
)
2424 if (vty
->node
== BGP_IPV6_NODE
)
2430 bgp_node_safi (struct vty
*vty
)
2432 if (vty
->node
== BGP_VPNV4_NODE
)
2433 return SAFI_MPLS_VPN
;
2434 if (vty
->node
== BGP_IPV4M_NODE
)
2435 return SAFI_MULTICAST
;
2436 return SAFI_UNICAST
;
2441 "network A.B.C.D/M",
2442 "Specify a network to announce via BGP\n"
2443 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2445 return bgp_static_set (vty
, vty
->index
, argv
[0],
2446 AFI_IP
, bgp_node_safi (vty
), 0);
2449 DEFUN (bgp_network_mask
,
2450 bgp_network_mask_cmd
,
2451 "network A.B.C.D mask A.B.C.D",
2452 "Specify a network to announce via BGP\n"
2458 char prefix_str
[BUFSIZ
];
2461 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
2463 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
2467 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
2471 return bgp_static_set (vty
, vty
->index
, prefix_str
,
2472 AFI_IP
, bgp_node_safi (vty
), 0);
2475 ALIAS (bgp_network_mask
,
2476 bgp_network_mask_natural_cmd
,
2478 "Specify a network to announce via BGP\n"
2481 DEFUN (bgp_network_backdoor
,
2482 bgp_network_backdoor_cmd
,
2483 "network A.B.C.D/M backdoor",
2484 "Specify a network to announce via BGP\n"
2485 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2486 "Specify a BGP backdoor route\n")
2488 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
, 1);
2491 DEFUN (bgp_network_mask_backdoor
,
2492 bgp_network_mask_backdoor_cmd
,
2493 "network A.B.C.D mask A.B.C.D backdoor",
2494 "Specify a network to announce via BGP\n"
2498 "Specify a BGP backdoor route\n")
2501 char prefix_str
[BUFSIZ
];
2504 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
2506 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
2510 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
2514 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
, 1);
2517 ALIAS (bgp_network_mask_backdoor
,
2518 bgp_network_mask_natural_backdoor_cmd
,
2519 "network A.B.C.D backdoor",
2520 "Specify a network to announce via BGP\n"
2522 "Specify a BGP backdoor route\n")
2524 DEFUN (no_bgp_network
,
2526 "no network A.B.C.D/M",
2528 "Specify a network to announce via BGP\n"
2529 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2531 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
2532 bgp_node_safi (vty
));
2535 ALIAS (no_bgp_network
,
2536 no_bgp_network_backdoor_cmd
,
2537 "no network A.B.C.D/M backdoor",
2539 "Specify a network to announce via BGP\n"
2540 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2541 "Specify a BGP backdoor route\n")
2543 DEFUN (no_bgp_network_mask
,
2544 no_bgp_network_mask_cmd
,
2545 "no network A.B.C.D mask A.B.C.D",
2547 "Specify a network to announce via BGP\n"
2548 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2551 char prefix_str
[BUFSIZ
];
2554 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
2556 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
2560 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
2564 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
2565 bgp_node_safi (vty
));
2568 ALIAS (no_bgp_network_mask
,
2569 no_bgp_network_mask_natural_cmd
,
2570 "no network A.B.C.D",
2571 "Specify a network to announce via BGP\n"
2574 ALIAS (no_bgp_network_mask
,
2575 no_bgp_network_mask_backdoor_cmd
,
2576 "no network A.B.C.D mask A.B.C.D backdoor",
2578 "Specify a network to announce via BGP\n"
2582 "Specify a BGP backdoor route\n")
2584 ALIAS (no_bgp_network_mask
,
2585 no_bgp_network_mask_natural_backdoor_cmd
,
2586 "no network A.B.C.D backdoor",
2588 "Specify a network to announce via BGP\n"
2590 "Specify a BGP backdoor route\n")
2593 DEFUN (ipv6_bgp_network
,
2594 ipv6_bgp_network_cmd
,
2595 "network X:X::X:X/M",
2596 "Specify a network to announce via BGP\n"
2597 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2599 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0);
2602 DEFUN (no_ipv6_bgp_network
,
2603 no_ipv6_bgp_network_cmd
,
2604 "no network X:X::X:X/M",
2606 "Specify a network to announce via BGP\n"
2607 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2609 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
2612 ALIAS (ipv6_bgp_network
,
2613 old_ipv6_bgp_network_cmd
,
2614 "ipv6 bgp network X:X::X:X/M",
2617 "Specify a network to announce via BGP\n"
2618 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2620 ALIAS (no_ipv6_bgp_network
,
2621 old_no_ipv6_bgp_network_cmd
,
2622 "no ipv6 bgp network X:X::X:X/M",
2626 "Specify a network to announce via BGP\n"
2627 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2628 #endif /* HAVE_IPV6 */
2630 /* Aggreagete address:
2632 advertise-map Set condition to advertise attribute
2633 as-set Generate AS set path information
2634 attribute-map Set attributes of aggregate
2635 route-map Set parameters of aggregate
2636 summary-only Filter more specific routes from updates
2637 suppress-map Conditionally filter more specific routes from updates
2640 struct bgp_aggregate
2642 /* Summary-only flag. */
2643 u_char summary_only
;
2645 /* AS set generation. */
2648 /* Route-map for aggregated route. */
2649 struct route_map
*map
;
2651 /* Suppress-count. */
2652 unsigned long count
;
2654 /* SAFI configuration. */
2658 struct bgp_aggregate
*
2659 bgp_aggregate_new ()
2661 struct bgp_aggregate
*new;
2662 new = XMALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
2663 memset (new, 0, sizeof (struct bgp_aggregate
));
2668 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
2670 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
2674 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
2675 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
2676 struct bgp_aggregate
*aggregate
)
2678 struct route_table
*table
;
2679 struct route_node
*top
;
2680 struct route_node
*rn
;
2682 struct aspath
*aspath
= NULL
;
2683 struct aspath
*asmerge
= NULL
;
2684 struct community
*community
= NULL
;
2685 struct community
*commerge
= NULL
;
2686 struct in_addr nexthop
;
2688 struct bgp_info
*ri
;
2689 struct bgp_info
*new;
2691 unsigned long match
= 0;
2693 /* Record adding route's nexthop and med. */
2696 nexthop
= rinew
->attr
->nexthop
;
2697 med
= rinew
->attr
->med
;
2700 /* ORIGIN attribute: If at least one route among routes that are
2701 aggregated has ORIGIN with the value INCOMPLETE, then the
2702 aggregated route must have the ORIGIN attribute with the value
2703 INCOMPLETE. Otherwise, if at least one route among routes that
2704 are aggregated has ORIGIN with the value EGP, then the aggregated
2705 route must have the origin attribute with the value EGP. In all
2706 other case the value of the ORIGIN attribute of the aggregated
2707 route is INTERNAL. */
2708 origin
= BGP_ORIGIN_IGP
;
2710 table
= bgp
->rib
[afi
][safi
];
2712 top
= route_node_get (table
, p
);
2713 for (rn
= route_node_get (table
, p
); rn
; rn
= route_next_until (rn
, top
))
2714 if (rn
->p
.prefixlen
> p
->prefixlen
)
2718 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2720 if (BGP_INFO_HOLDDOWN (ri
))
2723 if (del
&& ri
== del
)
2726 if (! rinew
&& first
)
2728 nexthop
= ri
->attr
->nexthop
;
2729 med
= ri
->attr
->med
;
2733 #ifdef AGGREGATE_NEXTHOP_CHECK
2734 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
2735 || ri
->attr
->med
!= med
)
2738 aspath_free (aspath
);
2740 community_free (community
);
2741 route_unlock_node (rn
);
2742 route_unlock_node (top
);
2745 #endif /* AGGREGATE_NEXTHOP_CHECK */
2747 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
2749 if (aggregate
->summary_only
)
2752 SET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
2758 if (aggregate
->as_set
)
2760 if (origin
< ri
->attr
->origin
)
2761 origin
= ri
->attr
->origin
;
2765 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
2766 aspath_free (aspath
);
2770 aspath
= aspath_dup (ri
->attr
->aspath
);
2772 if (ri
->attr
->community
)
2776 commerge
= community_merge (community
,
2777 ri
->attr
->community
);
2778 community
= community_uniq_sort (commerge
);
2779 community_free (commerge
);
2782 community
= community_dup (ri
->attr
->community
);
2788 bgp_process (bgp
, rn
, afi
, safi
, NULL
, NULL
, NULL
);
2790 route_unlock_node (top
);
2796 if (aggregate
->summary_only
)
2799 if (aggregate
->as_set
)
2801 if (origin
< rinew
->attr
->origin
)
2802 origin
= rinew
->attr
->origin
;
2806 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
2807 aspath_free (aspath
);
2811 aspath
= aspath_dup (rinew
->attr
->aspath
);
2813 if (rinew
->attr
->community
)
2817 commerge
= community_merge (community
,
2818 rinew
->attr
->community
);
2819 community
= community_uniq_sort (commerge
);
2820 community_free (commerge
);
2823 community
= community_dup (rinew
->attr
->community
);
2828 if (aggregate
->count
> 0)
2830 rn
= route_node_get (table
, p
);
2831 new = bgp_info_new ();
2832 new->type
= ZEBRA_ROUTE_BGP
;
2833 new->sub_type
= BGP_ROUTE_AGGREGATE
;
2834 new->peer
= peer_self
;
2835 SET_FLAG (new->flags
, BGP_INFO_VALID
);
2836 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
2837 new->uptime
= time (NULL
);
2839 bgp_info_add ((struct bgp_info
**) &rn
->info
, new);
2840 bgp_process (bgp
, rn
, afi
, safi
, NULL
, NULL
, NULL
);
2845 aspath_free (aspath
);
2847 community_free (community
);
2851 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
2852 struct bgp_aggregate
*);
2855 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
2856 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
2858 struct route_node
*child
;
2859 struct route_node
*rn
;
2860 struct bgp_aggregate
*aggregate
;
2862 /* MPLS-VPN aggregation is not yet supported. */
2863 if (safi
== SAFI_MPLS_VPN
)
2866 if (p
->prefixlen
== 0)
2869 if (BGP_INFO_HOLDDOWN (ri
))
2872 child
= route_node_get (bgp
->aggregate
[afi
][safi
], p
);
2874 /* Aggregate address configuration check. */
2875 for (rn
= child
; rn
; rn
= rn
->parent
)
2876 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
2878 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
2879 bgp_aggregate_route (bgp
, &rn
->p
, ri
, safi
, safi
, NULL
, aggregate
);
2881 route_unlock_node (child
);
2885 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
2886 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
2888 struct route_node
*child
;
2889 struct route_node
*rn
;
2890 struct bgp_aggregate
*aggregate
;
2892 /* MPLS-VPN aggregation is not yet supported. */
2893 if (safi
== SAFI_MPLS_VPN
)
2896 if (p
->prefixlen
== 0)
2899 if (BGP_INFO_HOLDDOWN (del
))
2902 child
= route_node_get (bgp
->aggregate
[afi
][safi
], p
);
2904 /* Aggregate address configuration check. */
2905 for (rn
= child
; rn
; rn
= rn
->parent
)
2906 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
2908 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
2909 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, safi
, safi
, del
, aggregate
);
2911 route_unlock_node (child
);
2915 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
2916 struct bgp_aggregate
*aggregate
)
2918 struct route_table
*table
;
2919 struct route_node
*top
;
2920 struct route_node
*rn
;
2921 struct bgp_info
*new;
2922 struct bgp_info
*ri
;
2923 unsigned long match
;
2924 u_char origin
= BGP_ORIGIN_IGP
;
2925 struct aspath
*aspath
= NULL
;
2926 struct aspath
*asmerge
= NULL
;
2927 struct community
*community
= NULL
;
2928 struct community
*commerge
= NULL
;
2930 table
= bgp
->rib
[afi
][safi
];
2933 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
2935 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
2938 /* If routes exists below this node, generate aggregate routes. */
2939 top
= route_node_get (table
, p
);
2940 for (rn
= route_node_get (table
, p
); rn
; rn
= route_next_until (rn
, top
))
2941 if (rn
->p
.prefixlen
> p
->prefixlen
)
2945 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2947 if (BGP_INFO_HOLDDOWN (ri
))
2950 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
2952 /* summary-only aggregate route suppress aggregated
2953 route announcement. */
2954 if (aggregate
->summary_only
)
2957 SET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
2960 /* as-set aggregate route generate origin, as path,
2961 community aggregation. */
2962 if (aggregate
->as_set
)
2964 if (origin
< ri
->attr
->origin
)
2965 origin
= ri
->attr
->origin
;
2969 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
2970 aspath_free (aspath
);
2974 aspath
= aspath_dup (ri
->attr
->aspath
);
2976 if (ri
->attr
->community
)
2980 commerge
= community_merge (community
,
2981 ri
->attr
->community
);
2982 community
= community_uniq_sort (commerge
);
2983 community_free (commerge
);
2986 community
= community_dup (ri
->attr
->community
);
2993 /* If this node is suppressed, process the change. */
2995 bgp_process (bgp
, rn
, afi
, safi
, NULL
, NULL
, NULL
);
2997 route_unlock_node (top
);
2999 /* Add aggregate route to BGP table. */
3000 if (aggregate
->count
)
3002 rn
= route_node_get (table
, p
);
3004 new = bgp_info_new ();
3005 new->type
= ZEBRA_ROUTE_BGP
;
3006 new->sub_type
= BGP_ROUTE_AGGREGATE
;
3007 new->peer
= peer_self
;
3008 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3009 new->attr
= bgp_attr_aggregate_intern (bgp
, origin
, aspath
, community
, aggregate
->as_set
);
3010 new->uptime
= time (NULL
);
3012 bgp_info_add ((struct bgp_info
**) &rn
->info
, new);
3014 /* Process change. */
3015 bgp_process (bgp
, rn
, afi
, safi
, NULL
, NULL
, NULL
);
3020 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3021 safi_t safi
, struct bgp_aggregate
*aggregate
)
3023 struct route_table
*table
;
3024 struct route_node
*top
;
3025 struct route_node
*rn
;
3026 struct bgp_info
*ri
;
3027 unsigned long match
;
3029 table
= bgp
->rib
[afi
][safi
];
3031 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
3033 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
3036 /* If routes exists below this node, generate aggregate routes. */
3037 top
= route_node_get (table
, p
);
3038 for (rn
= route_node_get (table
, p
); rn
; rn
= route_next_until (rn
, top
))
3039 if (rn
->p
.prefixlen
> p
->prefixlen
)
3043 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3045 if (BGP_INFO_HOLDDOWN (ri
))
3048 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
3050 if (aggregate
->summary_only
)
3054 if (ri
->suppress
== 0)
3056 SET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
3064 /* If this node is suppressed, process the change. */
3066 bgp_process (bgp
, rn
, afi
, safi
, NULL
, NULL
, NULL
);
3068 route_unlock_node (top
);
3070 /* Delete aggregate route from BGP table. */
3071 rn
= route_node_get (table
, p
);
3073 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3074 if (ri
->peer
== peer_self
3075 && ri
->type
== ZEBRA_ROUTE_BGP
3076 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
3079 /* Withdraw static BGP route from routing table. */
3082 bgp_info_delete ((struct bgp_info
**) &rn
->info
, ri
);
3083 bgp_process (bgp
, rn
, afi
, safi
, ri
, NULL
, NULL
);
3085 route_unlock_node (rn
);
3088 /* Unlock route_node_lookup. */
3089 route_unlock_node (rn
);
3092 /* Aggregate route attribute. */
3093 #define AGGREGATE_SUMMARY_ONLY 1
3094 #define AGGREGATE_AS_SET 1
3097 bgp_aggregate_set (struct vty
*vty
, char *prefix_str
, afi_t afi
, safi_t safi
,
3098 u_char summary_only
, u_char as_set
)
3102 struct route_node
*rn
;
3104 struct bgp_aggregate
*aggregate
;
3106 /* Convert string to prefix structure. */
3107 ret
= str2prefix (prefix_str
, &p
);
3110 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
3115 /* Get BGP structure. */
3118 /* Old configuration check. */
3119 rn
= route_node_get (bgp
->aggregate
[afi
][safi
], &p
);
3123 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
3124 route_unlock_node (rn
);
3128 /* Make aggregate address structure. */
3129 aggregate
= bgp_aggregate_new ();
3130 aggregate
->summary_only
= summary_only
;
3131 aggregate
->as_set
= as_set
;
3132 aggregate
->safi
= safi
;
3133 rn
->info
= aggregate
;
3135 /* Aggregate address insert into BGP routing table. */
3136 if (safi
& SAFI_UNICAST
)
3137 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
3138 if (safi
& SAFI_MULTICAST
)
3139 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
3145 bgp_aggregate_unset (struct vty
*vty
, char *prefix_str
, afi_t afi
, safi_t safi
)
3149 struct route_node
*rn
;
3151 struct bgp_aggregate
*aggregate
;
3153 /* Convert string to prefix structure. */
3154 ret
= str2prefix (prefix_str
, &p
);
3157 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
3162 /* Get BGP structure. */
3165 /* Old configuration check. */
3166 rn
= route_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
3169 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
3174 aggregate
= rn
->info
;
3175 if (aggregate
->safi
& SAFI_UNICAST
)
3176 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
3177 if (aggregate
->safi
& SAFI_MULTICAST
)
3178 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
3180 /* Unlock aggregate address configuration. */
3182 bgp_aggregate_free (aggregate
);
3183 route_unlock_node (rn
);
3184 route_unlock_node (rn
);
3189 DEFUN (aggregate_address
,
3190 aggregate_address_cmd
,
3191 "aggregate-address A.B.C.D/M",
3192 "Configure BGP aggregate entries\n"
3193 "Aggregate prefix\n")
3195 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
3198 DEFUN (aggregate_address_mask
,
3199 aggregate_address_mask_cmd
,
3200 "aggregate-address A.B.C.D A.B.C.D",
3201 "Configure BGP aggregate entries\n"
3202 "Aggregate address\n"
3206 char prefix_str
[BUFSIZ
];
3208 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3212 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3216 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
3220 DEFUN (aggregate_address_summary_only
,
3221 aggregate_address_summary_only_cmd
,
3222 "aggregate-address A.B.C.D/M summary-only",
3223 "Configure BGP aggregate entries\n"
3224 "Aggregate prefix\n"
3225 "Filter more specific routes from updates\n")
3227 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
3228 AGGREGATE_SUMMARY_ONLY
, 0);
3231 DEFUN (aggregate_address_mask_summary_only
,
3232 aggregate_address_mask_summary_only_cmd
,
3233 "aggregate-address A.B.C.D A.B.C.D summary-only",
3234 "Configure BGP aggregate entries\n"
3235 "Aggregate address\n"
3237 "Filter more specific routes from updates\n")
3240 char prefix_str
[BUFSIZ
];
3242 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3246 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3250 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
3251 AGGREGATE_SUMMARY_ONLY
, 0);
3254 DEFUN (aggregate_address_as_set
,
3255 aggregate_address_as_set_cmd
,
3256 "aggregate-address A.B.C.D/M as-set",
3257 "Configure BGP aggregate entries\n"
3258 "Aggregate prefix\n"
3259 "Generate AS set path information\n")
3261 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
3262 0, AGGREGATE_AS_SET
);
3265 DEFUN (aggregate_address_mask_as_set
,
3266 aggregate_address_mask_as_set_cmd
,
3267 "aggregate-address A.B.C.D A.B.C.D as-set",
3268 "Configure BGP aggregate entries\n"
3269 "Aggregate address\n"
3271 "Generate AS set path information\n")
3274 char prefix_str
[BUFSIZ
];
3276 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3280 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3284 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
3285 0, AGGREGATE_AS_SET
);
3289 DEFUN (aggregate_address_as_set_summary
,
3290 aggregate_address_as_set_summary_cmd
,
3291 "aggregate-address A.B.C.D/M as-set summary-only",
3292 "Configure BGP aggregate entries\n"
3293 "Aggregate prefix\n"
3294 "Generate AS set path information\n"
3295 "Filter more specific routes from updates\n")
3297 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
3298 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
3301 ALIAS (aggregate_address_as_set_summary
,
3302 aggregate_address_summary_as_set_cmd
,
3303 "aggregate-address A.B.C.D/M summary-only as-set",
3304 "Configure BGP aggregate entries\n"
3305 "Aggregate prefix\n"
3306 "Filter more specific routes from updates\n"
3307 "Generate AS set path information\n")
3309 DEFUN (aggregate_address_mask_as_set_summary
,
3310 aggregate_address_mask_as_set_summary_cmd
,
3311 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
3312 "Configure BGP aggregate entries\n"
3313 "Aggregate address\n"
3315 "Generate AS set path information\n"
3316 "Filter more specific routes from updates\n")
3319 char prefix_str
[BUFSIZ
];
3321 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3325 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3329 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
3330 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
3333 ALIAS (aggregate_address_mask_as_set_summary
,
3334 aggregate_address_mask_summary_as_set_cmd
,
3335 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
3336 "Configure BGP aggregate entries\n"
3337 "Aggregate address\n"
3339 "Filter more specific routes from updates\n"
3340 "Generate AS set path information\n")
3342 DEFUN (no_aggregate_address
,
3343 no_aggregate_address_cmd
,
3344 "no aggregate-address A.B.C.D/M",
3346 "Configure BGP aggregate entries\n"
3347 "Aggregate prefix\n")
3349 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
3352 ALIAS (no_aggregate_address
,
3353 no_aggregate_address_summary_only_cmd
,
3354 "no aggregate-address A.B.C.D/M summary-only",
3356 "Configure BGP aggregate entries\n"
3357 "Aggregate prefix\n"
3358 "Filter more specific routes from updates\n")
3360 ALIAS (no_aggregate_address
,
3361 no_aggregate_address_as_set_cmd
,
3362 "no aggregate-address A.B.C.D/M as-set",
3364 "Configure BGP aggregate entries\n"
3365 "Aggregate prefix\n"
3366 "Generate AS set path information\n")
3368 ALIAS (no_aggregate_address
,
3369 no_aggregate_address_as_set_summary_cmd
,
3370 "no aggregate-address A.B.C.D/M as-set summary-only",
3372 "Configure BGP aggregate entries\n"
3373 "Aggregate prefix\n"
3374 "Generate AS set path information\n"
3375 "Filter more specific routes from updates\n")
3377 ALIAS (no_aggregate_address
,
3378 no_aggregate_address_summary_as_set_cmd
,
3379 "no aggregate-address A.B.C.D/M summary-only as-set",
3381 "Configure BGP aggregate entries\n"
3382 "Aggregate prefix\n"
3383 "Filter more specific routes from updates\n"
3384 "Generate AS set path information\n")
3386 DEFUN (no_aggregate_address_mask
,
3387 no_aggregate_address_mask_cmd
,
3388 "no aggregate-address A.B.C.D A.B.C.D",
3390 "Configure BGP aggregate entries\n"
3391 "Aggregate address\n"
3395 char prefix_str
[BUFSIZ
];
3397 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3401 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
3405 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
3408 ALIAS (no_aggregate_address_mask
,
3409 no_aggregate_address_mask_summary_only_cmd
,
3410 "no aggregate-address A.B.C.D A.B.C.D summary-only",
3412 "Configure BGP aggregate entries\n"
3413 "Aggregate address\n"
3415 "Filter more specific routes from updates\n")
3417 ALIAS (no_aggregate_address_mask
,
3418 no_aggregate_address_mask_as_set_cmd
,
3419 "no aggregate-address A.B.C.D A.B.C.D as-set",
3421 "Configure BGP aggregate entries\n"
3422 "Aggregate address\n"
3424 "Generate AS set path information\n")
3426 ALIAS (no_aggregate_address_mask
,
3427 no_aggregate_address_mask_as_set_summary_cmd
,
3428 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
3430 "Configure BGP aggregate entries\n"
3431 "Aggregate address\n"
3433 "Generate AS set path information\n"
3434 "Filter more specific routes from updates\n")
3436 ALIAS (no_aggregate_address_mask
,
3437 no_aggregate_address_mask_summary_as_set_cmd
,
3438 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
3440 "Configure BGP aggregate entries\n"
3441 "Aggregate address\n"
3443 "Filter more specific routes from updates\n"
3444 "Generate AS set path information\n")
3447 DEFUN (ipv6_aggregate_address
,
3448 ipv6_aggregate_address_cmd
,
3449 "aggregate-address X:X::X:X/M",
3450 "Configure BGP aggregate entries\n"
3451 "Aggregate prefix\n")
3453 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
3456 DEFUN (ipv6_aggregate_address_summary_only
,
3457 ipv6_aggregate_address_summary_only_cmd
,
3458 "aggregate-address X:X::X:X/M summary-only",
3459 "Configure BGP aggregate entries\n"
3460 "Aggregate prefix\n"
3461 "Filter more specific routes from updates\n")
3463 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3464 AGGREGATE_SUMMARY_ONLY
, 0);
3467 DEFUN (no_ipv6_aggregate_address
,
3468 no_ipv6_aggregate_address_cmd
,
3469 "no aggregate-address X:X::X:X/M",
3471 "Configure BGP aggregate entries\n"
3472 "Aggregate prefix\n")
3474 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
3477 DEFUN (no_ipv6_aggregate_address_summary_only
,
3478 no_ipv6_aggregate_address_summary_only_cmd
,
3479 "no aggregate-address X:X::X:X/M summary-only",
3481 "Configure BGP aggregate entries\n"
3482 "Aggregate prefix\n"
3483 "Filter more specific routes from updates\n")
3485 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
3488 ALIAS (ipv6_aggregate_address
,
3489 old_ipv6_aggregate_address_cmd
,
3490 "ipv6 bgp aggregate-address X:X::X:X/M",
3493 "Configure BGP aggregate entries\n"
3494 "Aggregate prefix\n")
3496 ALIAS (ipv6_aggregate_address_summary_only
,
3497 old_ipv6_aggregate_address_summary_only_cmd
,
3498 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
3501 "Configure BGP aggregate entries\n"
3502 "Aggregate prefix\n"
3503 "Filter more specific routes from updates\n")
3505 ALIAS (no_ipv6_aggregate_address
,
3506 old_no_ipv6_aggregate_address_cmd
,
3507 "no ipv6 bgp aggregate-address X:X::X:X/M",
3511 "Configure BGP aggregate entries\n"
3512 "Aggregate prefix\n")
3514 ALIAS (no_ipv6_aggregate_address_summary_only
,
3515 old_no_ipv6_aggregate_address_summary_only_cmd
,
3516 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
3520 "Configure BGP aggregate entries\n"
3521 "Aggregate prefix\n"
3522 "Filter more specific routes from updates\n")
3523 #endif /* HAVE_IPV6 */
3525 /* Redistribute route treatment. */
3527 bgp_redistribute_add (struct prefix
*p
, struct in_addr
*nexthop
,
3528 u_int32_t metric
, u_char type
)
3531 struct listnode
*nn
;
3532 struct bgp_info
*new;
3533 struct route_node
*rn
;
3535 struct attr attr_new
;
3536 struct bgp_info info
;
3540 /* Make default attribute. */
3541 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
3543 attr
.nexthop
= *nexthop
;
3546 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3548 LIST_LOOP (bgp_list
, bgp
, nn
)
3550 afi
= family2afi (p
->family
);
3552 if (bgp
->redist
[afi
][type
])
3554 /* Copy attribute for modification. */
3557 /* Apply route-map. */
3558 if (bgp
->rmap
[afi
][type
].map
)
3560 info
.peer
= peer_self
;
3561 info
.attr
= &attr_new
;
3563 ret
= route_map_apply (bgp
->rmap
[afi
][type
].map
, p
, RMAP_BGP
,
3565 if (ret
== RMAP_DENYMATCH
)
3567 /* Free uninterned attribute. */
3568 bgp_attr_flush (&attr_new
);
3570 /* Unintern original. */
3571 aspath_unintern (attr
.aspath
);
3576 new = bgp_info_new ();
3578 new->peer
= peer_self
;
3579 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3580 new->attr
= bgp_attr_intern (&attr_new
);
3581 new->uptime
= time (NULL
);
3583 rn
= bgp_route_node_get (bgp
, afi
, SAFI_UNICAST
, p
, NULL
);
3584 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
3585 bgp_info_add ((struct bgp_info
**) &rn
->info
, new);
3586 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
, NULL
, NULL
, NULL
);
3590 /* Unintern original. */
3591 aspath_unintern (attr
.aspath
);
3595 bgp_redistribute_delete (struct prefix
*p
, u_char type
)
3598 struct listnode
*nn
;
3600 struct route_node
*rn
;
3601 struct bgp_info
*ri
;
3603 LIST_LOOP (bgp_list
, bgp
, nn
)
3605 afi
= family2afi (p
->family
);
3607 if (bgp
->redist
[afi
][type
])
3609 rn
= bgp_route_node_get (bgp
, afi
, SAFI_UNICAST
, p
, NULL
);
3611 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3612 if (ri
->peer
== peer_self
3613 && ri
->type
== type
)
3618 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
3619 bgp_info_delete ((struct bgp_info
**) &rn
->info
, ri
);
3620 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
, ri
, NULL
, NULL
);
3622 route_unlock_node (rn
);
3624 route_unlock_node (rn
);
3629 /* Withdraw specified route type's route. */
3631 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
)
3633 struct route_node
*rn
;
3634 struct bgp_info
*ri
;
3635 struct route_table
*table
;
3637 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
3639 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
3641 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3642 if (ri
->peer
== peer_self
3643 && ri
->type
== type
)
3648 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
3649 bgp_info_delete ((struct bgp_info
**) &rn
->info
, ri
);
3650 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
, ri
, NULL
, NULL
);
3652 route_unlock_node (rn
);
3657 /* Static function to display route. */
3659 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
3662 u_int32_t destination
;
3665 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
3666 destination
= ntohl (p
->u
.prefix4
.s_addr
);
3668 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
3669 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
3670 || (IN_CLASSA (destination
) && p
->prefixlen
== 8))
3672 /* When mask is natural, mask is not displayed. */
3675 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
3679 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
3681 vty_out (vty
, "%*s", len
, " ");
3684 /* Calculate line number of output data. */
3686 vty_calc_line (struct vty
*vty
, unsigned long length
)
3688 return vty
->width
? (((vty
->obuf
->length
- length
) / vty
->width
) + 1) : 1;
3691 enum bgp_display_type
3696 /* called from terminal list command */
3698 route_vty_out (struct vty
*vty
, struct prefix
*p
,
3699 struct bgp_info
*binfo
, int display
, safi_t safi
)
3702 unsigned long length
= 0;
3704 length
= vty
->obuf
->length
;
3706 /* Route status display. */
3707 if (binfo
->suppress
)
3709 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
3715 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
3717 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
3719 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
3724 /* Internal route. */
3725 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
3730 /* print prefix and mask */
3732 route_vty_out_route (p
, vty
);
3734 vty_out (vty
, "%*s", 17, " ");
3736 /* Print attribute */
3740 if (p
->family
== AF_INET
)
3742 if (safi
== SAFI_MPLS_VPN
)
3743 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
3745 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
3748 else if (p
->family
== AF_INET6
)
3752 if (attr
->mp_nexthop_len
== 16)
3754 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
3755 else if (attr
->mp_nexthop_len
== 32)
3756 vty_out (vty
, "%s(%s)",
3757 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
3758 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
, buf1
, BUFSIZ
));
3761 #endif /* HAVE_IPV6 */
3763 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
3764 vty_out (vty
, "%10d", attr
->med
);
3768 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
3769 vty_out (vty
, "%7d", attr
->local_pref
);
3773 vty_out (vty
, "%7u ",attr
->weight
);
3777 aspath_print_vty (vty
, attr
->aspath
);
3780 if (strlen (attr
->aspath
->str
) == 0)
3781 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
3783 vty_out (vty
, " %s", bgp_origin_str
[attr
->origin
]);
3785 vty_out (vty
, "%s", VTY_NEWLINE
);
3787 return vty_calc_line (vty
, length
);
3790 /* called from terminal list command */
3792 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
,
3793 struct attr
*attr
, safi_t safi
)
3795 /* Route status display. */
3800 /* print prefix and mask */
3801 route_vty_out_route (p
, vty
);
3803 /* Print attribute */
3806 if (p
->family
== AF_INET
)
3808 if (safi
== SAFI_MPLS_VPN
)
3809 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
3811 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
3814 else if (p
->family
== AF_INET6
)
3818 if (attr
->mp_nexthop_len
== 16)
3820 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
3821 else if (attr
->mp_nexthop_len
== 32)
3822 vty_out (vty
, "%s(%s)",
3823 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
3824 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
, buf1
, BUFSIZ
));
3827 #endif /* HAVE_IPV6 */
3829 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
3830 vty_out (vty
, "%10d", attr
->med
);
3834 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
3835 vty_out (vty
, "%7d", attr
->local_pref
);
3839 vty_out (vty
, "%7d ",attr
->weight
);
3843 aspath_print_vty (vty
, attr
->aspath
);
3846 if (strlen (attr
->aspath
->str
) == 0)
3847 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
3849 vty_out (vty
, " %s", bgp_origin_str
[attr
->origin
]);
3852 vty_out (vty
, "%s", VTY_NEWLINE
);
3856 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
3857 struct bgp_info
*binfo
, int display
, safi_t safi
)
3860 unsigned long length
= 0;
3861 u_int32_t label
= 0;
3863 length
= vty
->obuf
->length
;
3865 /* Route status display. */
3866 if (binfo
->suppress
)
3868 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
3874 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
3876 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
3878 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
3883 /* Internal route. */
3884 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
3889 /* print prefix and mask */
3891 route_vty_out_route (p
, vty
);
3893 vty_out (vty
, "%*s", 17, " ");
3895 /* Print attribute */
3899 if (p
->family
== AF_INET
)
3901 if (safi
== SAFI_MPLS_VPN
)
3902 vty_out (vty
, "%-16s", inet_ntoa (attr
->mp_nexthop_global_in
));
3904 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
3907 else if (p
->family
== AF_INET6
)
3911 if (attr
->mp_nexthop_len
== 16)
3913 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
));
3914 else if (attr
->mp_nexthop_len
== 32)
3915 vty_out (vty
, "%s(%s)",
3916 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
3917 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
, buf1
, BUFSIZ
));
3920 #endif /* HAVE_IPV6 */
3923 label
= decode_label (binfo
->tag
);
3925 vty_out (vty
, "notag/%d", label
);
3927 vty_out (vty
, "%s", VTY_NEWLINE
);
3929 return vty_calc_line (vty
, length
);
3934 route_vty_out_route_ipv6 (struct prefix
*p
, struct vty
*vty
)
3939 len
= vty_out (vty
, "%s/%d",
3940 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
3945 vty_out (vty
, "%*s", len
, " ");
3948 /* called from terminal list command */
3950 route_vty_out_ipv6 (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
)
3953 unsigned long length
;
3956 length
= vty
->obuf
->length
;
3958 /* Route status display. */
3959 if (binfo
->suppress
)
3961 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
3967 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
3972 /* Internal route. */
3973 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
3978 /* print prefix and mask */
3979 route_vty_out_route_ipv6 (p
, vty
);
3981 /* Print attribute */
3985 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
3986 vty_out (vty
, "%7d", attr
->med
);
3991 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
3992 vty_out (vty
, "%7d", attr
->local_pref
);
3997 vty_out (vty
, "%7d ",attr
->weight
);
4001 aspath_print_vty (vty
, attr
->aspath
);
4004 if (strlen (attr
->aspath
->str
) == 0)
4005 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
4007 vty_out (vty
, " %s", bgp_origin_str
[attr
->origin
]);
4009 vty_out (vty
, "%s", VTY_NEWLINE
);
4011 line
= vty_calc_line (vty
, length
);
4012 length
= vty
->obuf
->length
;
4019 if (attr
->mp_nexthop_len
== 16)
4020 vty_out (vty
, " %s%s",
4021 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
4023 else if (attr
->mp_nexthop_len
== 32)
4024 vty_out (vty
, " %s(%s)%s",
4025 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
4026 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
, buf1
, BUFSIZ
),
4029 return line
+ vty_calc_line (vty
, length
);
4032 /* called from terminal list command */
4034 route_vty_out_ipv6_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
)
4036 /* Selected tag display. */
4037 vty_out (vty
, "*> ");
4039 /* print prefix and mask */
4040 route_vty_out_route_ipv6 (p
, vty
);
4043 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
4044 vty_out (vty
, "%7d", attr
->med
);
4049 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
4050 vty_out (vty
, "%7d", attr
->local_pref
);
4055 vty_out (vty
, "%7d ",attr
->weight
);
4059 aspath_print_vty (vty
, attr
->aspath
);
4062 if (strlen (attr
->aspath
->str
) == 0)
4063 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
4065 vty_out (vty
, " %s", bgp_origin_str
[attr
->origin
]);
4067 vty_out (vty
, "%s", VTY_NEWLINE
);
4074 if (attr
->mp_nexthop_len
== 16)
4075 vty_out (vty
, " %s%s",
4076 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
4078 else if (attr
->mp_nexthop_len
== 32)
4079 vty_out (vty
, " %s(%s)%s",
4080 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
, buf
, BUFSIZ
),
4081 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
, buf1
, BUFSIZ
),
4085 #endif /* HAVE_IPV6 */
4088 route_vty_out_detail (struct vty
*vty
, struct prefix
*p
,
4089 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
)
4091 char buf
[INET6_ADDRSTRLEN
];
4095 int sockunion_vty_out (struct vty
*, union sockunion
*);
4098 bgp
= bgp_get_default ();
4102 /* Line1 display AS-path, Aggregator */
4106 if (attr
->aspath
->length
== 0)
4107 vty_out (vty
, "Local");
4109 aspath_print_vty (vty
, attr
->aspath
);
4112 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
)
4113 || CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
)
4114 || CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
4115 || CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
)
4116 || CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
4120 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR
))
4121 vty_out (vty
, " (aggregated by %d %s)", attr
->aggregator_as
,
4122 inet_ntoa (attr
->aggregator_addr
));
4123 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
4124 vty_out (vty
, " (Received from a RR-client)");
4125 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
4126 vty_out (vty
, " (Received from a RS-client)");
4127 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
4128 vty_out (vty
, " (history entry)");
4129 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
4130 vty_out (vty
, " (suppressed due to dampening)");
4132 vty_out (vty
, "%s", VTY_NEWLINE
);
4134 /* Line2 display Next-hop, Neighbor, Router-id */
4135 if (p
->family
== AF_INET
)
4137 vty_out (vty
, " %s", safi
== SAFI_MPLS_VPN
?
4138 inet_ntoa (attr
->mp_nexthop_global_in
) :
4139 inet_ntoa (attr
->nexthop
));
4144 vty_out (vty
, " %s",
4145 inet_ntop (AF_INET6
, &attr
->mp_nexthop_global
,
4146 buf
, INET6_ADDRSTRLEN
));
4148 #endif /* HAVE_IPV6 */
4150 if (binfo
->peer
== peer_self
)
4152 vty_out (vty
, " from %s ",
4153 p
->family
== AF_INET
? "0.0.0.0" : "::");
4154 vty_out (vty
, "(%s)", inet_ntoa(bgp
->id
));
4158 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
4159 vty_out (vty
, " (inaccessible)");
4160 else if (binfo
->igpmetric
)
4161 vty_out (vty
, " (metric %d)", binfo
->igpmetric
);
4162 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
4163 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
4164 vty_out (vty
, " (%s)", inet_ntoa (attr
->originator_id
));
4166 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
4168 vty_out (vty
, "%s", VTY_NEWLINE
);
4171 /* display nexthop local */
4172 if (attr
->mp_nexthop_len
== 32)
4174 vty_out (vty
, " (%s)%s",
4175 inet_ntop (AF_INET6
, &attr
->mp_nexthop_local
,
4176 buf
, INET6_ADDRSTRLEN
),
4179 #endif /* HAVE_IPV6 */
4181 /* Line 3 display Origin, Med, Locpref, Weight, valid, Int/Ext/Local, Atomic, best */
4182 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
4184 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
4185 vty_out (vty
, ", metric %d", attr
->med
);
4187 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
4188 vty_out (vty
, ", localpref %d", attr
->local_pref
);
4190 vty_out (vty
, ", localpref %d", bgp
->default_local_pref
);
4192 if (attr
->weight
!= 0)
4193 vty_out (vty
, ", weight %d", attr
->weight
);
4195 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
4196 vty_out (vty
, ", valid");
4198 if (binfo
->peer
!= peer_self
)
4200 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
4201 vty_out (vty
, ", internal");
4203 vty_out (vty
, ", %s",
4204 (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
) ? "confed-external" : "external"));
4206 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
4207 vty_out (vty
, ", aggregated, local");
4208 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
4209 vty_out (vty
, ", sourced");
4211 vty_out (vty
, ", sourced, local");
4213 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4214 vty_out (vty
, ", atomic-aggregate");
4216 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
4217 vty_out (vty
, ", best");
4219 vty_out (vty
, "%s", VTY_NEWLINE
);
4221 /* Line 4 display Community */
4222 if (attr
->community
)
4224 vty_out (vty
, " Community:");
4225 community_print_vty (vty
, attr
->community
);
4226 vty_out (vty
, "%s", VTY_NEWLINE
);
4229 /* Line 5 display Extended-community */
4230 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
4232 vty_out (vty
, " Extended Community:");
4233 ecommunity_vty_out (vty
, attr
->ecommunity
);
4234 vty_out (vty
, "%s", VTY_NEWLINE
);
4237 /* Line 6 display Originator, Cluster-id */
4238 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
4239 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
4241 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
4242 vty_out (vty
, " Originator: %s", inet_ntoa (attr
->originator_id
));
4244 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
4247 vty_out (vty
, ", Cluster list: ");
4248 for (i
= 0; i
< attr
->cluster
->length
/ 4; i
++)
4249 vty_out (vty
, "%s ", inet_ntoa (attr
->cluster
->list
[i
]));
4251 vty_out (vty
, "%s", VTY_NEWLINE
);
4254 if (binfo
->bgp_damp_info
)
4255 bgp_damp_info_print (vty
, binfo
);
4257 /* Line 7 display Uptime */
4258 vty_out (vty
, " Last update: %s", ctime (&binfo
->uptime
));
4260 vty_out (vty
, "%s", VTY_NEWLINE
);
4263 #define BGP_SHOW_V4_HEADER " Network Next Hop Metric LocPrf Weight Path%s"
4264 #define BGP_SHOW_V6_HEADER " Network Metric LocPrf Weight Path%s"
4268 bgp_show_type_normal
,
4269 bgp_show_type_regexp
,
4270 bgp_show_type_prefix_list
,
4271 bgp_show_type_filter_list
,
4272 bgp_show_type_neighbor
,
4273 bgp_show_type_cidr_only
,
4274 bgp_show_type_prefix_longer
,
4275 bgp_show_type_community_all
,
4276 bgp_show_type_community
,
4277 bgp_show_type_community_exact
,
4278 bgp_show_type_community_list
,
4279 bgp_show_type_community_list_exact
4283 bgp_show_callback (struct vty
*vty
, int unlock
)
4285 struct route_node
*rn
;
4286 struct bgp_info
*ri
;
4291 rn
= vty
->output_rn
;
4293 limit
= ((vty
->lines
== 0)
4294 ? 10 : (vty
->lines
> 0
4295 ? vty
->lines
: vty
->height
- 2));
4296 limit
= limit
> 0 ? limit
: 2;
4298 /* Quit of display. */
4301 route_unlock_node (rn
);
4302 if (vty
->output_clean
)
4303 (*vty
->output_clean
) (vty
);
4304 vty
->output_rn
= NULL
;
4305 vty
->output_func
= NULL
;
4306 vty
->output_clean
= NULL
;
4307 vty
->output_arg
= NULL
;
4311 for (; rn
; rn
= route_next (rn
))
4312 if (rn
->info
!= NULL
)
4316 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4318 if (vty
->output_type
== bgp_show_type_regexp
)
4320 regex_t
*regex
= vty
->output_arg
;
4322 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
4325 if (vty
->output_type
== bgp_show_type_prefix_list
)
4327 struct prefix_list
*plist
= vty
->output_arg
;
4329 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
4332 if (vty
->output_type
== bgp_show_type_filter_list
)
4334 struct as_list
*as_list
= vty
->output_arg
;
4336 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
4339 if (vty
->output_type
== bgp_show_type_neighbor
)
4341 union sockunion
*su
= vty
->output_arg
;
4343 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
4346 if (vty
->output_type
== bgp_show_type_cidr_only
)
4348 u_int32_t destination
;
4350 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
4351 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
4353 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
4355 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
4358 if (vty
->output_type
== bgp_show_type_prefix_longer
)
4360 struct prefix
*p
= vty
->output_arg
;
4362 if (! prefix_match (p
, &rn
->p
))
4365 if (vty
->output_type
== bgp_show_type_community_all
)
4367 if (! ri
->attr
->community
)
4370 if (vty
->output_type
== bgp_show_type_community
)
4372 struct community
*com
= vty
->output_arg
;
4374 if (! ri
->attr
->community
||
4375 ! community_match (ri
->attr
->community
, com
))
4378 if (vty
->output_type
== bgp_show_type_community_exact
)
4380 struct community
*com
= vty
->output_arg
;
4382 if (! ri
->attr
->community
||
4383 ! community_cmp (ri
->attr
->community
, com
))
4386 if (vty
->output_type
== bgp_show_type_community_list
)
4388 struct community_list
*list
= vty
->output_arg
;
4390 if (! community_list_match (ri
->attr
->community
, list
))
4393 if (vty
->output_type
== bgp_show_type_community_list_exact
)
4395 struct community_list
*list
= vty
->output_arg
;
4397 if (! community_list_match_exact (ri
->attr
->community
, list
))
4401 if (rn
->p
.family
== AF_INET
)
4403 count
+= route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
4407 else if (rn
->p
.family
== AF_INET6
)
4409 count
+= route_vty_out_ipv6 (vty
, &rn
->p
, ri
);
4412 #endif /* HAVE_IPV6 */
4416 vty
->output_count
++;
4418 /* Remember current pointer then suspend output. */
4421 vty
->status
= VTY_CONTINUE
;
4422 vty
->output_rn
= route_next (rn
);;
4423 vty
->output_func
= bgp_show_callback
;
4428 /* Total line display. */
4429 if (vty
->output_count
)
4430 vty_out (vty
, "%sTotal number of prefixes %ld%s",
4431 VTY_NEWLINE
, vty
->output_count
, VTY_NEWLINE
);
4433 if (vty
->output_clean
)
4434 (*vty
->output_clean
) (vty
);
4436 vty
->status
= VTY_CONTINUE
;
4437 vty
->output_rn
= NULL
;
4438 vty
->output_func
= NULL
;
4439 vty
->output_clean
= NULL
;
4440 vty
->output_arg
= NULL
;
4446 bgp_show (struct vty
*vty
, char *view_name
, afi_t afi
, safi_t safi
,
4447 enum bgp_show_type type
)
4450 struct bgp_info
*ri
;
4451 struct route_node
*rn
;
4452 struct route_table
*table
;
4458 limit
= ((vty
->lines
== 0)
4459 ? 10 : (vty
->lines
> 0
4460 ? vty
->lines
: vty
->height
- 2));
4461 limit
= limit
> 0 ? limit
: 2;
4463 /* BGP structure lookup. */
4466 bgp
= bgp_lookup_by_name (view_name
);
4469 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
4475 bgp
= bgp_get_default ();
4478 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
4485 /* This is first entry point, so reset total line. */
4486 vty
->output_count
= 0;
4487 vty
->output_type
= type
;
4489 table
= bgp
->rib
[afi
][safi
];
4491 /* Start processing of routes. */
4492 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
4493 if (rn
->info
!= NULL
)
4497 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4499 if (type
== bgp_show_type_regexp
)
4501 regex_t
*regex
= vty
->output_arg
;
4503 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
4506 if (type
== bgp_show_type_prefix_list
)
4508 struct prefix_list
*plist
= vty
->output_arg
;
4510 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
4513 if (type
== bgp_show_type_filter_list
)
4515 struct as_list
*as_list
= vty
->output_arg
;
4517 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
4520 if (type
== bgp_show_type_neighbor
)
4522 union sockunion
*su
= vty
->output_arg
;
4524 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
4527 if (type
== bgp_show_type_cidr_only
)
4529 u_int32_t destination
;
4531 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
4532 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
4534 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
4536 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
4539 if (type
== bgp_show_type_prefix_longer
)
4541 struct prefix
*p
= vty
->output_arg
;
4543 if (! prefix_match (p
, &rn
->p
))
4546 if (type
== bgp_show_type_community_all
)
4548 if (! ri
->attr
->community
)
4551 if (type
== bgp_show_type_community
)
4553 struct community
*com
= vty
->output_arg
;
4555 if (! ri
->attr
->community
||
4556 ! community_match (ri
->attr
->community
, com
))
4559 if (type
== bgp_show_type_community_exact
)
4561 struct community
*com
= vty
->output_arg
;
4563 if (! ri
->attr
->community
||
4564 ! community_cmp (ri
->attr
->community
, com
))
4567 if (type
== bgp_show_type_community_list
)
4569 struct community_list
*list
= vty
->output_arg
;
4571 if (! community_list_match (ri
->attr
->community
, list
))
4574 if (type
== bgp_show_type_community_list_exact
)
4576 struct community_list
*list
= vty
->output_arg
;
4578 if (! community_list_match_exact (ri
->attr
->community
, list
))
4584 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->id
), VTY_NEWLINE
);
4585 vty_out (vty
, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE
);
4586 vty_out (vty
, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE
, VTY_NEWLINE
);
4588 vty_out (vty
, BGP_SHOW_V4_HEADER
, VTY_NEWLINE
);
4589 else if (afi
== AFI_IP6
)
4590 vty_out (vty
, BGP_SHOW_V6_HEADER
, VTY_NEWLINE
);
4597 count
+= route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
);
4601 else if (afi
== AFI_IP6
)
4603 count
+= route_vty_out_ipv6 (vty
, &rn
->p
, ri
);
4606 #endif /* HAVE_IPV6 */
4610 vty
->output_count
++;
4612 /* Remember current pointer then suspend output. */
4613 if (count
>= limit
&& vty
->type
!= VTY_SHELL_SERV
)
4615 vty
->status
= VTY_START
;
4616 vty
->output_rn
= route_next (rn
);
4617 vty
->output_func
= bgp_show_callback
;
4618 vty
->output_type
= type
;
4624 /* No route is displayed */
4625 if (vty
->output_count
== 0)
4627 if (type
== bgp_show_type_normal
)
4628 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
4631 vty_out (vty
, "%sTotal number of prefixes %ld%s",
4632 VTY_NEWLINE
, vty
->output_count
, VTY_NEWLINE
);
4634 /* Clean up allocated resources. */
4635 if (vty
->output_clean
)
4636 (*vty
->output_clean
) (vty
);
4638 vty
->status
= VTY_START
;
4639 vty
->output_rn
= NULL
;
4640 vty
->output_func
= NULL
;
4641 vty
->output_clean
= NULL
;
4642 vty
->output_arg
= NULL
;
4647 /* Display specified route of BGP table. */
4649 bgp_show_route (struct vty
*vty
, char *view_name
, char *ip_str
,
4650 afi_t afi
, safi_t safi
, int prefix_check
)
4657 int no_advertise
= 0;
4659 char buf
[INET6_ADDRSTRLEN
];
4661 struct prefix match
;
4663 struct route_node
*rn
;
4664 struct bgp_info
*ri
;
4665 struct peer_conf
*conf
;
4666 struct listnode
*nn
;
4669 /* BGP structure lookup. */
4672 bgp
= bgp_lookup_by_name (view_name
);
4675 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
4681 bgp
= bgp_get_default ();
4684 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
4689 /* Check IP address argument. */
4690 ret
= str2prefix (ip_str
, &match
);
4693 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
4697 match
.family
= afi2family (afi
);
4699 /* Lookup route node. */
4700 rn
= route_node_match (bgp
->rib
[afi
][safi
], &match
);
4703 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
4710 if (p
->prefixlen
!= match
.prefixlen
)
4712 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
4717 /* Header of detailed BGP route information */
4718 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4721 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
4726 if (ri
->attr
->community
!= NULL
)
4728 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
4730 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
4732 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
4737 vty_out (vty
, "BGP routing table entry for %s/%d%s",
4738 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, INET6_ADDRSTRLEN
),
4739 p
->prefixlen
, VTY_NEWLINE
);
4741 vty_out (vty
, "Paths: (%d available", count
);
4744 vty_out (vty
, ", best #%d", best
);
4745 if (safi
== SAFI_UNICAST
)
4746 vty_out (vty
, ", table Default-IP-Routing-Table");
4749 vty_out (vty
, ", no best path");
4751 vty_out (vty
, ", not advertised to any peer");
4753 vty_out (vty
, ", not advertised to EBGP peer");
4755 vty_out (vty
, ", not advertised outside local AS");
4757 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
4758 vty_out (vty
, ")%s", VTY_NEWLINE
);
4760 /* advertised peer */
4761 LIST_LOOP (bgp
->peer_conf
, conf
, nn
)
4763 if (bgp_adj_lookup (conf
->peer
->adj_out
[afi
][safi
], p
, NULL
, safi
))
4766 vty_out (vty
, " Advertised to non peer-group peers:%s ", VTY_NEWLINE
);
4767 vty_out (vty
, " %s", sockunion2str (&conf
->peer
->su
, buf
, SU_ADDRSTRLEN
));
4772 vty_out (vty
, " Not advertised to any peer");
4773 vty_out (vty
, "%s", VTY_NEWLINE
);
4775 /* Node is locked by route_node_match(). */
4776 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4777 route_vty_out_detail (vty
, &rn
->p
, ri
, afi
, safi
);
4779 /* Work is done, so unlock the node. */
4780 route_unlock_node (rn
);
4785 /* BGP route print out function. */
4793 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
);
4796 DEFUN (show_ip_bgp_ipv4
,
4797 show_ip_bgp_ipv4_cmd
,
4798 "show ip bgp ipv4 (unicast|multicast)",
4803 "Address Family modifier\n"
4804 "Address Family modifier\n")
4806 if (strncmp (argv
[0], "m", 1) == 0)
4807 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
);
4809 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
);
4812 DEFUN (show_ip_bgp_route
,
4813 show_ip_bgp_route_cmd
,
4814 "show ip bgp A.B.C.D",
4818 "Network in the BGP routing table to display\n")
4820 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, 0);
4823 DEFUN (show_ip_bgp_ipv4_route
,
4824 show_ip_bgp_ipv4_route_cmd
,
4825 "show ip bgp ipv4 (unicast|multicast) A.B.C.D",
4830 "Address Family modifier\n"
4831 "Address Family modifier\n"
4832 "Network in the BGP routing table to display\n")
4834 if (strncmp (argv
[0], "m", 1) == 0)
4835 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, 0);
4837 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, 0);
4840 DEFUN (show_ip_bgp_prefix
,
4841 show_ip_bgp_prefix_cmd
,
4842 "show ip bgp A.B.C.D/M",
4846 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4848 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, 1);
4851 DEFUN (show_ip_bgp_ipv4_prefix
,
4852 show_ip_bgp_ipv4_prefix_cmd
,
4853 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M",
4858 "Address Family modifier\n"
4859 "Address Family modifier\n"
4860 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4862 if (strncmp (argv
[0], "m", 1) == 0)
4863 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, 1);
4865 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, 1);
4868 DEFUN (show_ip_bgp_view
,
4869 show_ip_bgp_view_cmd
,
4870 "show ip bgp view WORD",
4877 return bgp_show (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
);
4880 DEFUN (show_ip_bgp_view_route
,
4881 show_ip_bgp_view_route_cmd
,
4882 "show ip bgp view WORD A.B.C.D",
4888 "Network in the BGP routing table to display\n")
4890 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, 0);
4893 DEFUN (show_ip_bgp_view_prefix
,
4894 show_ip_bgp_view_prefix_cmd
,
4895 "show ip bgp view WORD A.B.C.D/M",
4901 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4903 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, 1);
4913 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
);
4924 DEFUN (show_ipv6_bgp
,
4931 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
);
4934 DEFUN (show_bgp_route
,
4936 "show bgp X:X::X:X",
4939 "Network in the BGP routing table to display\n")
4941 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0);
4944 ALIAS (show_bgp_route
,
4945 show_bgp_ipv6_route_cmd
,
4946 "show bgp ipv6 X:X::X:X",
4950 "Network in the BGP routing table to display\n")
4953 DEFUN (show_ipv6_bgp_route
,
4954 show_ipv6_bgp_route_cmd
,
4955 "show ipv6 bgp X:X::X:X",
4959 "Network in the BGP routing table to display\n")
4961 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0);
4964 DEFUN (show_bgp_prefix
,
4965 show_bgp_prefix_cmd
,
4966 "show bgp X:X::X:X/M",
4969 "IPv6 prefix <network>/<length>\n")
4971 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 1);
4974 ALIAS (show_bgp_prefix
,
4975 show_bgp_ipv6_prefix_cmd
,
4976 "show bgp ipv6 X:X::X:X/M",
4980 "IPv6 prefix <network>/<length>\n")
4983 DEFUN (show_ipv6_bgp_prefix
,
4984 show_ipv6_bgp_prefix_cmd
,
4985 "show ipv6 bgp X:X::X:X/M",
4989 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4991 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 1);
4995 DEFUN (show_ipv6_mbgp
,
5002 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
);
5006 DEFUN (show_ipv6_mbgp_route
,
5007 show_ipv6_mbgp_route_cmd
,
5008 "show ipv6 mbgp X:X::X:X",
5012 "Network in the MBGP routing table to display\n")
5014 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, 0);
5018 DEFUN (show_ipv6_mbgp_prefix
,
5019 show_ipv6_mbgp_prefix_cmd
,
5020 "show ipv6 mbgp X:X::X:X/M",
5024 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
5026 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, 1);
5031 bgp_show_regexp_clean (struct vty
*vty
)
5033 bgp_regex_free (vty
->output_arg
);
5037 bgp_show_regexp (struct vty
*vty
, int argc
, char **argv
, u_int16_t afi
,
5047 b
= buffer_new (1024);
5048 for (i
= 0; i
< argc
; i
++)
5051 buffer_putc (b
, ' ');
5054 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
5059 buffer_putstr (b
, argv
[i
]);
5061 buffer_putc (b
, '\0');
5063 regstr
= buffer_getstr (b
);
5066 regex
= bgp_regcomp (regstr
);
5069 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
5074 vty
->output_arg
= regex
;
5075 vty
->output_clean
= bgp_show_regexp_clean
;
5077 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_regexp
);
5080 DEFUN (show_ip_bgp_regexp
,
5081 show_ip_bgp_regexp_cmd
,
5082 "show ip bgp regexp .LINE",
5086 "Display routes matching the AS path regular expression\n"
5087 "A regular-expression to match the BGP AS paths\n")
5089 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
);
5092 DEFUN (show_ip_bgp_ipv4_regexp
,
5093 show_ip_bgp_ipv4_regexp_cmd
,
5094 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
5099 "Address Family modifier\n"
5100 "Address Family modifier\n"
5101 "Display routes matching the AS path regular expression\n"
5102 "A regular-expression to match the BGP AS paths\n")
5104 if (strncmp (argv
[0], "m", 1) == 0)
5105 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
);
5107 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
);
5111 DEFUN (show_bgp_regexp
,
5112 show_bgp_regexp_cmd
,
5113 "show bgp regexp .LINE",
5116 "Display routes matching the AS path regular expression\n"
5117 "A regular-expression to match the BGP AS paths\n")
5119 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
);
5122 ALIAS (show_bgp_regexp
,
5123 show_bgp_ipv6_regexp_cmd
,
5124 "show bgp ipv6 regexp .LINE",
5128 "Display routes matching the AS path regular expression\n"
5129 "A regular-expression to match the BGP AS paths\n")
5132 DEFUN (show_ipv6_bgp_regexp
,
5133 show_ipv6_bgp_regexp_cmd
,
5134 "show ipv6 bgp regexp .LINE",
5138 "Display routes matching the AS path regular expression\n"
5139 "A regular-expression to match the BGP AS paths\n")
5141 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
);
5145 DEFUN (show_ipv6_mbgp_regexp
,
5146 show_ipv6_mbgp_regexp_cmd
,
5147 "show ipv6 mbgp regexp .LINE",
5151 "Display routes matching the AS path regular expression\n"
5152 "A regular-expression to match the MBGP AS paths\n")
5154 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
);
5156 #endif /* HAVE_IPV6 */
5159 bgp_show_prefix_list (struct vty
*vty
, char *prefix_list_str
, u_int16_t afi
,
5162 struct prefix_list
*plist
;
5164 plist
= prefix_list_lookup (afi
, prefix_list_str
);
5167 vty_out (vty
, "%% %s is not a valid prefix-list name%s", prefix_list_str
, VTY_NEWLINE
);
5171 vty
->output_arg
= plist
;
5173 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_prefix_list
);
5176 DEFUN (show_ip_bgp_prefix_list
,
5177 show_ip_bgp_prefix_list_cmd
,
5178 "show ip bgp prefix-list WORD",
5182 "Display routes matching the prefix-list\n"
5183 "IP prefix-list name\n")
5185 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
);
5188 DEFUN (show_ip_bgp_ipv4_prefix_list
,
5189 show_ip_bgp_ipv4_prefix_list_cmd
,
5190 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
5195 "Address Family modifier\n"
5196 "Address Family modifier\n"
5197 "Display routes matching the prefix-list\n"
5198 "IP prefix-list name\n")
5200 if (strncmp (argv
[0], "m", 1) == 0)
5201 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
);
5203 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
);
5207 DEFUN (show_bgp_prefix_list
,
5208 show_bgp_prefix_list_cmd
,
5209 "show bgp prefix-list WORD",
5212 "Display routes matching the prefix-list\n"
5213 "IPv6 prefix-list name\n")
5215 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5218 ALIAS (show_bgp_prefix_list
,
5219 show_bgp_ipv6_prefix_list_cmd
,
5220 "show bgp ipv6 prefix-list WORD",
5224 "Display routes matching the prefix-list\n"
5225 "IPv6 prefix-list name\n")
5228 DEFUN (show_ipv6_bgp_prefix_list
,
5229 show_ipv6_bgp_prefix_list_cmd
,
5230 "show ipv6 bgp prefix-list WORD",
5234 "Display routes matching the prefix-list\n"
5235 "IPv6 prefix-list name\n")
5237 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5241 DEFUN (show_ipv6_mbgp_prefix_list
,
5242 show_ipv6_mbgp_prefix_list_cmd
,
5243 "show ipv6 mbgp prefix-list WORD",
5247 "Display routes matching the prefix-list\n"
5248 "IPv6 prefix-list name\n")
5250 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
);
5252 #endif /* HAVE_IPV6 */
5255 bgp_show_filter_list (struct vty
*vty
, char *filter
, u_int16_t afi
,
5258 struct as_list
*as_list
;
5260 as_list
= as_list_lookup (filter
);
5261 if (as_list
== NULL
)
5263 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
5267 vty
->output_arg
= as_list
;
5269 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_filter_list
);
5272 DEFUN (show_ip_bgp_filter_list
,
5273 show_ip_bgp_filter_list_cmd
,
5274 "show ip bgp filter-list WORD",
5278 "Display routes conforming to the filter-list\n"
5279 "Regular expression access list name\n")
5281 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
);
5284 DEFUN (show_ip_bgp_ipv4_filter_list
,
5285 show_ip_bgp_ipv4_filter_list_cmd
,
5286 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
5291 "Address Family modifier\n"
5292 "Address Family modifier\n"
5293 "Display routes conforming to the filter-list\n"
5294 "Regular expression access list name\n")
5296 if (strncmp (argv
[0], "m", 1) == 0)
5297 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
);
5299 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
);
5303 DEFUN (show_bgp_filter_list
,
5304 show_bgp_filter_list_cmd
,
5305 "show bgp filter-list WORD",
5308 "Display routes conforming to the filter-list\n"
5309 "Regular expression access list name\n")
5311 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5314 ALIAS (show_bgp_filter_list
,
5315 show_bgp_ipv6_filter_list_cmd
,
5316 "show bgp ipv6 filter-list WORD",
5320 "Display routes conforming to the filter-list\n"
5321 "Regular expression access list name\n")
5324 DEFUN (show_ipv6_bgp_filter_list
,
5325 show_ipv6_bgp_filter_list_cmd
,
5326 "show ipv6 bgp filter-list WORD",
5330 "Display routes conforming to the filter-list\n"
5331 "Regular expression access list name\n")
5333 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5337 DEFUN (show_ipv6_mbgp_filter_list
,
5338 show_ipv6_mbgp_filter_list_cmd
,
5339 "show ipv6 mbgp filter-list WORD",
5343 "Display routes conforming to the filter-list\n"
5344 "Regular expression access list name\n")
5346 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
);
5348 #endif /* HAVE_IPV6 */
5350 DEFUN (show_ip_bgp_cidr_only
,
5351 show_ip_bgp_cidr_only_cmd
,
5352 "show ip bgp cidr-only",
5356 "Display only routes with non-natural netmasks\n")
5358 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
5359 bgp_show_type_cidr_only
);
5362 DEFUN (show_ip_bgp_ipv4_cidr_only
,
5363 show_ip_bgp_ipv4_cidr_only_cmd
,
5364 "show ip bgp ipv4 (unicast|multicast) cidr-only",
5369 "Address Family modifier\n"
5370 "Address Family modifier\n"
5371 "Display only routes with non-natural netmasks\n")
5373 if (strncmp (argv
[0], "m", 1) == 0)
5374 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
5375 bgp_show_type_cidr_only
);
5377 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
5378 bgp_show_type_cidr_only
);
5381 DEFUN (show_ip_bgp_community_all
,
5382 show_ip_bgp_community_all_cmd
,
5383 "show ip bgp community",
5387 "Display routes matching the communities\n")
5389 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
5390 bgp_show_type_community_all
);
5393 DEFUN (show_ip_bgp_ipv4_community_all
,
5394 show_ip_bgp_ipv4_community_all_cmd
,
5395 "show ip bgp ipv4 (unicast|multicast) community",
5400 "Address Family modifier\n"
5401 "Address Family modifier\n"
5402 "Display routes matching the communities\n")
5404 if (strncmp (argv
[0], "m", 1) == 0)
5405 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
5406 bgp_show_type_community_all
);
5408 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
5409 bgp_show_type_community_all
);
5413 DEFUN (show_bgp_community_all
,
5414 show_bgp_community_all_cmd
,
5415 "show bgp community",
5418 "Display routes matching the communities\n")
5420 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
5421 bgp_show_type_community_all
);
5424 ALIAS (show_bgp_community_all
,
5425 show_bgp_ipv6_community_all_cmd
,
5426 "show bgp ipv6 community",
5430 "Display routes matching the communities\n")
5433 DEFUN (show_ipv6_bgp_community_all
,
5434 show_ipv6_bgp_community_all_cmd
,
5435 "show ipv6 bgp community",
5439 "Display routes matching the communities\n")
5441 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
5442 bgp_show_type_community_all
);
5446 DEFUN (show_ipv6_mbgp_community_all
,
5447 show_ipv6_mbgp_community_all_cmd
,
5448 "show ipv6 mbgp community",
5452 "Display routes matching the communities\n")
5454 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
5455 bgp_show_type_community_all
);
5457 #endif /* HAVE_IPV6 */
5460 bgp_show_community (struct vty
*vty
, int argc
, char **argv
, int exact
,
5461 u_int16_t afi
, u_char safi
)
5463 struct community
*com
;
5469 b
= buffer_new (1024);
5470 for (i
= 0; i
< argc
; i
++)
5473 buffer_putc (b
, ' ');
5476 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
5481 buffer_putstr (b
, argv
[i
]);
5483 buffer_putc (b
, '\0');
5485 str
= buffer_getstr (b
);
5488 com
= community_str2com (str
);
5492 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
5496 vty
->output_arg
= com
;
5499 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_community_exact
);
5501 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_community
);
5504 DEFUN (show_ip_bgp_community
,
5505 show_ip_bgp_community_cmd
,
5506 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
5510 "Display routes matching the communities\n"
5511 "community number\n"
5512 "Do not send outside local AS (well-known community)\n"
5513 "Do not advertise to any peer (well-known community)\n"
5514 "Do not export to next AS (well-known community)\n")
5516 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
5519 ALIAS (show_ip_bgp_community
,
5520 show_ip_bgp_community2_cmd
,
5521 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
5525 "Display routes matching the communities\n"
5526 "community number\n"
5527 "Do not send outside local AS (well-known community)\n"
5528 "Do not advertise to any peer (well-known community)\n"
5529 "Do not export to next AS (well-known community)\n"
5530 "community number\n"
5531 "Do not send outside local AS (well-known community)\n"
5532 "Do not advertise to any peer (well-known community)\n"
5533 "Do not export to next AS (well-known community)\n")
5535 ALIAS (show_ip_bgp_community
,
5536 show_ip_bgp_community3_cmd
,
5537 "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)",
5541 "Display routes matching the communities\n"
5542 "community number\n"
5543 "Do not send outside local AS (well-known community)\n"
5544 "Do not advertise to any peer (well-known community)\n"
5545 "Do not export to next AS (well-known community)\n"
5546 "community number\n"
5547 "Do not send outside local AS (well-known community)\n"
5548 "Do not advertise to any peer (well-known community)\n"
5549 "Do not export to next AS (well-known community)\n"
5550 "community number\n"
5551 "Do not send outside local AS (well-known community)\n"
5552 "Do not advertise to any peer (well-known community)\n"
5553 "Do not export to next AS (well-known community)\n")
5555 ALIAS (show_ip_bgp_community
,
5556 show_ip_bgp_community4_cmd
,
5557 "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)",
5561 "Display routes matching the communities\n"
5562 "community number\n"
5563 "Do not send outside local AS (well-known community)\n"
5564 "Do not advertise to any peer (well-known community)\n"
5565 "Do not export to next AS (well-known community)\n"
5566 "community number\n"
5567 "Do not send outside local AS (well-known community)\n"
5568 "Do not advertise to any peer (well-known community)\n"
5569 "Do not export to next AS (well-known community)\n"
5570 "community number\n"
5571 "Do not send outside local AS (well-known community)\n"
5572 "Do not advertise to any peer (well-known community)\n"
5573 "Do not export to next AS (well-known community)\n"
5574 "community number\n"
5575 "Do not send outside local AS (well-known community)\n"
5576 "Do not advertise to any peer (well-known community)\n"
5577 "Do not export to next AS (well-known community)\n")
5579 DEFUN (show_ip_bgp_ipv4_community
,
5580 show_ip_bgp_ipv4_community_cmd
,
5581 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
5586 "Address Family modifier\n"
5587 "Address Family modifier\n"
5588 "Display routes matching the communities\n"
5589 "community number\n"
5590 "Do not send outside local AS (well-known community)\n"
5591 "Do not advertise to any peer (well-known community)\n"
5592 "Do not export to next AS (well-known community)\n")
5594 if (strncmp (argv
[0], "m", 1) == 0)
5595 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
5597 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
5600 ALIAS (show_ip_bgp_ipv4_community
,
5601 show_ip_bgp_ipv4_community2_cmd
,
5602 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
5607 "Address Family modifier\n"
5608 "Address Family modifier\n"
5609 "Display routes matching the communities\n"
5610 "community number\n"
5611 "Do not send outside local AS (well-known community)\n"
5612 "Do not advertise to any peer (well-known community)\n"
5613 "Do not export to next AS (well-known community)\n"
5614 "community number\n"
5615 "Do not send outside local AS (well-known community)\n"
5616 "Do not advertise to any peer (well-known community)\n"
5617 "Do not export to next AS (well-known community)\n")
5619 ALIAS (show_ip_bgp_ipv4_community
,
5620 show_ip_bgp_ipv4_community3_cmd
,
5621 "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)",
5626 "Address Family modifier\n"
5627 "Address Family modifier\n"
5628 "Display routes matching the communities\n"
5629 "community number\n"
5630 "Do not send outside local AS (well-known community)\n"
5631 "Do not advertise to any peer (well-known community)\n"
5632 "Do not export to next AS (well-known community)\n"
5633 "community number\n"
5634 "Do not send outside local AS (well-known community)\n"
5635 "Do not advertise to any peer (well-known community)\n"
5636 "Do not export to next AS (well-known community)\n"
5637 "community number\n"
5638 "Do not send outside local AS (well-known community)\n"
5639 "Do not advertise to any peer (well-known community)\n"
5640 "Do not export to next AS (well-known community)\n")
5642 ALIAS (show_ip_bgp_ipv4_community
,
5643 show_ip_bgp_ipv4_community4_cmd
,
5644 "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)",
5649 "Address Family modifier\n"
5650 "Address Family modifier\n"
5651 "Display routes matching the communities\n"
5652 "community number\n"
5653 "Do not send outside local AS (well-known community)\n"
5654 "Do not advertise to any peer (well-known community)\n"
5655 "Do not export to next AS (well-known community)\n"
5656 "community number\n"
5657 "Do not send outside local AS (well-known community)\n"
5658 "Do not advertise to any peer (well-known community)\n"
5659 "Do not export to next AS (well-known community)\n"
5660 "community number\n"
5661 "Do not send outside local AS (well-known community)\n"
5662 "Do not advertise to any peer (well-known community)\n"
5663 "Do not export to next AS (well-known community)\n"
5664 "community number\n"
5665 "Do not send outside local AS (well-known community)\n"
5666 "Do not advertise to any peer (well-known community)\n"
5667 "Do not export to next AS (well-known community)\n")
5669 DEFUN (show_ip_bgp_community_exact
,
5670 show_ip_bgp_community_exact_cmd
,
5671 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
5675 "Display routes matching the communities\n"
5676 "community number\n"
5677 "Do not send outside local AS (well-known community)\n"
5678 "Do not advertise to any peer (well-known community)\n"
5679 "Do not export to next AS (well-known community)\n"
5680 "Exact match of the communities")
5682 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
5685 ALIAS (show_ip_bgp_community_exact
,
5686 show_ip_bgp_community2_exact_cmd
,
5687 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
5691 "Display routes matching the communities\n"
5692 "community number\n"
5693 "Do not send outside local AS (well-known community)\n"
5694 "Do not advertise to any peer (well-known community)\n"
5695 "Do not export to next AS (well-known community)\n"
5696 "community number\n"
5697 "Do not send outside local AS (well-known community)\n"
5698 "Do not advertise to any peer (well-known community)\n"
5699 "Do not export to next AS (well-known community)\n"
5700 "Exact match of the communities")
5702 ALIAS (show_ip_bgp_community_exact
,
5703 show_ip_bgp_community3_exact_cmd
,
5704 "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",
5708 "Display routes matching the communities\n"
5709 "community number\n"
5710 "Do not send outside local AS (well-known community)\n"
5711 "Do not advertise to any peer (well-known community)\n"
5712 "Do not export to next AS (well-known community)\n"
5713 "community number\n"
5714 "Do not send outside local AS (well-known community)\n"
5715 "Do not advertise to any peer (well-known community)\n"
5716 "Do not export to next AS (well-known community)\n"
5717 "community number\n"
5718 "Do not send outside local AS (well-known community)\n"
5719 "Do not advertise to any peer (well-known community)\n"
5720 "Do not export to next AS (well-known community)\n"
5721 "Exact match of the communities")
5723 ALIAS (show_ip_bgp_community_exact
,
5724 show_ip_bgp_community4_exact_cmd
,
5725 "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",
5729 "Display routes matching the communities\n"
5730 "community number\n"
5731 "Do not send outside local AS (well-known community)\n"
5732 "Do not advertise to any peer (well-known community)\n"
5733 "Do not export to next AS (well-known community)\n"
5734 "community number\n"
5735 "Do not send outside local AS (well-known community)\n"
5736 "Do not advertise to any peer (well-known community)\n"
5737 "Do not export to next AS (well-known community)\n"
5738 "community number\n"
5739 "Do not send outside local AS (well-known community)\n"
5740 "Do not advertise to any peer (well-known community)\n"
5741 "Do not export to next AS (well-known community)\n"
5742 "community number\n"
5743 "Do not send outside local AS (well-known community)\n"
5744 "Do not advertise to any peer (well-known community)\n"
5745 "Do not export to next AS (well-known community)\n"
5746 "Exact match of the communities")
5748 DEFUN (show_ip_bgp_ipv4_community_exact
,
5749 show_ip_bgp_ipv4_community_exact_cmd
,
5750 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
5755 "Address Family modifier\n"
5756 "Address Family modifier\n"
5757 "Display routes matching the communities\n"
5758 "community number\n"
5759 "Do not send outside local AS (well-known community)\n"
5760 "Do not advertise to any peer (well-known community)\n"
5761 "Do not export to next AS (well-known community)\n"
5762 "Exact match of the communities")
5764 if (strncmp (argv
[0], "m", 1) == 0)
5765 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
5767 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
5770 ALIAS (show_ip_bgp_ipv4_community_exact
,
5771 show_ip_bgp_ipv4_community2_exact_cmd
,
5772 "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",
5777 "Address Family modifier\n"
5778 "Address Family modifier\n"
5779 "Display routes matching the communities\n"
5780 "community number\n"
5781 "Do not send outside local AS (well-known community)\n"
5782 "Do not advertise to any peer (well-known community)\n"
5783 "Do not export to next AS (well-known community)\n"
5784 "community number\n"
5785 "Do not send outside local AS (well-known community)\n"
5786 "Do not advertise to any peer (well-known community)\n"
5787 "Do not export to next AS (well-known community)\n"
5788 "Exact match of the communities")
5790 ALIAS (show_ip_bgp_ipv4_community_exact
,
5791 show_ip_bgp_ipv4_community3_exact_cmd
,
5792 "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",
5797 "Address Family modifier\n"
5798 "Address Family modifier\n"
5799 "Display routes matching the communities\n"
5800 "community number\n"
5801 "Do not send outside local AS (well-known community)\n"
5802 "Do not advertise to any peer (well-known community)\n"
5803 "Do not export to next AS (well-known community)\n"
5804 "community number\n"
5805 "Do not send outside local AS (well-known community)\n"
5806 "Do not advertise to any peer (well-known community)\n"
5807 "Do not export to next AS (well-known community)\n"
5808 "community number\n"
5809 "Do not send outside local AS (well-known community)\n"
5810 "Do not advertise to any peer (well-known community)\n"
5811 "Do not export to next AS (well-known community)\n"
5812 "Exact match of the communities")
5814 ALIAS (show_ip_bgp_ipv4_community_exact
,
5815 show_ip_bgp_ipv4_community4_exact_cmd
,
5816 "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",
5821 "Address Family modifier\n"
5822 "Address Family modifier\n"
5823 "Display routes matching the communities\n"
5824 "community number\n"
5825 "Do not send outside local AS (well-known community)\n"
5826 "Do not advertise to any peer (well-known community)\n"
5827 "Do not export to next AS (well-known community)\n"
5828 "community number\n"
5829 "Do not send outside local AS (well-known community)\n"
5830 "Do not advertise to any peer (well-known community)\n"
5831 "Do not export to next AS (well-known community)\n"
5832 "community number\n"
5833 "Do not send outside local AS (well-known community)\n"
5834 "Do not advertise to any peer (well-known community)\n"
5835 "Do not export to next AS (well-known community)\n"
5836 "community number\n"
5837 "Do not send outside local AS (well-known community)\n"
5838 "Do not advertise to any peer (well-known community)\n"
5839 "Do not export to next AS (well-known community)\n"
5840 "Exact match of the communities")
5843 DEFUN (show_bgp_community
,
5844 show_bgp_community_cmd
,
5845 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
5848 "Display routes matching the communities\n"
5849 "community number\n"
5850 "Do not send outside local AS (well-known community)\n"
5851 "Do not advertise to any peer (well-known community)\n"
5852 "Do not export to next AS (well-known community)\n")
5854 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
5857 ALIAS (show_bgp_community
,
5858 show_bgp_ipv6_community_cmd
,
5859 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
5863 "Display routes matching the communities\n"
5864 "community number\n"
5865 "Do not send outside local AS (well-known community)\n"
5866 "Do not advertise to any peer (well-known community)\n"
5867 "Do not export to next AS (well-known community)\n")
5869 ALIAS (show_bgp_community
,
5870 show_bgp_community2_cmd
,
5871 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
5874 "Display routes matching the communities\n"
5875 "community number\n"
5876 "Do not send outside local AS (well-known community)\n"
5877 "Do not advertise to any peer (well-known community)\n"
5878 "Do not export to next AS (well-known community)\n"
5879 "community number\n"
5880 "Do not send outside local AS (well-known community)\n"
5881 "Do not advertise to any peer (well-known community)\n"
5882 "Do not export to next AS (well-known community)\n")
5884 ALIAS (show_bgp_community
,
5885 show_bgp_ipv6_community2_cmd
,
5886 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
5890 "Display routes matching the communities\n"
5891 "community number\n"
5892 "Do not send outside local AS (well-known community)\n"
5893 "Do not advertise to any peer (well-known community)\n"
5894 "Do not export to next AS (well-known community)\n"
5895 "community number\n"
5896 "Do not send outside local AS (well-known community)\n"
5897 "Do not advertise to any peer (well-known community)\n"
5898 "Do not export to next AS (well-known community)\n")
5900 ALIAS (show_bgp_community
,
5901 show_bgp_community3_cmd
,
5902 "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)",
5905 "Display routes matching the communities\n"
5906 "community number\n"
5907 "Do not send outside local AS (well-known community)\n"
5908 "Do not advertise to any peer (well-known community)\n"
5909 "Do not export to next AS (well-known community)\n"
5910 "community number\n"
5911 "Do not send outside local AS (well-known community)\n"
5912 "Do not advertise to any peer (well-known community)\n"
5913 "Do not export to next AS (well-known community)\n"
5914 "community number\n"
5915 "Do not send outside local AS (well-known community)\n"
5916 "Do not advertise to any peer (well-known community)\n"
5917 "Do not export to next AS (well-known community)\n")
5919 ALIAS (show_bgp_community
,
5920 show_bgp_ipv6_community3_cmd
,
5921 "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)",
5925 "Display routes matching the communities\n"
5926 "community number\n"
5927 "Do not send outside local AS (well-known community)\n"
5928 "Do not advertise to any peer (well-known community)\n"
5929 "Do not export to next AS (well-known community)\n"
5930 "community number\n"
5931 "Do not send outside local AS (well-known community)\n"
5932 "Do not advertise to any peer (well-known community)\n"
5933 "Do not export to next AS (well-known community)\n"
5934 "community number\n"
5935 "Do not send outside local AS (well-known community)\n"
5936 "Do not advertise to any peer (well-known community)\n"
5937 "Do not export to next AS (well-known community)\n")
5939 ALIAS (show_bgp_community
,
5940 show_bgp_community4_cmd
,
5941 "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)",
5944 "Display routes matching the communities\n"
5945 "community number\n"
5946 "Do not send outside local AS (well-known community)\n"
5947 "Do not advertise to any peer (well-known community)\n"
5948 "Do not export to next AS (well-known community)\n"
5949 "community number\n"
5950 "Do not send outside local AS (well-known community)\n"
5951 "Do not advertise to any peer (well-known community)\n"
5952 "Do not export to next AS (well-known community)\n"
5953 "community number\n"
5954 "Do not send outside local AS (well-known community)\n"
5955 "Do not advertise to any peer (well-known community)\n"
5956 "Do not export to next AS (well-known community)\n"
5957 "community number\n"
5958 "Do not send outside local AS (well-known community)\n"
5959 "Do not advertise to any peer (well-known community)\n"
5960 "Do not export to next AS (well-known community)\n")
5962 ALIAS (show_bgp_community
,
5963 show_bgp_ipv6_community4_cmd
,
5964 "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)",
5968 "Display routes matching the communities\n"
5969 "community number\n"
5970 "Do not send outside local AS (well-known community)\n"
5971 "Do not advertise to any peer (well-known community)\n"
5972 "Do not export to next AS (well-known community)\n"
5973 "community number\n"
5974 "Do not send outside local AS (well-known community)\n"
5975 "Do not advertise to any peer (well-known community)\n"
5976 "Do not export to next AS (well-known community)\n"
5977 "community number\n"
5978 "Do not send outside local AS (well-known community)\n"
5979 "Do not advertise to any peer (well-known community)\n"
5980 "Do not export to next AS (well-known community)\n"
5981 "community number\n"
5982 "Do not send outside local AS (well-known community)\n"
5983 "Do not advertise to any peer (well-known community)\n"
5984 "Do not export to next AS (well-known community)\n")
5987 DEFUN (show_ipv6_bgp_community
,
5988 show_ipv6_bgp_community_cmd
,
5989 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
5993 "Display routes matching the communities\n"
5994 "community number\n"
5995 "Do not send outside local AS (well-known community)\n"
5996 "Do not advertise to any peer (well-known community)\n"
5997 "Do not export to next AS (well-known community)\n")
5999 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
6003 ALIAS (show_ipv6_bgp_community
,
6004 show_ipv6_bgp_community2_cmd
,
6005 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6009 "Display routes matching the communities\n"
6010 "community number\n"
6011 "Do not send outside local AS (well-known community)\n"
6012 "Do not advertise to any peer (well-known community)\n"
6013 "Do not export to next AS (well-known community)\n"
6014 "community number\n"
6015 "Do not send outside local AS (well-known community)\n"
6016 "Do not advertise to any peer (well-known community)\n"
6017 "Do not export to next AS (well-known community)\n")
6020 ALIAS (show_ipv6_bgp_community
,
6021 show_ipv6_bgp_community3_cmd
,
6022 "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)",
6026 "Display routes matching the communities\n"
6027 "community number\n"
6028 "Do not send outside local AS (well-known community)\n"
6029 "Do not advertise to any peer (well-known community)\n"
6030 "Do not export to next AS (well-known community)\n"
6031 "community number\n"
6032 "Do not send outside local AS (well-known community)\n"
6033 "Do not advertise to any peer (well-known community)\n"
6034 "Do not export to next AS (well-known community)\n"
6035 "community number\n"
6036 "Do not send outside local AS (well-known community)\n"
6037 "Do not advertise to any peer (well-known community)\n"
6038 "Do not export to next AS (well-known community)\n")
6041 ALIAS (show_ipv6_bgp_community
,
6042 show_ipv6_bgp_community4_cmd
,
6043 "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)",
6047 "Display routes matching the communities\n"
6048 "community number\n"
6049 "Do not send outside local AS (well-known community)\n"
6050 "Do not advertise to any peer (well-known community)\n"
6051 "Do not export to next AS (well-known community)\n"
6052 "community number\n"
6053 "Do not send outside local AS (well-known community)\n"
6054 "Do not advertise to any peer (well-known community)\n"
6055 "Do not export to next AS (well-known community)\n"
6056 "community number\n"
6057 "Do not send outside local AS (well-known community)\n"
6058 "Do not advertise to any peer (well-known community)\n"
6059 "Do not export to next AS (well-known community)\n"
6060 "community number\n"
6061 "Do not send outside local AS (well-known community)\n"
6062 "Do not advertise to any peer (well-known community)\n"
6063 "Do not export to next AS (well-known community)\n")
6065 DEFUN (show_bgp_community_exact
,
6066 show_bgp_community_exact_cmd
,
6067 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6070 "Display routes matching the communities\n"
6071 "community number\n"
6072 "Do not send outside local AS (well-known community)\n"
6073 "Do not advertise to any peer (well-known community)\n"
6074 "Do not export to next AS (well-known community)\n"
6075 "Exact match of the communities")
6077 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
6080 ALIAS (show_bgp_community_exact
,
6081 show_bgp_ipv6_community_exact_cmd
,
6082 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6086 "Display routes matching the communities\n"
6087 "community number\n"
6088 "Do not send outside local AS (well-known community)\n"
6089 "Do not advertise to any peer (well-known community)\n"
6090 "Do not export to next AS (well-known community)\n"
6091 "Exact match of the communities")
6093 ALIAS (show_bgp_community_exact
,
6094 show_bgp_community2_exact_cmd
,
6095 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6098 "Display routes matching the communities\n"
6099 "community number\n"
6100 "Do not send outside local AS (well-known community)\n"
6101 "Do not advertise to any peer (well-known community)\n"
6102 "Do not export to next AS (well-known community)\n"
6103 "community number\n"
6104 "Do not send outside local AS (well-known community)\n"
6105 "Do not advertise to any peer (well-known community)\n"
6106 "Do not export to next AS (well-known community)\n"
6107 "Exact match of the communities")
6109 ALIAS (show_bgp_community_exact
,
6110 show_bgp_ipv6_community2_exact_cmd
,
6111 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6115 "Display routes matching the communities\n"
6116 "community number\n"
6117 "Do not send outside local AS (well-known community)\n"
6118 "Do not advertise to any peer (well-known community)\n"
6119 "Do not export to next AS (well-known community)\n"
6120 "community number\n"
6121 "Do not send outside local AS (well-known community)\n"
6122 "Do not advertise to any peer (well-known community)\n"
6123 "Do not export to next AS (well-known community)\n"
6124 "Exact match of the communities")
6126 ALIAS (show_bgp_community_exact
,
6127 show_bgp_community3_exact_cmd
,
6128 "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",
6131 "Display routes matching the communities\n"
6132 "community number\n"
6133 "Do not send outside local AS (well-known community)\n"
6134 "Do not advertise to any peer (well-known community)\n"
6135 "Do not export to next AS (well-known community)\n"
6136 "community number\n"
6137 "Do not send outside local AS (well-known community)\n"
6138 "Do not advertise to any peer (well-known community)\n"
6139 "Do not export to next AS (well-known community)\n"
6140 "community number\n"
6141 "Do not send outside local AS (well-known community)\n"
6142 "Do not advertise to any peer (well-known community)\n"
6143 "Do not export to next AS (well-known community)\n"
6144 "Exact match of the communities")
6146 ALIAS (show_bgp_community_exact
,
6147 show_bgp_ipv6_community3_exact_cmd
,
6148 "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",
6152 "Display routes matching the communities\n"
6153 "community number\n"
6154 "Do not send outside local AS (well-known community)\n"
6155 "Do not advertise to any peer (well-known community)\n"
6156 "Do not export to next AS (well-known community)\n"
6157 "community number\n"
6158 "Do not send outside local AS (well-known community)\n"
6159 "Do not advertise to any peer (well-known community)\n"
6160 "Do not export to next AS (well-known community)\n"
6161 "community number\n"
6162 "Do not send outside local AS (well-known community)\n"
6163 "Do not advertise to any peer (well-known community)\n"
6164 "Do not export to next AS (well-known community)\n"
6165 "Exact match of the communities")
6167 ALIAS (show_bgp_community_exact
,
6168 show_bgp_community4_exact_cmd
,
6169 "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",
6172 "Display routes matching the communities\n"
6173 "community number\n"
6174 "Do not send outside local AS (well-known community)\n"
6175 "Do not advertise to any peer (well-known community)\n"
6176 "Do not export to next AS (well-known community)\n"
6177 "community number\n"
6178 "Do not send outside local AS (well-known community)\n"
6179 "Do not advertise to any peer (well-known community)\n"
6180 "Do not export to next AS (well-known community)\n"
6181 "community number\n"
6182 "Do not send outside local AS (well-known community)\n"
6183 "Do not advertise to any peer (well-known community)\n"
6184 "Do not export to next AS (well-known community)\n"
6185 "community number\n"
6186 "Do not send outside local AS (well-known community)\n"
6187 "Do not advertise to any peer (well-known community)\n"
6188 "Do not export to next AS (well-known community)\n"
6189 "Exact match of the communities")
6191 ALIAS (show_bgp_community_exact
,
6192 show_bgp_ipv6_community4_exact_cmd
,
6193 "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",
6197 "Display routes matching the communities\n"
6198 "community number\n"
6199 "Do not send outside local AS (well-known community)\n"
6200 "Do not advertise to any peer (well-known community)\n"
6201 "Do not export to next AS (well-known community)\n"
6202 "community number\n"
6203 "Do not send outside local AS (well-known community)\n"
6204 "Do not advertise to any peer (well-known community)\n"
6205 "Do not export to next AS (well-known community)\n"
6206 "community number\n"
6207 "Do not send outside local AS (well-known community)\n"
6208 "Do not advertise to any peer (well-known community)\n"
6209 "Do not export to next AS (well-known community)\n"
6210 "community number\n"
6211 "Do not send outside local AS (well-known community)\n"
6212 "Do not advertise to any peer (well-known community)\n"
6213 "Do not export to next AS (well-known community)\n"
6214 "Exact match of the communities")
6217 DEFUN (show_ipv6_bgp_community_exact
,
6218 show_ipv6_bgp_community_exact_cmd
,
6219 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6223 "Display routes matching the communities\n"
6224 "community number\n"
6225 "Do not send outside local AS (well-known community)\n"
6226 "Do not advertise to any peer (well-known community)\n"
6227 "Do not export to next AS (well-known community)\n"
6228 "Exact match of the communities")
6230 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
6234 ALIAS (show_ipv6_bgp_community_exact
,
6235 show_ipv6_bgp_community2_exact_cmd
,
6236 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6240 "Display routes matching the communities\n"
6241 "community number\n"
6242 "Do not send outside local AS (well-known community)\n"
6243 "Do not advertise to any peer (well-known community)\n"
6244 "Do not export to next AS (well-known community)\n"
6245 "community number\n"
6246 "Do not send outside local AS (well-known community)\n"
6247 "Do not advertise to any peer (well-known community)\n"
6248 "Do not export to next AS (well-known community)\n"
6249 "Exact match of the communities")
6252 ALIAS (show_ipv6_bgp_community_exact
,
6253 show_ipv6_bgp_community3_exact_cmd
,
6254 "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",
6258 "Display routes matching the communities\n"
6259 "community number\n"
6260 "Do not send outside local AS (well-known community)\n"
6261 "Do not advertise to any peer (well-known community)\n"
6262 "Do not export to next AS (well-known community)\n"
6263 "community number\n"
6264 "Do not send outside local AS (well-known community)\n"
6265 "Do not advertise to any peer (well-known community)\n"
6266 "Do not export to next AS (well-known community)\n"
6267 "community number\n"
6268 "Do not send outside local AS (well-known community)\n"
6269 "Do not advertise to any peer (well-known community)\n"
6270 "Do not export to next AS (well-known community)\n"
6271 "Exact match of the communities")
6274 ALIAS (show_ipv6_bgp_community_exact
,
6275 show_ipv6_bgp_community4_exact_cmd
,
6276 "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",
6280 "Display routes matching the communities\n"
6281 "community number\n"
6282 "Do not send outside local AS (well-known community)\n"
6283 "Do not advertise to any peer (well-known community)\n"
6284 "Do not export to next AS (well-known community)\n"
6285 "community number\n"
6286 "Do not send outside local AS (well-known community)\n"
6287 "Do not advertise to any peer (well-known community)\n"
6288 "Do not export to next AS (well-known community)\n"
6289 "community number\n"
6290 "Do not send outside local AS (well-known community)\n"
6291 "Do not advertise to any peer (well-known community)\n"
6292 "Do not export to next AS (well-known community)\n"
6293 "community number\n"
6294 "Do not send outside local AS (well-known community)\n"
6295 "Do not advertise to any peer (well-known community)\n"
6296 "Do not export to next AS (well-known community)\n"
6297 "Exact match of the communities")
6300 DEFUN (show_ipv6_mbgp_community
,
6301 show_ipv6_mbgp_community_cmd
,
6302 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
6306 "Display routes matching the communities\n"
6307 "community number\n"
6308 "Do not send outside local AS (well-known community)\n"
6309 "Do not advertise to any peer (well-known community)\n"
6310 "Do not export to next AS (well-known community)\n")
6312 return bgp_show_community (vty
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
6316 ALIAS (show_ipv6_mbgp_community
,
6317 show_ipv6_mbgp_community2_cmd
,
6318 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
6322 "Display routes matching the communities\n"
6323 "community number\n"
6324 "Do not send outside local AS (well-known community)\n"
6325 "Do not advertise to any peer (well-known community)\n"
6326 "Do not export to next AS (well-known community)\n"
6327 "community number\n"
6328 "Do not send outside local AS (well-known community)\n"
6329 "Do not advertise to any peer (well-known community)\n"
6330 "Do not export to next AS (well-known community)\n")
6333 ALIAS (show_ipv6_mbgp_community
,
6334 show_ipv6_mbgp_community3_cmd
,
6335 "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)",
6339 "Display routes matching the communities\n"
6340 "community number\n"
6341 "Do not send outside local AS (well-known community)\n"
6342 "Do not advertise to any peer (well-known community)\n"
6343 "Do not export to next AS (well-known community)\n"
6344 "community number\n"
6345 "Do not send outside local AS (well-known community)\n"
6346 "Do not advertise to any peer (well-known community)\n"
6347 "Do not export to next AS (well-known community)\n"
6348 "community number\n"
6349 "Do not send outside local AS (well-known community)\n"
6350 "Do not advertise to any peer (well-known community)\n"
6351 "Do not export to next AS (well-known community)\n")
6354 ALIAS (show_ipv6_mbgp_community
,
6355 show_ipv6_mbgp_community4_cmd
,
6356 "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)",
6360 "Display routes matching the communities\n"
6361 "community number\n"
6362 "Do not send outside local AS (well-known community)\n"
6363 "Do not advertise to any peer (well-known community)\n"
6364 "Do not export to next AS (well-known community)\n"
6365 "community number\n"
6366 "Do not send outside local AS (well-known community)\n"
6367 "Do not advertise to any peer (well-known community)\n"
6368 "Do not export to next AS (well-known community)\n"
6369 "community number\n"
6370 "Do not send outside local AS (well-known community)\n"
6371 "Do not advertise to any peer (well-known community)\n"
6372 "Do not export to next AS (well-known community)\n"
6373 "community number\n"
6374 "Do not send outside local AS (well-known community)\n"
6375 "Do not advertise to any peer (well-known community)\n"
6376 "Do not export to next AS (well-known community)\n")
6379 DEFUN (show_ipv6_mbgp_community_exact
,
6380 show_ipv6_mbgp_community_exact_cmd
,
6381 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
6385 "Display routes matching the communities\n"
6386 "community number\n"
6387 "Do not send outside local AS (well-known community)\n"
6388 "Do not advertise to any peer (well-known community)\n"
6389 "Do not export to next AS (well-known community)\n"
6390 "Exact match of the communities")
6392 return bgp_show_community (vty
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
6396 ALIAS (show_ipv6_mbgp_community_exact
,
6397 show_ipv6_mbgp_community2_exact_cmd
,
6398 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
6402 "Display routes matching the communities\n"
6403 "community number\n"
6404 "Do not send outside local AS (well-known community)\n"
6405 "Do not advertise to any peer (well-known community)\n"
6406 "Do not export to next AS (well-known community)\n"
6407 "community number\n"
6408 "Do not send outside local AS (well-known community)\n"
6409 "Do not advertise to any peer (well-known community)\n"
6410 "Do not export to next AS (well-known community)\n"
6411 "Exact match of the communities")
6414 ALIAS (show_ipv6_mbgp_community_exact
,
6415 show_ipv6_mbgp_community3_exact_cmd
,
6416 "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",
6420 "Display routes matching the communities\n"
6421 "community number\n"
6422 "Do not send outside local AS (well-known community)\n"
6423 "Do not advertise to any peer (well-known community)\n"
6424 "Do not export to next AS (well-known community)\n"
6425 "community number\n"
6426 "Do not send outside local AS (well-known community)\n"
6427 "Do not advertise to any peer (well-known community)\n"
6428 "Do not export to next AS (well-known community)\n"
6429 "community number\n"
6430 "Do not send outside local AS (well-known community)\n"
6431 "Do not advertise to any peer (well-known community)\n"
6432 "Do not export to next AS (well-known community)\n"
6433 "Exact match of the communities")
6436 ALIAS (show_ipv6_mbgp_community_exact
,
6437 show_ipv6_mbgp_community4_exact_cmd
,
6438 "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",
6442 "Display routes matching the communities\n"
6443 "community number\n"
6444 "Do not send outside local AS (well-known community)\n"
6445 "Do not advertise to any peer (well-known community)\n"
6446 "Do not export to next AS (well-known community)\n"
6447 "community number\n"
6448 "Do not send outside local AS (well-known community)\n"
6449 "Do not advertise to any peer (well-known community)\n"
6450 "Do not export to next AS (well-known community)\n"
6451 "community number\n"
6452 "Do not send outside local AS (well-known community)\n"
6453 "Do not advertise to any peer (well-known community)\n"
6454 "Do not export to next AS (well-known community)\n"
6455 "community number\n"
6456 "Do not send outside local AS (well-known community)\n"
6457 "Do not advertise to any peer (well-known community)\n"
6458 "Do not export to next AS (well-known community)\n"
6459 "Exact match of the communities")
6460 #endif /* HAVE_IPV6 */
6463 bgp_show_community_list (struct vty
*vty
, char *com
, int exact
,
6464 u_int16_t afi
, u_char safi
)
6466 struct community_list
*list
;
6468 list
= community_list_lookup (com
);
6471 vty_out (vty
, "%% %s is not a valid community-list name%s", com
, VTY_NEWLINE
);
6475 vty
->output_arg
= list
;
6478 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_community_list_exact
);
6480 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_community_list
);
6483 DEFUN (show_ip_bgp_community_list
,
6484 show_ip_bgp_community_list_cmd
,
6485 "show ip bgp community-list WORD",
6489 "Display routes matching the community-list\n"
6490 "community-list name\n")
6492 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
6495 DEFUN (show_ip_bgp_ipv4_community_list
,
6496 show_ip_bgp_ipv4_community_list_cmd
,
6497 "show ip bgp ipv4 (unicast|multicast) community-list WORD",
6502 "Address Family modifier\n"
6503 "Address Family modifier\n"
6504 "Display routes matching the community-list\n"
6505 "community-list name\n")
6507 if (strncmp (argv
[0], "m", 1) == 0)
6508 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
6510 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
6513 DEFUN (show_ip_bgp_community_list_exact
,
6514 show_ip_bgp_community_list_exact_cmd
,
6515 "show ip bgp community-list WORD exact-match",
6519 "Display routes matching the community-list\n"
6520 "community-list name\n"
6521 "Exact match of the communities\n")
6523 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
6526 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
6527 show_ip_bgp_ipv4_community_list_exact_cmd
,
6528 "show ip bgp ipv4 (unicast|multicast) community-list WORD exact-match",
6533 "Address Family modifier\n"
6534 "Address Family modifier\n"
6535 "Display routes matching the community-list\n"
6536 "community-list name\n"
6537 "Exact match of the communities\n")
6539 if (strncmp (argv
[0], "m", 1) == 0)
6540 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
6542 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
6546 DEFUN (show_bgp_community_list
,
6547 show_bgp_community_list_cmd
,
6548 "show bgp community-list WORD",
6551 "Display routes matching the community-list\n"
6552 "community-list name\n")
6554 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
6557 ALIAS (show_bgp_community_list
,
6558 show_bgp_ipv6_community_list_cmd
,
6559 "show bgp ipv6 community-list WORD",
6563 "Display routes matching the community-list\n"
6564 "community-list name\n")
6567 DEFUN (show_ipv6_bgp_community_list
,
6568 show_ipv6_bgp_community_list_cmd
,
6569 "show ipv6 bgp community-list WORD",
6573 "Display routes matching the community-list\n"
6574 "community-list name\n")
6576 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
6580 DEFUN (show_ipv6_mbgp_community_list
,
6581 show_ipv6_mbgp_community_list_cmd
,
6582 "show ipv6 mbgp community-list WORD",
6586 "Display routes matching the community-list\n"
6587 "community-list name\n")
6589 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
6592 DEFUN (show_bgp_community_list_exact
,
6593 show_bgp_community_list_exact_cmd
,
6594 "show bgp community-list WORD exact-match",
6597 "Display routes matching the community-list\n"
6598 "community-list name\n"
6599 "Exact match of the communities\n")
6601 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
6604 ALIAS (show_bgp_community_list_exact
,
6605 show_bgp_ipv6_community_list_exact_cmd
,
6606 "show bgp ipv6 community-list WORD exact-match",
6610 "Display routes matching the community-list\n"
6611 "community-list name\n"
6612 "Exact match of the communities\n")
6615 DEFUN (show_ipv6_bgp_community_list_exact
,
6616 show_ipv6_bgp_community_list_exact_cmd
,
6617 "show ipv6 bgp community-list WORD exact-match",
6621 "Display routes matching the community-list\n"
6622 "community-list name\n"
6623 "Exact match of the communities\n")
6625 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
6629 DEFUN (show_ipv6_mbgp_community_list_exact
,
6630 show_ipv6_mbgp_community_list_exact_cmd
,
6631 "show ipv6 mbgp community-list WORD exact-match",
6635 "Display routes matching the community-list\n"
6636 "community-list name\n"
6637 "Exact match of the communities\n")
6639 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
6641 #endif /* HAVE_IPV6 */
6644 bgp_show_prefix_longer_clean (struct vty
*vty
)
6648 p
= vty
->output_arg
;
6653 bgp_show_prefix_longer (struct vty
*vty
, char *prefix
,
6654 u_int16_t afi
, u_char safi
)
6661 ret
= str2prefix (prefix
, p
);
6664 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
6668 vty
->output_arg
= p
;
6669 vty
->output_clean
= bgp_show_prefix_longer_clean
;
6671 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_prefix_longer
);
6674 DEFUN (show_ip_bgp_prefix_longer
,
6675 show_ip_bgp_prefix_longer_cmd
,
6676 "show ip bgp A.B.C.D/M longer-prefixes",
6680 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
6681 "Display route and more specific routes\n")
6683 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
);
6686 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
6687 show_ip_bgp_ipv4_prefix_longer_cmd
,
6688 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
6693 "Address Family modifier\n"
6694 "Address Family modifier\n"
6695 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
6696 "Display route and more specific routes\n")
6698 if (strncmp (argv
[0], "m", 1) == 0)
6699 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
);
6701 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
);
6705 DEFUN (show_bgp_prefix_longer
,
6706 show_bgp_prefix_longer_cmd
,
6707 "show bgp X:X::X:X/M longer-prefixes",
6710 "IPv6 prefix <network>/<length>\n"
6711 "Display route and more specific routes\n")
6713 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
6716 ALIAS (show_bgp_prefix_longer
,
6717 show_bgp_ipv6_prefix_longer_cmd
,
6718 "show bgp ipv6 X:X::X:X/M longer-prefixes",
6722 "IPv6 prefix <network>/<length>\n"
6723 "Display route and more specific routes\n")
6726 DEFUN (show_ipv6_bgp_prefix_longer
,
6727 show_ipv6_bgp_prefix_longer_cmd
,
6728 "show ipv6 bgp X:X::X:X/M longer-prefixes",
6732 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
6733 "Display route and more specific routes\n")
6735 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
6739 DEFUN (show_ipv6_mbgp_prefix_longer
,
6740 show_ipv6_mbgp_prefix_longer_cmd
,
6741 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
6745 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
6746 "Display route and more specific routes\n")
6748 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
);
6750 #endif /* HAVE_IPV6 */
6753 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
6756 struct route_table
*table
;
6757 struct route_node
*rn
;
6761 unsigned long output_count
;
6765 table
= peer
->adj_in
[afi
][safi
];
6767 table
= peer
->adj_out
[afi
][safi
];
6769 bgp
= bgp_get_default ();
6772 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
6773 if ((attr
= rn
->info
) != NULL
)
6779 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->id
), VTY_NEWLINE
);
6780 vty_out (vty
, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s", VTY_NEWLINE
);
6781 vty_out (vty
, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s", VTY_NEWLINE
, VTY_NEWLINE
);
6784 vty_out (vty
, BGP_SHOW_V4_HEADER
, VTY_NEWLINE
);
6785 else if (afi
== AFI_IP6
)
6786 vty_out (vty
, BGP_SHOW_V6_HEADER
, VTY_NEWLINE
);
6790 if (p
->family
== AF_INET
)
6792 route_vty_out_tmp (vty
, p
, attr
, safi
);
6796 else if (p
->family
== AF_INET6
)
6798 route_vty_out_ipv6_tmp (vty
, p
, attr
);
6801 #endif /* HAVE_IPV6 */
6803 if (output_count
!= 0)
6804 vty_out (vty
, "%sTotal number of prefixes %ld%s",
6805 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
6809 peer_adj_routes (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
, int in
)
6815 ret
= str2sockunion (ip_str
, &su
);
6818 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
6821 peer
= peer_lookup_by_su (&su
);
6822 if (! peer
|| ! peer
->afc
[afi
][safi
])
6824 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
6828 if (in
&& ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
6830 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s",
6834 show_adj_route (vty
, peer
, afi
, safi
, in
);
6839 DEFUN (show_ip_bgp_neighbor_advertised_route
,
6840 show_ip_bgp_neighbor_advertised_route_cmd
,
6841 "show ip bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
6845 "Detailed information on TCP and BGP neighbor connections\n"
6846 "Neighbor to display information about\n"
6847 "Neighbor to display information about\n"
6848 "Display the routes advertised to a BGP neighbor\n")
6850 return peer_adj_routes (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
, 0);
6853 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
6854 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
6855 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) advertised-routes",
6860 "Address Family modifier\n"
6861 "Address Family modifier\n"
6862 "Detailed information on TCP and BGP neighbor connections\n"
6863 "Neighbor to display information about\n"
6864 "Neighbor to display information about\n"
6865 "Display the routes advertised to a BGP neighbor\n")
6867 if (strncmp (argv
[0], "m", 1) == 0)
6868 return peer_adj_routes (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
, 0);
6870 return peer_adj_routes (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
, 0);
6874 DEFUN (show_bgp_neighbor_advertised_route
,
6875 show_bgp_neighbor_advertised_route_cmd
,
6876 "show bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
6879 "Detailed information on TCP and BGP neighbor connections\n"
6880 "Neighbor to display information about\n"
6881 "Neighbor to display information about\n"
6882 "Display the routes advertised to a BGP neighbor\n")
6884 return peer_adj_routes (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0);
6887 ALIAS (show_bgp_neighbor_advertised_route
,
6888 show_bgp_ipv6_neighbor_advertised_route_cmd
,
6889 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) advertised-routes",
6893 "Detailed information on TCP and BGP neighbor connections\n"
6894 "Neighbor to display information about\n"
6895 "Neighbor to display information about\n"
6896 "Display the routes advertised to a BGP neighbor\n")
6899 DEFUN (ipv6_bgp_neighbor_advertised_route
,
6900 ipv6_bgp_neighbor_advertised_route_cmd
,
6901 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
6905 "Detailed information on TCP and BGP neighbor connections\n"
6906 "Neighbor to display information about\n"
6907 "Neighbor to display information about\n"
6908 "Display the routes advertised to a BGP neighbor\n")
6910 return peer_adj_routes (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0);
6914 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
6915 ipv6_mbgp_neighbor_advertised_route_cmd
,
6916 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) advertised-routes",
6920 "Detailed information on TCP and BGP neighbor connections\n"
6921 "Neighbor to display information about\n"
6922 "Neighbor to display information about\n"
6923 "Display the routes advertised to a BGP neighbor\n")
6925 return peer_adj_routes (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, 0);
6927 #endif /* HAVE_IPV6 */
6929 DEFUN (show_ip_bgp_neighbor_received_routes
,
6930 show_ip_bgp_neighbor_received_routes_cmd
,
6931 "show ip bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
6935 "Detailed information on TCP and BGP neighbor connections\n"
6936 "Neighbor to display information about\n"
6937 "Neighbor to display information about\n"
6938 "Display the received routes from neighbor\n")
6940 return peer_adj_routes (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
, 1);
6943 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
6944 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
6945 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) received-routes",
6950 "Address Family modifier\n"
6951 "Address Family modifier\n"
6952 "Detailed information on TCP and BGP neighbor connections\n"
6953 "Neighbor to display information about\n"
6954 "Neighbor to display information about\n"
6955 "Display the received routes from neighbor\n")
6957 if (strncmp (argv
[0], "m", 1) == 0)
6958 return peer_adj_routes (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
, 1);
6960 return peer_adj_routes (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
, 1);
6964 DEFUN (show_bgp_neighbor_received_routes
,
6965 show_bgp_neighbor_received_routes_cmd
,
6966 "show bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
6969 "Detailed information on TCP and BGP neighbor connections\n"
6970 "Neighbor to display information about\n"
6971 "Neighbor to display information about\n"
6972 "Display the received routes from neighbor\n")
6974 return peer_adj_routes (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 1);
6977 ALIAS (show_bgp_neighbor_received_routes
,
6978 show_bgp_ipv6_neighbor_received_routes_cmd
,
6979 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) received-routes",
6983 "Detailed information on TCP and BGP neighbor connections\n"
6984 "Neighbor to display information about\n"
6985 "Neighbor to display information about\n"
6986 "Display the received routes from neighbor\n")
6989 DEFUN (ipv6_bgp_neighbor_received_routes
,
6990 ipv6_bgp_neighbor_received_routes_cmd
,
6991 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) received-routes",
6995 "Detailed information on TCP and BGP neighbor connections\n"
6996 "Neighbor to display information about\n"
6997 "Neighbor to display information about\n"
6998 "Display the received routes from neighbor\n")
7000 return peer_adj_routes (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 1);
7004 DEFUN (ipv6_mbgp_neighbor_received_routes
,
7005 ipv6_mbgp_neighbor_received_routes_cmd
,
7006 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) received-routes",
7010 "Detailed information on TCP and BGP neighbor connections\n"
7011 "Neighbor to display information about\n"
7012 "Neighbor to display information about\n"
7013 "Display the received routes from neighbor\n")
7015 return peer_adj_routes (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, 1);
7017 #endif /* HAVE_IPV6 */
7020 bgp_show_neighbor_route_clean (struct vty
*vty
)
7022 union sockunion
*su
;
7024 su
= vty
->output_arg
;
7025 XFREE (MTYPE_SOCKUNION
, su
);
7029 bgp_show_neighbor_route (struct vty
*vty
, char *ip_str
, u_int16_t afi
,
7032 union sockunion
*su
;
7035 su
= sockunion_str2su (ip_str
);
7038 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
7042 peer
= peer_lookup_by_su (su
);
7043 if (! peer
|| ! peer
->afc
[afi
][safi
])
7045 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
7046 XFREE (MTYPE_SOCKUNION
, su
);
7050 vty
->output_arg
= su
;
7051 vty
->output_clean
= bgp_show_neighbor_route_clean
;
7053 return bgp_show (vty
, NULL
, afi
, safi
, bgp_show_type_neighbor
);
7056 DEFUN (show_ip_bgp_neighbor_routes
,
7057 show_ip_bgp_neighbor_routes_cmd
,
7058 "show ip bgp neighbors (A.B.C.D|X:X::X:X) routes",
7062 "Detailed information on TCP and BGP neighbor connections\n"
7063 "Neighbor to display information about\n"
7064 "Neighbor to display information about\n"
7065 "Display routes learned from neighbor\n")
7067 return bgp_show_neighbor_route (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
);
7070 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
7071 show_ip_bgp_ipv4_neighbor_routes_cmd
,
7072 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X) routes",
7077 "Address Family modifier\n"
7078 "Address Family modifier\n"
7079 "Detailed information on TCP and BGP neighbor connections\n"
7080 "Neighbor to display information about\n"
7081 "Neighbor to display information about\n"
7082 "Display routes learned from neighbor\n")
7084 if (strncmp (argv
[0], "m", 1) == 0)
7085 return bgp_show_neighbor_route (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
);
7087 return bgp_show_neighbor_route (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
);
7090 DEFUN (show_bgp_neighbor_routes
,
7091 show_bgp_neighbor_routes_cmd
,
7092 "show bgp neighbors (A.B.C.D|X:X::X:X) routes",
7095 "Detailed information on TCP and BGP neighbor connections\n"
7096 "Neighbor to display information about\n"
7097 "Neighbor to display information about\n"
7098 "Display routes learned from neighbor\n")
7100 return bgp_show_neighbor_route (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
7103 ALIAS (show_bgp_neighbor_routes
,
7104 show_bgp_ipv6_neighbor_routes_cmd
,
7105 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
7109 "Detailed information on TCP and BGP neighbor connections\n"
7110 "Neighbor to display information about\n"
7111 "Neighbor to display information about\n"
7112 "Display routes learned from neighbor\n")
7115 DEFUN (ipv6_bgp_neighbor_routes
,
7116 ipv6_bgp_neighbor_routes_cmd
,
7117 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X) routes",
7121 "Detailed information on TCP and BGP neighbor connections\n"
7122 "Neighbor to display information about\n"
7123 "Neighbor to display information about\n"
7124 "Display routes learned from neighbor\n")
7126 return bgp_show_neighbor_route (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
7130 DEFUN (ipv6_mbgp_neighbor_routes
,
7131 ipv6_mbgp_neighbor_routes_cmd
,
7132 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X) routes",
7136 "Detailed information on TCP and BGP neighbor connections\n"
7137 "Neighbor to display information about\n"
7138 "Neighbor to display information about\n"
7139 "Display routes learned from neighbor\n")
7141 return bgp_show_neighbor_route (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
);
7143 #endif /* HAVE_IPV6 */
7145 struct route_table
*bgp_distance_table
;
7149 /* Distance value for the IP source prefix. */
7152 /* Name of the access-list to be matched. */
7156 struct bgp_distance
*
7159 struct bgp_distance
*new;
7160 new = XMALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
7161 memset (new, 0, sizeof (struct bgp_distance
));
7166 bgp_distance_free (struct bgp_distance
*bdistance
)
7168 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
7172 bgp_distance_set (struct vty
*vty
, char *distance_str
, char *ip_str
,
7173 char *access_list_str
)
7176 struct prefix_ipv4 p
;
7178 struct route_node
*rn
;
7179 struct bgp_distance
*bdistance
;
7181 ret
= str2prefix_ipv4 (ip_str
, &p
);
7184 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
7188 distance
= atoi (distance_str
);
7190 /* Get BGP distance node. */
7191 rn
= route_node_get (bgp_distance_table
, (struct prefix
*) &p
);
7194 bdistance
= rn
->info
;
7195 route_unlock_node (rn
);
7199 bdistance
= bgp_distance_new ();
7200 rn
->info
= bdistance
;
7203 /* Set distance value. */
7204 bdistance
->distance
= distance
;
7206 /* Reset access-list configuration. */
7207 if (bdistance
->access_list
)
7209 free (bdistance
->access_list
);
7210 bdistance
->access_list
= NULL
;
7212 if (access_list_str
)
7213 bdistance
->access_list
= strdup (access_list_str
);
7219 bgp_distance_unset (struct vty
*vty
, char *distance_str
, char *ip_str
,
7220 char *access_list_str
)
7223 struct prefix_ipv4 p
;
7225 struct route_node
*rn
;
7226 struct bgp_distance
*bdistance
;
7228 ret
= str2prefix_ipv4 (ip_str
, &p
);
7231 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
7235 distance
= atoi (distance_str
);
7237 rn
= route_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
7240 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
7244 bdistance
= rn
->info
;
7246 if (bdistance
->access_list
)
7247 free (bdistance
->access_list
);
7248 bgp_distance_free (bdistance
);
7251 route_unlock_node (rn
);
7252 route_unlock_node (rn
);
7258 bgp_distance_reset ()
7260 struct route_node
*rn
;
7261 struct bgp_distance
*bdistance
;
7263 for (rn
= route_top (bgp_distance_table
); rn
; rn
= route_next (rn
))
7264 if ((bdistance
= rn
->info
) != NULL
)
7266 if (bdistance
->access_list
)
7267 free (bdistance
->access_list
);
7268 bgp_distance_free (bdistance
);
7270 route_unlock_node (rn
);
7274 /* Apply BGP information to distance method. */
7276 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
7278 struct route_node
*rn
;
7279 struct prefix_ipv4 q
;
7281 struct bgp_distance
*bdistance
;
7282 struct access_list
*alist
;
7283 struct bgp_static
*bgp_static
;
7288 if (p
->family
!= AF_INET
)
7293 if (peer
->su
.sa
.sa_family
!= AF_INET
)
7296 memset (&q
, 0, sizeof (struct prefix_ipv4
));
7298 q
.prefix
= peer
->su
.sin
.sin_addr
;
7299 q
.prefixlen
= IPV4_MAX_BITLEN
;
7301 /* Check source address. */
7302 rn
= route_node_match (bgp_distance_table
, (struct prefix
*) &q
);
7305 bdistance
= rn
->info
;
7306 route_unlock_node (rn
);
7308 if (bdistance
->access_list
)
7310 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
7313 if (access_list_apply (alist
, p
) == FILTER_DENY
)
7316 return bdistance
->distance
;
7319 return bdistance
->distance
;
7322 if (peer_sort (peer
) == BGP_PEER_EBGP
)
7324 /* Backdoor check. */
7325 rn
= route_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
7328 bgp_static
= rn
->info
;
7329 route_unlock_node (rn
);
7331 if (bgp_static
->backdoor
)
7333 if (bgp
->distance_local
)
7334 return bgp
->distance_local
;
7336 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
7340 if (bgp
->distance_ebgp
)
7341 return bgp
->distance_ebgp
;
7345 if (bgp
->distance_ibgp
)
7346 return bgp
->distance_ibgp
;
7352 DEFUN (bgp_distance
,
7354 "distance bgp <1-255> <1-255> <1-255>",
7355 "Define an administrative distance\n"
7357 "Distance for routes external to the AS\n"
7358 "Distance for routes internal to the AS\n"
7359 "Distance for local routes\n")
7365 bgp
->distance_ebgp
= atoi (argv
[0]);
7366 bgp
->distance_ibgp
= atoi (argv
[1]);
7367 bgp
->distance_local
= atoi (argv
[2]);
7371 DEFUN (no_bgp_distance
,
7372 no_bgp_distance_cmd
,
7373 "no distance bgp <1-255> <1-255> <1-255>",
7375 "Define an administrative distance\n"
7377 "Distance for routes external to the AS\n"
7378 "Distance for routes internal to the AS\n"
7379 "Distance for local routes\n")
7385 bgp
->distance_ebgp
= 0;
7386 bgp
->distance_ibgp
= 0;
7387 bgp
->distance_local
= 0;
7391 ALIAS (no_bgp_distance
,
7392 no_bgp_distance2_cmd
,
7395 "Define an administrative distance\n"
7398 DEFUN (bgp_distance_source
,
7399 bgp_distance_source_cmd
,
7400 "distance <1-255> A.B.C.D/M",
7401 "Define an administrative distance\n"
7402 "Administrative distance\n"
7403 "IP source prefix\n")
7405 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
7409 DEFUN (no_bgp_distance_source
,
7410 no_bgp_distance_source_cmd
,
7411 "no distance <1-255> A.B.C.D/M",
7413 "Define an administrative distance\n"
7414 "Administrative distance\n"
7415 "IP source prefix\n")
7417 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
7421 DEFUN (bgp_distance_source_access_list
,
7422 bgp_distance_source_access_list_cmd
,
7423 "distance <1-255> A.B.C.D/M WORD",
7424 "Define an administrative distance\n"
7425 "Administrative distance\n"
7426 "IP source prefix\n"
7427 "Access list name\n")
7429 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
7433 DEFUN (no_bgp_distance_source_access_list
,
7434 no_bgp_distance_source_access_list_cmd
,
7435 "no distance <1-255> A.B.C.D/M WORD",
7437 "Define an administrative distance\n"
7438 "Administrative distance\n"
7439 "IP source prefix\n"
7440 "Access list name\n")
7442 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
7446 DEFUN (bgp_damp_set
,
7448 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
7449 "BGP Specific commands\n"
7450 "Enable route-flap dampening\n"
7451 "Half-life time for the penalty\n"
7452 "Value to start reusing a route\n"
7453 "Value to start suppressing a route\n"
7454 "Maximum duration to suppress a stable route\n")
7459 if (bgp_damp_enable (vty
, argc
, argv
) == CMD_SUCCESS
)
7461 SET_FLAG (bgp
->config
, BGP_CONFIG_DAMPENING
);
7468 ALIAS (bgp_damp_set
,
7470 "bgp dampening <1-45>",
7471 "BGP Specific commands\n"
7472 "Enable route-flap dampening\n"
7473 "Half-life time for the penalty\n")
7475 ALIAS (bgp_damp_set
,
7478 "BGP Specific commands\n"
7479 "Enable route-flap dampening\n")
7481 DEFUN (bgp_damp_unset
,
7485 "BGP Specific commands\n"
7486 "Enable route-flap dampening\n")
7491 if (bgp_damp_disable (vty
) == CMD_SUCCESS
)
7493 UNSET_FLAG (bgp
->config
, BGP_CONFIG_DAMPENING
);
7500 ALIAS (bgp_damp_unset
,
7501 bgp_damp_unset2_cmd
,
7502 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
7504 "BGP Specific commands\n"
7505 "Enable route-flap dampening\n"
7506 "Half-life time for the penalty\n"
7507 "Value to start reusing a route\n"
7508 "Value to start suppressing a route\n"
7509 "Maximum duration to suppress a stable route\n")
7512 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
7513 afi_t afi
, safi_t safi
, int *write
)
7515 struct route_node
*prn
;
7516 struct route_node
*rn
;
7517 struct route_table
*table
;
7519 struct prefix_rd
*prd
;
7520 struct bgp_static
*bgp_static
;
7522 char buf
[SU_ADDRSTRLEN
];
7523 char rdbuf
[RD_ADDRSTRLEN
];
7525 /* Network configuration. */
7526 for (prn
= route_top (bgp
->route
[afi
][safi
]); prn
; prn
= route_next (prn
))
7527 if ((table
= prn
->info
) != NULL
)
7528 for (rn
= route_top (table
); rn
; rn
= route_next (rn
))
7529 if ((bgp_static
= rn
->info
) != NULL
)
7532 prd
= (struct prefix_rd
*) &prn
->p
;
7534 /* "address-family" display. */
7535 bgp_config_write_family_header (vty
, afi
, safi
, write
);
7537 /* "network" configuration display. */
7538 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
7539 label
= decode_label (bgp_static
->tag
);
7541 vty_out (vty
, " network %s/%d rd %s tag %d",
7542 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
7545 vty_out (vty
, "%s", VTY_NEWLINE
);
7550 /* Configuration of static route announcement and aggregate
7553 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
7554 afi_t afi
, safi_t safi
, int *write
)
7556 struct route_node
*rn
;
7558 struct bgp_static
*bgp_static
;
7559 struct bgp_aggregate
*bgp_aggregate
;
7560 char buf
[SU_ADDRSTRLEN
];
7562 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
7563 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
7565 /* Network configuration. */
7566 for (rn
= route_top (bgp
->route
[afi
][safi
]); rn
; rn
= route_next (rn
))
7567 if ((bgp_static
= rn
->info
) != NULL
)
7571 /* "address-family" display. */
7572 bgp_config_write_family_header (vty
, afi
, safi
, write
);
7574 /* "network" configuration display. */
7575 vty_out (vty
, " network %s/%d",
7576 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
7579 if (bgp_static
->backdoor
)
7580 vty_out (vty
, " backdoor");
7582 vty_out (vty
, "%s", VTY_NEWLINE
);
7585 /* Aggregate-address configuration. */
7586 for (rn
= route_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= route_next (rn
))
7587 if ((bgp_aggregate
= rn
->info
) != NULL
)
7591 /* "address-family" display. */
7592 bgp_config_write_family_header (vty
, afi
, safi
, write
);
7594 vty_out (vty
, " aggregate-address %s/%d",
7595 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
7598 if (bgp_aggregate
->as_set
)
7599 vty_out (vty
, " as-set");
7601 if (bgp_aggregate
->summary_only
)
7602 vty_out (vty
, " summary-only");
7604 vty_out (vty
, "%s", VTY_NEWLINE
);
7611 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
7613 struct route_node
*rn
;
7614 struct bgp_distance
*bdistance
;
7616 /* Distance configuration. */
7617 if (bgp
->distance_ebgp
7618 && bgp
->distance_ibgp
7619 && bgp
->distance_local
7620 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
7621 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
7622 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
7623 vty_out (vty
, " distance bgp %d %d %d%s",
7624 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
7627 for (rn
= route_top (bgp_distance_table
); rn
; rn
= route_next (rn
))
7628 if ((bdistance
= rn
->info
) != NULL
)
7630 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
7631 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
7632 bdistance
->access_list
? bdistance
->access_list
: "",
7639 /* Allocate routing table structure and install commands. */
7643 /* Make static announcement peer. */
7644 peer_self
= peer_new ();
7645 peer_self
->host
= "Static announcement";
7647 /* Init BGP distance table. */
7648 bgp_distance_table
= route_table_init ();
7650 /* IPv4 BGP commands. */
7651 install_element (BGP_NODE
, &bgp_network_cmd
);
7652 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
7653 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
7654 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
7655 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
7656 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
7657 install_element (BGP_NODE
, &no_bgp_network_cmd
);
7658 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
7659 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
7660 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
7661 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
7662 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
7664 install_element (BGP_NODE
, &aggregate_address_cmd
);
7665 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
7666 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
7667 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
7668 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
7669 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
7670 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
7671 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
7672 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
7673 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
7674 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
7675 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
7676 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
7677 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
7678 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
7679 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
7680 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
7681 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
7682 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
7683 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
7685 /* IPv4 multicast configuration. */
7686 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
7687 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
7688 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
7689 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
7690 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
7691 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
7692 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
7693 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
7694 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
7695 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
7696 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
7697 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
7698 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
7699 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
7700 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
7701 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
7702 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
7703 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
7704 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
7705 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
7706 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
7707 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
7708 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
7709 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
7710 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
7711 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
7713 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
7714 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
7715 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
7716 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
7717 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
7718 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
7719 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
7720 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
7721 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
7722 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
7723 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
7724 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
7725 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
7726 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
7727 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
7728 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
7729 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
7730 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
7731 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
7732 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
7733 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
7734 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
7735 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
7736 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
7737 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
7738 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
7739 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
7740 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
7741 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
7742 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
7743 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
7744 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
7745 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
7746 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
7747 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
7748 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
7749 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
7750 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
7751 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
7752 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
7753 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
7754 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
7755 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
7756 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
7757 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
7758 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
7759 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
7761 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
7762 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
7763 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
7764 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
7765 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
7766 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
7767 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
7768 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
7769 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
7770 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
7771 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
7772 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
7773 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
7774 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
7775 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
7776 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
7777 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
7778 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
7779 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
7780 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
7781 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
7782 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
7783 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
7784 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
7785 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
7786 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
7787 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
7788 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
7789 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
7790 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
7791 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
7792 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
7793 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
7794 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
7795 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
7796 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
7797 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
7798 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
7799 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
7800 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
7801 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
7802 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
7803 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
7804 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
7805 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
7806 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
7807 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
7810 /* New config IPv6 BGP commands. */
7811 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
7812 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
7814 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
7815 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
7816 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
7817 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
7819 /* Old config IPv6 BGP commands. */
7820 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
7821 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
7823 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
7824 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
7825 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
7826 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
7828 install_element (VIEW_NODE
, &show_bgp_cmd
);
7829 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
7830 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
7831 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
7832 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
7833 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
7834 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
7835 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
7836 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
7837 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
7838 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
7839 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
7840 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
7841 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
7842 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
7843 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
7844 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
7845 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
7846 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
7847 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
7848 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
7849 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
7850 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
7851 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
7852 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
7853 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
7854 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
7855 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
7856 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
7857 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
7858 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
7859 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
7860 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
7861 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
7862 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
7863 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
7864 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
7865 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
7866 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
7867 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
7868 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
7869 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
7871 install_element (ENABLE_NODE
, &show_bgp_cmd
);
7872 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
7873 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
7874 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
7875 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
7876 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
7877 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
7878 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
7879 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
7880 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
7881 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
7882 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
7883 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
7884 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
7885 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
7886 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
7887 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
7888 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
7889 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
7890 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
7891 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
7892 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
7893 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
7894 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
7895 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
7896 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
7897 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
7898 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
7899 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
7900 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
7901 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
7902 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
7903 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
7904 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
7905 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
7906 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
7907 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
7908 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
7909 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
7910 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
7911 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
7912 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
7915 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
7916 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
7917 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
7918 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
7919 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
7920 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
7921 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
7922 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
7923 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
7924 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
7925 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
7926 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
7927 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
7928 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
7929 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
7930 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
7931 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
7932 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
7933 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
7934 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
7935 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
7936 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
7937 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
7938 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
7939 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
7940 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
7941 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
7942 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
7943 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
7944 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
7945 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
7946 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
7947 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
7948 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
7949 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
7950 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
7953 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
7954 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
7955 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
7956 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
7957 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
7958 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
7959 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
7960 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
7961 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
7962 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
7963 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
7964 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
7965 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
7966 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
7967 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
7968 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
7969 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
7970 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
7971 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
7972 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
7973 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
7974 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
7975 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
7976 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
7977 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
7978 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
7979 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
7980 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
7981 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
7982 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
7983 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
7984 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
7985 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
7986 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
7987 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
7988 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
7991 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
7992 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
7993 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
7994 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
7997 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
7998 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
7999 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
8000 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
8003 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
8004 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
8005 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
8006 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
8007 #endif /* HAVE_IPV6 */
8009 install_element (BGP_NODE
, &bgp_distance_cmd
);
8010 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
8011 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
8012 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
8013 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
8014 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
8015 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
8017 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
8018 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
8019 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
8020 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
8021 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);