1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
34 #include "sockunion.h"
37 #include "workqueue.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_table.h"
43 #include "bgpd/bgp_route.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_debug.h"
46 #include "bgpd/bgp_aspath.h"
47 #include "bgpd/bgp_regex.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_ecommunity.h"
50 #include "bgpd/bgp_clist.h"
51 #include "bgpd/bgp_packet.h"
52 #include "bgpd/bgp_filter.h"
53 #include "bgpd/bgp_fsm.h"
54 #include "bgpd/bgp_mplsvpn.h"
55 #include "bgpd/bgp_nexthop.h"
56 #include "bgpd/bgp_damp.h"
57 #include "bgpd/bgp_advertise.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_nht.h"
62 #include "bgpd/bgp_updgrp.h"
64 /* Extern from bgp_dump.c */
65 extern const char *bgp_origin_str
[];
66 extern const char *bgp_origin_long_str
[];
69 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
70 struct prefix_rd
*prd
)
73 struct bgp_node
*prn
= NULL
;
79 if (safi
== SAFI_MPLS_VPN
)
81 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
83 if (prn
->info
== NULL
)
84 prn
->info
= bgp_table_init (afi
, safi
);
86 bgp_unlock_node (prn
);
90 rn
= bgp_node_get (table
, p
);
92 if (safi
== SAFI_MPLS_VPN
)
98 /* Allocate bgp_info_extra */
99 static struct bgp_info_extra
*
100 bgp_info_extra_new (void)
102 struct bgp_info_extra
*new;
103 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
108 bgp_info_extra_free (struct bgp_info_extra
**extra
)
112 if ((*extra
)->damp_info
)
113 bgp_damp_info_free ((*extra
)->damp_info
, 0);
115 (*extra
)->damp_info
= NULL
;
117 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
123 /* Get bgp_info extra information for the given bgp_info, lazy allocated
126 struct bgp_info_extra
*
127 bgp_info_extra_get (struct bgp_info
*ri
)
130 ri
->extra
= bgp_info_extra_new();
134 /* Free bgp route information. */
136 bgp_info_free (struct bgp_info
*binfo
)
139 bgp_attr_unintern (&binfo
->attr
);
141 bgp_unlink_nexthop(binfo
);
142 bgp_info_extra_free (&binfo
->extra
);
143 bgp_info_mpath_free (&binfo
->mpath
);
145 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
147 XFREE (MTYPE_BGP_ROUTE
, binfo
);
151 bgp_info_lock (struct bgp_info
*binfo
)
158 bgp_info_unlock (struct bgp_info
*binfo
)
160 assert (binfo
&& binfo
->lock
> 0);
163 if (binfo
->lock
== 0)
166 zlog_debug ("%s: unlocked and freeing", __func__
);
167 zlog_backtrace (LOG_DEBUG
);
169 bgp_info_free (binfo
);
174 if (binfo
->lock
== 1)
176 zlog_debug ("%s: unlocked to 1", __func__
);
177 zlog_backtrace (LOG_DEBUG
);
185 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
187 struct bgp_info
*top
;
199 peer_lock (ri
->peer
); /* bgp_info peer reference */
202 /* Do the actual removal of info from RIB, for use by bgp_process
203 completion callback *only* */
205 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
208 ri
->next
->prev
= ri
->prev
;
210 ri
->prev
->next
= ri
->next
;
214 bgp_info_mpath_dequeue (ri
);
215 bgp_info_unlock (ri
);
216 bgp_unlock_node (rn
);
220 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
222 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
223 /* set of previous already took care of pcount */
224 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
227 /* undo the effects of a previous call to bgp_info_delete; typically
228 called when a route is deleted and then quickly re-added before the
229 deletion has been processed */
231 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
233 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
234 /* unset of previous already took care of pcount */
235 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
238 /* Adjust pcount as required */
240 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
242 struct bgp_table
*table
;
244 assert (rn
&& bgp_node_table (rn
));
245 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
247 table
= bgp_node_table (rn
);
249 if (ri
->peer
== ri
->peer
->bgp
->peer_self
)
252 if (!BGP_INFO_COUNTABLE (ri
)
253 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
256 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
258 /* slight hack, but more robust against errors. */
259 if (ri
->peer
->pcount
[table
->afi
][table
->safi
])
260 ri
->peer
->pcount
[table
->afi
][table
->safi
]--;
263 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
264 __func__
, ri
->peer
->host
);
265 zlog_backtrace (LOG_WARNING
);
266 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
269 else if (BGP_INFO_COUNTABLE (ri
)
270 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
272 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
273 ri
->peer
->pcount
[table
->afi
][table
->safi
]++;
278 /* Set/unset bgp_info flags, adjusting any other state as needed.
279 * This is here primarily to keep prefix-count in check.
282 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
284 SET_FLAG (ri
->flags
, flag
);
286 /* early bath if we know it's not a flag that changes countability state */
287 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
290 bgp_pcount_adjust (rn
, ri
);
294 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
296 UNSET_FLAG (ri
->flags
, flag
);
298 /* early bath if we know it's not a flag that changes countability state */
299 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
302 bgp_pcount_adjust (rn
, ri
);
305 /* Get MED value. If MED value is missing and "bgp bestpath
306 missing-as-worst" is specified, treat it as the worst value. */
308 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
310 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
314 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
321 /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */
323 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
324 int *paths_eq
, struct bgp_maxpaths_cfg
*mpath_cfg
, int debug
,
327 struct attr
*newattr
, *existattr
;
328 struct attr_extra
*newattre
, *existattre
;
329 bgp_peer_sort_t new_sort
;
330 bgp_peer_sort_t exist_sort
;
332 u_int32_t exist_pref
;
335 u_int32_t new_weight
;
336 u_int32_t exist_weight
;
337 uint32_t newm
, existm
;
338 struct in_addr new_id
;
339 struct in_addr exist_id
;
342 int internal_as_route
;
352 zlog_debug("%s: new is NULL", pfx_buf
);
359 zlog_debug("%s: path %s is the initial bestpath",
360 pfx_buf
, new->peer
->host
);
365 existattr
= exist
->attr
;
366 newattre
= newattr
->extra
;
367 existattre
= existattr
->extra
;
369 /* 1. Weight check. */
370 new_weight
= exist_weight
= 0;
373 new_weight
= newattre
->weight
;
375 exist_weight
= existattre
->weight
;
377 if (new_weight
> exist_weight
)
380 zlog_debug("%s: path %s wins over path %s due to weight %d > %d",
381 pfx_buf
, new->peer
->host
, exist
->peer
->host
, new_weight
,
386 if (new_weight
< exist_weight
)
389 zlog_debug("%s: path %s loses to path %s due to weight %d < %d",
390 pfx_buf
, new->peer
->host
, exist
->peer
->host
, new_weight
,
395 /* 2. Local preference check. */
396 new_pref
= exist_pref
= bgp
->default_local_pref
;
398 if (newattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
399 new_pref
= newattr
->local_pref
;
400 if (existattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
401 exist_pref
= existattr
->local_pref
;
403 if (new_pref
> exist_pref
)
406 zlog_debug("%s: path %s wins over path %s due to localpref %d > %d",
407 pfx_buf
, new->peer
->host
, exist
->peer
->host
, new_pref
,
412 if (new_pref
< exist_pref
)
415 zlog_debug("%s: path %s loses to path %s due to localpref %d < %d",
416 pfx_buf
, new->peer
->host
, exist
->peer
->host
, new_pref
,
421 /* 3. Local route check. We prefer:
423 * - BGP_ROUTE_AGGREGATE
424 * - BGP_ROUTE_REDISTRIBUTE
426 if (! (new->sub_type
== BGP_ROUTE_NORMAL
))
429 zlog_debug("%s: path %s wins over path %s due to preferred BGP_ROUTE type",
430 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
434 if (! (exist
->sub_type
== BGP_ROUTE_NORMAL
))
437 zlog_debug("%s: path %s loses to path %s due to preferred BGP_ROUTE type",
438 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
442 /* 4. AS path length check. */
443 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
445 int exist_hops
= aspath_count_hops (existattr
->aspath
);
446 int exist_confeds
= aspath_count_confeds (existattr
->aspath
);
448 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
452 aspath_hops
= aspath_count_hops (newattr
->aspath
);
453 aspath_hops
+= aspath_count_confeds (newattr
->aspath
);
455 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
458 zlog_debug("%s: path %s wins over path %s due to aspath (with confeds) hopcount %d < %d",
459 pfx_buf
, new->peer
->host
, exist
->peer
->host
,
460 aspath_hops
, (exist_hops
+ exist_confeds
));
464 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
467 zlog_debug("%s: path %s loses to path %s due to aspath (with confeds) hopcount %d > %d",
468 pfx_buf
, new->peer
->host
, exist
->peer
->host
,
469 aspath_hops
, (exist_hops
+ exist_confeds
));
475 int newhops
= aspath_count_hops (newattr
->aspath
);
477 if (newhops
< exist_hops
)
480 zlog_debug("%s: path %s wins over path %s due to aspath hopcount %d < %d",
481 pfx_buf
, new->peer
->host
, exist
->peer
->host
,
482 newhops
, exist_hops
);
486 if (newhops
> exist_hops
)
489 zlog_debug("%s: path %s loses to path %s due to aspath hopcount %d > %d",
490 pfx_buf
, new->peer
->host
, exist
->peer
->host
,
491 newhops
, exist_hops
);
497 /* 5. Origin check. */
498 if (newattr
->origin
< existattr
->origin
)
501 zlog_debug("%s: path %s wins over path %s due to ORIGIN %s < %s",
502 pfx_buf
, new->peer
->host
, exist
->peer
->host
,
503 bgp_origin_long_str
[newattr
->origin
],
504 bgp_origin_long_str
[existattr
->origin
]);
508 if (newattr
->origin
> existattr
->origin
)
511 zlog_debug("%s: path %s loses to path %s due to ORIGIN %s > %s",
512 pfx_buf
, new->peer
->host
, exist
->peer
->host
,
513 bgp_origin_long_str
[newattr
->origin
],
514 bgp_origin_long_str
[existattr
->origin
]);
519 internal_as_route
= (aspath_count_hops (newattr
->aspath
) == 0
520 && aspath_count_hops (existattr
->aspath
) == 0);
521 confed_as_route
= (aspath_count_confeds (newattr
->aspath
) > 0
522 && aspath_count_confeds (existattr
->aspath
) > 0
523 && aspath_count_hops (newattr
->aspath
) == 0
524 && aspath_count_hops (existattr
->aspath
) == 0);
526 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
527 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
529 || aspath_cmp_left (newattr
->aspath
, existattr
->aspath
)
530 || aspath_cmp_left_confed (newattr
->aspath
, existattr
->aspath
)
531 || internal_as_route
)
533 new_med
= bgp_med_value (new->attr
, bgp
);
534 exist_med
= bgp_med_value (exist
->attr
, bgp
);
536 if (new_med
< exist_med
)
539 zlog_debug("%s: path %s wins over path %s due to MED %d < %d",
540 pfx_buf
, new->peer
->host
, exist
->peer
->host
, new_med
,
545 if (new_med
> exist_med
)
548 zlog_debug("%s: path %s loses to path %s due to MED %d > %d",
549 pfx_buf
, new->peer
->host
, exist
->peer
->host
, new_med
,
555 /* 7. Peer type check. */
556 new_sort
= new->peer
->sort
;
557 exist_sort
= exist
->peer
->sort
;
559 if (new_sort
== BGP_PEER_EBGP
560 && (exist_sort
== BGP_PEER_IBGP
|| exist_sort
== BGP_PEER_CONFED
))
563 zlog_debug("%s: path %s wins over path %s due to eBGP peer > iBGP peer",
564 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
568 if (exist_sort
== BGP_PEER_EBGP
569 && (new_sort
== BGP_PEER_IBGP
|| new_sort
== BGP_PEER_CONFED
))
572 zlog_debug("%s: path %s loses to path %s due to iBGP peer < eBGP peer",
573 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
577 /* 8. IGP metric check. */
581 newm
= new->extra
->igpmetric
;
583 existm
= exist
->extra
->igpmetric
;
588 zlog_debug("%s: path %s wins over path %s due to IGP metric %d < %d",
589 pfx_buf
, new->peer
->host
, exist
->peer
->host
, newm
, existm
);
596 zlog_debug("%s: path %s loses to path %s due to IGP metric %d > %d",
597 pfx_buf
, new->peer
->host
, exist
->peer
->host
, newm
, existm
);
601 /* 9. Same IGP metric. Compare the cluster list length as
602 representative of IGP hops metric. Rewrite the metric value
603 pair (newm, existm) with the cluster list length. Prefer the
604 path with smaller cluster list length. */
607 if (peer_sort (new->peer
) == BGP_PEER_IBGP
608 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
609 && CHECK_FLAG (mpath_cfg
->ibgp_flags
,
610 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
612 newm
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
613 existm
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
618 zlog_debug("%s: path %s wins over path %s due to CLUSTER_LIST length %d < %d",
619 pfx_buf
, new->peer
->host
, exist
->peer
->host
, newm
,
627 zlog_debug("%s: path %s loses to path %s due to CLUSTER_LIST length %d > %d",
628 pfx_buf
, new->peer
->host
, exist
->peer
->host
, newm
,
635 /* 10. confed-external vs. confed-internal */
636 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
638 if (new_sort
== BGP_PEER_CONFED
&& exist_sort
== BGP_PEER_IBGP
)
641 zlog_debug("%s: path %s wins over path %s due to confed-external peer > confed-internal peer",
642 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
646 if (exist_sort
== BGP_PEER_CONFED
&& new_sort
== BGP_PEER_IBGP
)
649 zlog_debug("%s: path %s loses to path %s due to confed-internal peer < confed-external peer",
650 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
655 /* 11. Maximum path check. */
658 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
))
662 * For the two paths, all comparison steps till IGP metric
663 * have succeeded - including AS_PATH hop count. Since 'bgp
664 * bestpath as-path multipath-relax' knob is on, we don't need
665 * an exact match of AS_PATH. Thus, mark the paths are equal.
666 * That will trigger both these paths to get into the multipath
672 zlog_debug("%s: path %s and path %s are equal via multipath-relax",
673 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
675 else if (new->peer
->sort
== BGP_PEER_IBGP
)
677 if (aspath_cmp (new->attr
->aspath
, exist
->attr
->aspath
))
682 zlog_debug("%s: path %s and path %s are equal via matching aspaths",
683 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
686 else if (new->peer
->as
== exist
->peer
->as
)
691 zlog_debug("%s: path %s and path %s are equal via same remote-as",
692 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
698 * TODO: If unequal cost ibgp multipath is enabled we can
699 * mark the paths as equal here instead of returning
704 /* 12. If both paths are external, prefer the path that was received
705 first (the oldest one). This step minimizes route-flap, since a
706 newer path won't displace an older one, even if it was the
707 preferred route based on the additional decision criteria below. */
708 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
709 && new_sort
== BGP_PEER_EBGP
710 && exist_sort
== BGP_PEER_EBGP
)
712 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
715 zlog_debug("%s: path %s wins over path %s due to oldest external",
716 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
720 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
723 zlog_debug("%s: path %s loses to path %s due to oldest external",
724 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
729 /* 13. Router-ID comparision. */
730 /* If one of the paths is "stale", the corresponding peer router-id will
731 * be 0 and would always win over the other path. If originator id is
732 * used for the comparision, it will decide which path is better.
734 if (newattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
735 new_id
.s_addr
= newattre
->originator_id
.s_addr
;
737 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
738 if (existattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
739 exist_id
.s_addr
= existattre
->originator_id
.s_addr
;
741 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
743 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
746 zlog_debug("%s: path %s wins over path %s due to Router-ID comparison",
747 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
751 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
754 zlog_debug("%s: path %s loses to path %s due to Router-ID comparison",
755 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
759 /* 14. Cluster length comparision. */
760 new_cluster
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
761 exist_cluster
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
763 if (new_cluster
< exist_cluster
)
766 zlog_debug("%s: path %s wins over path %s due to CLUSTER_LIST length %d < %d",
767 pfx_buf
, new->peer
->host
, exist
->peer
->host
, new_cluster
,
772 if (new_cluster
> exist_cluster
)
775 zlog_debug("%s: path %s loses to path %s due to CLUSTER_LIST length %d > %d",
776 pfx_buf
, new->peer
->host
, exist
->peer
->host
, new_cluster
,
781 /* 15. Neighbor address comparision. */
782 /* Do this only if neither path is "stale" as stale paths do not have
783 * valid peer information (as the connection may or may not be up).
785 if (CHECK_FLAG (exist
->flags
, BGP_INFO_STALE
))
788 zlog_debug("%s: path %s wins over path %s due to latter path being STALE",
789 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
793 if (CHECK_FLAG (new->flags
, BGP_INFO_STALE
))
796 zlog_debug("%s: path %s loses to path %s due to former path being STALE",
797 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
801 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
806 zlog_debug("%s: path %s loses to path %s due to Neighor IP comparison",
807 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
814 zlog_debug("%s: path %s wins over path %s due to Neighor IP comparison",
815 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
820 zlog_debug("%s: path %s wins over path %s due to nothing left to compare",
821 pfx_buf
, new->peer
->host
, exist
->peer
->host
);
826 static enum filter_type
827 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
828 afi_t afi
, safi_t safi
)
830 struct bgp_filter
*filter
;
832 filter
= &peer
->filter
[afi
][safi
];
834 #define FILTER_EXIST_WARN(F,f,filter) \
835 if (BGP_DEBUG (update, UPDATE_IN) \
836 && !(F ## _IN (filter))) \
837 zlog_warn ("%s: Could not find configured input %s-list %s!", \
838 peer->host, #f, F ## _IN_NAME(filter));
840 if (DISTRIBUTE_IN_NAME (filter
)) {
841 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
843 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
847 if (PREFIX_LIST_IN_NAME (filter
)) {
848 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
850 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
854 if (FILTER_LIST_IN_NAME (filter
)) {
855 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
857 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
861 return FILTER_PERMIT
;
862 #undef FILTER_EXIST_WARN
865 static enum filter_type
866 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
867 afi_t afi
, safi_t safi
)
869 struct bgp_filter
*filter
;
871 filter
= &peer
->filter
[afi
][safi
];
873 #define FILTER_EXIST_WARN(F,f,filter) \
874 if (BGP_DEBUG (update, UPDATE_OUT) \
875 && !(F ## _OUT (filter))) \
876 zlog_warn ("%s: Could not find configured output %s-list %s!", \
877 peer->host, #f, F ## _OUT_NAME(filter));
879 if (DISTRIBUTE_OUT_NAME (filter
)) {
880 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
882 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
886 if (PREFIX_LIST_OUT_NAME (filter
)) {
887 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
889 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
893 if (FILTER_LIST_OUT_NAME (filter
)) {
894 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
896 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
900 return FILTER_PERMIT
;
901 #undef FILTER_EXIST_WARN
904 /* If community attribute includes no_export then return 1. */
906 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
910 /* NO_ADVERTISE check. */
911 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
914 /* NO_EXPORT check. */
915 if (peer
->sort
== BGP_PEER_EBGP
&&
916 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
919 /* NO_EXPORT_SUBCONFED check. */
920 if (peer
->sort
== BGP_PEER_EBGP
921 || peer
->sort
== BGP_PEER_CONFED
)
922 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
928 /* Route reflection loop check. */
930 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
932 struct in_addr cluster_id
;
934 if (attr
->extra
&& attr
->extra
->cluster
)
936 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
937 cluster_id
= peer
->bgp
->cluster_id
;
939 cluster_id
= peer
->bgp
->router_id
;
941 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
948 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
949 afi_t afi
, safi_t safi
, const char *rmap_name
)
951 struct bgp_filter
*filter
;
952 struct bgp_info info
;
953 route_map_result_t ret
;
954 struct route_map
*rmap
= NULL
;
956 filter
= &peer
->filter
[afi
][safi
];
958 /* Apply default weight value. */
960 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
964 rmap
= route_map_lookup_by_name(rmap_name
);
971 if (ROUTE_MAP_IN_NAME(filter
))
973 rmap
= ROUTE_MAP_IN (filter
);
980 /* Route map apply. */
983 /* Duplicate current value to new strucutre for modification. */
987 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
989 /* Apply BGP route map to the attribute. */
990 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
994 if (ret
== RMAP_DENYMATCH
)
996 /* Free newly generated AS path and community by route-map. */
997 bgp_attr_flush (attr
);
1005 bgp_output_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1006 afi_t afi
, safi_t safi
, const char *rmap_name
)
1008 struct bgp_filter
*filter
;
1009 struct bgp_info info
;
1010 route_map_result_t ret
;
1011 struct route_map
*rmap
= NULL
;
1013 filter
= &peer
->filter
[afi
][safi
];
1015 /* Apply default weight value. */
1017 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
1021 rmap
= route_map_lookup_by_name(rmap_name
);
1028 if (ROUTE_MAP_OUT_NAME(filter
))
1030 rmap
= ROUTE_MAP_OUT (filter
);
1037 /* Route map apply. */
1040 /* Duplicate current value to new strucutre for modification. */
1044 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1046 /* Apply BGP route map to the attribute. */
1047 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1049 peer
->rmap_type
= 0;
1051 if (ret
== RMAP_DENYMATCH
)
1052 /* caller has multiple error paths with bgp_attr_flush() */
1058 /* If this is an EBGP peer with remove-private-AS */
1060 bgp_peer_remove_private_as(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1061 struct peer
*peer
, struct attr
*attr
)
1063 if (peer
->sort
== BGP_PEER_EBGP
&&
1064 (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1065 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
) ||
1066 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
) ||
1067 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)))
1069 // Take action on the entire aspath
1070 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1071 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
1073 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
1074 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1076 // The entire aspath consists of private ASNs so create an empty aspath
1077 else if (aspath_private_as_check (attr
->aspath
))
1078 attr
->aspath
= aspath_empty_get ();
1080 // There are some public and some private ASNs, remove the private ASNs
1082 attr
->aspath
= aspath_remove_private_asns (attr
->aspath
);
1085 // 'all' was not specified so the entire aspath must be private ASNs
1086 // for us to do anything
1087 else if (aspath_private_as_check (attr
->aspath
))
1089 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
1090 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1092 attr
->aspath
= aspath_empty_get ();
1097 /* If this is an EBGP peer with as-override */
1099 bgp_peer_as_override(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1100 struct peer
*peer
, struct attr
*attr
)
1102 if (peer
->sort
== BGP_PEER_EBGP
&&
1103 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
))
1105 if (aspath_single_asn_check (attr
->aspath
, peer
->as
))
1106 attr
->aspath
= aspath_replace_specific_asn (attr
->aspath
, peer
->as
, bgp
->as
);
1111 subgroup_announce_reset_nhop (u_char family
, struct attr
*attr
)
1113 if (family
== AF_INET
)
1114 attr
->nexthop
.s_addr
= 0;
1116 if (family
== AF_INET6
)
1117 memset (&attr
->extra
->mp_nexthop_global
, 0, IPV6_MAX_BYTELEN
);
1122 subgroup_announce_check (struct bgp_info
*ri
, struct update_subgroup
*subgrp
,
1123 struct prefix
*p
, struct attr
*attr
)
1125 struct bgp_filter
*filter
;
1128 struct peer
*onlypeer
;
1130 struct attr
*riattr
;
1131 struct peer_af
*paf
;
1132 char buf
[SU_ADDRSTRLEN
];
1139 if (DISABLE_BGP_ANNOUNCE
)
1142 afi
= SUBGRP_AFI(subgrp
);
1143 safi
= SUBGRP_SAFI(subgrp
);
1144 peer
= SUBGRP_PEER(subgrp
);
1146 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_LONESOUL
))
1147 onlypeer
= SUBGRP_PFIRST(subgrp
)->peer
;
1150 filter
= &peer
->filter
[afi
][safi
];
1151 bgp
= SUBGRP_INST(subgrp
);
1152 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
1154 /* With addpath we may be asked to TX all kinds of paths so make sure
1156 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
) ||
1157 CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
) ||
1158 CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
1163 /* If this is not the bestpath then check to see if there is an enabled addpath
1164 * feature that requires us to advertise it */
1165 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1167 if (! bgp_addpath_tx_path(peer
, afi
, safi
, ri
))
1173 /* Aggregate-address suppress check. */
1174 if (ri
->extra
&& ri
->extra
->suppress
)
1175 if (! UNSUPPRESS_MAP_NAME (filter
))
1180 /* Do not send back route to sender. */
1181 if (onlypeer
&& from
== onlypeer
)
1186 /* Do not send the default route in the BGP table if the neighbor is
1187 * configured for default-originate */
1188 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
1190 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1193 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1195 #endif /* HAVE_IPV6 */
1198 /* Transparency check. */
1199 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
1200 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
1205 /* If community is not disabled check the no-export and local. */
1206 if (! transparent
&& bgp_community_filter (peer
, riattr
))
1208 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1209 zlog_debug ("subgrpannouncecheck: community filter check fail");
1213 /* If the attribute has originator-id and it is same as remote
1216 riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
) &&
1217 (IPV4_ADDR_SAME (&onlypeer
->remote_id
, &riattr
->extra
->originator_id
)))
1219 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1220 zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as "
1223 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1228 /* ORF prefix-list filter check */
1229 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1230 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1231 || CHECK_FLAG (peer
->af_cap
[afi
][safi
],
1232 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1233 if (peer
->orf_plist
[afi
][safi
])
1235 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1237 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1238 zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF",
1240 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1246 /* Output filter check. */
1247 if (bgp_output_filter (peer
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
1249 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1250 zlog_debug ("%s [Update:SEND] %s/%d is filtered",
1252 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1257 #ifdef BGP_SEND_ASPATH_CHECK
1258 /* AS path loop check. */
1259 if (onlypeer
&& aspath_loop_check (riattr
->aspath
, onlypeer
->as
))
1261 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1262 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u "
1263 "that is part of AS path.",
1264 onlypeer
->host
, onlypeer
->as
);
1267 #endif /* BGP_SEND_ASPATH_CHECK */
1269 /* If we're a CONFED we need to loop check the CONFED ID too */
1270 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
1272 if (aspath_loop_check(riattr
->aspath
, bgp
->confed_id
))
1274 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1275 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u"
1283 /* Route-Reflect check. */
1284 if (from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1289 /* IBGP reflection check. */
1292 /* A route from a Client peer. */
1293 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
1295 /* Reflect to all the Non-Client peers and also to the
1296 Client peers other than the originator. Originator check
1297 is already done. So there is noting to do. */
1298 /* no bgp client-to-client reflection check. */
1299 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
1300 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1301 PEER_FLAG_REFLECTOR_CLIENT
))
1306 /* A route from a Non-client peer. Reflect to all other
1308 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1309 PEER_FLAG_REFLECTOR_CLIENT
))
1314 /* For modify attribute, copy it to temporary structure. */
1315 bgp_attr_dup (attr
, riattr
);
1317 /* If local-preference is not set. */
1318 if ((peer
->sort
== BGP_PEER_IBGP
1319 || peer
->sort
== BGP_PEER_CONFED
)
1320 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
1322 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1323 attr
->local_pref
= bgp
->default_local_pref
;
1326 /* If originator-id is not set and the route is to be reflected,
1327 set the originator id */
1328 if (reflect
&& (!(attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))))
1330 attr
->extra
= bgp_attr_extra_get(attr
);
1331 IPV4_ADDR_COPY(&(attr
->extra
->originator_id
), &(from
->remote_id
));
1332 SET_FLAG(attr
->flag
, BGP_ATTR_ORIGINATOR_ID
);
1335 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
1336 if (peer
->sort
== BGP_PEER_EBGP
1337 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
1339 if (from
!= bgp
->peer_self
&& ! transparent
1340 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
1341 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
1344 /* Since the nexthop attribute can vary per peer, it is not explicitly set
1345 * in announce check, only certain flags and length (or number of nexthops
1346 * -- for IPv6/MP_REACH) are set here in order to guide the update formation
1347 * code in setting the nexthop(s) on a per peer basis in reformat_peer().
1348 * Typically, the source nexthop in the attribute is preserved but in the
1349 * scenarios where we know it will always be overwritten, we reset the
1350 * nexthop to "0" in an attempt to achieve better Update packing. An
1351 * example of this is when a prefix from each of 2 IBGP peers needs to be
1352 * announced to an EBGP peer (and they have the same attributes barring
1356 SET_FLAG(attr
->rmap_change_flags
, BATTR_REFLECTED
);
1359 /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
1360 * the peer (group) is configured to receive link-local nexthop unchanged
1361 * and it is available in the prefix OR we're not reflecting the route and
1362 * the peer (group) to whom we're going to announce is on a shared network
1363 * and this is either a self-originated route or the peer is EBGP.
1365 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1367 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
1368 if ((CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1369 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) &&
1370 IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
)) ||
1371 (!reflect
&& peer
->shared_network
&&
1372 (from
== bgp
->peer_self
|| peer
->sort
== BGP_PEER_EBGP
)))
1374 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
1377 /* Clear off link-local nexthop in source, whenever it is not needed to
1378 * ensure more prefixes share the same attribute for announcement.
1380 if (!(CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1381 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)))
1382 memset (&attr
->extra
->mp_nexthop_local
, 0, IPV6_MAX_BYTELEN
);
1384 #endif /* HAVE_IPV6 */
1386 bgp_peer_remove_private_as(bgp
, afi
, safi
, peer
, attr
);
1387 bgp_peer_as_override(bgp
, afi
, safi
, peer
, attr
);
1389 /* Route map & unsuppress-map apply. */
1390 if (ROUTE_MAP_OUT_NAME (filter
)
1391 || (ri
->extra
&& ri
->extra
->suppress
) )
1393 struct bgp_info info
;
1394 struct attr dummy_attr
;
1395 struct attr_extra dummy_extra
;
1397 dummy_attr
.extra
= &dummy_extra
;
1401 /* don't confuse inbound and outbound setting */
1402 RESET_FLAG(attr
->rmap_change_flags
);
1405 * The route reflector is not allowed to modify the attributes
1406 * of the reflected IBGP routes unless explicitly allowed.
1408 if ((from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1409 && !bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
))
1411 bgp_attr_dup (&dummy_attr
, attr
);
1412 info
.attr
= &dummy_attr
;
1415 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1417 if (ri
->extra
&& ri
->extra
->suppress
)
1418 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1420 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1422 peer
->rmap_type
= 0;
1424 if (ret
== RMAP_DENYMATCH
)
1426 bgp_attr_flush (attr
);
1431 /* After route-map has been applied, we check to see if the nexthop to
1432 * be carried in the attribute (that is used for the announcement) can
1433 * be cleared off or not. We do this in all cases where we would be
1434 * setting the nexthop to "ourselves". For IPv6, we only need to consider
1435 * the global nexthop here; the link-local nexthop would have been cleared
1436 * already, and if not, it is required by the update formation code.
1437 * Also see earlier comments in this function.
1440 * If route-map has performed some operation on the nexthop or the peer
1441 * configuration says to pass it unchanged, we cannot reset the nexthop
1442 * here, so only attempt to do it if these aren't true. Note that the
1443 * route-map handler itself might have cleared the nexthop, if for example,
1444 * it is configured as 'peer-address'.
1446 if (!bgp_rmap_nhop_changed(attr
->rmap_change_flags
,
1447 riattr
->rmap_change_flags
) &&
1449 !CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
))
1451 /* We can reset the nexthop, if setting (or forcing) it to 'self' */
1452 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
) ||
1453 CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_FORCE_NEXTHOP_SELF
))
1456 CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1457 PEER_FLAG_FORCE_NEXTHOP_SELF
))
1458 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ?
1459 AF_INET6
: p
->family
), attr
);
1461 else if (peer
->sort
== BGP_PEER_EBGP
)
1463 /* Can also reset the nexthop if announcing to EBGP, but only if
1464 * no peer in the subgroup is on a shared subnet.
1465 * Note: 3rd party nexthop currently implemented for IPv4 only.
1467 SUBGRP_FOREACH_PEER (subgrp
, paf
)
1469 if (bgp_multiaccess_check_v4 (riattr
->nexthop
, paf
->peer
))
1473 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ? AF_INET6
: p
->family
), attr
);
1475 /* If IPv6/MP and nexthop does not have any override and happens to
1476 * be a link-local address, reset it so that we don't pass along the
1477 * source's link-local IPv6 address to recipients who may not be on
1478 * the same interface.
1480 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1482 if (IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_global
))
1483 subgroup_announce_reset_nhop (AF_INET6
, attr
);
1490 struct bgp_info_pair
1492 struct bgp_info
*old
;
1493 struct bgp_info
*new;
1497 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
,
1498 struct bgp_maxpaths_cfg
*mpath_cfg
,
1499 struct bgp_info_pair
*result
)
1501 struct bgp_info
*new_select
;
1502 struct bgp_info
*old_select
;
1503 struct bgp_info
*ri
;
1504 struct bgp_info
*ri1
;
1505 struct bgp_info
*ri2
;
1506 struct bgp_info
*nextri
= NULL
;
1507 int paths_eq
, do_mpath
, debug
;
1508 struct list mp_list
;
1509 char pfx_buf
[PREFIX2STR_BUFFER
];
1511 bgp_mp_list_init (&mp_list
);
1512 do_mpath
= (mpath_cfg
->maxpaths_ebgp
> 1 || mpath_cfg
->maxpaths_ibgp
> 1);
1514 debug
= bgp_debug_bestpath(&rn
->p
);
1517 prefix2str (&rn
->p
, pfx_buf
, sizeof (pfx_buf
));
1519 /* bgp deterministic-med */
1521 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1524 /* Clear BGP_INFO_DMED_SELECTED for all paths */
1525 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1526 bgp_info_unset_flag (rn
, ri1
, BGP_INFO_DMED_SELECTED
);
1528 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1530 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1532 if (BGP_INFO_HOLDDOWN (ri1
))
1534 if (ri1
->peer
&& ri1
->peer
!= bgp
->peer_self
)
1535 if (ri1
->peer
->status
!= Established
)
1539 old_select
= CHECK_FLAG (ri1
->flags
, BGP_INFO_SELECTED
) ? ri1
: NULL
;
1542 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1544 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1546 if (BGP_INFO_HOLDDOWN (ri2
))
1549 ri2
->peer
!= bgp
->peer_self
&&
1550 !CHECK_FLAG (ri2
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1551 if (ri2
->peer
->status
!= Established
)
1554 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1555 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1558 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_SELECTED
))
1560 if (bgp_info_cmp (bgp
, ri2
, new_select
, &paths_eq
,
1561 mpath_cfg
, debug
, pfx_buf
))
1563 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1567 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1571 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1572 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1575 zlog_debug("%s: path %s is the bestpath from AS %d",
1576 pfx_buf
, new_select
->peer
->host
,
1577 aspath_get_firstas(new_select
->attr
->aspath
));
1581 /* Check old selected route and new selected route. */
1584 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1586 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1589 if (BGP_INFO_HOLDDOWN (ri
))
1591 /* reap REMOVED routes, if needs be
1592 * selected route must stay for a while longer though
1594 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1595 && (ri
!= old_select
))
1596 bgp_info_reap (rn
, ri
);
1602 ri
->peer
!= bgp
->peer_self
&&
1603 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1604 if (ri
->peer
->status
!= Established
)
1607 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1608 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1610 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1614 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1616 if (bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
))
1622 /* Now that we know which path is the bestpath see if any of the other paths
1623 * qualify as multipaths
1625 if (do_mpath
&& new_select
)
1628 zlog_debug("%s: path %s is the bestpath, now find multipaths",
1629 pfx_buf
, new_select
->peer
->host
);
1631 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1633 if (ri
== new_select
)
1636 zlog_debug("%s: path %s is the bestpath, add to the multipath list",
1637 pfx_buf
, ri
->peer
->host
);
1638 bgp_mp_list_add (&mp_list
, ri
);
1642 if (BGP_INFO_HOLDDOWN (ri
))
1646 ri
->peer
!= bgp
->peer_self
&&
1647 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1648 if (ri
->peer
->status
!= Established
)
1651 if (!bgp_info_nexthop_cmp (ri
, new_select
))
1654 zlog_debug("%s: path %s has the same nexthop as the bestpath, skip it",
1655 pfx_buf
, ri
->peer
->host
);
1659 bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
);
1664 zlog_debug("%s: path %s is equivalent to the bestpath, add to the multipath list",
1665 pfx_buf
, ri
->peer
->host
);
1666 bgp_mp_list_add (&mp_list
, ri
);
1671 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1672 bgp_info_mpath_aggregate_update (new_select
, old_select
);
1673 bgp_mp_list_clear (&mp_list
);
1675 result
->old
= old_select
;
1676 result
->new = new_select
;
1682 * A new route/change in bestpath of an existing route. Evaluate the path
1683 * for advertisement to the subgroup.
1686 subgroup_process_announce_selected (struct update_subgroup
*subgrp
,
1687 struct bgp_info
*selected
,
1688 struct bgp_node
*rn
,
1689 u_int32_t addpath_tx_id
)
1692 struct peer
*onlypeer
;
1694 struct attr_extra extra
;
1699 afi
= SUBGRP_AFI(subgrp
);
1700 safi
= SUBGRP_SAFI(subgrp
);
1701 onlypeer
= ((SUBGRP_PCOUNT(subgrp
) == 1) ?
1702 (SUBGRP_PFIRST(subgrp
))->peer
: NULL
);
1704 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1705 if (onlypeer
&& CHECK_FLAG (onlypeer
->af_sflags
[afi
][safi
],
1706 PEER_STATUS_ORF_WAIT_REFRESH
))
1709 /* It's initialized in bgp_announce_check() */
1710 attr
.extra
= &extra
;
1712 /* Announcement to the subgroup. If the route is filtered withdraw it. */
1715 if (subgroup_announce_check(selected
, subgrp
, p
, &attr
))
1716 bgp_adj_out_set_subgroup(rn
, subgrp
, &attr
, selected
);
1718 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, selected
->addpath_tx_id
);
1721 /* If selected is NULL we must withdraw the path using addpath_tx_id */
1724 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, addpath_tx_id
);
1730 struct bgp_process_queue
1733 struct bgp_node
*rn
;
1738 static wq_item_status
1739 bgp_process_main (struct work_queue
*wq
, void *data
)
1741 struct bgp_process_queue
*pq
= data
;
1742 struct bgp
*bgp
= pq
->bgp
;
1743 struct bgp_node
*rn
= pq
->rn
;
1744 afi_t afi
= pq
->afi
;
1745 safi_t safi
= pq
->safi
;
1746 struct prefix
*p
= &rn
->p
;
1747 struct bgp_info
*new_select
;
1748 struct bgp_info
*old_select
;
1749 struct bgp_info_pair old_and_new
;
1751 /* Is it end of initial update? (after startup) */
1754 quagga_timestamp(3, bgp
->update_delay_zebra_resume_time
,
1755 sizeof(bgp
->update_delay_zebra_resume_time
));
1757 bgp
->main_zebra_update_hold
= 0;
1758 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1759 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1761 bgp_zebra_announce_table(bgp
, afi
, safi
);
1763 bgp
->main_peers_update_hold
= 0;
1765 bgp_start_routeadv(bgp
);
1769 /* Best path selection. */
1770 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1771 old_select
= old_and_new
.old
;
1772 new_select
= old_and_new
.new;
1774 /* Nothing to do. */
1775 if (old_select
&& old_select
== new_select
&&
1776 !CHECK_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
) &&
1777 !CHECK_FLAG(old_select
->flags
, BGP_INFO_ATTR_CHANGED
) &&
1778 !bgp
->addpath_tx_used
[afi
][safi
])
1780 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
) ||
1781 CHECK_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
))
1782 bgp_zebra_announce (p
, old_select
, bgp
, afi
, safi
);
1784 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1785 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1789 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1790 UNSET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
1792 /* bestpath has changed; bump version */
1793 if (old_select
|| new_select
)
1795 bgp_bump_version(rn
);
1797 if (!bgp
->t_rmap_def_originate_eval
)
1800 THREAD_TIMER_ON(bm
->master
, bgp
->t_rmap_def_originate_eval
,
1801 update_group_refresh_default_originate_route_map
,
1802 bgp
, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER
);
1807 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1810 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1811 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1812 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1815 group_announce_route(bgp
, afi
, safi
, rn
, new_select
);
1818 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) && (! bgp
->name
&&
1819 ! bgp_option_check (BGP_OPT_NO_FIB
)))
1822 && new_select
->type
== ZEBRA_ROUTE_BGP
1823 && (new_select
->sub_type
== BGP_ROUTE_NORMAL
||
1824 new_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1825 bgp_zebra_announce (p
, new_select
, bgp
, afi
, safi
);
1828 /* Withdraw the route from the kernel. */
1830 && old_select
->type
== ZEBRA_ROUTE_BGP
1831 && (old_select
->sub_type
== BGP_ROUTE_NORMAL
||
1832 old_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1833 bgp_zebra_withdraw (p
, old_select
, safi
);
1837 /* Reap old select bgp_info, if it has been removed */
1838 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1839 bgp_info_reap (rn
, old_select
);
1841 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1846 bgp_processq_del (struct work_queue
*wq
, void *data
)
1848 struct bgp_process_queue
*pq
= data
;
1849 struct bgp_table
*table
;
1851 bgp_unlock (pq
->bgp
);
1854 table
= bgp_node_table (pq
->rn
);
1855 bgp_unlock_node (pq
->rn
);
1856 bgp_table_unlock (table
);
1858 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1862 bgp_process_queue_init (void)
1864 if (!bm
->process_main_queue
)
1866 bm
->process_main_queue
1867 = work_queue_new (bm
->master
, "process_main_queue");
1869 if ( !bm
->process_main_queue
)
1871 zlog_err ("%s: Failed to allocate work queue", __func__
);
1876 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1877 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1878 bm
->process_main_queue
->spec
.max_retries
= 0;
1879 bm
->process_main_queue
->spec
.hold
= 50;
1880 /* Use a higher yield value of 50ms for main queue processing */
1881 bm
->process_main_queue
->spec
.yield
= 50 * 1000L;
1885 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1887 struct bgp_process_queue
*pqnode
;
1889 /* already scheduled for processing? */
1890 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1893 if (bm
->process_main_queue
== NULL
)
1894 bgp_process_queue_init ();
1896 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1897 sizeof (struct bgp_process_queue
));
1901 /* all unlocked in bgp_processq_del */
1902 bgp_table_lock (bgp_node_table (rn
));
1903 pqnode
->rn
= bgp_lock_node (rn
);
1907 pqnode
->safi
= safi
;
1908 work_queue_add (bm
->process_main_queue
, pqnode
);
1909 SET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1914 bgp_add_eoiu_mark (struct bgp
*bgp
)
1916 struct bgp_process_queue
*pqnode
;
1918 if (bm
->process_main_queue
== NULL
)
1919 bgp_process_queue_init ();
1921 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1922 sizeof (struct bgp_process_queue
));
1929 work_queue_add (bm
->process_main_queue
, pqnode
);
1933 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1937 peer
= THREAD_ARG (thread
);
1938 peer
->t_pmax_restart
= NULL
;
1940 if (bgp_debug_neighbor_events(peer
))
1941 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1944 peer_clear (peer
, NULL
);
1950 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1951 safi_t safi
, int always
)
1953 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1956 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1958 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1962 zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1963 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1964 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1965 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1967 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1973 if (safi
== SAFI_MPLS_VPN
)
1974 safi
= SAFI_MPLS_LABELED_VPN
;
1976 ndata
[0] = (afi
>> 8);
1979 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1980 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1981 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1982 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1984 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
1985 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
1986 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
1989 /* Dynamic peers will just close their connection. */
1990 if (peer_dynamic_neighbor (peer
))
1993 /* restart timer start */
1994 if (peer
->pmax_restart
[afi
][safi
])
1996 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
1998 if (bgp_debug_neighbor_events(peer
))
1999 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
2000 peer
->host
, peer
->v_pmax_restart
);
2002 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
2003 peer
->v_pmax_restart
);
2009 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2011 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
2013 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
2017 zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
2018 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
2019 peer
->pmax
[afi
][safi
]);
2020 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2023 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2027 /* Unconditionally remove the route from the RIB, without taking
2028 * damping into consideration (eg, because the session went down)
2031 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2032 afi_t afi
, safi_t safi
)
2034 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2036 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2037 bgp_info_delete (rn
, ri
); /* keep historical info */
2039 bgp_process (peer
->bgp
, rn
, afi
, safi
);
2043 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2044 afi_t afi
, safi_t safi
)
2046 int status
= BGP_DAMP_NONE
;
2048 /* apply dampening, if result is suppressed, we'll be retaining
2049 * the bgp_info in the RIB for historical reference.
2051 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2052 && peer
->sort
== BGP_PEER_EBGP
)
2053 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
2054 == BGP_DAMP_SUPPRESSED
)
2056 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2060 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2063 static struct bgp_info
*
2064 info_make (int type
, int sub_type
, u_short instance
, struct peer
*peer
, struct attr
*attr
,
2065 struct bgp_node
*rn
)
2067 struct bgp_info
*new;
2069 /* Make new BGP info. */
2070 new = XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
2072 new->instance
= instance
;
2073 new->sub_type
= sub_type
;
2076 new->uptime
= bgp_clock ();
2078 new->addpath_tx_id
= ++peer
->bgp
->addpath_tx_id
;
2083 bgp_info_addpath_rx_str(struct bgp_info
*ri
, char *buf
)
2085 if (ri
&& ri
->addpath_rx_id
)
2086 sprintf(buf
, " with addpath ID %d", ri
->addpath_rx_id
);
2089 /* Check if received nexthop is valid or not. */
2091 bgp_update_martian_nexthop (afi_t afi
, safi_t safi
, struct attr
*attr
)
2093 struct attr_extra
*attre
= attr
->extra
;
2096 /* Only validated for unicast and multicast currently. */
2097 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2100 /* If NEXT_HOP is present, validate it. */
2101 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2103 if (attr
->nexthop
.s_addr
== 0 ||
2104 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2105 bgp_nexthop_self (attr
))
2109 /* If MP_NEXTHOP is present, validate it. */
2110 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2111 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2112 * it is not an IPv6 link-local address.
2114 if (attre
&& attre
->mp_nexthop_len
)
2116 switch (attre
->mp_nexthop_len
)
2118 case BGP_ATTR_NHLEN_IPV4
:
2119 case BGP_ATTR_NHLEN_VPNV4
:
2120 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2121 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2125 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2126 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2127 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2128 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2129 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2131 #endif /* HAVE_IPV6 */
2143 bgp_update_main (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2144 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2145 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2149 int aspath_loop_count
= 0;
2150 struct bgp_node
*rn
;
2152 struct attr new_attr
;
2153 struct attr_extra new_extra
;
2154 struct attr
*attr_new
;
2155 struct bgp_info
*ri
;
2156 struct bgp_info
*new;
2158 char buf
[SU_ADDRSTRLEN
];
2163 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2165 /* When peer's soft reconfiguration enabled. Record input packet in
2167 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2168 && peer
!= bgp
->peer_self
)
2169 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2171 /* Check previously received route. */
2172 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2173 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2174 ri
->addpath_rx_id
== addpath_id
)
2177 /* AS path local-as loop check. */
2178 if (peer
->change_local_as
)
2180 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2181 aspath_loop_count
= 1;
2183 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2185 reason
= "as-path contains our own AS;";
2190 /* AS path loop check. */
2191 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2192 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2193 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2194 > peer
->allowas_in
[afi
][safi
]))
2196 reason
= "as-path contains our own AS;";
2200 /* Route reflector originator ID check. */
2201 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2202 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2204 reason
= "originator is us;";
2208 /* Route reflector cluster ID check. */
2209 if (bgp_cluster_filter (peer
, attr
))
2211 reason
= "reflected from the same cluster;";
2215 /* Apply incoming filter. */
2216 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2222 new_attr
.extra
= &new_extra
;
2223 bgp_attr_dup (&new_attr
, attr
);
2225 /* Apply incoming route-map.
2226 * NB: new_attr may now contain newly allocated values from route-map "set"
2227 * commands, so we need bgp_attr_flush in the error paths, until we intern
2228 * the attr (which takes over the memory references) */
2229 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2231 reason
= "route-map;";
2232 bgp_attr_flush (&new_attr
);
2236 /* next hop check. */
2237 if (bgp_update_martian_nexthop (afi
, safi
, &new_attr
))
2239 reason
= "martian or self next-hop;";
2240 bgp_attr_flush (&new_attr
);
2244 attr_new
= bgp_attr_intern (&new_attr
);
2246 /* If the update is implicit withdraw. */
2249 ri
->uptime
= bgp_clock ();
2251 /* Same attribute comes in. */
2252 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2253 && attrhash_cmp (ri
->attr
, attr_new
))
2255 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2256 && peer
->sort
== BGP_PEER_EBGP
2257 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2259 if (bgp_debug_update(peer
, p
, NULL
, 1))
2261 bgp_info_addpath_rx_str(ri
, buf2
);
2262 zlog_debug ("%s rcvd %s/%d%s",
2264 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2265 p
->prefixlen
, buf2
);
2268 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2270 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2271 bgp_process (bgp
, rn
, afi
, safi
);
2274 else /* Duplicate - odd */
2276 if (bgp_debug_update(peer
, p
, NULL
, 1))
2278 if (!peer
->rcvd_attr_printed
)
2280 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2281 peer
->rcvd_attr_printed
= 1;
2284 bgp_info_addpath_rx_str(ri
, buf2
);
2285 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2287 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2288 p
->prefixlen
, buf2
);
2291 /* graceful restart STALE flag unset. */
2292 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2294 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2295 bgp_process (bgp
, rn
, afi
, safi
);
2299 bgp_unlock_node (rn
);
2300 bgp_attr_unintern (&attr_new
);
2305 /* Withdraw/Announce before we fully processed the withdraw */
2306 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2308 if (bgp_debug_update(peer
, p
, NULL
, 1))
2310 bgp_info_addpath_rx_str(ri
, buf2
);
2311 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2313 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2314 p
->prefixlen
, buf2
);
2316 bgp_info_restore (rn
, ri
);
2319 /* Received Logging. */
2320 if (bgp_debug_update(peer
, p
, NULL
, 1))
2322 bgp_info_addpath_rx_str(ri
, buf2
);
2323 zlog_debug ("%s rcvd %s/%d%s",
2325 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2326 p
->prefixlen
, buf2
);
2329 /* graceful restart STALE flag unset. */
2330 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2331 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2333 /* The attribute is changed. */
2334 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2336 /* implicit withdraw, decrement aggregate and pcount here.
2337 * only if update is accepted, they'll increment below.
2339 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2341 /* Update bgp route dampening information. */
2342 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2343 && peer
->sort
== BGP_PEER_EBGP
)
2345 /* This is implicit withdraw so we should update dampening
2347 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2348 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2351 /* Update to new attribute. */
2352 bgp_attr_unintern (&ri
->attr
);
2353 ri
->attr
= attr_new
;
2355 /* Update MPLS tag. */
2356 if (safi
== SAFI_MPLS_VPN
)
2357 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2359 /* Update bgp route dampening information. */
2360 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2361 && peer
->sort
== BGP_PEER_EBGP
)
2363 /* Now we do normal update dampening. */
2364 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2365 if (ret
== BGP_DAMP_SUPPRESSED
)
2367 bgp_unlock_node (rn
);
2372 /* Nexthop reachability check. */
2373 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2375 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2376 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2377 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2382 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2383 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2386 if (BGP_DEBUG(nht
, NHT
))
2388 char buf1
[INET6_ADDRSTRLEN
];
2389 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2390 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2392 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2396 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2398 /* Process change. */
2399 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2401 bgp_process (bgp
, rn
, afi
, safi
);
2402 bgp_unlock_node (rn
);
2405 } // End of implicit withdraw
2407 /* Received Logging. */
2408 if (bgp_debug_update(peer
, p
, NULL
, 1))
2410 if (!peer
->rcvd_attr_printed
)
2412 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2413 peer
->rcvd_attr_printed
= 1;
2416 bgp_info_addpath_rx_str(ri
, buf2
);
2417 zlog_debug ("%s rcvd %s/%d%s",
2419 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2420 p
->prefixlen
, buf2
);
2423 /* Make new BGP info. */
2424 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2426 /* Update MPLS tag. */
2427 if (safi
== SAFI_MPLS_VPN
)
2428 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2430 /* Nexthop reachability check. */
2431 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2433 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2434 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2435 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2440 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2441 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2444 if (BGP_DEBUG(nht
, NHT
))
2446 char buf1
[INET6_ADDRSTRLEN
];
2447 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2448 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2450 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2454 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2457 new->addpath_rx_id
= addpath_id
;
2459 /* Increment prefix */
2460 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2462 /* Register new BGP information. */
2463 bgp_info_add (rn
, new);
2465 /* route_node_get lock */
2466 bgp_unlock_node (rn
);
2468 /* If maximum prefix count is configured and current prefix
2470 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2473 /* Process change. */
2474 bgp_process (bgp
, rn
, afi
, safi
);
2478 /* This BGP update is filtered. Log the reason then update BGP
2481 if (bgp_debug_update(peer
, p
, NULL
, 1))
2483 if (!peer
->rcvd_attr_printed
)
2485 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2486 peer
->rcvd_attr_printed
= 1;
2489 bgp_info_addpath_rx_str(ri
, buf2
);
2490 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2492 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2493 p
->prefixlen
, buf2
, reason
);
2497 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2499 bgp_unlock_node (rn
);
2505 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2506 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2507 struct prefix_rd
*prd
, u_char
*tag
, int soft_reconfig
)
2509 return bgp_update_main (peer
, p
, addpath_id
, attr
, afi
, safi
, type
, sub_type
,
2510 prd
, tag
, soft_reconfig
);
2514 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2515 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2516 struct prefix_rd
*prd
, u_char
*tag
)
2519 char buf
[SU_ADDRSTRLEN
];
2521 struct bgp_node
*rn
;
2522 struct bgp_info
*ri
;
2527 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2529 /* If peer is soft reconfiguration enabled. Record input packet for
2530 further calculation. */
2531 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2532 && peer
!= bgp
->peer_self
)
2533 bgp_adj_in_unset (rn
, peer
, addpath_id
);
2535 /* Lookup withdrawn route. */
2536 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2537 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2538 ri
->addpath_rx_id
== addpath_id
)
2542 if (bgp_debug_update(peer
, p
, NULL
, 1))
2544 bgp_info_addpath_rx_str(ri
, buf2
);
2545 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2547 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2548 p
->prefixlen
, buf2
);
2551 /* Withdraw specified route from routing table. */
2552 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2553 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2554 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2555 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2556 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2559 /* Unlock bgp_node_get() lock. */
2560 bgp_unlock_node (rn
);
2566 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2568 struct update_subgroup
*subgrp
;
2569 subgrp
= peer_subgroup(peer
, afi
, safi
);
2570 subgroup_default_originate(subgrp
, withdraw
);
2575 * bgp_stop_announce_route_timer
2578 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2580 if (!paf
->t_announce_route
)
2583 THREAD_TIMER_OFF (paf
->t_announce_route
);
2587 * bgp_announce_route_timer_expired
2589 * Callback that is invoked when the route announcement timer for a
2593 bgp_announce_route_timer_expired (struct thread
*t
)
2595 struct peer_af
*paf
;
2599 paf
= THREAD_ARG (t
);
2602 assert (paf
->t_announce_route
);
2603 paf
->t_announce_route
= NULL
;
2605 if (peer
->status
!= Established
)
2608 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2611 peer_af_announce_route (paf
, 1);
2616 * bgp_announce_route
2618 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2621 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2623 struct peer_af
*paf
;
2624 struct update_subgroup
*subgrp
;
2626 paf
= peer_af_find (peer
, afi
, safi
);
2629 subgrp
= PAF_SUBGRP(paf
);
2632 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2633 * or a refresh has already been triggered.
2635 if (!subgrp
|| paf
->t_announce_route
)
2639 * Start a timer to stagger/delay the announce. This serves
2640 * two purposes - announcement can potentially be combined for
2641 * multiple peers and the announcement doesn't happen in the
2644 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2645 bgp_announce_route_timer_expired
, paf
,
2646 (subgrp
->peer_count
== 1) ?
2647 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2648 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2652 * Announce routes from all AF tables to a peer.
2654 * This should ONLY be called when there is a need to refresh the
2655 * routes to the peer based on a policy change for this peer alone
2656 * or a route refresh request received from the peer.
2657 * The operation will result in splitting the peer from its existing
2658 * subgroups and putting it in new subgroups.
2661 bgp_announce_route_all (struct peer
*peer
)
2666 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2667 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2668 bgp_announce_route (peer
, afi
, safi
);
2672 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2673 struct bgp_table
*table
, struct prefix_rd
*prd
)
2676 struct bgp_node
*rn
;
2677 struct bgp_adj_in
*ain
;
2680 table
= peer
->bgp
->rib
[afi
][safi
];
2682 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2683 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2685 if (ain
->peer
== peer
)
2687 struct bgp_info
*ri
= rn
->info
;
2688 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
2690 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
2691 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2696 bgp_unlock_node (rn
);
2704 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2706 struct bgp_node
*rn
;
2707 struct bgp_table
*table
;
2709 if (peer
->status
!= Established
)
2712 if (safi
!= SAFI_MPLS_VPN
)
2713 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
2715 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2716 rn
= bgp_route_next (rn
))
2717 if ((table
= rn
->info
) != NULL
)
2719 struct prefix_rd prd
;
2720 prd
.family
= AF_UNSPEC
;
2722 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
2724 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
2729 struct bgp_clear_node_queue
2731 struct bgp_node
*rn
;
2734 static wq_item_status
2735 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2737 struct bgp_clear_node_queue
*cnq
= data
;
2738 struct bgp_node
*rn
= cnq
->rn
;
2739 struct peer
*peer
= wq
->spec
.data
;
2740 struct bgp_info
*ri
;
2741 afi_t afi
= bgp_node_table (rn
)->afi
;
2742 safi_t safi
= bgp_node_table (rn
)->safi
;
2744 assert (rn
&& peer
);
2746 /* It is possible that we have multiple paths for a prefix from a peer
2747 * if that peer is using AddPath.
2749 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2750 if (ri
->peer
== peer
)
2752 /* graceful restart STALE flag set. */
2753 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2754 && peer
->nsf
[afi
][safi
]
2755 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2756 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2757 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2759 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2765 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2767 struct bgp_clear_node_queue
*cnq
= data
;
2768 struct bgp_node
*rn
= cnq
->rn
;
2769 struct bgp_table
*table
= bgp_node_table (rn
);
2771 bgp_unlock_node (rn
);
2772 bgp_table_unlock (table
);
2773 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2777 bgp_clear_node_complete (struct work_queue
*wq
)
2779 struct peer
*peer
= wq
->spec
.data
;
2781 /* Tickle FSM to start moving again */
2782 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2784 peer_unlock (peer
); /* bgp_clear_route */
2788 bgp_clear_node_queue_init (struct peer
*peer
)
2790 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2792 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2793 #undef CLEAR_QUEUE_NAME_LEN
2795 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2797 zlog_err ("%s: Failed to allocate work queue", __func__
);
2800 peer
->clear_node_queue
->spec
.hold
= 10;
2801 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2802 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2803 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2804 peer
->clear_node_queue
->spec
.max_retries
= 0;
2806 /* we only 'lock' this peer reference when the queue is actually active */
2807 peer
->clear_node_queue
->spec
.data
= peer
;
2811 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2812 struct bgp_table
*table
)
2814 struct bgp_node
*rn
;
2818 table
= peer
->bgp
->rib
[afi
][safi
];
2820 /* If still no table => afi/safi isn't configured at all or smth. */
2824 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2826 struct bgp_info
*ri
;
2827 struct bgp_adj_in
*ain
;
2828 struct bgp_adj_in
*ain_next
;
2830 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2831 * queued for every clearing peer, regardless of whether it is
2832 * relevant to the peer at hand.
2834 * Overview: There are 3 different indices which need to be
2835 * scrubbed, potentially, when a peer is removed:
2837 * 1 peer's routes visible via the RIB (ie accepted routes)
2838 * 2 peer's routes visible by the (optional) peer's adj-in index
2839 * 3 other routes visible by the peer's adj-out index
2841 * 3 there is no hurry in scrubbing, once the struct peer is
2842 * removed from bgp->peer, we could just GC such deleted peer's
2843 * adj-outs at our leisure.
2845 * 1 and 2 must be 'scrubbed' in some way, at least made
2846 * invisible via RIB index before peer session is allowed to be
2847 * brought back up. So one needs to know when such a 'search' is
2852 * - there'd be a single global queue or a single RIB walker
2853 * - rather than tracking which route_nodes still need to be
2854 * examined on a peer basis, we'd track which peers still
2857 * Given that our per-peer prefix-counts now should be reliable,
2858 * this may actually be achievable. It doesn't seem to be a huge
2859 * problem at this time,
2861 * It is possible that we have multiple paths for a prefix from a peer
2862 * if that peer is using AddPath.
2867 ain_next
= ain
->next
;
2869 if (ain
->peer
== peer
)
2871 bgp_adj_in_remove (rn
, ain
);
2872 bgp_unlock_node (rn
);
2878 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2879 if (ri
->peer
== peer
)
2881 struct bgp_clear_node_queue
*cnq
;
2883 /* both unlocked in bgp_clear_node_queue_del */
2884 bgp_table_lock (bgp_node_table (rn
));
2886 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2887 sizeof (struct bgp_clear_node_queue
));
2889 work_queue_add (peer
->clear_node_queue
, cnq
);
2897 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2899 struct bgp_node
*rn
;
2900 struct bgp_table
*table
;
2902 if (peer
->clear_node_queue
== NULL
)
2903 bgp_clear_node_queue_init (peer
);
2905 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2906 * Idle until it receives a Clearing_Completed event. This protects
2907 * against peers which flap faster than we can we clear, which could
2910 * a) race with routes from the new session being installed before
2911 * clear_route_node visits the node (to delete the route of that
2913 * b) resource exhaustion, clear_route_node likely leads to an entry
2914 * on the process_main queue. Fast-flapping could cause that queue
2918 /* lock peer in assumption that clear-node-queue will get nodes; if so,
2919 * the unlock will happen upon work-queue completion; other wise, the
2920 * unlock happens at the end of this function.
2922 if (!peer
->clear_node_queue
->thread
)
2925 if (safi
!= SAFI_MPLS_VPN
)
2926 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
2928 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2929 rn
= bgp_route_next (rn
))
2930 if ((table
= rn
->info
) != NULL
)
2931 bgp_clear_route_table (peer
, afi
, safi
, table
);
2933 /* unlock if no nodes got added to the clear-node-queue. */
2934 if (!peer
->clear_node_queue
->thread
)
2940 bgp_clear_route_all (struct peer
*peer
)
2945 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2946 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2947 bgp_clear_route (peer
, afi
, safi
);
2951 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2953 struct bgp_table
*table
;
2954 struct bgp_node
*rn
;
2955 struct bgp_adj_in
*ain
;
2956 struct bgp_adj_in
*ain_next
;
2958 table
= peer
->bgp
->rib
[afi
][safi
];
2960 /* It is possible that we have multiple paths for a prefix from a peer
2961 * if that peer is using AddPath.
2963 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2969 ain_next
= ain
->next
;
2971 if (ain
->peer
== peer
)
2973 bgp_adj_in_remove (rn
, ain
);
2974 bgp_unlock_node (rn
);
2983 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2985 struct bgp_node
*rn
;
2986 struct bgp_info
*ri
;
2987 struct bgp_table
*table
;
2989 table
= peer
->bgp
->rib
[afi
][safi
];
2991 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2993 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2994 if (ri
->peer
== peer
)
2996 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2997 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3003 /* Delete all kernel routes. */
3005 bgp_cleanup_routes (void)
3008 struct listnode
*node
, *nnode
;
3009 struct bgp_node
*rn
;
3010 struct bgp_table
*table
;
3011 struct bgp_info
*ri
;
3013 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
3015 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
3017 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3018 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3019 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3020 && ri
->type
== ZEBRA_ROUTE_BGP
3021 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3022 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3023 bgp_zebra_withdraw (&rn
->p
, ri
,SAFI_UNICAST
);
3025 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
3027 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3028 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3029 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3030 && ri
->type
== ZEBRA_ROUTE_BGP
3031 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3032 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3033 bgp_zebra_withdraw (&rn
->p
, ri
,SAFI_UNICAST
);
3041 bgp_zclient_reset ();
3042 access_list_reset ();
3043 prefix_list_reset ();
3047 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3049 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3050 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3053 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3056 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3065 int addpath_encoded
;
3066 u_int32_t addpath_id
;
3068 /* Check peer status. */
3069 if (peer
->status
!= Established
)
3073 lim
= pnt
+ packet
->length
;
3075 safi
= packet
->safi
;
3077 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3079 for (; pnt
< lim
; pnt
+= psize
)
3081 /* Clear prefix structure. */
3082 memset (&p
, 0, sizeof (struct prefix
));
3084 if (addpath_encoded
)
3087 /* When packet overflow occurs return immediately. */
3088 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3091 addpath_id
= ntohl(*((uint32_t*) pnt
));
3092 pnt
+= BGP_ADDPATH_ID_LEN
;
3095 /* Fetch prefix length. */
3096 p
.prefixlen
= *pnt
++;
3097 p
.family
= afi2family (afi
);
3099 /* Already checked in nlri_sanity_check(). We do double check
3101 if ((afi
== AFI_IP
&& p
.prefixlen
> 32)
3102 || (afi
== AFI_IP6
&& p
.prefixlen
> 128))
3105 /* Packet size overflow check. */
3106 psize
= PSIZE (p
.prefixlen
);
3108 /* When packet overflow occur return immediately. */
3109 if (pnt
+ psize
> lim
)
3112 /* Fetch prefix from NLRI packet. */
3113 memcpy (&p
.u
.prefix
, pnt
, psize
);
3115 /* Check address. */
3116 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3118 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3121 * From draft-ietf-idr-bgp4-22, Section 6.3:
3122 * If a BGP router receives an UPDATE message with a
3123 * semantically incorrect NLRI field, in which a prefix is
3124 * semantically incorrect (eg. an unexpected multicast IP
3125 * address), it should ignore the prefix.
3127 zlog_err ("IPv4 unicast NLRI is multicast address %s",
3128 inet_ntoa (p
.u
.prefix4
));
3135 /* Check address. */
3136 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3138 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3142 zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
3143 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3148 #endif /* HAVE_IPV6 */
3150 /* Normal process. */
3152 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3153 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3155 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3156 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3158 /* Address family configuration mismatch or maximum-prefix count
3164 /* Packet length consistency check. */
3171 /* NLRI encode syntax check routine. */
3173 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, safi_t safi
, u_char
*pnt
,
3174 bgp_size_t length
, int *numpfx
)
3179 int addpath_encoded
;
3183 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3185 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3186 syntactic validity. If the field is syntactically incorrect,
3187 then the Error Subcode is set to Invalid Network Field. */
3192 /* If the NLRI is encoded using addpath then the first 4 bytes are
3193 * the addpath ID. */
3194 if (addpath_encoded
)
3196 if (pnt
+ BGP_ADDPATH_ID_LEN
> end
)
3198 zlog_err ("%s [Error] Update packet error"
3199 " (prefix data addpath overflow)",
3201 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3202 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3205 pnt
+= BGP_ADDPATH_ID_LEN
;
3210 /* Prefix length check. */
3211 if ((afi
== AFI_IP
&& prefixlen
> 32)
3212 || (afi
== AFI_IP6
&& prefixlen
> 128))
3214 zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
3215 peer
->host
, prefixlen
);
3216 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3217 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3221 /* Packet size overflow check. */
3222 psize
= PSIZE (prefixlen
);
3224 if (pnt
+ psize
> end
)
3226 zlog_err ("%s [Error] Update packet error"
3227 " (prefix data overflow prefix size is %d)",
3229 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3230 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3238 /* Packet length consistency check. */
3241 zlog_err ("%s [Error] Update packet error"
3242 " (prefix length mismatch with total length)",
3244 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3245 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3251 static struct bgp_static
*
3252 bgp_static_new (void)
3254 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3258 bgp_static_free (struct bgp_static
*bgp_static
)
3260 if (bgp_static
->rmap
.name
)
3261 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3262 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3266 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3267 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3269 struct bgp_node
*rn
;
3270 struct bgp_info
*ri
;
3271 struct bgp_info
*new;
3272 struct bgp_info info
;
3274 struct attr
*attr_new
;
3277 assert (bgp_static
);
3281 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3283 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3285 attr
.nexthop
= bgp_static
->igpnexthop
;
3286 attr
.med
= bgp_static
->igpmetric
;
3287 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3289 if (bgp_static
->atomic
)
3290 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3292 /* Apply route-map. */
3293 if (bgp_static
->rmap
.name
)
3295 struct attr attr_tmp
= attr
;
3296 info
.peer
= bgp
->peer_self
;
3297 info
.attr
= &attr_tmp
;
3299 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3301 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3303 bgp
->peer_self
->rmap_type
= 0;
3305 if (ret
== RMAP_DENYMATCH
)
3307 /* Free uninterned attribute. */
3308 bgp_attr_flush (&attr_tmp
);
3310 /* Unintern original. */
3311 aspath_unintern (&attr
.aspath
);
3312 bgp_attr_extra_free (&attr
);
3313 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3316 attr_new
= bgp_attr_intern (&attr_tmp
);
3319 attr_new
= bgp_attr_intern (&attr
);
3321 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3322 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3323 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3328 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3329 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3330 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3332 bgp_unlock_node (rn
);
3333 bgp_attr_unintern (&attr_new
);
3334 aspath_unintern (&attr
.aspath
);
3335 bgp_attr_extra_free (&attr
);
3340 /* The attribute is changed. */
3341 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3343 /* Rewrite BGP route information. */
3344 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3345 bgp_info_restore(rn
, ri
);
3347 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3348 bgp_attr_unintern (&ri
->attr
);
3349 ri
->attr
= attr_new
;
3350 ri
->uptime
= bgp_clock ();
3352 /* Nexthop reachability check. */
3353 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3355 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3356 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3359 if (BGP_DEBUG(nht
, NHT
))
3361 char buf1
[INET6_ADDRSTRLEN
];
3362 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3364 zlog_debug("%s(%s): Route not in table, not advertising",
3365 __FUNCTION__
, buf1
);
3367 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3372 /* Delete the NHT structure if any, if we're toggling between
3373 * enabling/disabling import check. We deregister the route
3374 * from NHT to avoid overloading NHT and the process interaction
3376 bgp_unlink_nexthop(ri
);
3377 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3379 /* Process change. */
3380 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3381 bgp_process (bgp
, rn
, afi
, safi
);
3382 bgp_unlock_node (rn
);
3383 aspath_unintern (&attr
.aspath
);
3384 bgp_attr_extra_free (&attr
);
3389 /* Make new BGP info. */
3390 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3392 /* Nexthop reachability check. */
3393 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3395 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3396 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3399 if (BGP_DEBUG(nht
, NHT
))
3401 char buf1
[INET6_ADDRSTRLEN
];
3402 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3404 zlog_debug("%s(%s): Route not in table, not advertising",
3405 __FUNCTION__
, buf1
);
3407 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3412 /* Delete the NHT structure if any, if we're toggling between
3413 * enabling/disabling import check. We deregister the route
3414 * from NHT to avoid overloading NHT and the process interaction
3416 bgp_unlink_nexthop(new);
3418 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3421 /* Aggregate address increment. */
3422 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3424 /* Register new BGP information. */
3425 bgp_info_add (rn
, new);
3427 /* route_node_get lock */
3428 bgp_unlock_node (rn
);
3430 /* Process change. */
3431 bgp_process (bgp
, rn
, afi
, safi
);
3433 /* Unintern original. */
3434 aspath_unintern (&attr
.aspath
);
3435 bgp_attr_extra_free (&attr
);
3439 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3440 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3442 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3446 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3447 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3449 struct bgp_node
*rn
;
3450 struct bgp_info
*new;
3452 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3454 /* Make new BGP info. */
3455 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
,
3456 bgp_attr_default_intern(BGP_ORIGIN_IGP
), rn
);
3458 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3459 new->extra
= bgp_info_extra_new();
3460 memcpy (new->extra
->tag
, tag
, 3);
3462 /* Aggregate address increment. */
3463 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3465 /* Register new BGP information. */
3466 bgp_info_add (rn
, new);
3468 /* route_node_get lock */
3469 bgp_unlock_node (rn
);
3471 /* Process change. */
3472 bgp_process (bgp
, rn
, afi
, safi
);
3476 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3479 struct bgp_node
*rn
;
3480 struct bgp_info
*ri
;
3482 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3484 /* Check selected route and self inserted route. */
3485 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3486 if (ri
->peer
== bgp
->peer_self
3487 && ri
->type
== ZEBRA_ROUTE_BGP
3488 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3491 /* Withdraw static BGP route from routing table. */
3494 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3495 bgp_unlink_nexthop(ri
);
3496 bgp_info_delete (rn
, ri
);
3497 bgp_process (bgp
, rn
, afi
, safi
);
3500 /* Unlock bgp_node_lookup. */
3501 bgp_unlock_node (rn
);
3505 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3506 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3508 struct bgp_node
*rn
;
3509 struct bgp_info
*ri
;
3511 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3513 /* Check selected route and self inserted route. */
3514 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3515 if (ri
->peer
== bgp
->peer_self
3516 && ri
->type
== ZEBRA_ROUTE_BGP
3517 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3520 /* Withdraw static BGP route from routing table. */
3523 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3524 bgp_info_delete (rn
, ri
);
3525 bgp_process (bgp
, rn
, afi
, safi
);
3528 /* Unlock bgp_node_lookup. */
3529 bgp_unlock_node (rn
);
3532 /* Configure static BGP network. When user don't run zebra, static
3533 route should be installed as valid. */
3535 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3536 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3540 struct bgp_static
*bgp_static
;
3541 struct bgp_node
*rn
;
3542 u_char need_update
= 0;
3544 /* Convert IP prefix string to struct prefix. */
3545 ret
= str2prefix (ip_str
, &p
);
3548 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3552 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3554 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3558 #endif /* HAVE_IPV6 */
3562 /* Set BGP static route configuration. */
3563 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3567 /* Configuration change. */
3568 bgp_static
= rn
->info
;
3570 /* Check previous routes are installed into BGP. */
3571 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3574 bgp_static
->backdoor
= backdoor
;
3578 if (bgp_static
->rmap
.name
)
3579 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3580 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3581 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3585 if (bgp_static
->rmap
.name
)
3586 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3587 bgp_static
->rmap
.name
= NULL
;
3588 bgp_static
->rmap
.map
= NULL
;
3589 bgp_static
->valid
= 0;
3591 bgp_unlock_node (rn
);
3595 /* New configuration. */
3596 bgp_static
= bgp_static_new ();
3597 bgp_static
->backdoor
= backdoor
;
3598 bgp_static
->valid
= 0;
3599 bgp_static
->igpmetric
= 0;
3600 bgp_static
->igpnexthop
.s_addr
= 0;
3604 if (bgp_static
->rmap
.name
)
3605 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3606 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3607 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3609 rn
->info
= bgp_static
;
3612 bgp_static
->valid
= 1;
3614 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3616 if (! bgp_static
->backdoor
)
3617 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3622 /* Configure static BGP network. */
3624 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3625 afi_t afi
, safi_t safi
)
3629 struct bgp_static
*bgp_static
;
3630 struct bgp_node
*rn
;
3632 /* Convert IP prefix string to struct prefix. */
3633 ret
= str2prefix (ip_str
, &p
);
3636 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3640 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3642 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3646 #endif /* HAVE_IPV6 */
3650 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3653 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3658 bgp_static
= rn
->info
;
3660 /* Update BGP RIB. */
3661 if (! bgp_static
->backdoor
)
3662 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3664 /* Clear configuration. */
3665 bgp_static_free (bgp_static
);
3667 bgp_unlock_node (rn
);
3668 bgp_unlock_node (rn
);
3673 /* Called from bgp_delete(). Delete all static routes from the BGP
3676 bgp_static_delete (struct bgp
*bgp
)
3680 struct bgp_node
*rn
;
3681 struct bgp_node
*rm
;
3682 struct bgp_table
*table
;
3683 struct bgp_static
*bgp_static
;
3685 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3686 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3687 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3688 if (rn
->info
!= NULL
)
3690 if (safi
== SAFI_MPLS_VPN
)
3694 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3696 bgp_static
= rn
->info
;
3697 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3698 AFI_IP
, SAFI_MPLS_VPN
,
3699 (struct prefix_rd
*)&rn
->p
,
3701 bgp_static_free (bgp_static
);
3703 bgp_unlock_node (rn
);
3708 bgp_static
= rn
->info
;
3709 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3710 bgp_static_free (bgp_static
);
3712 bgp_unlock_node (rn
);
3718 bgp_static_redo_import_check (struct bgp
*bgp
)
3722 struct bgp_node
*rn
;
3723 struct bgp_static
*bgp_static
;
3725 /* Use this flag to force reprocessing of the route */
3726 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3727 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3728 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3729 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3730 if (rn
->info
!= NULL
)
3732 bgp_static
= rn
->info
;
3733 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
3735 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3739 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3740 const char *tag_str
)
3744 struct prefix_rd prd
;
3746 struct bgp_node
*prn
;
3747 struct bgp_node
*rn
;
3748 struct bgp_table
*table
;
3749 struct bgp_static
*bgp_static
;
3754 ret
= str2prefix (ip_str
, &p
);
3757 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3762 ret
= str2prefix_rd (rd_str
, &prd
);
3765 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3769 ret
= str2tag (tag_str
, tag
);
3772 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3776 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3777 (struct prefix
*)&prd
);
3778 if (prn
->info
== NULL
)
3779 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3781 bgp_unlock_node (prn
);
3784 rn
= bgp_node_get (table
, &p
);
3788 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3789 bgp_unlock_node (rn
);
3793 /* New configuration. */
3794 bgp_static
= bgp_static_new ();
3795 bgp_static
->valid
= 1;
3796 memcpy (bgp_static
->tag
, tag
, 3);
3797 rn
->info
= bgp_static
;
3799 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3805 /* Configure static BGP network. */
3807 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3808 const char *rd_str
, const char *tag_str
)
3813 struct prefix_rd prd
;
3814 struct bgp_node
*prn
;
3815 struct bgp_node
*rn
;
3816 struct bgp_table
*table
;
3817 struct bgp_static
*bgp_static
;
3822 /* Convert IP prefix string to struct prefix. */
3823 ret
= str2prefix (ip_str
, &p
);
3826 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3831 ret
= str2prefix_rd (rd_str
, &prd
);
3834 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3838 ret
= str2tag (tag_str
, tag
);
3841 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3845 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3846 (struct prefix
*)&prd
);
3847 if (prn
->info
== NULL
)
3848 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3850 bgp_unlock_node (prn
);
3853 rn
= bgp_node_lookup (table
, &p
);
3857 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3859 bgp_static
= rn
->info
;
3860 bgp_static_free (bgp_static
);
3862 bgp_unlock_node (rn
);
3863 bgp_unlock_node (rn
);
3866 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3872 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
3873 const char *rmap_name
)
3875 struct bgp_rmap
*rmap
;
3877 rmap
= &bgp
->table_map
[afi
][safi
];
3881 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
3882 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
3883 rmap
->map
= route_map_lookup_by_name (rmap_name
);
3888 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
3893 bgp_zebra_announce_table(bgp
, afi
, safi
);
3899 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
3900 const char *rmap_name
)
3902 struct bgp_rmap
*rmap
;
3904 rmap
= &bgp
->table_map
[afi
][safi
];
3906 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
3910 bgp_zebra_announce_table(bgp
, afi
, safi
);
3916 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
3917 safi_t safi
, int *write
)
3919 if (bgp
->table_map
[afi
][safi
].name
)
3921 bgp_config_write_family_header (vty
, afi
, safi
, write
);
3922 vty_out (vty
, " table-map %s%s",
3923 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
3930 DEFUN (bgp_table_map
,
3933 "BGP table to RIB route download filter\n"
3934 "Name of the route map\n")
3936 return bgp_table_map_set (vty
, vty
->index
,
3937 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
3939 DEFUN (no_bgp_table_map
,
3940 no_bgp_table_map_cmd
,
3941 "no table-map WORD",
3942 "BGP table to RIB route download filter\n"
3943 "Name of the route map\n")
3945 return bgp_table_map_unset (vty
, vty
->index
,
3946 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
3951 "network A.B.C.D/M",
3952 "Specify a network to announce via BGP\n"
3953 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
3955 return bgp_static_set (vty
, vty
->index
, argv
[0],
3956 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
3959 DEFUN (bgp_network_route_map
,
3960 bgp_network_route_map_cmd
,
3961 "network A.B.C.D/M route-map WORD",
3962 "Specify a network to announce via BGP\n"
3963 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3964 "Route-map to modify the attributes\n"
3965 "Name of the route map\n")
3967 return bgp_static_set (vty
, vty
->index
, argv
[0],
3968 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
3971 DEFUN (bgp_network_backdoor
,
3972 bgp_network_backdoor_cmd
,
3973 "network A.B.C.D/M backdoor",
3974 "Specify a network to announce via BGP\n"
3975 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
3976 "Specify a BGP backdoor route\n")
3978 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
3982 DEFUN (bgp_network_mask
,
3983 bgp_network_mask_cmd
,
3984 "network A.B.C.D mask A.B.C.D",
3985 "Specify a network to announce via BGP\n"
3991 char prefix_str
[BUFSIZ
];
3993 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
3996 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4000 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4001 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4004 DEFUN (bgp_network_mask_route_map
,
4005 bgp_network_mask_route_map_cmd
,
4006 "network A.B.C.D mask A.B.C.D route-map WORD",
4007 "Specify a network to announce via BGP\n"
4011 "Route-map to modify the attributes\n"
4012 "Name of the route map\n")
4015 char prefix_str
[BUFSIZ
];
4017 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4020 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4024 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4025 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4028 DEFUN (bgp_network_mask_backdoor
,
4029 bgp_network_mask_backdoor_cmd
,
4030 "network A.B.C.D mask A.B.C.D backdoor",
4031 "Specify a network to announce via BGP\n"
4035 "Specify a BGP backdoor route\n")
4038 char prefix_str
[BUFSIZ
];
4040 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4043 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4047 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4051 DEFUN (bgp_network_mask_natural
,
4052 bgp_network_mask_natural_cmd
,
4054 "Specify a network to announce via BGP\n"
4058 char prefix_str
[BUFSIZ
];
4060 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4063 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4067 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4068 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4071 DEFUN (bgp_network_mask_natural_route_map
,
4072 bgp_network_mask_natural_route_map_cmd
,
4073 "network A.B.C.D route-map WORD",
4074 "Specify a network to announce via BGP\n"
4076 "Route-map to modify the attributes\n"
4077 "Name of the route map\n")
4080 char prefix_str
[BUFSIZ
];
4082 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4085 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4089 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4090 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4093 DEFUN (bgp_network_mask_natural_backdoor
,
4094 bgp_network_mask_natural_backdoor_cmd
,
4095 "network A.B.C.D backdoor",
4096 "Specify a network to announce via BGP\n"
4098 "Specify a BGP backdoor route\n")
4101 char prefix_str
[BUFSIZ
];
4103 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4106 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4110 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4114 DEFUN (no_bgp_network
,
4116 "no network A.B.C.D/M",
4118 "Specify a network to announce via BGP\n"
4119 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4121 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4122 bgp_node_safi (vty
));
4125 ALIAS (no_bgp_network
,
4126 no_bgp_network_route_map_cmd
,
4127 "no network A.B.C.D/M route-map WORD",
4129 "Specify a network to announce via BGP\n"
4130 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4131 "Route-map to modify the attributes\n"
4132 "Name of the route map\n")
4134 ALIAS (no_bgp_network
,
4135 no_bgp_network_backdoor_cmd
,
4136 "no network A.B.C.D/M backdoor",
4138 "Specify a network to announce via BGP\n"
4139 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4140 "Specify a BGP backdoor route\n")
4142 DEFUN (no_bgp_network_mask
,
4143 no_bgp_network_mask_cmd
,
4144 "no network A.B.C.D mask A.B.C.D",
4146 "Specify a network to announce via BGP\n"
4152 char prefix_str
[BUFSIZ
];
4154 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4157 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4161 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4162 bgp_node_safi (vty
));
4165 ALIAS (no_bgp_network_mask
,
4166 no_bgp_network_mask_route_map_cmd
,
4167 "no network A.B.C.D mask A.B.C.D route-map WORD",
4169 "Specify a network to announce via BGP\n"
4173 "Route-map to modify the attributes\n"
4174 "Name of the route map\n")
4176 ALIAS (no_bgp_network_mask
,
4177 no_bgp_network_mask_backdoor_cmd
,
4178 "no network A.B.C.D mask A.B.C.D backdoor",
4180 "Specify a network to announce via BGP\n"
4184 "Specify a BGP backdoor route\n")
4186 DEFUN (no_bgp_network_mask_natural
,
4187 no_bgp_network_mask_natural_cmd
,
4188 "no network A.B.C.D",
4190 "Specify a network to announce via BGP\n"
4194 char prefix_str
[BUFSIZ
];
4196 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4199 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4203 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4204 bgp_node_safi (vty
));
4207 ALIAS (no_bgp_network_mask_natural
,
4208 no_bgp_network_mask_natural_route_map_cmd
,
4209 "no network A.B.C.D route-map WORD",
4211 "Specify a network to announce via BGP\n"
4213 "Route-map to modify the attributes\n"
4214 "Name of the route map\n")
4216 ALIAS (no_bgp_network_mask_natural
,
4217 no_bgp_network_mask_natural_backdoor_cmd
,
4218 "no network A.B.C.D backdoor",
4220 "Specify a network to announce via BGP\n"
4222 "Specify a BGP backdoor route\n")
4225 DEFUN (ipv6_bgp_network
,
4226 ipv6_bgp_network_cmd
,
4227 "network X:X::X:X/M",
4228 "Specify a network to announce via BGP\n"
4229 "IPv6 prefix <network>/<length>\n")
4231 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4235 DEFUN (ipv6_bgp_network_route_map
,
4236 ipv6_bgp_network_route_map_cmd
,
4237 "network X:X::X:X/M route-map WORD",
4238 "Specify a network to announce via BGP\n"
4239 "IPv6 prefix <network>/<length>\n"
4240 "Route-map to modify the attributes\n"
4241 "Name of the route map\n")
4243 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4244 bgp_node_safi (vty
), argv
[1], 0);
4247 DEFUN (no_ipv6_bgp_network
,
4248 no_ipv6_bgp_network_cmd
,
4249 "no network X:X::X:X/M",
4251 "Specify a network to announce via BGP\n"
4252 "IPv6 prefix <network>/<length>\n")
4254 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4257 ALIAS (no_ipv6_bgp_network
,
4258 no_ipv6_bgp_network_route_map_cmd
,
4259 "no network X:X::X:X/M route-map WORD",
4261 "Specify a network to announce via BGP\n"
4262 "IPv6 prefix <network>/<length>\n"
4263 "Route-map to modify the attributes\n"
4264 "Name of the route map\n")
4266 ALIAS (ipv6_bgp_network
,
4267 old_ipv6_bgp_network_cmd
,
4268 "ipv6 bgp network X:X::X:X/M",
4271 "Specify a network to announce via BGP\n"
4272 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4274 ALIAS (no_ipv6_bgp_network
,
4275 old_no_ipv6_bgp_network_cmd
,
4276 "no ipv6 bgp network X:X::X:X/M",
4280 "Specify a network to announce via BGP\n"
4281 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4282 #endif /* HAVE_IPV6 */
4284 /* Aggreagete address:
4286 advertise-map Set condition to advertise attribute
4287 as-set Generate AS set path information
4288 attribute-map Set attributes of aggregate
4289 route-map Set parameters of aggregate
4290 summary-only Filter more specific routes from updates
4291 suppress-map Conditionally filter more specific routes from updates
4294 struct bgp_aggregate
4296 /* Summary-only flag. */
4297 u_char summary_only
;
4299 /* AS set generation. */
4302 /* Route-map for aggregated route. */
4303 struct route_map
*map
;
4305 /* Suppress-count. */
4306 unsigned long count
;
4308 /* SAFI configuration. */
4312 static struct bgp_aggregate
*
4313 bgp_aggregate_new (void)
4315 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4319 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4321 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4324 /* Update an aggregate as routes are added/removed from the BGP table */
4326 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4327 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4328 struct bgp_aggregate
*aggregate
)
4330 struct bgp_table
*table
;
4331 struct bgp_node
*top
;
4332 struct bgp_node
*rn
;
4334 struct aspath
*aspath
= NULL
;
4335 struct aspath
*asmerge
= NULL
;
4336 struct community
*community
= NULL
;
4337 struct community
*commerge
= NULL
;
4338 #if defined(AGGREGATE_NEXTHOP_CHECK)
4339 struct in_addr nexthop
;
4342 struct bgp_info
*ri
;
4343 struct bgp_info
*new;
4345 unsigned long match
= 0;
4346 u_char atomic_aggregate
= 0;
4348 /* Record adding route's nexthop and med. */
4351 #if defined(AGGREGATE_NEXTHOP_CHECK)
4352 nexthop
= rinew
->attr
->nexthop
;
4353 med
= rinew
->attr
->med
;
4357 /* ORIGIN attribute: If at least one route among routes that are
4358 aggregated has ORIGIN with the value INCOMPLETE, then the
4359 aggregated route must have the ORIGIN attribute with the value
4360 INCOMPLETE. Otherwise, if at least one route among routes that
4361 are aggregated has ORIGIN with the value EGP, then the aggregated
4362 route must have the origin attribute with the value EGP. In all
4363 other case the value of the ORIGIN attribute of the aggregated
4364 route is INTERNAL. */
4365 origin
= BGP_ORIGIN_IGP
;
4367 table
= bgp
->rib
[afi
][safi
];
4369 top
= bgp_node_get (table
, p
);
4370 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4371 if (rn
->p
.prefixlen
> p
->prefixlen
)
4375 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4377 if (BGP_INFO_HOLDDOWN (ri
))
4380 if (del
&& ri
== del
)
4383 if (! rinew
&& first
)
4385 #if defined(AGGREGATE_NEXTHOP_CHECK)
4386 nexthop
= ri
->attr
->nexthop
;
4387 med
= ri
->attr
->med
;
4392 #ifdef AGGREGATE_NEXTHOP_CHECK
4393 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4394 || ri
->attr
->med
!= med
)
4397 aspath_free (aspath
);
4399 community_free (community
);
4400 bgp_unlock_node (rn
);
4401 bgp_unlock_node (top
);
4404 #endif /* AGGREGATE_NEXTHOP_CHECK */
4406 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4407 atomic_aggregate
= 1;
4409 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4411 if (aggregate
->summary_only
)
4413 (bgp_info_extra_get (ri
))->suppress
++;
4414 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4420 if (origin
< ri
->attr
->origin
)
4421 origin
= ri
->attr
->origin
;
4423 if (aggregate
->as_set
)
4427 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4428 aspath_free (aspath
);
4432 aspath
= aspath_dup (ri
->attr
->aspath
);
4434 if (ri
->attr
->community
)
4438 commerge
= community_merge (community
,
4439 ri
->attr
->community
);
4440 community
= community_uniq_sort (commerge
);
4441 community_free (commerge
);
4444 community
= community_dup (ri
->attr
->community
);
4450 bgp_process (bgp
, rn
, afi
, safi
);
4452 bgp_unlock_node (top
);
4458 if (aggregate
->summary_only
)
4459 (bgp_info_extra_get (rinew
))->suppress
++;
4461 if (origin
< rinew
->attr
->origin
)
4462 origin
= rinew
->attr
->origin
;
4464 if (aggregate
->as_set
)
4468 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4469 aspath_free (aspath
);
4473 aspath
= aspath_dup (rinew
->attr
->aspath
);
4475 if (rinew
->attr
->community
)
4479 commerge
= community_merge (community
,
4480 rinew
->attr
->community
);
4481 community
= community_uniq_sort (commerge
);
4482 community_free (commerge
);
4485 community
= community_dup (rinew
->attr
->community
);
4490 if (aggregate
->count
> 0)
4492 rn
= bgp_node_get (table
, p
);
4493 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4494 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4496 atomic_aggregate
), rn
);
4497 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4499 bgp_info_add (rn
, new);
4500 bgp_unlock_node (rn
);
4501 bgp_process (bgp
, rn
, afi
, safi
);
4506 aspath_free (aspath
);
4508 community_free (community
);
4512 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4513 struct bgp_aggregate
*);
4516 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4517 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4519 struct bgp_node
*child
;
4520 struct bgp_node
*rn
;
4521 struct bgp_aggregate
*aggregate
;
4522 struct bgp_table
*table
;
4524 /* MPLS-VPN aggregation is not yet supported. */
4525 if (safi
== SAFI_MPLS_VPN
)
4528 table
= bgp
->aggregate
[afi
][safi
];
4530 /* No aggregates configured. */
4531 if (bgp_table_top_nolock (table
) == NULL
)
4534 if (p
->prefixlen
== 0)
4537 if (BGP_INFO_HOLDDOWN (ri
))
4540 child
= bgp_node_get (table
, p
);
4542 /* Aggregate address configuration check. */
4543 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4544 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4546 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4547 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4549 bgp_unlock_node (child
);
4553 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4554 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4556 struct bgp_node
*child
;
4557 struct bgp_node
*rn
;
4558 struct bgp_aggregate
*aggregate
;
4559 struct bgp_table
*table
;
4561 /* MPLS-VPN aggregation is not yet supported. */
4562 if (safi
== SAFI_MPLS_VPN
)
4565 table
= bgp
->aggregate
[afi
][safi
];
4567 /* No aggregates configured. */
4568 if (bgp_table_top_nolock (table
) == NULL
)
4571 if (p
->prefixlen
== 0)
4574 child
= bgp_node_get (table
, p
);
4576 /* Aggregate address configuration check. */
4577 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4578 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4580 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4581 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4583 bgp_unlock_node (child
);
4586 /* Called via bgp_aggregate_set when the user configures aggregate-address */
4588 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4589 struct bgp_aggregate
*aggregate
)
4591 struct bgp_table
*table
;
4592 struct bgp_node
*top
;
4593 struct bgp_node
*rn
;
4594 struct bgp_info
*new;
4595 struct bgp_info
*ri
;
4596 unsigned long match
;
4597 u_char origin
= BGP_ORIGIN_IGP
;
4598 struct aspath
*aspath
= NULL
;
4599 struct aspath
*asmerge
= NULL
;
4600 struct community
*community
= NULL
;
4601 struct community
*commerge
= NULL
;
4602 u_char atomic_aggregate
= 0;
4604 table
= bgp
->rib
[afi
][safi
];
4607 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4609 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4612 /* If routes exists below this node, generate aggregate routes. */
4613 top
= bgp_node_get (table
, p
);
4614 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4615 if (rn
->p
.prefixlen
> p
->prefixlen
)
4619 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4621 if (BGP_INFO_HOLDDOWN (ri
))
4624 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4625 atomic_aggregate
= 1;
4627 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4629 /* summary-only aggregate route suppress aggregated
4630 route announcement. */
4631 if (aggregate
->summary_only
)
4633 (bgp_info_extra_get (ri
))->suppress
++;
4634 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4638 /* If at least one route among routes that are aggregated has
4639 * ORIGIN with the value INCOMPLETE, then the aggregated route
4640 * MUST have the ORIGIN attribute with the value INCOMPLETE.
4641 * Otherwise, if at least one route among routes that are
4642 * aggregated has ORIGIN with the value EGP, then the aggregated
4643 * route MUST have the ORIGIN attribute with the value EGP.
4645 if (origin
< ri
->attr
->origin
)
4646 origin
= ri
->attr
->origin
;
4648 /* as-set aggregate route generate origin, as path,
4649 community aggregation. */
4650 if (aggregate
->as_set
)
4654 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4655 aspath_free (aspath
);
4659 aspath
= aspath_dup (ri
->attr
->aspath
);
4661 if (ri
->attr
->community
)
4665 commerge
= community_merge (community
,
4666 ri
->attr
->community
);
4667 community
= community_uniq_sort (commerge
);
4668 community_free (commerge
);
4671 community
= community_dup (ri
->attr
->community
);
4678 /* If this node is suppressed, process the change. */
4680 bgp_process (bgp
, rn
, afi
, safi
);
4682 bgp_unlock_node (top
);
4684 /* Add aggregate route to BGP table. */
4685 if (aggregate
->count
)
4687 rn
= bgp_node_get (table
, p
);
4688 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4689 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4691 atomic_aggregate
), rn
);
4692 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4694 bgp_info_add (rn
, new);
4695 bgp_unlock_node (rn
);
4697 /* Process change. */
4698 bgp_process (bgp
, rn
, afi
, safi
);
4703 aspath_free (aspath
);
4705 community_free (community
);
4710 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4711 safi_t safi
, struct bgp_aggregate
*aggregate
)
4713 struct bgp_table
*table
;
4714 struct bgp_node
*top
;
4715 struct bgp_node
*rn
;
4716 struct bgp_info
*ri
;
4717 unsigned long match
;
4719 table
= bgp
->rib
[afi
][safi
];
4721 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4723 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4726 /* If routes exists below this node, generate aggregate routes. */
4727 top
= bgp_node_get (table
, p
);
4728 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4729 if (rn
->p
.prefixlen
> p
->prefixlen
)
4733 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4735 if (BGP_INFO_HOLDDOWN (ri
))
4738 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4740 if (aggregate
->summary_only
&& ri
->extra
)
4742 ri
->extra
->suppress
--;
4744 if (ri
->extra
->suppress
== 0)
4746 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4754 /* If this node was suppressed, process the change. */
4756 bgp_process (bgp
, rn
, afi
, safi
);
4758 bgp_unlock_node (top
);
4760 /* Delete aggregate route from BGP table. */
4761 rn
= bgp_node_get (table
, p
);
4763 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4764 if (ri
->peer
== bgp
->peer_self
4765 && ri
->type
== ZEBRA_ROUTE_BGP
4766 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4769 /* Withdraw static BGP route from routing table. */
4772 bgp_info_delete (rn
, ri
);
4773 bgp_process (bgp
, rn
, afi
, safi
);
4776 /* Unlock bgp_node_lookup. */
4777 bgp_unlock_node (rn
);
4780 /* Aggregate route attribute. */
4781 #define AGGREGATE_SUMMARY_ONLY 1
4782 #define AGGREGATE_AS_SET 1
4785 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4786 afi_t afi
, safi_t safi
)
4790 struct bgp_node
*rn
;
4792 struct bgp_aggregate
*aggregate
;
4794 /* Convert string to prefix structure. */
4795 ret
= str2prefix (prefix_str
, &p
);
4798 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4803 /* Get BGP structure. */
4806 /* Old configuration check. */
4807 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4810 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4815 aggregate
= rn
->info
;
4816 if (aggregate
->safi
& SAFI_UNICAST
)
4817 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4818 if (aggregate
->safi
& SAFI_MULTICAST
)
4819 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4821 /* Unlock aggregate address configuration. */
4823 bgp_aggregate_free (aggregate
);
4824 bgp_unlock_node (rn
);
4825 bgp_unlock_node (rn
);
4831 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4832 afi_t afi
, safi_t safi
,
4833 u_char summary_only
, u_char as_set
)
4837 struct bgp_node
*rn
;
4839 struct bgp_aggregate
*aggregate
;
4841 /* Convert string to prefix structure. */
4842 ret
= str2prefix (prefix_str
, &p
);
4845 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4850 /* Get BGP structure. */
4853 /* Old configuration check. */
4854 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4858 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4859 /* try to remove the old entry */
4860 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
4863 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
4864 bgp_unlock_node (rn
);
4869 /* Make aggregate address structure. */
4870 aggregate
= bgp_aggregate_new ();
4871 aggregate
->summary_only
= summary_only
;
4872 aggregate
->as_set
= as_set
;
4873 aggregate
->safi
= safi
;
4874 rn
->info
= aggregate
;
4876 /* Aggregate address insert into BGP routing table. */
4877 if (safi
& SAFI_UNICAST
)
4878 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4879 if (safi
& SAFI_MULTICAST
)
4880 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4885 DEFUN (aggregate_address
,
4886 aggregate_address_cmd
,
4887 "aggregate-address A.B.C.D/M",
4888 "Configure BGP aggregate entries\n"
4889 "Aggregate prefix\n")
4891 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4894 DEFUN (aggregate_address_mask
,
4895 aggregate_address_mask_cmd
,
4896 "aggregate-address A.B.C.D A.B.C.D",
4897 "Configure BGP aggregate entries\n"
4898 "Aggregate address\n"
4902 char prefix_str
[BUFSIZ
];
4904 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4908 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4912 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4916 DEFUN (aggregate_address_summary_only
,
4917 aggregate_address_summary_only_cmd
,
4918 "aggregate-address A.B.C.D/M summary-only",
4919 "Configure BGP aggregate entries\n"
4920 "Aggregate prefix\n"
4921 "Filter more specific routes from updates\n")
4923 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4924 AGGREGATE_SUMMARY_ONLY
, 0);
4927 DEFUN (aggregate_address_mask_summary_only
,
4928 aggregate_address_mask_summary_only_cmd
,
4929 "aggregate-address A.B.C.D A.B.C.D summary-only",
4930 "Configure BGP aggregate entries\n"
4931 "Aggregate address\n"
4933 "Filter more specific routes from updates\n")
4936 char prefix_str
[BUFSIZ
];
4938 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4942 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4946 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4947 AGGREGATE_SUMMARY_ONLY
, 0);
4950 DEFUN (aggregate_address_as_set
,
4951 aggregate_address_as_set_cmd
,
4952 "aggregate-address A.B.C.D/M as-set",
4953 "Configure BGP aggregate entries\n"
4954 "Aggregate prefix\n"
4955 "Generate AS set path information\n")
4957 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4958 0, AGGREGATE_AS_SET
);
4961 DEFUN (aggregate_address_mask_as_set
,
4962 aggregate_address_mask_as_set_cmd
,
4963 "aggregate-address A.B.C.D A.B.C.D as-set",
4964 "Configure BGP aggregate entries\n"
4965 "Aggregate address\n"
4967 "Generate AS set path information\n")
4970 char prefix_str
[BUFSIZ
];
4972 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4976 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4980 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
4981 0, AGGREGATE_AS_SET
);
4985 DEFUN (aggregate_address_as_set_summary
,
4986 aggregate_address_as_set_summary_cmd
,
4987 "aggregate-address A.B.C.D/M as-set summary-only",
4988 "Configure BGP aggregate entries\n"
4989 "Aggregate prefix\n"
4990 "Generate AS set path information\n"
4991 "Filter more specific routes from updates\n")
4993 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4994 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
4997 ALIAS (aggregate_address_as_set_summary
,
4998 aggregate_address_summary_as_set_cmd
,
4999 "aggregate-address A.B.C.D/M summary-only as-set",
5000 "Configure BGP aggregate entries\n"
5001 "Aggregate prefix\n"
5002 "Filter more specific routes from updates\n"
5003 "Generate AS set path information\n")
5005 DEFUN (aggregate_address_mask_as_set_summary
,
5006 aggregate_address_mask_as_set_summary_cmd
,
5007 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5008 "Configure BGP aggregate entries\n"
5009 "Aggregate address\n"
5011 "Generate AS set path information\n"
5012 "Filter more specific routes from updates\n")
5015 char prefix_str
[BUFSIZ
];
5017 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5021 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5025 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5026 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5029 ALIAS (aggregate_address_mask_as_set_summary
,
5030 aggregate_address_mask_summary_as_set_cmd
,
5031 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5032 "Configure BGP aggregate entries\n"
5033 "Aggregate address\n"
5035 "Filter more specific routes from updates\n"
5036 "Generate AS set path information\n")
5038 DEFUN (no_aggregate_address
,
5039 no_aggregate_address_cmd
,
5040 "no aggregate-address A.B.C.D/M",
5042 "Configure BGP aggregate entries\n"
5043 "Aggregate prefix\n")
5045 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5048 ALIAS (no_aggregate_address
,
5049 no_aggregate_address_summary_only_cmd
,
5050 "no aggregate-address A.B.C.D/M summary-only",
5052 "Configure BGP aggregate entries\n"
5053 "Aggregate prefix\n"
5054 "Filter more specific routes from updates\n")
5056 ALIAS (no_aggregate_address
,
5057 no_aggregate_address_as_set_cmd
,
5058 "no aggregate-address A.B.C.D/M as-set",
5060 "Configure BGP aggregate entries\n"
5061 "Aggregate prefix\n"
5062 "Generate AS set path information\n")
5064 ALIAS (no_aggregate_address
,
5065 no_aggregate_address_as_set_summary_cmd
,
5066 "no aggregate-address A.B.C.D/M as-set summary-only",
5068 "Configure BGP aggregate entries\n"
5069 "Aggregate prefix\n"
5070 "Generate AS set path information\n"
5071 "Filter more specific routes from updates\n")
5073 ALIAS (no_aggregate_address
,
5074 no_aggregate_address_summary_as_set_cmd
,
5075 "no aggregate-address A.B.C.D/M summary-only as-set",
5077 "Configure BGP aggregate entries\n"
5078 "Aggregate prefix\n"
5079 "Filter more specific routes from updates\n"
5080 "Generate AS set path information\n")
5082 DEFUN (no_aggregate_address_mask
,
5083 no_aggregate_address_mask_cmd
,
5084 "no aggregate-address A.B.C.D A.B.C.D",
5086 "Configure BGP aggregate entries\n"
5087 "Aggregate address\n"
5091 char prefix_str
[BUFSIZ
];
5093 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5097 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5101 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5104 ALIAS (no_aggregate_address_mask
,
5105 no_aggregate_address_mask_summary_only_cmd
,
5106 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5108 "Configure BGP aggregate entries\n"
5109 "Aggregate address\n"
5111 "Filter more specific routes from updates\n")
5113 ALIAS (no_aggregate_address_mask
,
5114 no_aggregate_address_mask_as_set_cmd
,
5115 "no aggregate-address A.B.C.D A.B.C.D as-set",
5117 "Configure BGP aggregate entries\n"
5118 "Aggregate address\n"
5120 "Generate AS set path information\n")
5122 ALIAS (no_aggregate_address_mask
,
5123 no_aggregate_address_mask_as_set_summary_cmd
,
5124 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5126 "Configure BGP aggregate entries\n"
5127 "Aggregate address\n"
5129 "Generate AS set path information\n"
5130 "Filter more specific routes from updates\n")
5132 ALIAS (no_aggregate_address_mask
,
5133 no_aggregate_address_mask_summary_as_set_cmd
,
5134 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5136 "Configure BGP aggregate entries\n"
5137 "Aggregate address\n"
5139 "Filter more specific routes from updates\n"
5140 "Generate AS set path information\n")
5143 DEFUN (ipv6_aggregate_address
,
5144 ipv6_aggregate_address_cmd
,
5145 "aggregate-address X:X::X:X/M",
5146 "Configure BGP aggregate entries\n"
5147 "Aggregate prefix\n")
5149 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5152 DEFUN (ipv6_aggregate_address_summary_only
,
5153 ipv6_aggregate_address_summary_only_cmd
,
5154 "aggregate-address X:X::X:X/M summary-only",
5155 "Configure BGP aggregate entries\n"
5156 "Aggregate prefix\n"
5157 "Filter more specific routes from updates\n")
5159 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5160 AGGREGATE_SUMMARY_ONLY
, 0);
5163 DEFUN (no_ipv6_aggregate_address
,
5164 no_ipv6_aggregate_address_cmd
,
5165 "no aggregate-address X:X::X:X/M",
5167 "Configure BGP aggregate entries\n"
5168 "Aggregate prefix\n")
5170 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5173 DEFUN (no_ipv6_aggregate_address_summary_only
,
5174 no_ipv6_aggregate_address_summary_only_cmd
,
5175 "no aggregate-address X:X::X:X/M summary-only",
5177 "Configure BGP aggregate entries\n"
5178 "Aggregate prefix\n"
5179 "Filter more specific routes from updates\n")
5181 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5184 ALIAS (ipv6_aggregate_address
,
5185 old_ipv6_aggregate_address_cmd
,
5186 "ipv6 bgp aggregate-address X:X::X:X/M",
5189 "Configure BGP aggregate entries\n"
5190 "Aggregate prefix\n")
5192 ALIAS (ipv6_aggregate_address_summary_only
,
5193 old_ipv6_aggregate_address_summary_only_cmd
,
5194 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5197 "Configure BGP aggregate entries\n"
5198 "Aggregate prefix\n"
5199 "Filter more specific routes from updates\n")
5201 ALIAS (no_ipv6_aggregate_address
,
5202 old_no_ipv6_aggregate_address_cmd
,
5203 "no ipv6 bgp aggregate-address X:X::X:X/M",
5207 "Configure BGP aggregate entries\n"
5208 "Aggregate prefix\n")
5210 ALIAS (no_ipv6_aggregate_address_summary_only
,
5211 old_no_ipv6_aggregate_address_summary_only_cmd
,
5212 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5216 "Configure BGP aggregate entries\n"
5217 "Aggregate prefix\n"
5218 "Filter more specific routes from updates\n")
5219 #endif /* HAVE_IPV6 */
5221 /* Redistribute route treatment. */
5223 bgp_redistribute_add (struct prefix
*p
, const struct in_addr
*nexthop
,
5224 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5225 u_int32_t metric
, u_char type
, u_short instance
, u_short tag
)
5228 struct listnode
*node
, *nnode
;
5229 struct bgp_info
*new;
5230 struct bgp_info
*bi
;
5231 struct bgp_info info
;
5232 struct bgp_node
*bn
;
5234 struct attr
*new_attr
;
5237 struct bgp_redist
*red
;
5239 /* Make default attribute. */
5240 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5242 attr
.nexthop
= *nexthop
;
5243 attr
.nh_ifindex
= ifindex
;
5248 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5249 extra
->mp_nexthop_global
= *nexthop6
;
5250 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5255 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5256 attr
.extra
->tag
= tag
;
5258 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5260 afi
= family2afi (p
->family
);
5262 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5265 struct attr attr_new
;
5266 struct attr_extra extra_new
;
5268 /* Copy attribute for modification. */
5269 attr_new
.extra
= &extra_new
;
5270 bgp_attr_dup (&attr_new
, &attr
);
5272 if (red
->redist_metric_flag
)
5273 attr_new
.med
= red
->redist_metric
;
5275 /* Apply route-map. */
5278 info
.peer
= bgp
->peer_self
;
5279 info
.attr
= &attr_new
;
5281 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5283 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5285 bgp
->peer_self
->rmap_type
= 0;
5287 if (ret
== RMAP_DENYMATCH
)
5289 /* Free uninterned attribute. */
5290 bgp_attr_flush (&attr_new
);
5292 /* Unintern original. */
5293 aspath_unintern (&attr
.aspath
);
5294 bgp_attr_extra_free (&attr
);
5295 bgp_redistribute_delete (p
, type
, instance
);
5300 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5301 afi
, SAFI_UNICAST
, p
, NULL
);
5303 new_attr
= bgp_attr_intern (&attr_new
);
5305 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5306 if (bi
->peer
== bgp
->peer_self
5307 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5312 /* Ensure the (source route) type is updated. */
5314 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5315 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5317 bgp_attr_unintern (&new_attr
);
5318 aspath_unintern (&attr
.aspath
);
5319 bgp_attr_extra_free (&attr
);
5320 bgp_unlock_node (bn
);
5325 /* The attribute is changed. */
5326 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5328 /* Rewrite BGP route information. */
5329 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5330 bgp_info_restore(bn
, bi
);
5332 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5333 bgp_attr_unintern (&bi
->attr
);
5334 bi
->attr
= new_attr
;
5335 bi
->uptime
= bgp_clock ();
5337 /* Process change. */
5338 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5339 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5340 bgp_unlock_node (bn
);
5341 aspath_unintern (&attr
.aspath
);
5342 bgp_attr_extra_free (&attr
);
5347 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5349 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5351 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5352 bgp_info_add (bn
, new);
5353 bgp_unlock_node (bn
);
5354 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5358 /* Unintern original. */
5359 aspath_unintern (&attr
.aspath
);
5360 bgp_attr_extra_free (&attr
);
5364 bgp_redistribute_delete (struct prefix
*p
, u_char type
, u_short instance
)
5367 struct listnode
*node
, *nnode
;
5369 struct bgp_node
*rn
;
5370 struct bgp_info
*ri
;
5371 struct bgp_redist
*red
;
5373 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
5375 afi
= family2afi (p
->family
);
5377 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5380 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5382 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5383 if (ri
->peer
== bgp
->peer_self
5384 && ri
->type
== type
)
5389 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5390 bgp_info_delete (rn
, ri
);
5391 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5393 bgp_unlock_node (rn
);
5398 /* Withdraw specified route type's route. */
5400 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5402 struct bgp_node
*rn
;
5403 struct bgp_info
*ri
;
5404 struct bgp_table
*table
;
5406 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5408 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5410 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5411 if (ri
->peer
== bgp
->peer_self
5413 && ri
->instance
== instance
)
5418 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5419 bgp_info_delete (rn
, ri
);
5420 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5425 /* Static function to display route. */
5427 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5430 u_int32_t destination
;
5433 if (p
->family
== AF_INET
)
5435 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5436 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5438 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5439 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5440 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5441 || p
->u
.prefix4
.s_addr
== 0)
5443 /* When mask is natural, mask is not displayed. */
5446 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5449 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5454 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5456 vty_out (vty
, "%*s", len
, " ");
5459 enum bgp_display_type
5464 /* Print the short form route status for a bgp_info */
5466 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
5467 json_object
*json_path
)
5472 /* Route status display. */
5473 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5474 json_object_boolean_true_add(json_path
, "removed");
5476 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5477 json_object_boolean_true_add(json_path
, "stale");
5479 if (binfo
->extra
&& binfo
->extra
->suppress
)
5480 json_object_boolean_true_add(json_path
, "suppressed");
5482 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5483 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5484 json_object_boolean_true_add(json_path
, "valid");
5487 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5488 json_object_boolean_true_add(json_path
, "history");
5490 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5491 json_object_boolean_true_add(json_path
, "damped");
5493 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5494 json_object_boolean_true_add(json_path
, "bestpath");
5496 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5497 json_object_boolean_true_add(json_path
, "multipath");
5499 /* Internal route. */
5500 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5501 json_object_string_add(json_path
, "pathFrom", "internal");
5503 json_object_string_add(json_path
, "pathFrom", "external");
5508 /* Route status display. */
5509 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5511 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5513 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5515 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5516 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5522 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5524 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5526 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5528 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5533 /* Internal route. */
5534 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5540 /* called from terminal list command */
5542 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5543 struct bgp_info
*binfo
, int display
, safi_t safi
,
5544 json_object
*json_paths
)
5547 json_object
*json_path
= NULL
;
5548 json_object
*json_nexthops
= NULL
;
5549 json_object
*json_nexthop_global
= NULL
;
5550 json_object
*json_nexthop_ll
= NULL
;
5553 json_path
= json_object_new_object();
5555 /* short status lead text */
5556 route_vty_short_status_out (vty
, binfo
, json_path
);
5560 /* print prefix and mask */
5562 route_vty_out_route (p
, vty
);
5564 vty_out (vty
, "%*s", 17, " ");
5567 /* Print attribute */
5573 if (p
->family
== AF_INET
5574 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5578 json_nexthop_global
= json_object_new_object();
5580 if (safi
== SAFI_MPLS_VPN
)
5581 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5583 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
5585 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
5586 json_object_boolean_true_add(json_nexthop_global
, "used");
5590 if (safi
== SAFI_MPLS_VPN
)
5591 vty_out (vty
, "%-16s",
5592 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5594 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5600 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5607 json_nexthop_global
= json_object_new_object();
5608 json_object_string_add(json_nexthop_global
, "ip",
5609 inet_ntop (AF_INET6
,
5610 &attr
->extra
->mp_nexthop_global
,
5612 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
5613 json_object_string_add(json_nexthop_global
, "scope", "global");
5615 /* We display both LL & GL if both have been received */
5616 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5618 json_nexthop_ll
= json_object_new_object();
5619 json_object_string_add(json_nexthop_ll
, "ip",
5620 inet_ntop (AF_INET6
,
5621 &attr
->extra
->mp_nexthop_local
,
5623 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
5624 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
5626 if (IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
5627 &attr
->extra
->mp_nexthop_local
) != 0)
5628 json_object_boolean_true_add(json_nexthop_ll
, "used");
5630 json_object_boolean_true_add(json_nexthop_global
, "used");
5633 json_object_boolean_true_add(json_nexthop_global
, "used");
5637 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5639 if (binfo
->peer
->conf_if
)
5641 len
= vty_out (vty
, "%s",
5642 binfo
->peer
->conf_if
);
5643 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
5646 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
5648 vty_out (vty
, "%*s", len
, " ");
5652 len
= vty_out (vty
, "%s",
5653 inet_ntop (AF_INET6
,
5654 &attr
->extra
->mp_nexthop_local
,
5659 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5661 vty_out (vty
, "%*s", len
, " ");
5666 len
= vty_out (vty
, "%s",
5667 inet_ntop (AF_INET6
,
5668 &attr
->extra
->mp_nexthop_global
,
5673 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5675 vty_out (vty
, "%*s", len
, " ");
5679 #endif /* HAVE_IPV6 */
5682 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5684 json_object_int_add(json_path
, "med", attr
->med
);
5686 vty_out (vty
, "%10u", attr
->med
);
5692 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5694 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
5696 vty_out (vty
, "%7u", attr
->local_pref
);
5704 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
5706 json_object_int_add(json_path
, "weight", 0);
5709 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5715 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
5717 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5722 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
5724 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5729 json_object_string_add(json_path
, "alert", "No attributes");
5731 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
5736 if (json_nexthop_global
|| json_nexthop_ll
)
5738 json_nexthops
= json_object_new_array();
5740 if (json_nexthop_global
)
5741 json_object_array_add(json_nexthops
, json_nexthop_global
);
5743 if (json_nexthop_ll
)
5744 json_object_array_add(json_nexthops
, json_nexthop_ll
);
5746 json_object_object_add(json_path
, "nexthops", json_nexthops
);
5749 json_object_array_add(json_paths
, json_path
);
5752 vty_out (vty
, "%s", VTY_NEWLINE
);
5755 /* called from terminal list command */
5757 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
5758 u_char use_json
, json_object
*json_ar
)
5760 json_object
*json_status
= NULL
;
5761 json_object
*json_net
= NULL
;
5763 /* Route status display. */
5766 json_status
= json_object_new_object();
5767 json_net
= json_object_new_object();
5776 /* print prefix and mask */
5778 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
5780 route_vty_out_route (p
, vty
);
5782 /* Print attribute */
5787 if (p
->family
== AF_INET
&& (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5789 if (safi
== SAFI_MPLS_VPN
)
5790 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5792 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
5795 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5799 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5802 #endif /* HAVE_IPV6 */
5804 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5805 json_object_int_add(json_net
, "metric", attr
->med
);
5807 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5808 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
5811 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
5813 json_object_int_add(json_net
, "weight", 0);
5817 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
5820 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
5824 if (p
->family
== AF_INET
&& (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5826 if (safi
== SAFI_MPLS_VPN
)
5827 vty_out (vty
, "%-16s",
5828 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5830 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5833 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5838 assert (attr
->extra
);
5840 len
= vty_out (vty
, "%s",
5841 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5845 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5847 vty_out (vty
, "%*s", len
, " ");
5849 #endif /* HAVE_IPV6 */
5850 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5851 vty_out (vty
, "%10u", attr
->med
);
5855 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5856 vty_out (vty
, "%7u", attr
->local_pref
);
5860 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5864 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5867 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5872 json_object_boolean_true_add(json_status
, "*");
5873 json_object_boolean_true_add(json_status
, ">");
5874 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
5875 char buf_cut
[BUFSIZ
];
5876 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
5879 vty_out (vty
, "%s", VTY_NEWLINE
);
5883 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5884 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
5886 json_object
*json_out
= NULL
;
5888 u_int32_t label
= 0;
5894 json_out
= json_object_new_object();
5896 /* short status lead text */
5897 route_vty_short_status_out (vty
, binfo
, json_out
);
5899 /* print prefix and mask */
5903 route_vty_out_route (p
, vty
);
5905 vty_out (vty
, "%*s", 17, " ");
5908 /* Print attribute */
5912 if (p
->family
== AF_INET
5913 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5915 if (safi
== SAFI_MPLS_VPN
)
5918 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5920 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5925 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
5927 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5931 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5933 assert (attr
->extra
);
5937 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
5940 json_object_string_add(json_out
, "mpNexthopGlobalIn",
5941 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
5944 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5947 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
5951 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5953 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5955 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
5956 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
5959 vty_out (vty
, "%s(%s)",
5960 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5962 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
5967 #endif /* HAVE_IPV6 */
5970 label
= decode_label (binfo
->extra
->tag
);
5975 json_object_int_add(json_out
, "notag", label
);
5976 json_object_array_add(json
, json_out
);
5980 vty_out (vty
, "notag/%d", label
);
5981 vty_out (vty
, "%s", VTY_NEWLINE
);
5985 /* dampening route */
5987 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
5988 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
5992 char timebuf
[BGP_UPTIME_LEN
];
5994 /* short status lead text */
5995 route_vty_short_status_out (vty
, binfo
, json
);
5997 /* print prefix and mask */
6001 route_vty_out_route (p
, vty
);
6003 vty_out (vty
, "%*s", 17, " ");
6006 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6011 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6016 json_object_int_add(json
, "peerHost", len
);
6018 vty_out (vty
, "%*s", len
, " ");
6022 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6024 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6026 /* Print attribute */
6034 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6036 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6041 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6043 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6046 vty_out (vty
, "%s", VTY_NEWLINE
);
6051 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6052 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6055 struct bgp_damp_info
*bdi
;
6056 char timebuf
[BGP_UPTIME_LEN
];
6062 bdi
= binfo
->extra
->damp_info
;
6064 /* short status lead text */
6065 route_vty_short_status_out (vty
, binfo
, json
);
6067 /* print prefix and mask */
6071 route_vty_out_route (p
, vty
);
6073 vty_out (vty
, "%*s", 17, " ");
6076 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6081 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6086 json_object_int_add(json
, "peerHost", len
);
6088 vty_out (vty
, "%*s", len
, " ");
6091 len
= vty_out (vty
, "%d", bdi
->flap
);
6101 json_object_int_add(json
, "bdiFlap", len
);
6103 vty_out (vty
, "%*s", len
, " ");
6107 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6109 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6110 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6112 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6113 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6116 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6118 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6123 vty_out (vty
, "%*s ", 8, " ");
6126 /* Print attribute */
6134 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6136 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6141 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6143 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6146 vty_out (vty
, "%s", VTY_NEWLINE
);
6150 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6151 const char *header
, json_object
*json_adv_to
)
6153 char buf1
[INET6_ADDRSTRLEN
];
6154 json_object
*json_peer
= NULL
;
6158 /* 'advertised-to' is a dictionary of peers we have advertised this
6159 * prefix too. The key is the peer's IP or swpX, the value is the
6160 * hostname if we know it and "" if not.
6162 json_peer
= json_object_new_object();
6165 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6168 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6170 json_object_object_add(json_adv_to
,
6171 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6178 vty_out (vty
, "%s", header
);
6182 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6185 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6187 vty_out (vty
, " %s(%s)", peer
->hostname
,
6188 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6193 vty_out (vty
, " %s", peer
->conf_if
);
6195 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6201 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6202 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6203 json_object
*json_paths
)
6205 char buf
[INET6_ADDRSTRLEN
];
6208 int sockunion_vty_out (struct vty
*, union sockunion
*);
6209 #ifdef HAVE_CLOCK_MONOTONIC
6212 json_object
*json_bestpath
= NULL
;
6213 json_object
*json_cluster_list
= NULL
;
6214 json_object
*json_cluster_list_list
= NULL
;
6215 json_object
*json_ext_community
= NULL
;
6216 json_object
*json_last_update
= NULL
;
6217 json_object
*json_nexthop_global
= NULL
;
6218 json_object
*json_nexthop_ll
= NULL
;
6219 json_object
*json_nexthops
= NULL
;
6220 json_object
*json_path
= NULL
;
6221 json_object
*json_peer
= NULL
;
6222 json_object
*json_string
= NULL
;
6223 json_object
*json_adv_to
= NULL
;
6225 struct listnode
*node
, *nnode
;
6227 int addpath_capable
;
6233 json_path
= json_object_new_object();
6234 json_peer
= json_object_new_object();
6235 json_nexthop_global
= json_object_new_object();
6242 /* Line1 display AS-path, Aggregator */
6247 json_object_lock(attr
->aspath
->json
);
6248 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6252 if (attr
->aspath
->segments
)
6253 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6255 vty_out (vty
, " Local");
6259 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6262 json_object_boolean_true_add(json_path
, "removed");
6264 vty_out (vty
, ", (removed)");
6267 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6270 json_object_boolean_true_add(json_path
, "stale");
6272 vty_out (vty
, ", (stale)");
6275 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6279 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6280 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6284 vty_out (vty
, ", (aggregated by %u %s)",
6285 attr
->extra
->aggregator_as
,
6286 inet_ntoa (attr
->extra
->aggregator_addr
));
6290 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6293 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6295 vty_out (vty
, ", (Received from a RR-client)");
6298 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6301 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6303 vty_out (vty
, ", (Received from a RS-client)");
6306 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6309 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6311 vty_out (vty
, ", (history entry)");
6313 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6316 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6318 vty_out (vty
, ", (suppressed due to dampening)");
6322 vty_out (vty
, "%s", VTY_NEWLINE
);
6324 /* Line2 display Next-hop, Neighbor, Router-id */
6325 /* Display the nexthop */
6326 if (p
->family
== AF_INET
6327 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6329 if (safi
== SAFI_MPLS_VPN
)
6332 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6334 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6339 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6341 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6345 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6350 assert (attr
->extra
);
6353 json_object_string_add(json_nexthop_global
, "ip",
6354 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6355 buf
, INET6_ADDRSTRLEN
));
6356 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6357 json_object_string_add(json_nexthop_global
, "scope", "global");
6361 vty_out (vty
, " %s",
6362 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6363 buf
, INET6_ADDRSTRLEN
));
6366 #endif /* HAVE_IPV6 */
6369 /* Display the IGP cost or 'inaccessible' */
6370 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6373 json_object_boolean_false_add(json_nexthop_global
, "accessible");
6375 vty_out (vty
, " (inaccessible)");
6379 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6382 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
6384 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
6387 /* IGP cost is 0, display this only for json */
6391 json_object_int_add(json_nexthop_global
, "metric", 0);
6395 json_object_boolean_true_add(json_nexthop_global
, "accessible");
6398 /* Display peer "from" output */
6399 /* This path was originated locally */
6400 if (binfo
->peer
== bgp
->peer_self
)
6403 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6406 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
6408 vty_out (vty
, " from 0.0.0.0 ");
6413 json_object_string_add(json_peer
, "peerId", "::");
6415 vty_out (vty
, " from :: ");
6419 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
6421 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
6424 /* We RXed this path from one of our peers */
6430 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6431 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6433 if (binfo
->peer
->hostname
)
6434 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
6436 if (binfo
->peer
->domainname
)
6437 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
6439 if (binfo
->peer
->conf_if
)
6440 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
6444 if (binfo
->peer
->conf_if
)
6446 if (binfo
->peer
->hostname
&&
6447 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6448 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6449 binfo
->peer
->conf_if
);
6451 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
6455 if (binfo
->peer
->hostname
&&
6456 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6457 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6460 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6463 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6464 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6466 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6471 vty_out (vty
, "%s", VTY_NEWLINE
);
6474 /* display the link-local nexthop */
6475 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6479 json_nexthop_ll
= json_object_new_object();
6480 json_object_string_add(json_nexthop_ll
, "ip",
6481 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6482 buf
, INET6_ADDRSTRLEN
));
6483 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6484 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6486 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
6487 json_object_boolean_true_add(json_nexthop_ll
, "used");
6491 vty_out (vty
, " (%s) (used)%s",
6492 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6493 buf
, INET6_ADDRSTRLEN
),
6497 /* If we do not have a link-local nexthop then we must flag the global as "used" */
6501 json_object_boolean_true_add(json_nexthop_global
, "used");
6503 #endif /* HAVE_IPV6 */
6505 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
6507 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6509 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6511 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6514 json_object_int_add(json_path
, "med", attr
->med
);
6516 vty_out (vty
, ", metric %u", attr
->med
);
6519 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6522 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6524 vty_out (vty
, ", localpref %u", attr
->local_pref
);
6529 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
6531 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
6534 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6537 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6539 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
6542 if (attr
->extra
&& attr
->extra
->tag
!= 0)
6545 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
6547 vty_out (vty
, ", tag %d", attr
->extra
->tag
);
6550 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6553 json_object_boolean_false_add(json_path
, "valid");
6555 vty_out (vty
, ", invalid");
6557 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6560 json_object_boolean_true_add(json_path
, "valid");
6562 vty_out (vty
, ", valid");
6565 if (binfo
->peer
!= bgp
->peer_self
)
6567 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6569 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
6572 json_object_string_add(json_peer
, "type", "confed-internal");
6574 vty_out (vty
, ", confed-internal");
6579 json_object_string_add(json_peer
, "type", "internal");
6581 vty_out (vty
, ", internal");
6586 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
6589 json_object_string_add(json_peer
, "type", "confed-external");
6591 vty_out (vty
, ", confed-external");
6596 json_object_string_add(json_peer
, "type", "external");
6598 vty_out (vty
, ", external");
6602 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6606 json_object_boolean_true_add(json_path
, "aggregated");
6607 json_object_boolean_true_add(json_path
, "local");
6611 vty_out (vty
, ", aggregated, local");
6614 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
6617 json_object_boolean_true_add(json_path
, "sourced");
6619 vty_out (vty
, ", sourced");
6625 json_object_boolean_true_add(json_path
, "sourced");
6626 json_object_boolean_true_add(json_path
, "local");
6630 vty_out (vty
, ", sourced, local");
6634 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
6637 json_object_boolean_true_add(json_path
, "atomicAggregate");
6639 vty_out (vty
, ", atomic-aggregate");
6642 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
6643 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
6644 bgp_info_mpath_count (binfo
)))
6647 json_object_boolean_true_add(json_path
, "multipath");
6649 vty_out (vty
, ", multipath");
6652 // Mark the bestpath(s)
6653 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
6655 first_as
= aspath_get_firstas(attr
->aspath
);
6660 json_bestpath
= json_object_new_object();
6661 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
6666 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
6668 vty_out (vty
, ", bestpath-from-AS Local");
6672 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6677 json_bestpath
= json_object_new_object();
6678 json_object_boolean_true_add(json_bestpath
, "overall");
6681 vty_out (vty
, ", best");
6685 json_object_object_add(json_path
, "bestpath", json_bestpath
);
6688 vty_out (vty
, "%s", VTY_NEWLINE
);
6690 /* Line 4 display Community */
6691 if (attr
->community
)
6695 json_object_lock(attr
->community
->json
);
6696 json_object_object_add(json_path
, "community", attr
->community
->json
);
6700 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
6705 /* Line 5 display Extended-community */
6706 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
6710 json_ext_community
= json_object_new_object();
6711 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
6712 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
6716 vty_out (vty
, " Extended Community: %s%s",
6717 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
6721 /* Line 6 display Originator, Cluster-id */
6722 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
6723 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
6725 assert (attr
->extra
);
6726 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6729 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
6731 vty_out (vty
, " Originator: %s",
6732 inet_ntoa (attr
->extra
->originator_id
));
6735 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
6741 json_cluster_list
= json_object_new_object();
6742 json_cluster_list_list
= json_object_new_array();
6744 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6746 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6747 json_object_array_add(json_cluster_list_list
, json_string
);
6750 /* struct cluster_list does not have "str" variable like
6751 * aspath and community do. Add this someday if someone
6753 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
6755 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
6756 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
6760 vty_out (vty
, ", Cluster list: ");
6762 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6764 vty_out (vty
, "%s ",
6765 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6771 vty_out (vty
, "%s", VTY_NEWLINE
);
6774 if (binfo
->extra
&& binfo
->extra
->damp_info
)
6775 bgp_damp_info_vty (vty
, binfo
, json_path
);
6777 /* Line 7 display Addpath IDs */
6778 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
6782 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
6783 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
6787 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
6788 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
6793 /* If we used addpath to TX a non-bestpath we need to display
6794 * "Advertised to" on a path-by-path basis */
6795 if (bgp
->addpath_tx_used
[afi
][safi
])
6799 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6801 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
6802 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
6804 if ((addpath_capable
&& has_adj
) ||
6805 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
6807 if (json_path
&& !json_adv_to
)
6808 json_adv_to
= json_object_new_object();
6810 route_vty_out_advertised_to(vty
, peer
, &first
,
6820 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
6827 vty_out (vty
, "%s", VTY_NEWLINE
);
6832 /* Line 8 display Uptime */
6833 #ifdef HAVE_CLOCK_MONOTONIC
6834 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
6837 json_last_update
= json_object_new_object();
6838 json_object_int_add(json_last_update
, "epoch", tbuf
);
6839 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
6840 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
6843 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
6847 json_last_update
= json_object_new_object();
6848 json_object_int_add(json_last_update
, "epoch", tbuf
);
6849 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
6850 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
6853 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
6854 #endif /* HAVE_CLOCK_MONOTONIC */
6857 /* We've constructed the json object for this path, add it to the json
6862 if (json_nexthop_global
|| json_nexthop_ll
)
6864 json_nexthops
= json_object_new_array();
6866 if (json_nexthop_global
)
6867 json_object_array_add(json_nexthops
, json_nexthop_global
);
6869 if (json_nexthop_ll
)
6870 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6872 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6875 json_object_object_add(json_path
, "peer", json_peer
);
6876 json_object_array_add(json_paths
, json_path
);
6879 vty_out (vty
, "%s", VTY_NEWLINE
);
6882 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
6883 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6884 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6888 bgp_show_type_normal
,
6889 bgp_show_type_regexp
,
6890 bgp_show_type_prefix_list
,
6891 bgp_show_type_filter_list
,
6892 bgp_show_type_route_map
,
6893 bgp_show_type_neighbor
,
6894 bgp_show_type_cidr_only
,
6895 bgp_show_type_prefix_longer
,
6896 bgp_show_type_community_all
,
6897 bgp_show_type_community
,
6898 bgp_show_type_community_exact
,
6899 bgp_show_type_community_list
,
6900 bgp_show_type_community_list_exact
,
6901 bgp_show_type_flap_statistics
,
6902 bgp_show_type_flap_address
,
6903 bgp_show_type_flap_prefix
,
6904 bgp_show_type_flap_cidr_only
,
6905 bgp_show_type_flap_regexp
,
6906 bgp_show_type_flap_filter_list
,
6907 bgp_show_type_flap_prefix_list
,
6908 bgp_show_type_flap_prefix_longer
,
6909 bgp_show_type_flap_route_map
,
6910 bgp_show_type_flap_neighbor
,
6911 bgp_show_type_dampend_paths
,
6912 bgp_show_type_damp_neighbor
6916 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
6917 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
6919 struct bgp_info
*ri
;
6920 struct bgp_node
*rn
;
6923 unsigned long output_count
;
6927 json_object
*json
= NULL
;
6928 json_object
*json_paths
= NULL
;
6929 json_object
*json_routes
= NULL
;
6933 json
= json_object_new_object();
6934 json_object_int_add(json
, "tableVersion", table
->version
);
6935 json_object_string_add(json
, "routerId", inet_ntoa (*router_id
));
6936 json_routes
= json_object_new_object();
6939 /* This is first entry point, so reset total line. */
6942 /* Start processing of routes. */
6943 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6944 if (rn
->info
!= NULL
)
6949 json_paths
= json_object_new_array();
6953 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6955 if (type
== bgp_show_type_flap_statistics
6956 || type
== bgp_show_type_flap_address
6957 || type
== bgp_show_type_flap_prefix
6958 || type
== bgp_show_type_flap_cidr_only
6959 || type
== bgp_show_type_flap_regexp
6960 || type
== bgp_show_type_flap_filter_list
6961 || type
== bgp_show_type_flap_prefix_list
6962 || type
== bgp_show_type_flap_prefix_longer
6963 || type
== bgp_show_type_flap_route_map
6964 || type
== bgp_show_type_flap_neighbor
6965 || type
== bgp_show_type_dampend_paths
6966 || type
== bgp_show_type_damp_neighbor
)
6968 if (!(ri
->extra
&& ri
->extra
->damp_info
))
6971 if (type
== bgp_show_type_regexp
6972 || type
== bgp_show_type_flap_regexp
)
6974 regex_t
*regex
= output_arg
;
6976 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
6979 if (type
== bgp_show_type_prefix_list
6980 || type
== bgp_show_type_flap_prefix_list
)
6982 struct prefix_list
*plist
= output_arg
;
6984 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
6987 if (type
== bgp_show_type_filter_list
6988 || type
== bgp_show_type_flap_filter_list
)
6990 struct as_list
*as_list
= output_arg
;
6992 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
6995 if (type
== bgp_show_type_route_map
6996 || type
== bgp_show_type_flap_route_map
)
6998 struct route_map
*rmap
= output_arg
;
6999 struct bgp_info binfo
;
7000 struct attr dummy_attr
;
7001 struct attr_extra dummy_extra
;
7004 dummy_attr
.extra
= &dummy_extra
;
7005 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7007 binfo
.peer
= ri
->peer
;
7008 binfo
.attr
= &dummy_attr
;
7010 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7011 if (ret
== RMAP_DENYMATCH
)
7014 if (type
== bgp_show_type_neighbor
7015 || type
== bgp_show_type_flap_neighbor
7016 || type
== bgp_show_type_damp_neighbor
)
7018 union sockunion
*su
= output_arg
;
7020 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7023 if (type
== bgp_show_type_cidr_only
7024 || type
== bgp_show_type_flap_cidr_only
)
7026 u_int32_t destination
;
7028 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7029 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7031 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7033 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7036 if (type
== bgp_show_type_prefix_longer
7037 || type
== bgp_show_type_flap_prefix_longer
)
7039 struct prefix
*p
= output_arg
;
7041 if (! prefix_match (p
, &rn
->p
))
7044 if (type
== bgp_show_type_community_all
)
7046 if (! ri
->attr
->community
)
7049 if (type
== bgp_show_type_community
)
7051 struct community
*com
= output_arg
;
7053 if (! ri
->attr
->community
||
7054 ! community_match (ri
->attr
->community
, com
))
7057 if (type
== bgp_show_type_community_exact
)
7059 struct community
*com
= output_arg
;
7061 if (! ri
->attr
->community
||
7062 ! community_cmp (ri
->attr
->community
, com
))
7065 if (type
== bgp_show_type_community_list
)
7067 struct community_list
*list
= output_arg
;
7069 if (! community_list_match (ri
->attr
->community
, list
))
7072 if (type
== bgp_show_type_community_list_exact
)
7074 struct community_list
*list
= output_arg
;
7076 if (! community_list_exact_match (ri
->attr
->community
, list
))
7079 if (type
== bgp_show_type_flap_address
7080 || type
== bgp_show_type_flap_prefix
)
7082 struct prefix
*p
= output_arg
;
7084 if (! prefix_match (&rn
->p
, p
))
7087 if (type
== bgp_show_type_flap_prefix
)
7088 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7091 if (type
== bgp_show_type_dampend_paths
7092 || type
== bgp_show_type_damp_neighbor
)
7094 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7095 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7099 if (!use_json
&& header
)
7101 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (*router_id
), VTY_NEWLINE
);
7102 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7103 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7104 if (type
== bgp_show_type_dampend_paths
7105 || type
== bgp_show_type_damp_neighbor
)
7106 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7107 else if (type
== bgp_show_type_flap_statistics
7108 || type
== bgp_show_type_flap_address
7109 || type
== bgp_show_type_flap_prefix
7110 || type
== bgp_show_type_flap_cidr_only
7111 || type
== bgp_show_type_flap_regexp
7112 || type
== bgp_show_type_flap_filter_list
7113 || type
== bgp_show_type_flap_prefix_list
7114 || type
== bgp_show_type_flap_prefix_longer
7115 || type
== bgp_show_type_flap_route_map
7116 || type
== bgp_show_type_flap_neighbor
)
7117 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7119 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7123 if (type
== bgp_show_type_dampend_paths
7124 || type
== bgp_show_type_damp_neighbor
)
7125 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7126 else if (type
== bgp_show_type_flap_statistics
7127 || type
== bgp_show_type_flap_address
7128 || type
== bgp_show_type_flap_prefix
7129 || type
== bgp_show_type_flap_cidr_only
7130 || type
== bgp_show_type_flap_regexp
7131 || type
== bgp_show_type_flap_filter_list
7132 || type
== bgp_show_type_flap_prefix_list
7133 || type
== bgp_show_type_flap_prefix_longer
7134 || type
== bgp_show_type_flap_route_map
7135 || type
== bgp_show_type_flap_neighbor
)
7136 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7138 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7148 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7149 json_object_object_add(json_routes
, buf2
, json_paths
);
7156 json_object_object_add(json
, "routes", json_routes
);
7157 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7158 json_object_free(json
);
7162 /* No route is displayed */
7163 if (output_count
== 0)
7165 if (type
== bgp_show_type_normal
)
7166 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
7169 vty_out (vty
, "%sTotal number of prefixes %ld%s",
7170 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
7177 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7178 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7180 struct bgp_table
*table
;
7184 bgp
= bgp_get_default ();
7190 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7194 table
= bgp
->rib
[afi
][safi
];
7196 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
, use_json
);
7199 /* Header of detailed BGP route information */
7201 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7202 struct bgp_node
*rn
,
7203 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7206 struct bgp_info
*ri
;
7209 struct listnode
*node
, *nnode
;
7210 char buf1
[INET6_ADDRSTRLEN
];
7211 char buf2
[INET6_ADDRSTRLEN
];
7216 int no_advertise
= 0;
7219 json_object
*json_adv_to
= NULL
;
7225 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7226 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7230 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7231 (safi
== SAFI_MPLS_VPN
?
7232 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7233 safi
== SAFI_MPLS_VPN
? ":" : "",
7234 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7235 p
->prefixlen
, VTY_NEWLINE
);
7238 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7241 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7244 if (ri
->extra
&& ri
->extra
->suppress
)
7246 if (ri
->attr
->community
!= NULL
)
7248 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7250 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7252 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7260 vty_out (vty
, "Paths: (%d available", count
);
7263 vty_out (vty
, ", best #%d", best
);
7264 if (safi
== SAFI_UNICAST
)
7265 vty_out (vty
, ", table Default-IP-Routing-Table");
7268 vty_out (vty
, ", no best path");
7271 vty_out (vty
, ", not advertised to any peer");
7273 vty_out (vty
, ", not advertised to EBGP peer");
7275 vty_out (vty
, ", not advertised outside local AS");
7278 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7279 vty_out (vty
, ")%s", VTY_NEWLINE
);
7282 /* If we are not using addpath then we can display Advertised to and that will
7283 * show what peers we advertised the bestpath to. If we are using addpath
7284 * though then we must display Advertised to on a path-by-path basis. */
7285 if (!bgp
->addpath_tx_used
[afi
][safi
])
7287 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7289 if (bgp_adj_out_lookup (peer
, rn
, 0))
7291 if (json
&& !json_adv_to
)
7292 json_adv_to
= json_object_new_object();
7294 route_vty_out_advertised_to(vty
, peer
, &first
,
7295 " Advertised to non peer-group peers:\n ",
7304 json_object_object_add(json
, "advertisedTo", json_adv_to
);
7310 vty_out (vty
, " Not advertised to any peer");
7311 vty_out (vty
, "%s", VTY_NEWLINE
);
7316 /* Display specified route of BGP table. */
7318 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
7319 struct bgp_table
*rib
, const char *ip_str
,
7320 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7321 int prefix_check
, enum bgp_path_type pathtype
,
7327 struct prefix match
;
7328 struct bgp_node
*rn
;
7329 struct bgp_node
*rm
;
7330 struct bgp_info
*ri
;
7331 struct bgp_table
*table
;
7332 json_object
*json
= NULL
;
7333 json_object
*json_paths
= NULL
;
7335 /* Check IP address argument. */
7336 ret
= str2prefix (ip_str
, &match
);
7339 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
7343 match
.family
= afi2family (afi
);
7347 json
= json_object_new_object();
7348 json_paths
= json_object_new_array();
7351 if (safi
== SAFI_MPLS_VPN
)
7353 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
7355 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
7358 if ((table
= rn
->info
) != NULL
)
7362 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
7364 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
7366 bgp_unlock_node (rm
);
7370 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
7374 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
7375 AFI_IP
, SAFI_MPLS_VPN
, json
);
7381 if (pathtype
== BGP_PATH_ALL
||
7382 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7383 (pathtype
== BGP_PATH_MULTIPATH
&&
7384 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7385 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
, json_paths
);
7388 bgp_unlock_node (rm
);
7397 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
7399 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
7401 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7405 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
7410 if (pathtype
== BGP_PATH_ALL
||
7411 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7412 (pathtype
== BGP_PATH_MULTIPATH
&&
7413 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7414 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
7418 bgp_unlock_node (rn
);
7425 json_object_object_add(json
, "paths", json_paths
);
7427 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7428 json_object_free(json
);
7434 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
7442 /* Display specified route of Main RIB */
7444 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
7445 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7446 int prefix_check
, enum bgp_path_type pathtype
,
7451 /* BGP structure lookup. */
7454 bgp
= bgp_lookup_by_name (view_name
);
7457 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
7463 bgp
= bgp_get_default ();
7466 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7471 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
7472 afi
, safi
, prd
, prefix_check
, pathtype
,
7476 /* BGP route print out function. */
7479 "show ip bgp {json}",
7483 "JavaScript Object Notation\n")
7485 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7488 DEFUN (show_ip_bgp_ipv4
,
7489 show_ip_bgp_ipv4_cmd
,
7490 "show ip bgp ipv4 (unicast|multicast) {json}",
7495 "Address Family modifier\n"
7496 "Address Family modifier\n"
7497 "JavaScript Object Notation\n")
7499 u_char uj
= use_json(argc
, argv
);
7501 if (strncmp (argv
[0], "m", 1) == 0)
7502 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
7505 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
7508 ALIAS (show_ip_bgp_ipv4
,
7509 show_bgp_ipv4_safi_cmd
,
7510 "show bgp ipv4 (unicast|multicast) {json}",
7514 "Address Family modifier\n"
7515 "Address Family modifier\n"
7516 "JavaScript Object Notation\n")
7518 DEFUN (show_ip_bgp_route
,
7519 show_ip_bgp_route_cmd
,
7520 "show ip bgp A.B.C.D {json}",
7524 "Network in the BGP routing table to display\n"
7525 "JavaScript Object Notation\n")
7527 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7530 DEFUN (show_ip_bgp_route_pathtype
,
7531 show_ip_bgp_route_pathtype_cmd
,
7532 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
7536 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7537 "Display only the bestpath\n"
7538 "Display only multipaths\n"
7539 "JavaScript Object Notation\n")
7541 u_char uj
= use_json(argc
, argv
);
7543 if (strncmp (argv
[1], "b", 1) == 0)
7544 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7546 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7549 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
7550 show_bgp_ipv4_safi_route_pathtype_cmd
,
7551 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
7555 "Address Family modifier\n"
7556 "Address Family modifier\n"
7557 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7558 "Display only the bestpath\n"
7559 "Display only multipaths\n"
7560 "JavaScript Object Notation\n")
7562 u_char uj
= use_json(argc
, argv
);
7564 if (strncmp (argv
[0], "m", 1) == 0)
7565 if (strncmp (argv
[2], "b", 1) == 0)
7566 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7568 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7570 if (strncmp (argv
[2], "b", 1) == 0)
7571 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7573 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7576 DEFUN (show_ip_bgp_ipv4_route
,
7577 show_ip_bgp_ipv4_route_cmd
,
7578 "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
7583 "Address Family modifier\n"
7584 "Address Family modifier\n"
7585 "Network in the BGP routing table to display\n"
7586 "JavaScript Object Notation\n")
7588 u_char uj
= use_json(argc
, argv
);
7590 if (strncmp (argv
[0], "m", 1) == 0)
7591 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7593 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7596 ALIAS (show_ip_bgp_ipv4_route
,
7597 show_bgp_ipv4_safi_route_cmd
,
7598 "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
7602 "Address Family modifier\n"
7603 "Address Family modifier\n"
7604 "Network in the BGP routing table to display\n"
7605 "JavaScript Object Notation\n")
7607 DEFUN (show_ip_bgp_vpnv4_all_route
,
7608 show_ip_bgp_vpnv4_all_route_cmd
,
7609 "show ip bgp vpnv4 all A.B.C.D {json}",
7613 "Display VPNv4 NLRI specific information\n"
7614 "Display information about all VPNv4 NLRIs\n"
7615 "Network in the BGP routing table to display\n"
7616 "JavaScript Object Notation\n")
7618 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7622 DEFUN (show_ip_bgp_vpnv4_rd_route
,
7623 show_ip_bgp_vpnv4_rd_route_cmd
,
7624 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
7628 "Display VPNv4 NLRI specific information\n"
7629 "Display information for a route distinguisher\n"
7630 "VPN Route Distinguisher\n"
7631 "Network in the BGP routing table to display\n"
7632 "JavaScript Object Notation\n")
7635 struct prefix_rd prd
;
7636 u_char uj
= use_json(argc
, argv
);
7638 ret
= str2prefix_rd (argv
[0], &prd
);
7641 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
7644 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, uj
);
7647 DEFUN (show_ip_bgp_prefix
,
7648 show_ip_bgp_prefix_cmd
,
7649 "show ip bgp A.B.C.D/M {json}",
7653 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7654 "JavaScript Object Notation\n")
7656 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
7659 DEFUN (show_ip_bgp_prefix_pathtype
,
7660 show_ip_bgp_prefix_pathtype_cmd
,
7661 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
7665 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7666 "Display only the bestpath\n"
7667 "Display only multipaths\n"
7668 "JavaScript Object Notation\n")
7670 u_char uj
= use_json(argc
, argv
);
7671 if (strncmp (argv
[1], "b", 1) == 0)
7672 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7674 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7677 DEFUN (show_ip_bgp_ipv4_prefix
,
7678 show_ip_bgp_ipv4_prefix_cmd
,
7679 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
7684 "Address Family modifier\n"
7685 "Address Family modifier\n"
7686 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7687 "JavaScript Object Notation\n")
7689 u_char uj
= use_json(argc
, argv
);
7691 if (strncmp (argv
[0], "m", 1) == 0)
7692 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
7694 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
7697 ALIAS (show_ip_bgp_ipv4_prefix
,
7698 show_bgp_ipv4_safi_prefix_cmd
,
7699 "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
7703 "Address Family modifier\n"
7704 "Address Family modifier\n"
7705 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7706 "JavaScript Object Notation\n")
7708 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
7709 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
7710 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
7715 "Address Family modifier\n"
7716 "Address Family modifier\n"
7717 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7718 "Display only the bestpath\n"
7719 "Display only multipaths\n"
7720 "JavaScript Object Notation\n")
7722 u_char uj
= use_json(argc
, argv
);
7724 if (strncmp (argv
[0], "m", 1) == 0)
7725 if (strncmp (argv
[2], "b", 1) == 0)
7726 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7728 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7730 if (strncmp (argv
[2], "b", 1) == 0)
7731 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7733 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7736 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
7737 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
7738 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
7742 "Address Family modifier\n"
7743 "Address Family modifier\n"
7744 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7745 "Display only the bestpath\n"
7746 "Display only multipaths\n"
7747 "JavaScript Object Notation\n")
7749 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
7750 show_ip_bgp_vpnv4_all_prefix_cmd
,
7751 "show ip bgp vpnv4 all A.B.C.D/M {json}",
7755 "Display VPNv4 NLRI specific information\n"
7756 "Display information about all VPNv4 NLRIs\n"
7757 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7758 "JavaScript Object Notation\n")
7760 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
7763 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
7764 show_ip_bgp_vpnv4_rd_prefix_cmd
,
7765 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
7769 "Display VPNv4 NLRI specific information\n"
7770 "Display information for a route distinguisher\n"
7771 "VPN Route Distinguisher\n"
7772 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7773 "JavaScript Object Notation\n")
7776 struct prefix_rd prd
;
7778 ret
= str2prefix_rd (argv
[0], &prd
);
7781 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
7784 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7787 DEFUN (show_ip_bgp_view
,
7788 show_ip_bgp_view_cmd
,
7789 "show ip bgp view WORD {json}",
7795 "JavaScript Object Notation\n")
7799 /* BGP structure lookup. */
7800 bgp
= bgp_lookup_by_name (argv
[0]);
7803 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
7807 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7810 DEFUN (show_ip_bgp_view_route
,
7811 show_ip_bgp_view_route_cmd
,
7812 "show ip bgp view WORD A.B.C.D {json}",
7818 "Network in the BGP routing table to display\n"
7819 "JavaScript Object Notation\n")
7821 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7824 DEFUN (show_ip_bgp_view_prefix
,
7825 show_ip_bgp_view_prefix_cmd
,
7826 "show ip bgp view WORD A.B.C.D/M {json}",
7832 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7833 "JavaScript Object Notation\n")
7835 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
7844 "JavaScript Object Notation\n")
7846 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
7847 NULL
, use_json(argc
, argv
));
7852 "show bgp ipv6 {json}",
7856 "JavaScript Object Notation\n")
7858 DEFUN (show_bgp_ipv6_safi
,
7859 show_bgp_ipv6_safi_cmd
,
7860 "show bgp ipv6 (unicast|multicast) {json}",
7864 "Address Family modifier\n"
7865 "Address Family modifier\n"
7866 "JavaScript Object Notation\n")
7868 u_char uj
= use_json(argc
, argv
);
7869 if (strncmp (argv
[0], "m", 1) == 0)
7870 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
7873 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
7877 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
7879 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
7880 " next release%sPlese use 'show bgp ipv6' instead%s%s",
7881 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
7885 DEFUN (show_ipv6_bgp
,
7887 "show ipv6 bgp {json}",
7891 "JavaScript Object Notation\n")
7893 bgp_show_ipv6_bgp_deprecate_warning(vty
);
7894 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
7895 NULL
, use_json(argc
, argv
));
7898 DEFUN (show_bgp_route
,
7900 "show bgp X:X::X:X {json}",
7903 "Network in the BGP routing table to display\n"
7904 "JavaScript Object Notation\n")
7906 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7909 ALIAS (show_bgp_route
,
7910 show_bgp_ipv6_route_cmd
,
7911 "show bgp ipv6 X:X::X:X {json}",
7915 "Network in the BGP routing table to display\n"
7916 "JavaScript Object Notation\n")
7918 DEFUN (show_bgp_ipv6_safi_route
,
7919 show_bgp_ipv6_safi_route_cmd
,
7920 "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
7924 "Address Family modifier\n"
7925 "Address Family modifier\n"
7926 "Network in the BGP routing table to display\n"
7927 "JavaScript Object Notation\n")
7929 u_char uj
= use_json(argc
, argv
);
7930 if (strncmp (argv
[0], "m", 1) == 0)
7931 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7933 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7936 DEFUN (show_bgp_route_pathtype
,
7937 show_bgp_route_pathtype_cmd
,
7938 "show bgp X:X::X:X (bestpath|multipath) {json}",
7941 "Network in the BGP routing table to display\n"
7942 "Display only the bestpath\n"
7943 "Display only multipaths\n"
7944 "JavaScript Object Notation\n")
7946 u_char uj
= use_json(argc
, argv
);
7947 if (strncmp (argv
[1], "b", 1) == 0)
7948 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7950 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7953 ALIAS (show_bgp_route_pathtype
,
7954 show_bgp_ipv6_route_pathtype_cmd
,
7955 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
7959 "Network in the BGP routing table to display\n"
7960 "Display only the bestpath\n"
7961 "Display only multipaths\n"
7962 "JavaScript Object Notation\n")
7964 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
7965 show_bgp_ipv6_safi_route_pathtype_cmd
,
7966 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
7970 "Address Family modifier\n"
7971 "Address Family modifier\n"
7972 "Network in the BGP routing table to display\n"
7973 "Display only the bestpath\n"
7974 "Display only multipaths\n"
7975 "JavaScript Object Notation\n")
7977 u_char uj
= use_json(argc
, argv
);
7978 if (strncmp (argv
[0], "m", 1) == 0)
7979 if (strncmp (argv
[2], "b", 1) == 0)
7980 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7982 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7984 if (strncmp (argv
[2], "b", 1) == 0)
7985 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7987 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7991 DEFUN (show_ipv6_bgp_route
,
7992 show_ipv6_bgp_route_cmd
,
7993 "show ipv6 bgp X:X::X:X {json}",
7997 "Network in the BGP routing table to display\n"
7998 "JavaScript Object Notation\n")
8000 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8001 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8004 DEFUN (show_bgp_prefix
,
8005 show_bgp_prefix_cmd
,
8006 "show bgp X:X::X:X/M {json}",
8009 "IPv6 prefix <network>/<length>\n"
8010 "JavaScript Object Notation\n")
8012 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8015 ALIAS (show_bgp_prefix
,
8016 show_bgp_ipv6_prefix_cmd
,
8017 "show bgp ipv6 X:X::X:X/M {json}",
8021 "IPv6 prefix <network>/<length>\n"
8022 "JavaScript Object Notation\n")
8024 DEFUN (show_bgp_ipv6_safi_prefix
,
8025 show_bgp_ipv6_safi_prefix_cmd
,
8026 "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
8030 "Address Family modifier\n"
8031 "Address Family modifier\n"
8032 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8033 "JavaScript Object Notation\n")
8035 u_char uj
= use_json(argc
, argv
);
8036 if (strncmp (argv
[0], "m", 1) == 0)
8037 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8039 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8042 DEFUN (show_bgp_prefix_pathtype
,
8043 show_bgp_prefix_pathtype_cmd
,
8044 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8047 "IPv6 prefix <network>/<length>\n"
8048 "Display only the bestpath\n"
8049 "Display only multipaths\n"
8050 "JavaScript Object Notation\n")
8052 u_char uj
= use_json(argc
, argv
);
8053 if (strncmp (argv
[1], "b", 1) == 0)
8054 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8056 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8059 ALIAS (show_bgp_prefix_pathtype
,
8060 show_bgp_ipv6_prefix_pathtype_cmd
,
8061 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8065 "IPv6 prefix <network>/<length>\n"
8066 "Display only the bestpath\n"
8067 "Display only multipaths\n"
8068 "JavaScript Object Notation\n")
8070 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8071 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8072 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
8076 "Address Family modifier\n"
8077 "Address Family modifier\n"
8078 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8079 "Display only the bestpath\n"
8080 "Display only multipaths\n"
8081 "JavaScript Object Notation\n")
8083 u_char uj
= use_json(argc
, argv
);
8084 if (strncmp (argv
[0], "m", 1) == 0)
8085 if (strncmp (argv
[2], "b", 1) == 0)
8086 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8088 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8090 if (strncmp (argv
[2], "b", 1) == 0)
8091 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8093 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8097 DEFUN (show_ipv6_bgp_prefix
,
8098 show_ipv6_bgp_prefix_cmd
,
8099 "show ipv6 bgp X:X::X:X/M {json}",
8103 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8104 "JavaScript Object Notation\n")
8106 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8107 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8110 DEFUN (show_bgp_view
,
8112 "show bgp view WORD {json}",
8117 "JavaScript Object Notation\n")
8121 /* BGP structure lookup. */
8122 bgp
= bgp_lookup_by_name (argv
[0]);
8125 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
8129 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8132 ALIAS (show_bgp_view
,
8133 show_bgp_view_ipv6_cmd
,
8134 "show bgp view WORD ipv6 {json}",
8140 "JavaScript Object Notation\n")
8142 DEFUN (show_bgp_view_route
,
8143 show_bgp_view_route_cmd
,
8144 "show bgp view WORD X:X::X:X {json}",
8149 "Network in the BGP routing table to display\n"
8150 "JavaScript Object Notation\n")
8152 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8155 ALIAS (show_bgp_view_route
,
8156 show_bgp_view_ipv6_route_cmd
,
8157 "show bgp view WORD ipv6 X:X::X:X {json}",
8163 "Network in the BGP routing table to display\n"
8164 "JavaScript Object Notation\n")
8166 DEFUN (show_bgp_view_prefix
,
8167 show_bgp_view_prefix_cmd
,
8168 "show bgp view WORD X:X::X:X/M {json}",
8173 "IPv6 prefix <network>/<length>\n"
8174 "JavaScript Object Notation\n")
8176 return bgp_show_route (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8179 ALIAS (show_bgp_view_prefix
,
8180 show_bgp_view_ipv6_prefix_cmd
,
8181 "show bgp view WORD ipv6 X:X::X:X/M {json}",
8187 "IPv6 prefix <network>/<length>\n"
8188 "JavaScript Object Notation\n")
8191 DEFUN (show_ipv6_mbgp
,
8193 "show ipv6 mbgp {json}",
8197 "JavaScript Object Notation\n")
8199 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8200 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8201 NULL
, use_json(argc
, argv
));
8205 DEFUN (show_ipv6_mbgp_route
,
8206 show_ipv6_mbgp_route_cmd
,
8207 "show ipv6 mbgp X:X::X:X {json}",
8211 "Network in the MBGP routing table to display\n"
8212 "JavaScript Object Notation\n")
8214 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8215 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8219 DEFUN (show_ipv6_mbgp_prefix
,
8220 show_ipv6_mbgp_prefix_cmd
,
8221 "show ipv6 mbgp X:X::X:X/M {json}",
8225 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8226 "JavaScript Object Notation\n")
8228 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8229 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8235 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
8236 safi_t safi
, enum bgp_show_type type
)
8246 b
= buffer_new (1024);
8247 for (i
= 0; i
< argc
; i
++)
8250 buffer_putc (b
, ' ');
8253 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
8258 buffer_putstr (b
, argv
[i
]);
8260 buffer_putc (b
, '\0');
8262 regstr
= buffer_getstr (b
);
8265 regex
= bgp_regcomp (regstr
);
8266 XFREE(MTYPE_TMP
, regstr
);
8269 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
8274 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
8275 bgp_regex_free (regex
);
8279 DEFUN (show_ip_bgp_regexp
,
8280 show_ip_bgp_regexp_cmd
,
8281 "show ip bgp regexp .LINE",
8285 "Display routes matching the AS path regular expression\n"
8286 "A regular-expression to match the BGP AS paths\n")
8288 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8289 bgp_show_type_regexp
);
8292 DEFUN (show_ip_bgp_flap_regexp
,
8293 show_ip_bgp_flap_regexp_cmd
,
8294 "show ip bgp flap-statistics regexp .LINE",
8298 "Display flap statistics of routes\n"
8299 "Display routes matching the AS path regular expression\n"
8300 "A regular-expression to match the BGP AS paths\n")
8302 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8303 bgp_show_type_flap_regexp
);
8306 DEFUN (show_ip_bgp_ipv4_regexp
,
8307 show_ip_bgp_ipv4_regexp_cmd
,
8308 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
8313 "Address Family modifier\n"
8314 "Address Family modifier\n"
8315 "Display routes matching the AS path regular expression\n"
8316 "A regular-expression to match the BGP AS paths\n")
8318 if (strncmp (argv
[0], "m", 1) == 0)
8319 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
8320 bgp_show_type_regexp
);
8322 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8323 bgp_show_type_regexp
);
8327 DEFUN (show_bgp_regexp
,
8328 show_bgp_regexp_cmd
,
8329 "show bgp regexp .LINE",
8332 "Display routes matching the AS path regular expression\n"
8333 "A regular-expression to match the BGP AS paths\n")
8335 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
8336 bgp_show_type_regexp
);
8339 ALIAS (show_bgp_regexp
,
8340 show_bgp_ipv6_regexp_cmd
,
8341 "show bgp ipv6 regexp .LINE",
8345 "Display routes matching the AS path regular expression\n"
8346 "A regular-expression to match the BGP AS paths\n")
8349 DEFUN (show_ipv6_bgp_regexp
,
8350 show_ipv6_bgp_regexp_cmd
,
8351 "show ipv6 bgp regexp .LINE",
8355 "Display routes matching the AS path regular expression\n"
8356 "A regular-expression to match the BGP AS paths\n")
8358 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8359 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
8360 bgp_show_type_regexp
);
8364 DEFUN (show_ipv6_mbgp_regexp
,
8365 show_ipv6_mbgp_regexp_cmd
,
8366 "show ipv6 mbgp regexp .LINE",
8370 "Display routes matching the AS path regular expression\n"
8371 "A regular-expression to match the MBGP AS paths\n")
8373 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8374 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
8375 bgp_show_type_regexp
);
8377 #endif /* HAVE_IPV6 */
8380 bgp_show_prefix_list (struct vty
*vty
, const char *prefix_list_str
, afi_t afi
,
8381 safi_t safi
, enum bgp_show_type type
)
8383 struct prefix_list
*plist
;
8385 plist
= prefix_list_lookup (afi
, prefix_list_str
);
8388 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
8389 prefix_list_str
, VTY_NEWLINE
);
8393 return bgp_show (vty
, NULL
, afi
, safi
, type
, plist
, 0);
8396 DEFUN (show_ip_bgp_prefix_list
,
8397 show_ip_bgp_prefix_list_cmd
,
8398 "show ip bgp prefix-list WORD",
8402 "Display routes conforming to the prefix-list\n"
8403 "IP prefix-list name\n")
8405 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8406 bgp_show_type_prefix_list
);
8409 DEFUN (show_ip_bgp_flap_prefix_list
,
8410 show_ip_bgp_flap_prefix_list_cmd
,
8411 "show ip bgp flap-statistics prefix-list WORD",
8415 "Display flap statistics of routes\n"
8416 "Display routes conforming to the prefix-list\n"
8417 "IP prefix-list name\n")
8419 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8420 bgp_show_type_flap_prefix_list
);
8423 DEFUN (show_ip_bgp_ipv4_prefix_list
,
8424 show_ip_bgp_ipv4_prefix_list_cmd
,
8425 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8430 "Address Family modifier\n"
8431 "Address Family modifier\n"
8432 "Display routes conforming to the prefix-list\n"
8433 "IP prefix-list name\n")
8435 if (strncmp (argv
[0], "m", 1) == 0)
8436 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8437 bgp_show_type_prefix_list
);
8439 return bgp_show_prefix_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8440 bgp_show_type_prefix_list
);
8444 DEFUN (show_bgp_prefix_list
,
8445 show_bgp_prefix_list_cmd
,
8446 "show bgp prefix-list WORD",
8449 "Display routes conforming to the prefix-list\n"
8450 "IPv6 prefix-list name\n")
8452 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8453 bgp_show_type_prefix_list
);
8456 ALIAS (show_bgp_prefix_list
,
8457 show_bgp_ipv6_prefix_list_cmd
,
8458 "show bgp ipv6 prefix-list WORD",
8462 "Display routes conforming to the prefix-list\n"
8463 "IPv6 prefix-list name\n")
8466 DEFUN (show_ipv6_bgp_prefix_list
,
8467 show_ipv6_bgp_prefix_list_cmd
,
8468 "show ipv6 bgp prefix-list WORD",
8472 "Display routes matching the prefix-list\n"
8473 "IPv6 prefix-list name\n")
8475 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8476 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8477 bgp_show_type_prefix_list
);
8481 DEFUN (show_ipv6_mbgp_prefix_list
,
8482 show_ipv6_mbgp_prefix_list_cmd
,
8483 "show ipv6 mbgp prefix-list WORD",
8487 "Display routes matching the prefix-list\n"
8488 "IPv6 prefix-list name\n")
8490 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8491 return bgp_show_prefix_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8492 bgp_show_type_prefix_list
);
8494 #endif /* HAVE_IPV6 */
8497 bgp_show_filter_list (struct vty
*vty
, const char *filter
, afi_t afi
,
8498 safi_t safi
, enum bgp_show_type type
)
8500 struct as_list
*as_list
;
8502 as_list
= as_list_lookup (filter
);
8503 if (as_list
== NULL
)
8505 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
8509 return bgp_show (vty
, NULL
, afi
, safi
, type
, as_list
, 0);
8512 DEFUN (show_ip_bgp_filter_list
,
8513 show_ip_bgp_filter_list_cmd
,
8514 "show ip bgp filter-list WORD",
8518 "Display routes conforming to the filter-list\n"
8519 "Regular expression access list name\n")
8521 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8522 bgp_show_type_filter_list
);
8525 DEFUN (show_ip_bgp_flap_filter_list
,
8526 show_ip_bgp_flap_filter_list_cmd
,
8527 "show ip bgp flap-statistics filter-list WORD",
8531 "Display flap statistics of routes\n"
8532 "Display routes conforming to the filter-list\n"
8533 "Regular expression access list name\n")
8535 return bgp_show_filter_list (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8536 bgp_show_type_flap_filter_list
);
8539 DEFUN (show_ip_bgp_ipv4_filter_list
,
8540 show_ip_bgp_ipv4_filter_list_cmd
,
8541 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8546 "Address Family modifier\n"
8547 "Address Family modifier\n"
8548 "Display routes conforming to the filter-list\n"
8549 "Regular expression access list name\n")
8551 if (strncmp (argv
[0], "m", 1) == 0)
8552 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8553 bgp_show_type_filter_list
);
8555 return bgp_show_filter_list (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8556 bgp_show_type_filter_list
);
8560 DEFUN (show_bgp_filter_list
,
8561 show_bgp_filter_list_cmd
,
8562 "show bgp filter-list WORD",
8565 "Display routes conforming to the filter-list\n"
8566 "Regular expression access list name\n")
8568 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8569 bgp_show_type_filter_list
);
8572 ALIAS (show_bgp_filter_list
,
8573 show_bgp_ipv6_filter_list_cmd
,
8574 "show bgp ipv6 filter-list WORD",
8578 "Display routes conforming to the filter-list\n"
8579 "Regular expression access list name\n")
8582 DEFUN (show_ipv6_bgp_filter_list
,
8583 show_ipv6_bgp_filter_list_cmd
,
8584 "show ipv6 bgp filter-list WORD",
8588 "Display routes conforming to the filter-list\n"
8589 "Regular expression access list name\n")
8591 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8592 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8593 bgp_show_type_filter_list
);
8597 DEFUN (show_ipv6_mbgp_filter_list
,
8598 show_ipv6_mbgp_filter_list_cmd
,
8599 "show ipv6 mbgp filter-list WORD",
8603 "Display routes conforming to the filter-list\n"
8604 "Regular expression access list name\n")
8606 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8607 return bgp_show_filter_list (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8608 bgp_show_type_filter_list
);
8610 #endif /* HAVE_IPV6 */
8613 bgp_show_route_map (struct vty
*vty
, const char *rmap_str
, afi_t afi
,
8614 safi_t safi
, enum bgp_show_type type
)
8616 struct route_map
*rmap
;
8618 rmap
= route_map_lookup_by_name (rmap_str
);
8621 vty_out (vty
, "%% %s is not a valid route-map name%s",
8622 rmap_str
, VTY_NEWLINE
);
8626 return bgp_show (vty
, NULL
, afi
, safi
, type
, rmap
, 0);
8629 DEFUN (show_ip_bgp_route_map
,
8630 show_ip_bgp_route_map_cmd
,
8631 "show ip bgp route-map WORD",
8635 "Display routes matching the route-map\n"
8636 "A route-map to match on\n")
8638 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8639 bgp_show_type_route_map
);
8642 DEFUN (show_ip_bgp_flap_route_map
,
8643 show_ip_bgp_flap_route_map_cmd
,
8644 "show ip bgp flap-statistics route-map WORD",
8648 "Display flap statistics of routes\n"
8649 "Display routes matching the route-map\n"
8650 "A route-map to match on\n")
8652 return bgp_show_route_map (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8653 bgp_show_type_flap_route_map
);
8656 DEFUN (show_ip_bgp_ipv4_route_map
,
8657 show_ip_bgp_ipv4_route_map_cmd
,
8658 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
8663 "Address Family modifier\n"
8664 "Address Family modifier\n"
8665 "Display routes matching the route-map\n"
8666 "A route-map to match on\n")
8668 if (strncmp (argv
[0], "m", 1) == 0)
8669 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8670 bgp_show_type_route_map
);
8672 return bgp_show_route_map (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8673 bgp_show_type_route_map
);
8676 DEFUN (show_bgp_route_map
,
8677 show_bgp_route_map_cmd
,
8678 "show bgp route-map WORD",
8681 "Display routes matching the route-map\n"
8682 "A route-map to match on\n")
8684 return bgp_show_route_map (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8685 bgp_show_type_route_map
);
8688 ALIAS (show_bgp_route_map
,
8689 show_bgp_ipv6_route_map_cmd
,
8690 "show bgp ipv6 route-map WORD",
8694 "Display routes matching the route-map\n"
8695 "A route-map to match on\n")
8697 DEFUN (show_ip_bgp_cidr_only
,
8698 show_ip_bgp_cidr_only_cmd
,
8699 "show ip bgp cidr-only",
8703 "Display only routes with non-natural netmasks\n")
8705 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
8706 bgp_show_type_cidr_only
, NULL
, 0);
8709 DEFUN (show_ip_bgp_flap_cidr_only
,
8710 show_ip_bgp_flap_cidr_only_cmd
,
8711 "show ip bgp flap-statistics cidr-only",
8715 "Display flap statistics of routes\n"
8716 "Display only routes with non-natural netmasks\n")
8718 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
8719 bgp_show_type_flap_cidr_only
, NULL
, 0);
8722 DEFUN (show_ip_bgp_ipv4_cidr_only
,
8723 show_ip_bgp_ipv4_cidr_only_cmd
,
8724 "show ip bgp ipv4 (unicast|multicast) cidr-only",
8729 "Address Family modifier\n"
8730 "Address Family modifier\n"
8731 "Display only routes with non-natural netmasks\n")
8733 if (strncmp (argv
[0], "m", 1) == 0)
8734 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
8735 bgp_show_type_cidr_only
, NULL
, 0);
8737 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
8738 bgp_show_type_cidr_only
, NULL
, 0);
8741 DEFUN (show_ip_bgp_community_all
,
8742 show_ip_bgp_community_all_cmd
,
8743 "show ip bgp community",
8747 "Display routes matching the communities\n")
8749 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
8750 bgp_show_type_community_all
, NULL
, 0);
8753 DEFUN (show_ip_bgp_ipv4_community_all
,
8754 show_ip_bgp_ipv4_community_all_cmd
,
8755 "show ip bgp ipv4 (unicast|multicast) community",
8760 "Address Family modifier\n"
8761 "Address Family modifier\n"
8762 "Display routes matching the communities\n")
8764 if (strncmp (argv
[0], "m", 1) == 0)
8765 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
8766 bgp_show_type_community_all
, NULL
, 0);
8768 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
8769 bgp_show_type_community_all
, NULL
, 0);
8773 DEFUN (show_bgp_community_all
,
8774 show_bgp_community_all_cmd
,
8775 "show bgp community",
8778 "Display routes matching the communities\n")
8780 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
8781 bgp_show_type_community_all
, NULL
, 0);
8784 ALIAS (show_bgp_community_all
,
8785 show_bgp_ipv6_community_all_cmd
,
8786 "show bgp ipv6 community",
8790 "Display routes matching the communities\n")
8793 DEFUN (show_ipv6_bgp_community_all
,
8794 show_ipv6_bgp_community_all_cmd
,
8795 "show ipv6 bgp community",
8799 "Display routes matching the communities\n")
8801 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8802 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
8803 bgp_show_type_community_all
, NULL
, 0);
8807 DEFUN (show_ipv6_mbgp_community_all
,
8808 show_ipv6_mbgp_community_all_cmd
,
8809 "show ipv6 mbgp community",
8813 "Display routes matching the communities\n")
8815 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8816 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
8817 bgp_show_type_community_all
, NULL
, 0);
8819 #endif /* HAVE_IPV6 */
8822 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
8823 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
8825 struct community
*com
;
8832 /* BGP structure lookup */
8835 bgp
= bgp_lookup_by_name (view_name
);
8838 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
8844 bgp
= bgp_get_default ();
8847 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8852 b
= buffer_new (1024);
8853 for (i
= 0; i
< argc
; i
++)
8856 buffer_putc (b
, ' ');
8859 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
8864 buffer_putstr (b
, argv
[i
]);
8866 buffer_putc (b
, '\0');
8868 str
= buffer_getstr (b
);
8871 com
= community_str2com (str
);
8872 XFREE (MTYPE_TMP
, str
);
8875 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
8879 return bgp_show (vty
, bgp
, afi
, safi
,
8880 (exact
? bgp_show_type_community_exact
:
8881 bgp_show_type_community
), com
, 0);
8884 DEFUN (show_ip_bgp_community
,
8885 show_ip_bgp_community_cmd
,
8886 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
8890 "Display routes matching the communities\n"
8891 "community number\n"
8892 "Do not send outside local AS (well-known community)\n"
8893 "Do not advertise to any peer (well-known community)\n"
8894 "Do not export to next AS (well-known community)\n")
8896 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
8899 ALIAS (show_ip_bgp_community
,
8900 show_ip_bgp_community2_cmd
,
8901 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8905 "Display routes matching the communities\n"
8906 "community number\n"
8907 "Do not send outside local AS (well-known community)\n"
8908 "Do not advertise to any peer (well-known community)\n"
8909 "Do not export to next AS (well-known community)\n"
8910 "community number\n"
8911 "Do not send outside local AS (well-known community)\n"
8912 "Do not advertise to any peer (well-known community)\n"
8913 "Do not export to next AS (well-known community)\n")
8915 ALIAS (show_ip_bgp_community
,
8916 show_ip_bgp_community3_cmd
,
8917 "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)",
8921 "Display routes matching the communities\n"
8922 "community number\n"
8923 "Do not send outside local AS (well-known community)\n"
8924 "Do not advertise to any peer (well-known community)\n"
8925 "Do not export to next AS (well-known community)\n"
8926 "community number\n"
8927 "Do not send outside local AS (well-known community)\n"
8928 "Do not advertise to any peer (well-known community)\n"
8929 "Do not export to next AS (well-known community)\n"
8930 "community number\n"
8931 "Do not send outside local AS (well-known community)\n"
8932 "Do not advertise to any peer (well-known community)\n"
8933 "Do not export to next AS (well-known community)\n")
8935 ALIAS (show_ip_bgp_community
,
8936 show_ip_bgp_community4_cmd
,
8937 "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)",
8941 "Display routes matching the communities\n"
8942 "community number\n"
8943 "Do not send outside local AS (well-known community)\n"
8944 "Do not advertise to any peer (well-known community)\n"
8945 "Do not export to next AS (well-known community)\n"
8946 "community number\n"
8947 "Do not send outside local AS (well-known community)\n"
8948 "Do not advertise to any peer (well-known community)\n"
8949 "Do not export to next AS (well-known community)\n"
8950 "community number\n"
8951 "Do not send outside local AS (well-known community)\n"
8952 "Do not advertise to any peer (well-known community)\n"
8953 "Do not export to next AS (well-known community)\n"
8954 "community number\n"
8955 "Do not send outside local AS (well-known community)\n"
8956 "Do not advertise to any peer (well-known community)\n"
8957 "Do not export to next AS (well-known community)\n")
8959 DEFUN (show_ip_bgp_ipv4_community
,
8960 show_ip_bgp_ipv4_community_cmd
,
8961 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
8966 "Address Family modifier\n"
8967 "Address Family modifier\n"
8968 "Display routes matching the communities\n"
8969 "community number\n"
8970 "Do not send outside local AS (well-known community)\n"
8971 "Do not advertise to any peer (well-known community)\n"
8972 "Do not export to next AS (well-known community)\n")
8974 if (strncmp (argv
[0], "m", 1) == 0)
8975 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
8977 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
8980 ALIAS (show_ip_bgp_ipv4_community
,
8981 show_ip_bgp_ipv4_community2_cmd
,
8982 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
8987 "Address Family modifier\n"
8988 "Address Family modifier\n"
8989 "Display routes matching the communities\n"
8990 "community number\n"
8991 "Do not send outside local AS (well-known community)\n"
8992 "Do not advertise to any peer (well-known community)\n"
8993 "Do not export to next AS (well-known community)\n"
8994 "community number\n"
8995 "Do not send outside local AS (well-known community)\n"
8996 "Do not advertise to any peer (well-known community)\n"
8997 "Do not export to next AS (well-known community)\n")
8999 ALIAS (show_ip_bgp_ipv4_community
,
9000 show_ip_bgp_ipv4_community3_cmd
,
9001 "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)",
9006 "Address Family modifier\n"
9007 "Address Family modifier\n"
9008 "Display routes matching the communities\n"
9009 "community number\n"
9010 "Do not send outside local AS (well-known community)\n"
9011 "Do not advertise to any peer (well-known community)\n"
9012 "Do not export to next AS (well-known community)\n"
9013 "community number\n"
9014 "Do not send outside local AS (well-known community)\n"
9015 "Do not advertise to any peer (well-known community)\n"
9016 "Do not export to next AS (well-known community)\n"
9017 "community number\n"
9018 "Do not send outside local AS (well-known community)\n"
9019 "Do not advertise to any peer (well-known community)\n"
9020 "Do not export to next AS (well-known community)\n")
9022 ALIAS (show_ip_bgp_ipv4_community
,
9023 show_ip_bgp_ipv4_community4_cmd
,
9024 "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)",
9029 "Address Family modifier\n"
9030 "Address Family modifier\n"
9031 "Display routes matching the communities\n"
9032 "community number\n"
9033 "Do not send outside local AS (well-known community)\n"
9034 "Do not advertise to any peer (well-known community)\n"
9035 "Do not export to next AS (well-known community)\n"
9036 "community number\n"
9037 "Do not send outside local AS (well-known community)\n"
9038 "Do not advertise to any peer (well-known community)\n"
9039 "Do not export to next AS (well-known community)\n"
9040 "community number\n"
9041 "Do not send outside local AS (well-known community)\n"
9042 "Do not advertise to any peer (well-known community)\n"
9043 "Do not export to next AS (well-known community)\n"
9044 "community number\n"
9045 "Do not send outside local AS (well-known community)\n"
9046 "Do not advertise to any peer (well-known community)\n"
9047 "Do not export to next AS (well-known community)\n")
9049 DEFUN (show_bgp_view_afi_safi_community_all
,
9050 show_bgp_view_afi_safi_community_all_cmd
,
9052 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community",
9054 "show bgp view WORD ipv4 (unicast|multicast) community",
9064 "Address Family modifier\n"
9065 "Address Family modifier\n"
9066 "Display routes matching the communities\n")
9072 /* BGP structure lookup. */
9073 bgp
= bgp_lookup_by_name (argv
[0]);
9076 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
9081 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9082 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9085 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9087 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
9090 DEFUN (show_bgp_view_afi_safi_community
,
9091 show_bgp_view_afi_safi_community_cmd
,
9093 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9095 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9105 "Address family modifier\n"
9106 "Address family modifier\n"
9107 "Display routes matching the communities\n"
9108 "community number\n"
9109 "Do not send outside local AS (well-known community)\n"
9110 "Do not advertise to any peer (well-known community)\n"
9111 "Do not export to next AS (well-known community)\n")
9117 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9118 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9119 return bgp_show_community (vty
, argv
[0], argc
-3, &argv
[3], 0, afi
, safi
);
9122 safi
= (strncmp (argv
[1], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9123 return bgp_show_community (vty
, argv
[0], argc
-2, &argv
[2], 0, afi
, safi
);
9127 ALIAS (show_bgp_view_afi_safi_community
,
9128 show_bgp_view_afi_safi_community2_cmd
,
9130 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9132 "show bgp view WORD ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9142 "Address family modifier\n"
9143 "Address family modifier\n"
9144 "Display routes matching the communities\n"
9145 "community number\n"
9146 "Do not send outside local AS (well-known community)\n"
9147 "Do not advertise to any peer (well-known community)\n"
9148 "Do not export to next AS (well-known community)\n"
9149 "community number\n"
9150 "Do not send outside local AS (well-known community)\n"
9151 "Do not advertise to any peer (well-known community)\n"
9152 "Do not export to next AS (well-known community)\n")
9154 ALIAS (show_bgp_view_afi_safi_community
,
9155 show_bgp_view_afi_safi_community3_cmd
,
9157 "show bgp view WORD (ipv4|ipv6) (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)",
9159 "show bgp view WORD 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)",
9169 "Address family modifier\n"
9170 "Address family modifier\n"
9171 "Display routes matching the communities\n"
9172 "community number\n"
9173 "Do not send outside local AS (well-known community)\n"
9174 "Do not advertise to any peer (well-known community)\n"
9175 "Do not export to next AS (well-known community)\n"
9176 "community number\n"
9177 "Do not send outside local AS (well-known community)\n"
9178 "Do not advertise to any peer (well-known community)\n"
9179 "Do not export to next AS (well-known community)\n"
9180 "community number\n"
9181 "Do not send outside local AS (well-known community)\n"
9182 "Do not advertise to any peer (well-known community)\n"
9183 "Do not export to next AS (well-known community)\n")
9185 ALIAS (show_bgp_view_afi_safi_community
,
9186 show_bgp_view_afi_safi_community4_cmd
,
9188 "show bgp view WORD (ipv4|ipv6) (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)",
9190 "show bgp view WORD 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)",
9200 "Address family modifier\n"
9201 "Address family modifier\n"
9202 "Display routes matching the communities\n"
9203 "community number\n"
9204 "Do not send outside local AS (well-known community)\n"
9205 "Do not advertise to any peer (well-known community)\n"
9206 "Do not export to next AS (well-known community)\n"
9207 "community number\n"
9208 "Do not send outside local AS (well-known community)\n"
9209 "Do not advertise to any peer (well-known community)\n"
9210 "Do not export to next AS (well-known community)\n"
9211 "community number\n"
9212 "Do not send outside local AS (well-known community)\n"
9213 "Do not advertise to any peer (well-known community)\n"
9214 "Do not export to next AS (well-known community)\n"
9215 "community number\n"
9216 "Do not send outside local AS (well-known community)\n"
9217 "Do not advertise to any peer (well-known community)\n"
9218 "Do not export to next AS (well-known community)\n")
9220 DEFUN (show_ip_bgp_community_exact
,
9221 show_ip_bgp_community_exact_cmd
,
9222 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9226 "Display routes matching the communities\n"
9227 "community number\n"
9228 "Do not send outside local AS (well-known community)\n"
9229 "Do not advertise to any peer (well-known community)\n"
9230 "Do not export to next AS (well-known community)\n"
9231 "Exact match of the communities")
9233 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
9236 ALIAS (show_ip_bgp_community_exact
,
9237 show_ip_bgp_community2_exact_cmd
,
9238 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9242 "Display routes matching the communities\n"
9243 "community number\n"
9244 "Do not send outside local AS (well-known community)\n"
9245 "Do not advertise to any peer (well-known community)\n"
9246 "Do not export to next AS (well-known community)\n"
9247 "community number\n"
9248 "Do not send outside local AS (well-known community)\n"
9249 "Do not advertise to any peer (well-known community)\n"
9250 "Do not export to next AS (well-known community)\n"
9251 "Exact match of the communities")
9253 ALIAS (show_ip_bgp_community_exact
,
9254 show_ip_bgp_community3_exact_cmd
,
9255 "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",
9259 "Display routes matching the communities\n"
9260 "community number\n"
9261 "Do not send outside local AS (well-known community)\n"
9262 "Do not advertise to any peer (well-known community)\n"
9263 "Do not export to next AS (well-known community)\n"
9264 "community number\n"
9265 "Do not send outside local AS (well-known community)\n"
9266 "Do not advertise to any peer (well-known community)\n"
9267 "Do not export to next AS (well-known community)\n"
9268 "community number\n"
9269 "Do not send outside local AS (well-known community)\n"
9270 "Do not advertise to any peer (well-known community)\n"
9271 "Do not export to next AS (well-known community)\n"
9272 "Exact match of the communities")
9274 ALIAS (show_ip_bgp_community_exact
,
9275 show_ip_bgp_community4_exact_cmd
,
9276 "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",
9280 "Display routes matching the communities\n"
9281 "community number\n"
9282 "Do not send outside local AS (well-known community)\n"
9283 "Do not advertise to any peer (well-known community)\n"
9284 "Do not export to next AS (well-known community)\n"
9285 "community number\n"
9286 "Do not send outside local AS (well-known community)\n"
9287 "Do not advertise to any peer (well-known community)\n"
9288 "Do not export to next AS (well-known community)\n"
9289 "community number\n"
9290 "Do not send outside local AS (well-known community)\n"
9291 "Do not advertise to any peer (well-known community)\n"
9292 "Do not export to next AS (well-known community)\n"
9293 "community number\n"
9294 "Do not send outside local AS (well-known community)\n"
9295 "Do not advertise to any peer (well-known community)\n"
9296 "Do not export to next AS (well-known community)\n"
9297 "Exact match of the communities")
9299 DEFUN (show_ip_bgp_ipv4_community_exact
,
9300 show_ip_bgp_ipv4_community_exact_cmd
,
9301 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9306 "Address Family modifier\n"
9307 "Address Family modifier\n"
9308 "Display routes matching the communities\n"
9309 "community number\n"
9310 "Do not send outside local AS (well-known community)\n"
9311 "Do not advertise to any peer (well-known community)\n"
9312 "Do not export to next AS (well-known community)\n"
9313 "Exact match of the communities")
9315 if (strncmp (argv
[0], "m", 1) == 0)
9316 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
9318 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
9321 ALIAS (show_ip_bgp_ipv4_community_exact
,
9322 show_ip_bgp_ipv4_community2_exact_cmd
,
9323 "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",
9328 "Address Family modifier\n"
9329 "Address Family modifier\n"
9330 "Display routes matching the communities\n"
9331 "community number\n"
9332 "Do not send outside local AS (well-known community)\n"
9333 "Do not advertise to any peer (well-known community)\n"
9334 "Do not export to next AS (well-known community)\n"
9335 "community number\n"
9336 "Do not send outside local AS (well-known community)\n"
9337 "Do not advertise to any peer (well-known community)\n"
9338 "Do not export to next AS (well-known community)\n"
9339 "Exact match of the communities")
9341 ALIAS (show_ip_bgp_ipv4_community_exact
,
9342 show_ip_bgp_ipv4_community3_exact_cmd
,
9343 "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",
9348 "Address Family modifier\n"
9349 "Address Family modifier\n"
9350 "Display routes matching the communities\n"
9351 "community number\n"
9352 "Do not send outside local AS (well-known community)\n"
9353 "Do not advertise to any peer (well-known community)\n"
9354 "Do not export to next AS (well-known community)\n"
9355 "community number\n"
9356 "Do not send outside local AS (well-known community)\n"
9357 "Do not advertise to any peer (well-known community)\n"
9358 "Do not export to next AS (well-known community)\n"
9359 "community number\n"
9360 "Do not send outside local AS (well-known community)\n"
9361 "Do not advertise to any peer (well-known community)\n"
9362 "Do not export to next AS (well-known community)\n"
9363 "Exact match of the communities")
9365 ALIAS (show_ip_bgp_ipv4_community_exact
,
9366 show_ip_bgp_ipv4_community4_exact_cmd
,
9367 "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",
9372 "Address Family modifier\n"
9373 "Address Family modifier\n"
9374 "Display routes matching the communities\n"
9375 "community number\n"
9376 "Do not send outside local AS (well-known community)\n"
9377 "Do not advertise to any peer (well-known community)\n"
9378 "Do not export to next AS (well-known community)\n"
9379 "community number\n"
9380 "Do not send outside local AS (well-known community)\n"
9381 "Do not advertise to any peer (well-known community)\n"
9382 "Do not export to next AS (well-known community)\n"
9383 "community number\n"
9384 "Do not send outside local AS (well-known community)\n"
9385 "Do not advertise to any peer (well-known community)\n"
9386 "Do not export to next AS (well-known community)\n"
9387 "community number\n"
9388 "Do not send outside local AS (well-known community)\n"
9389 "Do not advertise to any peer (well-known community)\n"
9390 "Do not export to next AS (well-known community)\n"
9391 "Exact match of the communities")
9394 DEFUN (show_bgp_community
,
9395 show_bgp_community_cmd
,
9396 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9399 "Display routes matching the communities\n"
9400 "community number\n"
9401 "Do not send outside local AS (well-known community)\n"
9402 "Do not advertise to any peer (well-known community)\n"
9403 "Do not export to next AS (well-known community)\n")
9405 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
9408 ALIAS (show_bgp_community
,
9409 show_bgp_ipv6_community_cmd
,
9410 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9414 "Display routes matching the communities\n"
9415 "community number\n"
9416 "Do not send outside local AS (well-known community)\n"
9417 "Do not advertise to any peer (well-known community)\n"
9418 "Do not export to next AS (well-known community)\n")
9420 ALIAS (show_bgp_community
,
9421 show_bgp_community2_cmd
,
9422 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9425 "Display routes matching the communities\n"
9426 "community number\n"
9427 "Do not send outside local AS (well-known community)\n"
9428 "Do not advertise to any peer (well-known community)\n"
9429 "Do not export to next AS (well-known community)\n"
9430 "community number\n"
9431 "Do not send outside local AS (well-known community)\n"
9432 "Do not advertise to any peer (well-known community)\n"
9433 "Do not export to next AS (well-known community)\n")
9435 ALIAS (show_bgp_community
,
9436 show_bgp_ipv6_community2_cmd
,
9437 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9441 "Display routes matching the communities\n"
9442 "community number\n"
9443 "Do not send outside local AS (well-known community)\n"
9444 "Do not advertise to any peer (well-known community)\n"
9445 "Do not export to next AS (well-known community)\n"
9446 "community number\n"
9447 "Do not send outside local AS (well-known community)\n"
9448 "Do not advertise to any peer (well-known community)\n"
9449 "Do not export to next AS (well-known community)\n")
9451 ALIAS (show_bgp_community
,
9452 show_bgp_community3_cmd
,
9453 "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)",
9456 "Display routes matching the communities\n"
9457 "community number\n"
9458 "Do not send outside local AS (well-known community)\n"
9459 "Do not advertise to any peer (well-known community)\n"
9460 "Do not export to next AS (well-known community)\n"
9461 "community number\n"
9462 "Do not send outside local AS (well-known community)\n"
9463 "Do not advertise to any peer (well-known community)\n"
9464 "Do not export to next AS (well-known community)\n"
9465 "community number\n"
9466 "Do not send outside local AS (well-known community)\n"
9467 "Do not advertise to any peer (well-known community)\n"
9468 "Do not export to next AS (well-known community)\n")
9470 ALIAS (show_bgp_community
,
9471 show_bgp_ipv6_community3_cmd
,
9472 "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)",
9476 "Display routes matching the communities\n"
9477 "community number\n"
9478 "Do not send outside local AS (well-known community)\n"
9479 "Do not advertise to any peer (well-known community)\n"
9480 "Do not export to next AS (well-known community)\n"
9481 "community number\n"
9482 "Do not send outside local AS (well-known community)\n"
9483 "Do not advertise to any peer (well-known community)\n"
9484 "Do not export to next AS (well-known community)\n"
9485 "community number\n"
9486 "Do not send outside local AS (well-known community)\n"
9487 "Do not advertise to any peer (well-known community)\n"
9488 "Do not export to next AS (well-known community)\n")
9490 ALIAS (show_bgp_community
,
9491 show_bgp_community4_cmd
,
9492 "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)",
9495 "Display routes matching the communities\n"
9496 "community number\n"
9497 "Do not send outside local AS (well-known community)\n"
9498 "Do not advertise to any peer (well-known community)\n"
9499 "Do not export to next AS (well-known community)\n"
9500 "community number\n"
9501 "Do not send outside local AS (well-known community)\n"
9502 "Do not advertise to any peer (well-known community)\n"
9503 "Do not export to next AS (well-known community)\n"
9504 "community number\n"
9505 "Do not send outside local AS (well-known community)\n"
9506 "Do not advertise to any peer (well-known community)\n"
9507 "Do not export to next AS (well-known community)\n"
9508 "community number\n"
9509 "Do not send outside local AS (well-known community)\n"
9510 "Do not advertise to any peer (well-known community)\n"
9511 "Do not export to next AS (well-known community)\n")
9513 ALIAS (show_bgp_community
,
9514 show_bgp_ipv6_community4_cmd
,
9515 "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)",
9519 "Display routes matching the communities\n"
9520 "community number\n"
9521 "Do not send outside local AS (well-known community)\n"
9522 "Do not advertise to any peer (well-known community)\n"
9523 "Do not export to next AS (well-known community)\n"
9524 "community number\n"
9525 "Do not send outside local AS (well-known community)\n"
9526 "Do not advertise to any peer (well-known community)\n"
9527 "Do not export to next AS (well-known community)\n"
9528 "community number\n"
9529 "Do not send outside local AS (well-known community)\n"
9530 "Do not advertise to any peer (well-known community)\n"
9531 "Do not export to next AS (well-known community)\n"
9532 "community number\n"
9533 "Do not send outside local AS (well-known community)\n"
9534 "Do not advertise to any peer (well-known community)\n"
9535 "Do not export to next AS (well-known community)\n")
9538 DEFUN (show_ipv6_bgp_community
,
9539 show_ipv6_bgp_community_cmd
,
9540 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9544 "Display routes matching the communities\n"
9545 "community number\n"
9546 "Do not send outside local AS (well-known community)\n"
9547 "Do not advertise to any peer (well-known community)\n"
9548 "Do not export to next AS (well-known community)\n")
9550 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9551 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
9555 ALIAS (show_ipv6_bgp_community
,
9556 show_ipv6_bgp_community2_cmd
,
9557 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9561 "Display routes matching the communities\n"
9562 "community number\n"
9563 "Do not send outside local AS (well-known community)\n"
9564 "Do not advertise to any peer (well-known community)\n"
9565 "Do not export to next AS (well-known community)\n"
9566 "community number\n"
9567 "Do not send outside local AS (well-known community)\n"
9568 "Do not advertise to any peer (well-known community)\n"
9569 "Do not export to next AS (well-known community)\n")
9572 ALIAS (show_ipv6_bgp_community
,
9573 show_ipv6_bgp_community3_cmd
,
9574 "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)",
9578 "Display routes matching the communities\n"
9579 "community number\n"
9580 "Do not send outside local AS (well-known community)\n"
9581 "Do not advertise to any peer (well-known community)\n"
9582 "Do not export to next AS (well-known community)\n"
9583 "community number\n"
9584 "Do not send outside local AS (well-known community)\n"
9585 "Do not advertise to any peer (well-known community)\n"
9586 "Do not export to next AS (well-known community)\n"
9587 "community number\n"
9588 "Do not send outside local AS (well-known community)\n"
9589 "Do not advertise to any peer (well-known community)\n"
9590 "Do not export to next AS (well-known community)\n")
9593 ALIAS (show_ipv6_bgp_community
,
9594 show_ipv6_bgp_community4_cmd
,
9595 "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)",
9599 "Display routes matching the communities\n"
9600 "community number\n"
9601 "Do not send outside local AS (well-known community)\n"
9602 "Do not advertise to any peer (well-known community)\n"
9603 "Do not export to next AS (well-known community)\n"
9604 "community number\n"
9605 "Do not send outside local AS (well-known community)\n"
9606 "Do not advertise to any peer (well-known community)\n"
9607 "Do not export to next AS (well-known community)\n"
9608 "community number\n"
9609 "Do not send outside local AS (well-known community)\n"
9610 "Do not advertise to any peer (well-known community)\n"
9611 "Do not export to next AS (well-known community)\n"
9612 "community number\n"
9613 "Do not send outside local AS (well-known community)\n"
9614 "Do not advertise to any peer (well-known community)\n"
9615 "Do not export to next AS (well-known community)\n")
9617 DEFUN (show_bgp_community_exact
,
9618 show_bgp_community_exact_cmd
,
9619 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9622 "Display routes matching the communities\n"
9623 "community number\n"
9624 "Do not send outside local AS (well-known community)\n"
9625 "Do not advertise to any peer (well-known community)\n"
9626 "Do not export to next AS (well-known community)\n"
9627 "Exact match of the communities")
9629 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
9632 ALIAS (show_bgp_community_exact
,
9633 show_bgp_ipv6_community_exact_cmd
,
9634 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9638 "Display routes matching the communities\n"
9639 "community number\n"
9640 "Do not send outside local AS (well-known community)\n"
9641 "Do not advertise to any peer (well-known community)\n"
9642 "Do not export to next AS (well-known community)\n"
9643 "Exact match of the communities")
9645 ALIAS (show_bgp_community_exact
,
9646 show_bgp_community2_exact_cmd
,
9647 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9650 "Display routes matching the communities\n"
9651 "community number\n"
9652 "Do not send outside local AS (well-known community)\n"
9653 "Do not advertise to any peer (well-known community)\n"
9654 "Do not export to next AS (well-known community)\n"
9655 "community number\n"
9656 "Do not send outside local AS (well-known community)\n"
9657 "Do not advertise to any peer (well-known community)\n"
9658 "Do not export to next AS (well-known community)\n"
9659 "Exact match of the communities")
9661 ALIAS (show_bgp_community_exact
,
9662 show_bgp_ipv6_community2_exact_cmd
,
9663 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9667 "Display routes matching the communities\n"
9668 "community number\n"
9669 "Do not send outside local AS (well-known community)\n"
9670 "Do not advertise to any peer (well-known community)\n"
9671 "Do not export to next AS (well-known community)\n"
9672 "community number\n"
9673 "Do not send outside local AS (well-known community)\n"
9674 "Do not advertise to any peer (well-known community)\n"
9675 "Do not export to next AS (well-known community)\n"
9676 "Exact match of the communities")
9678 ALIAS (show_bgp_community_exact
,
9679 show_bgp_community3_exact_cmd
,
9680 "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",
9683 "Display routes matching the communities\n"
9684 "community number\n"
9685 "Do not send outside local AS (well-known community)\n"
9686 "Do not advertise to any peer (well-known community)\n"
9687 "Do not export to next AS (well-known community)\n"
9688 "community number\n"
9689 "Do not send outside local AS (well-known community)\n"
9690 "Do not advertise to any peer (well-known community)\n"
9691 "Do not export to next AS (well-known community)\n"
9692 "community number\n"
9693 "Do not send outside local AS (well-known community)\n"
9694 "Do not advertise to any peer (well-known community)\n"
9695 "Do not export to next AS (well-known community)\n"
9696 "Exact match of the communities")
9698 ALIAS (show_bgp_community_exact
,
9699 show_bgp_ipv6_community3_exact_cmd
,
9700 "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",
9704 "Display routes matching the communities\n"
9705 "community number\n"
9706 "Do not send outside local AS (well-known community)\n"
9707 "Do not advertise to any peer (well-known community)\n"
9708 "Do not export to next AS (well-known community)\n"
9709 "community number\n"
9710 "Do not send outside local AS (well-known community)\n"
9711 "Do not advertise to any peer (well-known community)\n"
9712 "Do not export to next AS (well-known community)\n"
9713 "community number\n"
9714 "Do not send outside local AS (well-known community)\n"
9715 "Do not advertise to any peer (well-known community)\n"
9716 "Do not export to next AS (well-known community)\n"
9717 "Exact match of the communities")
9719 ALIAS (show_bgp_community_exact
,
9720 show_bgp_community4_exact_cmd
,
9721 "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",
9724 "Display routes matching the communities\n"
9725 "community number\n"
9726 "Do not send outside local AS (well-known community)\n"
9727 "Do not advertise to any peer (well-known community)\n"
9728 "Do not export to next AS (well-known community)\n"
9729 "community number\n"
9730 "Do not send outside local AS (well-known community)\n"
9731 "Do not advertise to any peer (well-known community)\n"
9732 "Do not export to next AS (well-known community)\n"
9733 "community number\n"
9734 "Do not send outside local AS (well-known community)\n"
9735 "Do not advertise to any peer (well-known community)\n"
9736 "Do not export to next AS (well-known community)\n"
9737 "community number\n"
9738 "Do not send outside local AS (well-known community)\n"
9739 "Do not advertise to any peer (well-known community)\n"
9740 "Do not export to next AS (well-known community)\n"
9741 "Exact match of the communities")
9743 ALIAS (show_bgp_community_exact
,
9744 show_bgp_ipv6_community4_exact_cmd
,
9745 "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",
9749 "Display routes matching the communities\n"
9750 "community number\n"
9751 "Do not send outside local AS (well-known community)\n"
9752 "Do not advertise to any peer (well-known community)\n"
9753 "Do not export to next AS (well-known community)\n"
9754 "community number\n"
9755 "Do not send outside local AS (well-known community)\n"
9756 "Do not advertise to any peer (well-known community)\n"
9757 "Do not export to next AS (well-known community)\n"
9758 "community number\n"
9759 "Do not send outside local AS (well-known community)\n"
9760 "Do not advertise to any peer (well-known community)\n"
9761 "Do not export to next AS (well-known community)\n"
9762 "community number\n"
9763 "Do not send outside local AS (well-known community)\n"
9764 "Do not advertise to any peer (well-known community)\n"
9765 "Do not export to next AS (well-known community)\n"
9766 "Exact match of the communities")
9769 DEFUN (show_ipv6_bgp_community_exact
,
9770 show_ipv6_bgp_community_exact_cmd
,
9771 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9775 "Display routes matching the communities\n"
9776 "community number\n"
9777 "Do not send outside local AS (well-known community)\n"
9778 "Do not advertise to any peer (well-known community)\n"
9779 "Do not export to next AS (well-known community)\n"
9780 "Exact match of the communities")
9782 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9783 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
9787 ALIAS (show_ipv6_bgp_community_exact
,
9788 show_ipv6_bgp_community2_exact_cmd
,
9789 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9793 "Display routes matching the communities\n"
9794 "community number\n"
9795 "Do not send outside local AS (well-known community)\n"
9796 "Do not advertise to any peer (well-known community)\n"
9797 "Do not export to next AS (well-known community)\n"
9798 "community number\n"
9799 "Do not send outside local AS (well-known community)\n"
9800 "Do not advertise to any peer (well-known community)\n"
9801 "Do not export to next AS (well-known community)\n"
9802 "Exact match of the communities")
9805 ALIAS (show_ipv6_bgp_community_exact
,
9806 show_ipv6_bgp_community3_exact_cmd
,
9807 "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",
9811 "Display routes matching the communities\n"
9812 "community number\n"
9813 "Do not send outside local AS (well-known community)\n"
9814 "Do not advertise to any peer (well-known community)\n"
9815 "Do not export to next AS (well-known community)\n"
9816 "community number\n"
9817 "Do not send outside local AS (well-known community)\n"
9818 "Do not advertise to any peer (well-known community)\n"
9819 "Do not export to next AS (well-known community)\n"
9820 "community number\n"
9821 "Do not send outside local AS (well-known community)\n"
9822 "Do not advertise to any peer (well-known community)\n"
9823 "Do not export to next AS (well-known community)\n"
9824 "Exact match of the communities")
9827 ALIAS (show_ipv6_bgp_community_exact
,
9828 show_ipv6_bgp_community4_exact_cmd
,
9829 "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",
9833 "Display routes matching the communities\n"
9834 "community number\n"
9835 "Do not send outside local AS (well-known community)\n"
9836 "Do not advertise to any peer (well-known community)\n"
9837 "Do not export to next AS (well-known community)\n"
9838 "community number\n"
9839 "Do not send outside local AS (well-known community)\n"
9840 "Do not advertise to any peer (well-known community)\n"
9841 "Do not export to next AS (well-known community)\n"
9842 "community number\n"
9843 "Do not send outside local AS (well-known community)\n"
9844 "Do not advertise to any peer (well-known community)\n"
9845 "Do not export to next AS (well-known community)\n"
9846 "community number\n"
9847 "Do not send outside local AS (well-known community)\n"
9848 "Do not advertise to any peer (well-known community)\n"
9849 "Do not export to next AS (well-known community)\n"
9850 "Exact match of the communities")
9853 DEFUN (show_ipv6_mbgp_community
,
9854 show_ipv6_mbgp_community_cmd
,
9855 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
9859 "Display routes matching the communities\n"
9860 "community number\n"
9861 "Do not send outside local AS (well-known community)\n"
9862 "Do not advertise to any peer (well-known community)\n"
9863 "Do not export to next AS (well-known community)\n")
9865 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9866 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
9870 ALIAS (show_ipv6_mbgp_community
,
9871 show_ipv6_mbgp_community2_cmd
,
9872 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9876 "Display routes matching the communities\n"
9877 "community number\n"
9878 "Do not send outside local AS (well-known community)\n"
9879 "Do not advertise to any peer (well-known community)\n"
9880 "Do not export to next AS (well-known community)\n"
9881 "community number\n"
9882 "Do not send outside local AS (well-known community)\n"
9883 "Do not advertise to any peer (well-known community)\n"
9884 "Do not export to next AS (well-known community)\n")
9887 ALIAS (show_ipv6_mbgp_community
,
9888 show_ipv6_mbgp_community3_cmd
,
9889 "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)",
9893 "Display routes matching the communities\n"
9894 "community number\n"
9895 "Do not send outside local AS (well-known community)\n"
9896 "Do not advertise to any peer (well-known community)\n"
9897 "Do not export to next AS (well-known community)\n"
9898 "community number\n"
9899 "Do not send outside local AS (well-known community)\n"
9900 "Do not advertise to any peer (well-known community)\n"
9901 "Do not export to next AS (well-known community)\n"
9902 "community number\n"
9903 "Do not send outside local AS (well-known community)\n"
9904 "Do not advertise to any peer (well-known community)\n"
9905 "Do not export to next AS (well-known community)\n")
9908 ALIAS (show_ipv6_mbgp_community
,
9909 show_ipv6_mbgp_community4_cmd
,
9910 "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)",
9914 "Display routes matching the communities\n"
9915 "community number\n"
9916 "Do not send outside local AS (well-known community)\n"
9917 "Do not advertise to any peer (well-known community)\n"
9918 "Do not export to next AS (well-known community)\n"
9919 "community number\n"
9920 "Do not send outside local AS (well-known community)\n"
9921 "Do not advertise to any peer (well-known community)\n"
9922 "Do not export to next AS (well-known community)\n"
9923 "community number\n"
9924 "Do not send outside local AS (well-known community)\n"
9925 "Do not advertise to any peer (well-known community)\n"
9926 "Do not export to next AS (well-known community)\n"
9927 "community number\n"
9928 "Do not send outside local AS (well-known community)\n"
9929 "Do not advertise to any peer (well-known community)\n"
9930 "Do not export to next AS (well-known community)\n")
9933 DEFUN (show_ipv6_mbgp_community_exact
,
9934 show_ipv6_mbgp_community_exact_cmd
,
9935 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9939 "Display routes matching the communities\n"
9940 "community number\n"
9941 "Do not send outside local AS (well-known community)\n"
9942 "Do not advertise to any peer (well-known community)\n"
9943 "Do not export to next AS (well-known community)\n"
9944 "Exact match of the communities")
9946 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9947 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
9951 ALIAS (show_ipv6_mbgp_community_exact
,
9952 show_ipv6_mbgp_community2_exact_cmd
,
9953 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9957 "Display routes matching the communities\n"
9958 "community number\n"
9959 "Do not send outside local AS (well-known community)\n"
9960 "Do not advertise to any peer (well-known community)\n"
9961 "Do not export to next AS (well-known community)\n"
9962 "community number\n"
9963 "Do not send outside local AS (well-known community)\n"
9964 "Do not advertise to any peer (well-known community)\n"
9965 "Do not export to next AS (well-known community)\n"
9966 "Exact match of the communities")
9969 ALIAS (show_ipv6_mbgp_community_exact
,
9970 show_ipv6_mbgp_community3_exact_cmd
,
9971 "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",
9975 "Display routes matching the communities\n"
9976 "community number\n"
9977 "Do not send outside local AS (well-known community)\n"
9978 "Do not advertise to any peer (well-known community)\n"
9979 "Do not export to next AS (well-known community)\n"
9980 "community number\n"
9981 "Do not send outside local AS (well-known community)\n"
9982 "Do not advertise to any peer (well-known community)\n"
9983 "Do not export to next AS (well-known community)\n"
9984 "community number\n"
9985 "Do not send outside local AS (well-known community)\n"
9986 "Do not advertise to any peer (well-known community)\n"
9987 "Do not export to next AS (well-known community)\n"
9988 "Exact match of the communities")
9991 ALIAS (show_ipv6_mbgp_community_exact
,
9992 show_ipv6_mbgp_community4_exact_cmd
,
9993 "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",
9997 "Display routes matching the communities\n"
9998 "community number\n"
9999 "Do not send outside local AS (well-known community)\n"
10000 "Do not advertise to any peer (well-known community)\n"
10001 "Do not export to next AS (well-known community)\n"
10002 "community number\n"
10003 "Do not send outside local AS (well-known community)\n"
10004 "Do not advertise to any peer (well-known community)\n"
10005 "Do not export to next AS (well-known community)\n"
10006 "community number\n"
10007 "Do not send outside local AS (well-known community)\n"
10008 "Do not advertise to any peer (well-known community)\n"
10009 "Do not export to next AS (well-known community)\n"
10010 "community number\n"
10011 "Do not send outside local AS (well-known community)\n"
10012 "Do not advertise to any peer (well-known community)\n"
10013 "Do not export to next AS (well-known community)\n"
10014 "Exact match of the communities")
10015 #endif /* HAVE_IPV6 */
10018 bgp_show_community_list (struct vty
*vty
, const char *com
, int exact
,
10019 afi_t afi
, safi_t safi
)
10021 struct community_list
*list
;
10023 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
10026 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
10028 return CMD_WARNING
;
10031 return bgp_show (vty
, NULL
, afi
, safi
,
10032 (exact
? bgp_show_type_community_list_exact
:
10033 bgp_show_type_community_list
), list
, 0);
10036 DEFUN (show_ip_bgp_community_list
,
10037 show_ip_bgp_community_list_cmd
,
10038 "show ip bgp community-list (<1-500>|WORD)",
10042 "Display routes matching the community-list\n"
10043 "community-list number\n"
10044 "community-list name\n")
10046 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
10049 DEFUN (show_ip_bgp_ipv4_community_list
,
10050 show_ip_bgp_ipv4_community_list_cmd
,
10051 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10056 "Address Family modifier\n"
10057 "Address Family modifier\n"
10058 "Display routes matching the community-list\n"
10059 "community-list number\n"
10060 "community-list name\n")
10062 if (strncmp (argv
[0], "m", 1) == 0)
10063 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
10065 return bgp_show_community_list (vty
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
10068 DEFUN (show_ip_bgp_community_list_exact
,
10069 show_ip_bgp_community_list_exact_cmd
,
10070 "show ip bgp community-list (<1-500>|WORD) exact-match",
10074 "Display routes matching the community-list\n"
10075 "community-list number\n"
10076 "community-list name\n"
10077 "Exact match of the communities\n")
10079 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
10082 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
10083 show_ip_bgp_ipv4_community_list_exact_cmd
,
10084 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10089 "Address Family modifier\n"
10090 "Address Family modifier\n"
10091 "Display routes matching the community-list\n"
10092 "community-list number\n"
10093 "community-list name\n"
10094 "Exact match of the communities\n")
10096 if (strncmp (argv
[0], "m", 1) == 0)
10097 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
10099 return bgp_show_community_list (vty
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
10103 DEFUN (show_bgp_community_list
,
10104 show_bgp_community_list_cmd
,
10105 "show bgp community-list (<1-500>|WORD)",
10108 "Display routes matching the community-list\n"
10109 "community-list number\n"
10110 "community-list name\n")
10112 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10115 ALIAS (show_bgp_community_list
,
10116 show_bgp_ipv6_community_list_cmd
,
10117 "show bgp ipv6 community-list (<1-500>|WORD)",
10121 "Display routes matching the community-list\n"
10122 "community-list number\n"
10123 "community-list name\n")
10126 DEFUN (show_ipv6_bgp_community_list
,
10127 show_ipv6_bgp_community_list_cmd
,
10128 "show ipv6 bgp community-list WORD",
10132 "Display routes matching the community-list\n"
10133 "community-list name\n")
10135 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10136 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10140 DEFUN (show_ipv6_mbgp_community_list
,
10141 show_ipv6_mbgp_community_list_cmd
,
10142 "show ipv6 mbgp community-list WORD",
10146 "Display routes matching the community-list\n"
10147 "community-list name\n")
10149 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10150 return bgp_show_community_list (vty
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
10153 DEFUN (show_bgp_community_list_exact
,
10154 show_bgp_community_list_exact_cmd
,
10155 "show bgp community-list (<1-500>|WORD) exact-match",
10158 "Display routes matching the community-list\n"
10159 "community-list number\n"
10160 "community-list name\n"
10161 "Exact match of the communities\n")
10163 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10166 ALIAS (show_bgp_community_list_exact
,
10167 show_bgp_ipv6_community_list_exact_cmd
,
10168 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10172 "Display routes matching the community-list\n"
10173 "community-list number\n"
10174 "community-list name\n"
10175 "Exact match of the communities\n")
10178 DEFUN (show_ipv6_bgp_community_list_exact
,
10179 show_ipv6_bgp_community_list_exact_cmd
,
10180 "show ipv6 bgp community-list WORD exact-match",
10184 "Display routes matching the community-list\n"
10185 "community-list name\n"
10186 "Exact match of the communities\n")
10188 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10189 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10193 DEFUN (show_ipv6_mbgp_community_list_exact
,
10194 show_ipv6_mbgp_community_list_exact_cmd
,
10195 "show ipv6 mbgp community-list WORD exact-match",
10199 "Display routes matching the community-list\n"
10200 "community-list name\n"
10201 "Exact match of the communities\n")
10203 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10204 return bgp_show_community_list (vty
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
10206 #endif /* HAVE_IPV6 */
10209 bgp_show_prefix_longer (struct vty
*vty
, const char *prefix
, afi_t afi
,
10210 safi_t safi
, enum bgp_show_type type
)
10217 ret
= str2prefix (prefix
, p
);
10220 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
10221 return CMD_WARNING
;
10224 ret
= bgp_show (vty
, NULL
, afi
, safi
, type
, p
, 0);
10229 DEFUN (show_ip_bgp_prefix_longer
,
10230 show_ip_bgp_prefix_longer_cmd
,
10231 "show ip bgp A.B.C.D/M longer-prefixes",
10235 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10236 "Display route and more specific routes\n")
10238 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10239 bgp_show_type_prefix_longer
);
10242 DEFUN (show_ip_bgp_flap_prefix_longer
,
10243 show_ip_bgp_flap_prefix_longer_cmd
,
10244 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
10248 "Display flap statistics of routes\n"
10249 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10250 "Display route and more specific routes\n")
10252 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10253 bgp_show_type_flap_prefix_longer
);
10256 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
10257 show_ip_bgp_ipv4_prefix_longer_cmd
,
10258 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
10263 "Address Family modifier\n"
10264 "Address Family modifier\n"
10265 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10266 "Display route and more specific routes\n")
10268 if (strncmp (argv
[0], "m", 1) == 0)
10269 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
10270 bgp_show_type_prefix_longer
);
10272 return bgp_show_prefix_longer (vty
, argv
[1], AFI_IP
, SAFI_UNICAST
,
10273 bgp_show_type_prefix_longer
);
10276 DEFUN (show_ip_bgp_flap_address
,
10277 show_ip_bgp_flap_address_cmd
,
10278 "show ip bgp flap-statistics A.B.C.D",
10282 "Display flap statistics of routes\n"
10283 "Network in the BGP routing table to display\n")
10285 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10286 bgp_show_type_flap_address
);
10289 DEFUN (show_ip_bgp_flap_prefix
,
10290 show_ip_bgp_flap_prefix_cmd
,
10291 "show ip bgp flap-statistics A.B.C.D/M",
10295 "Display flap statistics of routes\n"
10296 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10298 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10299 bgp_show_type_flap_prefix
);
10302 DEFUN (show_bgp_prefix_longer
,
10303 show_bgp_prefix_longer_cmd
,
10304 "show bgp X:X::X:X/M longer-prefixes",
10307 "IPv6 prefix <network>/<length>\n"
10308 "Display route and more specific routes\n")
10310 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
10311 bgp_show_type_prefix_longer
);
10314 ALIAS (show_bgp_prefix_longer
,
10315 show_bgp_ipv6_prefix_longer_cmd
,
10316 "show bgp ipv6 X:X::X:X/M longer-prefixes",
10320 "IPv6 prefix <network>/<length>\n"
10321 "Display route and more specific routes\n")
10324 DEFUN (show_ipv6_bgp_prefix_longer
,
10325 show_ipv6_bgp_prefix_longer_cmd
,
10326 "show ipv6 bgp X:X::X:X/M longer-prefixes",
10330 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
10331 "Display route and more specific routes\n")
10333 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10334 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
10335 bgp_show_type_prefix_longer
);
10339 DEFUN (show_ipv6_mbgp_prefix_longer
,
10340 show_ipv6_mbgp_prefix_longer_cmd
,
10341 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
10345 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
10346 "Display route and more specific routes\n")
10348 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10349 return bgp_show_prefix_longer (vty
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
10350 bgp_show_type_prefix_longer
);
10352 #endif /* HAVE_IPV6 */
10354 static struct peer
*
10355 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
10356 const char *ip_str
, u_char use_json
)
10361 union sockunion su
;
10363 /* BGP structure lookup. */
10366 bgp
= bgp_lookup_by_name (view_name
);
10371 json_object
*json_no
= NULL
;
10372 json_no
= json_object_new_object();
10373 json_object_string_add(json_no
, "warning", "Can't find BGP view");
10374 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10375 json_object_free(json_no
);
10378 vty_out (vty
, "Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
10384 bgp
= bgp_get_default ();
10389 json_object
*json_no
= NULL
;
10390 json_no
= json_object_new_object();
10391 json_object_string_add(json_no
, "warning", "No BGP process configured");
10392 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10393 json_object_free(json_no
);
10396 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10401 /* Get peer sockunion. */
10402 ret
= str2sockunion (ip_str
, &su
);
10405 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
10408 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
10414 json_object
*json_no
= NULL
;
10415 json_no
= json_object_new_object();
10416 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
10417 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10418 json_object_free(json_no
);
10421 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
10428 /* Peer structure lookup. */
10429 peer
= peer_lookup (bgp
, &su
);
10434 json_object
*json_no
= NULL
;
10435 json_no
= json_object_new_object();
10436 json_object_string_add(json_no
, "warning","No such neighbor");
10437 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10438 json_object_free(json_no
);
10441 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
10450 BGP_STATS_MAXBITLEN
= 0,
10452 BGP_STATS_PREFIXES
,
10454 BGP_STATS_UNAGGREGATEABLE
,
10455 BGP_STATS_MAX_AGGREGATEABLE
,
10456 BGP_STATS_AGGREGATES
,
10458 BGP_STATS_ASPATH_COUNT
,
10459 BGP_STATS_ASPATH_MAXHOPS
,
10460 BGP_STATS_ASPATH_TOTHOPS
,
10461 BGP_STATS_ASPATH_MAXSIZE
,
10462 BGP_STATS_ASPATH_TOTSIZE
,
10463 BGP_STATS_ASN_HIGHEST
,
10467 static const char *table_stats_strs
[] =
10469 [BGP_STATS_PREFIXES
] = "Total Prefixes",
10470 [BGP_STATS_TOTPLEN
] = "Average prefix length",
10471 [BGP_STATS_RIB
] = "Total Advertisements",
10472 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
10473 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
10474 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
10475 [BGP_STATS_SPACE
] = "Address space advertised",
10476 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
10477 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
10478 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
10479 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
10480 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
10481 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
10482 [BGP_STATS_MAX
] = NULL
,
10485 struct bgp_table_stats
10487 struct bgp_table
*table
;
10488 unsigned long long counts
[BGP_STATS_MAX
];
10492 #define TALLY_SIGFIG 100000
10493 static unsigned long
10494 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
10496 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
10497 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
10498 unsigned long ret
= newtot
/ count
;
10500 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
10508 bgp_table_stats_walker (struct thread
*t
)
10510 struct bgp_node
*rn
;
10511 struct bgp_node
*top
;
10512 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
10513 unsigned int space
= 0;
10515 if (!(top
= bgp_table_top (ts
->table
)))
10518 switch (top
->p
.family
)
10521 space
= IPV4_MAX_BITLEN
;
10524 space
= IPV6_MAX_BITLEN
;
10528 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
10530 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
10532 struct bgp_info
*ri
;
10533 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
10534 unsigned int rinum
= 0;
10542 ts
->counts
[BGP_STATS_PREFIXES
]++;
10543 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
10546 ts
->counts
[BGP_STATS_AVGPLEN
]
10547 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
10548 ts
->counts
[BGP_STATS_AVGPLEN
],
10552 /* check if the prefix is included by any other announcements */
10553 while (prn
&& !prn
->info
)
10554 prn
= bgp_node_parent_nolock (prn
);
10556 if (prn
== NULL
|| prn
== top
)
10558 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
10559 /* announced address space */
10561 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
10563 else if (prn
->info
)
10564 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
10566 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
10569 ts
->counts
[BGP_STATS_RIB
]++;
10572 (CHECK_FLAG (ri
->attr
->flag
,
10573 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
10574 ts
->counts
[BGP_STATS_AGGREGATES
]++;
10576 /* as-path stats */
10577 if (ri
->attr
&& ri
->attr
->aspath
)
10579 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
10580 unsigned int size
= aspath_size (ri
->attr
->aspath
);
10581 as_t highest
= aspath_highest (ri
->attr
->aspath
);
10583 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
10585 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
10586 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
10588 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
10589 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
10591 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
10592 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
10594 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
10595 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
10596 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
10598 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
10599 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
10600 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
10603 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
10604 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
10612 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
10614 struct bgp_table_stats ts
;
10617 if (!bgp
->rib
[afi
][safi
])
10619 vty_out (vty
, "%% No RIB exist for the AFI/SAFI%s", VTY_NEWLINE
);
10620 return CMD_WARNING
;
10623 memset (&ts
, 0, sizeof (ts
));
10624 ts
.table
= bgp
->rib
[afi
][safi
];
10625 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
10627 vty_out (vty
, "BGP %s RIB statistics%s%s",
10628 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
10630 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
10632 if (!table_stats_strs
[i
])
10638 case BGP_STATS_ASPATH_AVGHOPS
:
10639 case BGP_STATS_ASPATH_AVGSIZE
:
10640 case BGP_STATS_AVGPLEN
:
10641 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
10642 vty_out (vty
, "%12.2f",
10643 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
10646 case BGP_STATS_ASPATH_TOTHOPS
:
10647 case BGP_STATS_ASPATH_TOTSIZE
:
10648 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
10649 vty_out (vty
, "%12.2f",
10651 (float)ts
.counts
[i
] /
10652 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
10655 case BGP_STATS_TOTPLEN
:
10656 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
10657 vty_out (vty
, "%12.2f",
10659 (float)ts
.counts
[i
] /
10660 (float)ts
.counts
[BGP_STATS_PREFIXES
]
10663 case BGP_STATS_SPACE
:
10664 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
10665 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
10666 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
10668 vty_out (vty
, "%30s: ", "%% announced ");
10669 vty_out (vty
, "%12.2f%s",
10670 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
10671 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
10673 vty_out (vty
, "%30s: ", "/8 equivalent ");
10674 vty_out (vty
, "%12.2f%s",
10675 (float)ts
.counts
[BGP_STATS_SPACE
] /
10676 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
10678 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
10680 vty_out (vty
, "%30s: ", "/24 equivalent ");
10681 vty_out (vty
, "%12.2f",
10682 (float)ts
.counts
[BGP_STATS_SPACE
] /
10683 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
10686 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
10687 vty_out (vty
, "%12llu", ts
.counts
[i
]);
10690 vty_out (vty
, "%s", VTY_NEWLINE
);
10692 return CMD_SUCCESS
;
10696 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
10697 const char *afi_str
, const char *safi_str
)
10704 bgp
= bgp_lookup_by_name (name
);
10706 bgp
= bgp_get_default ();
10710 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
10711 return CMD_WARNING
;
10713 if (strncmp (afi_str
, "ipv", 3) == 0)
10715 if (strncmp (afi_str
, "ipv4", 4) == 0)
10717 else if (strncmp (afi_str
, "ipv6", 4) == 0)
10721 vty_out (vty
, "%% Invalid address family %s%s",
10722 afi_str
, VTY_NEWLINE
);
10723 return CMD_WARNING
;
10725 if (strncmp (safi_str
, "m", 1) == 0)
10726 safi
= SAFI_MULTICAST
;
10727 else if (strncmp (safi_str
, "u", 1) == 0)
10728 safi
= SAFI_UNICAST
;
10729 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
10730 safi
= SAFI_MPLS_LABELED_VPN
;
10733 vty_out (vty
, "%% Invalid subsequent address family %s%s",
10734 safi_str
, VTY_NEWLINE
);
10735 return CMD_WARNING
;
10740 vty_out (vty
, "%% Invalid address family %s%s",
10741 afi_str
, VTY_NEWLINE
);
10742 return CMD_WARNING
;
10745 return bgp_table_stats (vty
, bgp
, afi
, safi
);
10748 DEFUN (show_bgp_statistics
,
10749 show_bgp_statistics_cmd
,
10750 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
10755 "Address Family modifier\n"
10756 "Address Family modifier\n"
10757 "BGP RIB advertisement statistics\n")
10759 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
10762 ALIAS (show_bgp_statistics
,
10763 show_bgp_statistics_vpnv4_cmd
,
10764 "show bgp (ipv4) (vpnv4) statistics",
10768 "Address Family modifier\n"
10769 "BGP RIB advertisement statistics\n")
10771 DEFUN (show_bgp_statistics_view
,
10772 show_bgp_statistics_view_cmd
,
10773 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) statistics",
10779 "Address Family modifier\n"
10780 "Address Family modifier\n"
10781 "BGP RIB advertisement statistics\n")
10783 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
10786 ALIAS (show_bgp_statistics_view
,
10787 show_bgp_statistics_view_vpnv4_cmd
,
10788 "show bgp view WORD (ipv4) (vpnv4) statistics",
10793 "Address Family modifier\n"
10794 "BGP RIB advertisement statistics\n")
10806 PCOUNT_PFCNT
, /* the figure we display to users */
10810 static const char *pcount_strs
[] =
10812 [PCOUNT_ADJ_IN
] = "Adj-in",
10813 [PCOUNT_DAMPED
] = "Damped",
10814 [PCOUNT_REMOVED
] = "Removed",
10815 [PCOUNT_HISTORY
] = "History",
10816 [PCOUNT_STALE
] = "Stale",
10817 [PCOUNT_VALID
] = "Valid",
10818 [PCOUNT_ALL
] = "All RIB",
10819 [PCOUNT_COUNTED
] = "PfxCt counted",
10820 [PCOUNT_PFCNT
] = "Useable",
10821 [PCOUNT_MAX
] = NULL
,
10824 struct peer_pcounts
10826 unsigned int count
[PCOUNT_MAX
];
10827 const struct peer
*peer
;
10828 const struct bgp_table
*table
;
10832 bgp_peer_count_walker (struct thread
*t
)
10834 struct bgp_node
*rn
;
10835 struct peer_pcounts
*pc
= THREAD_ARG (t
);
10836 const struct peer
*peer
= pc
->peer
;
10838 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
10840 struct bgp_adj_in
*ain
;
10841 struct bgp_info
*ri
;
10843 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
10844 if (ain
->peer
== peer
)
10845 pc
->count
[PCOUNT_ADJ_IN
]++;
10847 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
10849 char buf
[SU_ADDRSTRLEN
];
10851 if (ri
->peer
!= peer
)
10854 pc
->count
[PCOUNT_ALL
]++;
10856 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
10857 pc
->count
[PCOUNT_DAMPED
]++;
10858 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
10859 pc
->count
[PCOUNT_HISTORY
]++;
10860 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
10861 pc
->count
[PCOUNT_REMOVED
]++;
10862 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
10863 pc
->count
[PCOUNT_STALE
]++;
10864 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
10865 pc
->count
[PCOUNT_VALID
]++;
10866 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
10867 pc
->count
[PCOUNT_PFCNT
]++;
10869 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
10871 pc
->count
[PCOUNT_COUNTED
]++;
10872 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
10873 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
10875 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
10876 buf
, SU_ADDRSTRLEN
),
10882 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
10883 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
10885 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
10886 buf
, SU_ADDRSTRLEN
),
10896 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
10898 struct peer_pcounts pcounts
= { .peer
= peer
};
10900 json_object
*json
= NULL
;
10901 json_object
*json_loop
= NULL
;
10905 json
= json_object_new_object();
10906 json_loop
= json_object_new_object();
10909 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
10910 || !peer
->bgp
->rib
[afi
][safi
])
10914 json_object_string_add(json
, "warning", "No such neighbor or address family");
10915 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
10916 json_object_free(json
);
10919 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
10921 return CMD_WARNING
;
10924 memset (&pcounts
, 0, sizeof(pcounts
));
10925 pcounts
.peer
= peer
;
10926 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
10928 /* in-place call via thread subsystem so as to record execution time
10929 * * stats for the thread-walk (i.e. ensure this can't be blamed on
10930 * * on just vty_read()).
10932 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
10936 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
10937 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
10938 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
10940 for (i
= 0; i
< PCOUNT_MAX
; i
++)
10941 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
10943 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
10945 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
10947 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
10948 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
10950 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
10951 json_object_free(json
);
10956 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
10958 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
10959 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
10964 vty_out (vty
, "Prefix counts for %s, %s%s",
10965 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
10968 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
10969 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
10970 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
10972 for (i
= 0; i
< PCOUNT_MAX
; i
++)
10973 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
10975 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
10977 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
10978 peer
->host
, VTY_NEWLINE
);
10979 vty_out (vty
, "Please report this bug, with the above command output%s",
10984 return CMD_SUCCESS
;
10987 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
10988 show_ip_bgp_neighbor_prefix_counts_cmd
,
10989 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
10993 "Detailed information on TCP and BGP neighbor connections\n"
10994 "Neighbor to display information about\n"
10995 "Neighbor to display information about\n"
10996 "Neighbor on bgp configured interface\n"
10997 "Display detailed prefix count information\n"
10998 "JavaScript Object Notation\n")
11001 u_char uj
= use_json(argc
, argv
);
11003 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11005 return CMD_WARNING
;
11007 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11010 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
11011 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
11012 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11016 "Detailed information on TCP and BGP neighbor connections\n"
11017 "Neighbor to display information about\n"
11018 "Neighbor to display information about\n"
11019 "Neighbor on bgp configured interface\n"
11020 "Display detailed prefix count information\n"
11021 "JavaScript Object Notation\n")
11024 u_char uj
= use_json(argc
, argv
);
11026 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11028 return CMD_WARNING
;
11030 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11033 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
11034 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
11035 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11040 "Address Family modifier\n"
11041 "Address Family modifier\n"
11042 "Detailed information on TCP and BGP neighbor connections\n"
11043 "Neighbor to display information about\n"
11044 "Neighbor to display information about\n"
11045 "Neighbor on bgp configured interface\n"
11046 "Display detailed prefix count information\n"
11047 "JavaScript Object Notation\n")
11050 u_char uj
= use_json(argc
, argv
);
11052 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11054 return CMD_WARNING
;
11056 if (strncmp (argv
[0], "m", 1) == 0)
11057 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, uj
);
11059 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11062 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
11063 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
11064 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11069 "Address Family modifier\n"
11070 "Address Family modifier\n"
11071 "Detailed information on TCP and BGP neighbor connections\n"
11072 "Neighbor to display information about\n"
11073 "Neighbor to display information about\n"
11074 "Neighbor on bgp configured interface\n"
11075 "Display detailed prefix count information\n"
11076 "JavaScript Object Notation\n")
11079 u_char uj
= use_json(argc
, argv
);
11081 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11083 return CMD_WARNING
;
11085 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
, uj
);
11089 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
11090 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
11092 struct bgp_table
*table
;
11093 struct bgp_adj_in
*ain
;
11094 struct bgp_adj_out
*adj
;
11095 unsigned long output_count
;
11096 unsigned long filtered_count
;
11097 struct bgp_node
*rn
;
11102 struct attr_extra extra
;
11104 struct update_subgroup
*subgrp
;
11105 json_object
*json_scode
= NULL
;
11106 json_object
*json_ocode
= NULL
;
11107 json_object
*json_ar
= NULL
;
11108 struct peer_af
*paf
;
11112 json_scode
= json_object_new_object();
11113 json_ocode
= json_object_new_object();
11114 json_ar
= json_object_new_object();
11116 json_object_string_add(json_scode
, "suppressed", "s");
11117 json_object_string_add(json_scode
, "damped", "d");
11118 json_object_string_add(json_scode
, "history", "h");
11119 json_object_string_add(json_scode
, "valid", "*");
11120 json_object_string_add(json_scode
, "best", ">");
11121 json_object_string_add(json_scode
, "multipath", "=");
11122 json_object_string_add(json_scode
, "internal", "i");
11123 json_object_string_add(json_scode
, "ribFailure", "r");
11124 json_object_string_add(json_scode
, "stale", "S");
11125 json_object_string_add(json_scode
, "removed", "R");
11127 json_object_string_add(json_ocode
, "igp", "i");
11128 json_object_string_add(json_ocode
, "egp", "e");
11129 json_object_string_add(json_ocode
, "incomplete", "?");
11138 json_object_string_add(json
, "alert", "no BGP");
11139 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11140 json_object_free(json
);
11143 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
11147 table
= bgp
->rib
[afi
][safi
];
11149 output_count
= filtered_count
= 0;
11150 subgrp
= peer_subgroup(peer
, afi
, safi
);
11152 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11156 json_object_int_add(json
, "bgpTableVersion", table
->version
);
11157 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11158 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11159 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11160 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
11164 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11165 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11166 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11168 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
11169 VTY_NEWLINE
, VTY_NEWLINE
);
11174 attr
.extra
= &extra
;
11175 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
11179 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11181 if (ain
->peer
== peer
)
11187 json_object_int_add(json
, "bgpTableVersion", 0);
11188 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11189 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11190 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11194 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11195 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11196 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11203 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
11208 bgp_attr_dup(&attr
, ain
->attr
);
11209 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
11211 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
11222 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
11223 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
11224 if (paf
->peer
== peer
)
11230 json_object_int_add(json
, "bgpTableVersion", table
->version
);
11231 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11232 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11233 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11237 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
11238 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11239 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11240 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11248 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
11254 bgp_attr_dup(&attr
, adj
->attr
);
11255 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
11256 if (ret
!= RMAP_DENY
)
11258 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
11268 json_object_object_add(json
, "advertisedRoutes", json_ar
);
11270 if (output_count
!= 0)
11273 json_object_int_add(json
, "totalPrefixCounter", output_count
);
11275 vty_out (vty
, "%sTotal number of prefixes %ld%s",
11276 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
11280 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11281 json_object_free(json
);
11287 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
11288 int in
, const char *rmap_name
, u_char use_json
)
11290 json_object
*json
= NULL
;
11293 json
= json_object_new_object();
11295 if (!peer
|| !peer
->afc
[afi
][safi
])
11299 json_object_string_add(json
, "warning", "No such neighbor or address family");
11300 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11301 json_object_free(json
);
11304 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11306 return CMD_WARNING
;
11309 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11313 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
11314 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11315 json_object_free(json
);
11318 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
11320 return CMD_WARNING
;
11323 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
11325 return CMD_SUCCESS
;
11328 DEFUN (show_ip_bgp_view_neighbor_advertised_route
,
11329 show_ip_bgp_view_neighbor_advertised_route_cmd
,
11330 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11336 "Detailed information on TCP and BGP neighbor connections\n"
11337 "Neighbor to display information about\n"
11338 "Neighbor to display information about\n"
11339 "Display the routes advertised to a BGP neighbor\n"
11340 "JavaScript Object Notation\n")
11343 u_char uj
= use_json(argc
, argv
);
11345 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
11346 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1], uj
);
11348 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11351 return CMD_WARNING
;
11353 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
11356 DEFUN (show_ip_bgp_neighbor_advertised_route
,
11357 show_ip_bgp_neighbor_advertised_route_cmd
,
11358 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11362 "Detailed information on TCP and BGP neighbor connections\n"
11363 "Neighbor to display information about\n"
11364 "Neighbor to display information about\n"
11365 "Neighbor on bgp configured interface\n"
11366 "Display the routes advertised to a BGP neighbor\n"
11367 "JavaScript Object Notation\n")
11371 const char *rmap_name
= NULL
;
11372 u_char uj
= use_json(argc
, argv
);
11374 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11377 return CMD_WARNING
;
11379 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
11381 rmap_name
= argv
[1];
11383 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
11386 ALIAS (show_ip_bgp_neighbor_advertised_route
,
11387 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
11388 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
11392 "Detailed information on TCP and BGP neighbor connections\n"
11393 "Neighbor to display information about\n"
11394 "Neighbor to display information about\n"
11395 "Neighbor on bgp configured interface\n"
11396 "Display the routes advertised to a BGP neighbor\n"
11397 "JavaScript Object Notation\n")
11399 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
11400 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
11401 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11406 "Address Family modifier\n"
11407 "Address Family modifier\n"
11408 "Detailed information on TCP and BGP neighbor connections\n"
11409 "Neighbor to display information about\n"
11410 "Neighbor to display information about\n"
11411 "Neighbor on bgp configured interface\n"
11412 "Display the routes advertised to a BGP neighbor\n"
11413 "JavaScript Object Notation\n")
11416 const char *rmap_name
= NULL
;
11417 u_char uj
= use_json(argc
, argv
);
11419 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11421 return CMD_WARNING
;
11423 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
11424 rmap_name
= argv
[2];
11426 if (strncmp (argv
[0], "m", 1) == 0)
11427 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0, rmap_name
, uj
);
11429 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
11432 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
11433 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
11434 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
11439 "Address Family modifier\n"
11440 "Address Family modifier\n"
11441 "Detailed information on TCP and BGP neighbor connections\n"
11442 "Neighbor to display information about\n"
11443 "Neighbor to display information about\n"
11444 "Neighbor on bgp configured interface\n"
11445 "Display the routes advertised to a BGP neighbor\n"
11446 "Route-map to control what is displayed\n"
11447 "JavaScript Object Notation\n")
11450 DEFUN (show_bgp_view_neighbor_advertised_route
,
11451 show_bgp_view_neighbor_advertised_route_cmd
,
11452 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11457 "Detailed information on TCP and BGP neighbor connections\n"
11458 "Neighbor to display information about\n"
11459 "Neighbor to display information about\n"
11460 "Neighbor on bgp configured interface\n"
11461 "Display the routes advertised to a BGP neighbor\n"
11462 "JavaScript Object Notation\n")
11465 u_char uj
= use_json(argc
, argv
);
11467 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
11468 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1], uj
);
11470 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11473 return CMD_WARNING
;
11475 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
11478 ALIAS (show_bgp_view_neighbor_advertised_route
,
11479 show_bgp_view_ipv6_neighbor_advertised_route_cmd
,
11480 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11486 "Detailed information on TCP and BGP neighbor connections\n"
11487 "Neighbor to display information about\n"
11488 "Neighbor to display information about\n"
11489 "Neighbor on bgp configured interface\n"
11490 "Display the routes advertised to a BGP neighbor\n"
11491 "JavaScript Object Notation\n")
11493 DEFUN (show_bgp_neighbor_advertised_route
,
11494 show_bgp_neighbor_advertised_route_cmd
,
11495 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11498 "Detailed information on TCP and BGP neighbor connections\n"
11499 "Neighbor to display information about\n"
11500 "Neighbor to display information about\n"
11501 "Neighbor on bgp configured interface\n"
11502 "Display the routes advertised to a BGP neighbor\n"
11503 "JavaScript Object Notation\n")
11507 const char *rmap_name
= NULL
;
11508 u_char uj
= use_json(argc
, argv
);
11510 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11513 return CMD_WARNING
;
11515 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
11516 rmap_name
= argv
[1];
11518 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
11521 ALIAS (show_bgp_neighbor_advertised_route
,
11522 show_bgp_ipv6_neighbor_advertised_route_cmd
,
11523 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11527 "Detailed information on TCP and BGP neighbor connections\n"
11528 "Neighbor to display information about\n"
11529 "Neighbor to display information about\n"
11530 "Neighbor on bgp configured interface\n"
11531 "Display the routes advertised to a BGP neighbor\n"
11532 "JavaScript Object Notation\n")
11535 ALIAS (show_bgp_neighbor_advertised_route
,
11536 ipv6_bgp_neighbor_advertised_route_cmd
,
11537 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11541 "Detailed information on TCP and BGP neighbor connections\n"
11542 "Neighbor to display information about\n"
11543 "Neighbor to display information about\n"
11544 "Neighbor on bgp configured interface\n"
11545 "Display the routes advertised to a BGP neighbor\n"
11546 "JavaScript Object Notation\n")
11549 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
11550 ipv6_mbgp_neighbor_advertised_route_cmd
,
11551 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11555 "Detailed information on TCP and BGP neighbor connections\n"
11556 "Neighbor to display information about\n"
11557 "Neighbor to display information about\n"
11558 "Neighbor on bgp configured interface\n"
11559 "Neighbor on bgp configured interface\n"
11560 "Display the routes advertised to a BGP neighbor\n"
11561 "JavaScript Object Notation\n")
11564 u_char uj
= use_json(argc
, argv
);
11566 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11568 return CMD_WARNING
;
11570 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11571 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
11573 #endif /* HAVE_IPV6 */
11575 DEFUN (show_bgp_view_neighbor_received_routes
,
11576 show_bgp_view_neighbor_received_routes_cmd
,
11577 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
11582 "Detailed information on TCP and BGP neighbor connections\n"
11583 "Neighbor to display information about\n"
11584 "Neighbor to display information about\n"
11585 "Neighbor on bgp configured interface\n"
11586 "Display the received routes from neighbor\n"
11587 "JavaScript Object Notation\n")
11590 u_char uj
= use_json(argc
, argv
);
11595 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1], uj
);
11597 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11602 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1], uj
);
11604 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11608 return CMD_WARNING
;
11610 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
11613 DEFUN (show_ip_bgp_view_neighbor_received_routes
,
11614 show_ip_bgp_view_neighbor_received_routes_cmd
,
11615 "show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
11621 "Detailed information on TCP and BGP neighbor connections\n"
11622 "Neighbor to display information about\n"
11623 "Neighbor to display information about\n"
11624 "Neighbor on bgp configured interface\n"
11625 "Display the received routes from neighbor\n"
11626 "JavaScript Object Notation\n")
11629 u_char uj
= use_json(argc
, argv
);
11631 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
11632 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1], uj
);
11634 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11637 return CMD_WARNING
;
11639 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
11642 ALIAS (show_bgp_view_neighbor_received_routes
,
11643 show_bgp_view_ipv6_neighbor_received_routes_cmd
,
11644 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
11650 "Detailed information on TCP and BGP neighbor connections\n"
11651 "Neighbor to display information about\n"
11652 "Neighbor to display information about\n"
11653 "Neighbor on bgp configured interface\n"
11654 "Display the received routes from neighbor\n"
11655 "JavaScript Object Notation\n")
11657 DEFUN (show_ip_bgp_neighbor_received_routes
,
11658 show_ip_bgp_neighbor_received_routes_cmd
,
11659 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
11663 "Detailed information on TCP and BGP neighbor connections\n"
11664 "Neighbor to display information about\n"
11665 "Neighbor to display information about\n"
11666 "Neighbor on bgp configured interface\n"
11667 "Display the received routes from neighbor\n"
11668 "JavaScript Object Notation\n")
11672 const char *rmap_name
= NULL
;
11673 u_char uj
= use_json(argc
, argv
);
11675 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11678 return CMD_WARNING
;
11680 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
11681 rmap_name
= argv
[1];
11683 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
11686 ALIAS (show_ip_bgp_neighbor_received_routes
,
11687 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
11688 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
11692 "Detailed information on TCP and BGP neighbor connections\n"
11693 "Neighbor to display information about\n"
11694 "Neighbor to display information about\n"
11695 "Neighbor on bgp configured interface\n"
11696 "Display the received routes from neighbor\n"
11697 "JavaScript Object Notation\n")
11699 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
11700 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
11701 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
11706 "Address Family modifier\n"
11707 "Address Family modifier\n"
11708 "Detailed information on TCP and BGP neighbor connections\n"
11709 "Neighbor to display information about\n"
11710 "Neighbor to display information about\n"
11711 "Neighbor on bgp configured interface\n"
11712 "Display the received routes from neighbor\n"
11713 "JavaScript Object Notation\n")
11716 const char *rmap_name
= NULL
;
11717 u_char uj
= use_json(argc
, argv
);
11719 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11721 return CMD_WARNING
;
11723 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
11724 rmap_name
= argv
[2];
11726 if (strncmp (argv
[0], "m", 1) == 0)
11727 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1, rmap_name
, uj
);
11729 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
11732 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
11733 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
11734 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
11739 "Address Family modifier\n"
11740 "Address Family modifier\n"
11741 "Detailed information on TCP and BGP neighbor connections\n"
11742 "Neighbor to display information about\n"
11743 "Neighbor to display information about\n"
11744 "Neighbor on bgp configured interface\n"
11745 "Display the received routes from neighbor\n"
11746 "JavaScript Object Notation\n")
11748 DEFUN (show_bgp_view_afi_safi_neighbor_adv_recd_routes
,
11749 show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
,
11751 "show bgp view WORD (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
11753 "show bgp view WORD ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
11763 "Address family modifier\n"
11764 "Address family modifier\n"
11765 "Detailed information on TCP and BGP neighbor connections\n"
11766 "Neighbor to display information about\n"
11767 "Neighbor to display information about\n"
11768 "Neighbor on bgp configured interface\n"
11769 "Display the advertised routes to neighbor\n"
11770 "Display the received routes from neighbor\n"
11771 "JavaScript Object Notation\n")
11777 u_char uj
= use_json(argc
, argv
);
11779 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[3], uj
);
11782 return CMD_WARNING
;
11784 afi
= (strncmp (argv
[1], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
11785 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
11786 in
= (strncmp (argv
[4], "r", 1) == 0) ? 1 : 0;
11788 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
11791 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
11792 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
11793 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
11797 "Detailed information on TCP and BGP neighbor connections\n"
11798 "Neighbor to display information about\n"
11799 "Neighbor to display information about\n"
11800 "Neighbor on bgp configured interface\n"
11801 "Display information received from a BGP neighbor\n"
11802 "Display the prefixlist filter\n"
11803 "JavaScript Object Notation\n")
11806 union sockunion su
;
11809 u_char uj
= use_json(argc
, argv
);
11811 ret
= str2sockunion (argv
[0], &su
);
11814 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
11819 json_object
*json_no
= NULL
;
11820 json_object
*json_sub
= NULL
;
11821 json_no
= json_object_new_object();
11822 json_sub
= json_object_new_object();
11823 json_object_string_add(json_no
, "warning", "Malformed address or name");
11824 json_object_string_add(json_sub
, "warningCause", argv
[0]);
11825 json_object_object_add(json_no
, "detail", json_sub
);
11826 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11827 json_object_free(json_no
);
11830 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
11831 return CMD_WARNING
;
11836 peer
= peer_lookup (NULL
, &su
);
11841 json_object
*json_no
= NULL
;
11842 json_no
= json_object_new_object();
11843 json_object_string_add(json_no
, "warning", "Peer not found");
11844 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11845 json_object_free(json_no
);
11848 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
11849 return CMD_WARNING
;
11853 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
11854 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
11858 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
11859 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
11865 json_object
*json_no
= NULL
;
11866 json_no
= json_object_new_object();
11867 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
11868 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11869 json_object_free(json_no
);
11872 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
11875 return CMD_SUCCESS
;
11878 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
11879 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
11880 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
11885 "Address Family modifier\n"
11886 "Address Family modifier\n"
11887 "Detailed information on TCP and BGP neighbor connections\n"
11888 "Neighbor to display information about\n"
11889 "Neighbor to display information about\n"
11890 "Neighbor on bgp configured interface\n"
11891 "Display information received from a BGP neighbor\n"
11892 "Display the prefixlist filter\n"
11893 "JavaScript Object Notation\n")
11896 union sockunion su
;
11899 u_char uj
= use_json(argc
, argv
);
11901 ret
= str2sockunion (argv
[1], &su
);
11904 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
11909 json_object
*json_no
= NULL
;
11910 json_object
*json_sub
= NULL
;
11911 json_no
= json_object_new_object();
11912 json_sub
= json_object_new_object();
11913 json_object_string_add(json_no
, "warning", "Malformed address or name");
11914 json_object_string_add(json_sub
, "warningCause", argv
[1]);
11915 json_object_object_add(json_no
, "detail", json_sub
);
11916 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11917 json_object_free(json_no
);
11920 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
11921 return CMD_WARNING
;
11926 peer
= peer_lookup (NULL
, &su
);
11931 json_object
*json_no
= NULL
;
11932 json_no
= json_object_new_object();
11933 json_object_string_add(json_no
, "warning", "Peer not found");
11934 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11935 json_object_free(json_no
);
11938 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
11939 return CMD_WARNING
;
11943 if (strncmp (argv
[0], "m", 1) == 0)
11945 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
11946 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
11950 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
11951 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
11957 json_object
*json_no
= NULL
;
11958 json_no
= json_object_new_object();
11959 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
11960 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11961 json_object_free(json_no
);
11964 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
11969 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
11970 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
11974 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
11975 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
11981 json_object
*json_no
= NULL
;
11982 json_no
= json_object_new_object();
11983 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
11984 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11985 json_object_free(json_no
);
11988 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
11992 return CMD_SUCCESS
;
11995 ALIAS (show_bgp_view_neighbor_received_routes
,
11996 show_bgp_neighbor_received_routes_cmd
,
11997 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12000 "Detailed information on TCP and BGP neighbor connections\n"
12001 "Neighbor to display information about\n"
12002 "Neighbor to display information about\n"
12003 "Neighbor on bgp configured interface\n"
12004 "Display the received routes from neighbor\n"
12005 "JavaScript Object Notation\n")
12007 ALIAS (show_bgp_view_neighbor_received_routes
,
12008 show_bgp_ipv6_neighbor_received_routes_cmd
,
12009 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12013 "Detailed information on TCP and BGP neighbor connections\n"
12014 "Neighbor to display information about\n"
12015 "Neighbor to display information about\n"
12016 "Neighbor on bgp configured interface\n"
12017 "Display the received routes from neighbor\n"
12018 "JavaScript Object Notation\n")
12020 DEFUN (show_bgp_neighbor_received_prefix_filter
,
12021 show_bgp_neighbor_received_prefix_filter_cmd
,
12022 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12025 "Detailed information on TCP and BGP neighbor connections\n"
12026 "Neighbor to display information about\n"
12027 "Neighbor to display information about\n"
12028 "Neighbor on bgp configured interface\n"
12029 "Display information received from a BGP neighbor\n"
12030 "Display the prefixlist filter\n"
12031 "JavaScript Object Notation\n")
12034 union sockunion su
;
12037 u_char uj
= use_json(argc
, argv
);
12039 ret
= str2sockunion (argv
[0], &su
);
12042 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12047 json_object
*json_no
= NULL
;
12048 json_object
*json_sub
= NULL
;
12049 json_no
= json_object_new_object();
12050 json_sub
= json_object_new_object();
12051 json_object_string_add(json_no
, "warning", "Malformed address or name");
12052 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12053 json_object_object_add(json_no
, "detail", json_sub
);
12054 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12055 json_object_free(json_no
);
12058 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12059 return CMD_WARNING
;
12064 peer
= peer_lookup (NULL
, &su
);
12069 json_object
*json_no
= NULL
;
12070 json_no
= json_object_new_object();
12071 json_object_string_add(json_no
, "warning", "No Peer");
12072 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12073 json_object_free(json_no
);
12076 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12077 return CMD_WARNING
;
12081 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
12082 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
12086 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
12087 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
12093 json_object
*json_no
= NULL
;
12094 json_no
= json_object_new_object();
12095 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12096 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12097 json_object_free(json_no
);
12100 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12103 return CMD_SUCCESS
;
12106 ALIAS (show_bgp_neighbor_received_prefix_filter
,
12107 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
12108 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12112 "Detailed information on TCP and BGP neighbor connections\n"
12113 "Neighbor to display information about\n"
12114 "Neighbor to display information about\n"
12115 "Neighbor on bgp configured interface\n"
12116 "Display information received from a BGP neighbor\n"
12117 "Display the prefixlist filter\n"
12118 "JavaScript Object Notation\n")
12121 ALIAS (show_bgp_view_neighbor_received_routes
,
12122 ipv6_bgp_neighbor_received_routes_cmd
,
12123 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12127 "Detailed information on TCP and BGP neighbor connections\n"
12128 "Neighbor to display information about\n"
12129 "Neighbor to display information about\n"
12130 "Neighbor on bgp configured interface\n"
12131 "Display the received routes from neighbor\n"
12132 "JavaScript Object Notation\n")
12135 DEFUN (ipv6_mbgp_neighbor_received_routes
,
12136 ipv6_mbgp_neighbor_received_routes_cmd
,
12137 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12141 "Detailed information on TCP and BGP neighbor connections\n"
12142 "Neighbor to display information about\n"
12143 "Neighbor to display information about\n"
12144 "Neighbor on bgp configured interface\n"
12145 "Display the received routes from neighbor\n"
12146 "JavaScript Object Notation\n")
12149 u_char uj
= use_json(argc
, argv
);
12151 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12153 return CMD_WARNING
;
12155 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12156 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
12159 DEFUN (show_bgp_view_neighbor_received_prefix_filter
,
12160 show_bgp_view_neighbor_received_prefix_filter_cmd
,
12161 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12166 "Detailed information on TCP and BGP neighbor connections\n"
12167 "Neighbor to display information about\n"
12168 "Neighbor to display information about\n"
12169 "Neighbor on bgp configured interface\n"
12170 "Display information received from a BGP neighbor\n"
12171 "Display the prefixlist filter\n"
12172 "JavaScript Object Notation\n")
12175 union sockunion su
;
12179 u_char uj
= use_json(argc
, argv
);
12181 /* BGP structure lookup. */
12182 bgp
= bgp_lookup_by_name (argv
[0]);
12187 json_object
*json_no
= NULL
;
12188 json_no
= json_object_new_object();
12189 json_object_string_add(json_no
, "warning", "Can't find BGP view");
12190 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12191 json_object_free(json_no
);
12194 vty_out (vty
, "Can't find BGP view %s%s", argv
[0], VTY_NEWLINE
);
12195 return CMD_WARNING
;
12198 ret
= str2sockunion (argv
[1], &su
);
12201 peer
= peer_lookup_by_conf_if (bgp
, argv
[1]);
12206 json_object
*json_no
= NULL
;
12207 json_object
*json_sub
= NULL
;
12208 json_no
= json_object_new_object();
12209 json_sub
= json_object_new_object();
12210 json_object_string_add(json_no
, "warning", "Malformed address or name");
12211 json_object_string_add(json_sub
, "warningCause", argv
[1]);
12212 json_object_object_add(json_no
, "detail", json_sub
);
12213 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12214 json_object_free(json_no
);
12217 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
12218 return CMD_WARNING
;
12223 peer
= peer_lookup (bgp
, &su
);
12228 json_object
*json_no
= NULL
;
12229 json_no
= json_object_new_object();
12230 json_object_boolean_true_add(json_no
, "noPeer");
12231 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12232 json_object_free(json_no
);
12235 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12236 return CMD_WARNING
;
12241 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
12242 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
12246 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
12247 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
12250 return CMD_SUCCESS
;
12252 ALIAS (show_bgp_view_neighbor_received_prefix_filter
,
12253 show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
,
12254 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12260 "Detailed information on TCP and BGP neighbor connections\n"
12261 "Neighbor to display information about\n"
12262 "Neighbor to display information about\n"
12263 "Neighbor on bgp configured interface\n"
12264 "Display information received from a BGP neighbor\n"
12265 "Display the prefixlist filter\n"
12266 "JavaScript Object NOtation\n")
12267 #endif /* HAVE_IPV6 */
12270 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
12271 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
12273 if (! peer
|| ! peer
->afc
[afi
][safi
])
12277 json_object
*json_no
= NULL
;
12278 json_no
= json_object_new_object();
12279 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
12280 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12281 json_object_free(json_no
);
12284 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12285 return CMD_WARNING
;
12288 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
12291 DEFUN (show_ip_bgp_neighbor_routes
,
12292 show_ip_bgp_neighbor_routes_cmd
,
12293 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12297 "Detailed information on TCP and BGP neighbor connections\n"
12298 "Neighbor to display information about\n"
12299 "Neighbor to display information about\n"
12300 "Neighbor on bgp configured interface\n"
12301 "Display routes learned from neighbor\n"
12302 "JavaScript Object Notation\n")
12305 u_char uj
= use_json(argc
, argv
);
12307 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12309 return CMD_WARNING
;
12311 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12312 bgp_show_type_neighbor
, uj
);
12315 DEFUN (show_ip_bgp_neighbor_flap
,
12316 show_ip_bgp_neighbor_flap_cmd
,
12317 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
12321 "Detailed information on TCP and BGP neighbor connections\n"
12322 "Neighbor to display information about\n"
12323 "Neighbor to display information about\n"
12324 "Neighbor on bgp configured interface\n"
12325 "Display flap statistics of the routes learned from neighbor\n"
12326 "JavaScript Object Notation\n")
12329 u_char uj
= use_json(argc
, argv
);
12331 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12333 return CMD_WARNING
;
12335 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12336 bgp_show_type_flap_neighbor
, uj
);
12339 DEFUN (show_ip_bgp_neighbor_damp
,
12340 show_ip_bgp_neighbor_damp_cmd
,
12341 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
12345 "Detailed information on TCP and BGP neighbor connections\n"
12346 "Neighbor to display information about\n"
12347 "Neighbor to display information about\n"
12348 "Neighbor on bgp configured interface\n"
12349 "Display the dampened routes received from neighbor\n"
12350 "JavaScript Object Notation\n")
12353 u_char uj
= use_json(argc
, argv
);
12355 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12357 return CMD_WARNING
;
12359 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12360 bgp_show_type_damp_neighbor
, uj
);
12363 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
12364 show_ip_bgp_ipv4_neighbor_routes_cmd
,
12365 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12370 "Address Family modifier\n"
12371 "Address Family modifier\n"
12372 "Detailed information on TCP and BGP neighbor connections\n"
12373 "Neighbor to display information about\n"
12374 "Neighbor to display information about\n"
12375 "Neighbor on bgp configured interface\n"
12376 "Display routes learned from neighbor\n"
12377 "JavaScript Object Notation\n")
12380 u_char uj
= use_json(argc
, argv
);
12382 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12384 return CMD_WARNING
;
12386 if (strncmp (argv
[0], "m", 1) == 0)
12387 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
12388 bgp_show_type_neighbor
, uj
);
12390 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12391 bgp_show_type_neighbor
, uj
);
12395 DEFUN (show_bgp_view_neighbor_routes
,
12396 show_bgp_view_neighbor_routes_cmd
,
12397 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12402 "Detailed information on TCP and BGP neighbor connections\n"
12403 "Neighbor to display information about\n"
12404 "Neighbor to display information about\n"
12405 "Neighbor on bgp configured interface\n"
12406 "Display routes learned from neighbor\n"
12407 "JavaScript Object Notation\n")
12410 u_char uj
= use_json(argc
, argv
);
12412 if ((argc
== 3 && argv
[2] && strcmp(argv
[2], "json") == 0)
12413 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12414 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1], uj
);
12416 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12419 return CMD_WARNING
;
12421 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
12422 bgp_show_type_neighbor
, uj
);
12425 ALIAS (show_bgp_view_neighbor_routes
,
12426 show_bgp_view_ipv6_neighbor_routes_cmd
,
12427 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12433 "Detailed information on TCP and BGP neighbor connections\n"
12434 "Neighbor to display information about\n"
12435 "Neighbor to display information about\n"
12436 "Neighbor on bgp configured interface\n"
12437 "Display routes learned from neighbor\n"
12438 "JavaScript Object Notation\n")
12440 DEFUN (show_bgp_view_neighbor_damp
,
12441 show_bgp_view_neighbor_damp_cmd
,
12442 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
12447 "Detailed information on TCP and BGP neighbor connections\n"
12448 "Neighbor to display information about\n"
12449 "Neighbor to display information about\n"
12450 "Neighbor on bgp configured interface\n"
12451 "Display the dampened routes received from neighbor\n"
12452 "JavaScript Object Notation\n")
12455 u_char uj
= use_json(argc
, argv
);
12457 if ((argc
== 3 && argv
[2] && strcmp(argv
[2], "json") == 0)
12458 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12459 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1], uj
);
12461 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12464 return CMD_WARNING
;
12466 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
12467 bgp_show_type_damp_neighbor
, uj
);
12470 ALIAS (show_bgp_view_neighbor_damp
,
12471 show_bgp_view_ipv6_neighbor_damp_cmd
,
12472 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
12478 "Detailed information on TCP and BGP neighbor connections\n"
12479 "Neighbor to display information about\n"
12480 "Neighbor to display information about\n"
12481 "Neighbor on bgp configured interface\n"
12482 "Display the dampened routes received from neighbor\n"
12483 "JavaScript Object Notation\n")
12485 DEFUN (show_bgp_view_neighbor_flap
,
12486 show_bgp_view_neighbor_flap_cmd
,
12487 "show bgp view WORD neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
12492 "Detailed information on TCP and BGP neighbor connections\n"
12493 "Neighbor to display information about\n"
12494 "Neighbor to display information about\n"
12495 "Neighbor on bgp configured interface\n"
12496 "Display flap statistics of the routes learned from neighbor\n"
12497 "JavaScript Object Notation\n")
12500 u_char uj
= use_json(argc
, argv
);
12502 if ((argc
== 3 && argv
[2] && strcmp(argv
[2], "json") == 0)
12503 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12504 peer
= peer_lookup_in_view (vty
, argv
[0], argv
[1], uj
);
12506 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12509 return CMD_WARNING
;
12511 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
12512 bgp_show_type_flap_neighbor
, uj
);
12515 ALIAS (show_bgp_view_neighbor_flap
,
12516 show_bgp_view_ipv6_neighbor_flap_cmd
,
12517 "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
12523 "Detailed information on TCP and BGP neighbor connections\n"
12524 "Neighbor to display information about\n"
12525 "Neighbor to display information about\n"
12526 "Neighbor on bgp configured interface\n"
12527 "Display flap statistics of the routes learned from neighbor\n"
12528 "JavaScript Object Notation\n")
12530 ALIAS (show_bgp_view_neighbor_routes
,
12531 show_bgp_neighbor_routes_cmd
,
12532 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12535 "Detailed information on TCP and BGP neighbor connections\n"
12536 "Neighbor to display information about\n"
12537 "Neighbor to display information about\n"
12538 "Neighbor on bgp configured interface\n"
12539 "Display routes learned from neighbor\n"
12540 "JavaScript Object Notation\n")
12543 ALIAS (show_bgp_view_neighbor_routes
,
12544 show_bgp_ipv6_neighbor_routes_cmd
,
12545 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12549 "Detailed information on TCP and BGP neighbor connections\n"
12550 "Neighbor to display information about\n"
12551 "Neighbor to display information about\n"
12552 "Neighbor on bgp configured interface\n"
12553 "Display routes learned from neighbor\n"
12554 "JavaScript Object Notation\n")
12557 ALIAS (show_bgp_view_neighbor_routes
,
12558 ipv6_bgp_neighbor_routes_cmd
,
12559 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12563 "Detailed information on TCP and BGP neighbor connections\n"
12564 "Neighbor to display information about\n"
12565 "Neighbor to display information about\n"
12566 "Neighbor on bgp configured interface\n"
12567 "Display routes learned from neighbor\n"
12568 "JavaScript Object Notation\n")
12571 DEFUN (ipv6_mbgp_neighbor_routes
,
12572 ipv6_mbgp_neighbor_routes_cmd
,
12573 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12577 "Detailed information on TCP and BGP neighbor connections\n"
12578 "Neighbor to display information about\n"
12579 "Neighbor to display information about\n"
12580 "Neighbor on bgp configured interface\n"
12581 "Display routes learned from neighbor\n"
12582 "JavaScript Object Notation\n")
12585 u_char uj
= use_json(argc
, argv
);
12587 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12589 return CMD_WARNING
;
12591 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12592 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
12593 bgp_show_type_neighbor
, uj
);
12596 ALIAS (show_bgp_view_neighbor_flap
,
12597 show_bgp_neighbor_flap_cmd
,
12598 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
12601 "Detailed information on TCP and BGP neighbor connections\n"
12602 "Neighbor to display information about\n"
12603 "Neighbor to display information about\n"
12604 "Neighbor on bgp configured interface\n"
12605 "Display flap statistics of the routes learned from neighbor\n"
12606 "JavaScript Object Notation\n")
12608 ALIAS (show_bgp_view_neighbor_flap
,
12609 show_bgp_ipv6_neighbor_flap_cmd
,
12610 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
12614 "Detailed information on TCP and BGP neighbor connections\n"
12615 "Neighbor to display information about\n"
12616 "Neighbor to display information about\n"
12617 "Neighbor on bgp configured interface\n"
12618 "Display flap statistics of the routes learned from neighbor\n"
12619 "JavaScript Object Notation\n")
12621 ALIAS (show_bgp_view_neighbor_damp
,
12622 show_bgp_neighbor_damp_cmd
,
12623 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
12626 "Detailed information on TCP and BGP neighbor connections\n"
12627 "Neighbor to display information about\n"
12628 "Neighbor to display information about\n"
12629 "Neighbor on bgp configured interface\n"
12630 "Display the dampened routes received from neighbor\n"
12631 "JavaScript Object Notation\n")
12633 ALIAS (show_bgp_view_neighbor_damp
,
12634 show_bgp_ipv6_neighbor_damp_cmd
,
12635 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
12639 "Detailed information on TCP and BGP neighbor connections\n"
12640 "Neighbor to display information about\n"
12641 "Neighbor to display information about\n"
12642 "Neighbor on bgp configured interface\n"
12643 "Display the dampened routes received from neighbor\n"
12644 "JavaScript Object Notation\n")
12646 #endif /* HAVE_IPV6 */
12648 struct bgp_table
*bgp_distance_table
;
12650 struct bgp_distance
12652 /* Distance value for the IP source prefix. */
12655 /* Name of the access-list to be matched. */
12659 static struct bgp_distance
*
12660 bgp_distance_new (void)
12662 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
12666 bgp_distance_free (struct bgp_distance
*bdistance
)
12668 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
12672 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
12673 const char *ip_str
, const char *access_list_str
)
12676 struct prefix_ipv4 p
;
12678 struct bgp_node
*rn
;
12679 struct bgp_distance
*bdistance
;
12681 ret
= str2prefix_ipv4 (ip_str
, &p
);
12684 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
12685 return CMD_WARNING
;
12688 distance
= atoi (distance_str
);
12690 /* Get BGP distance node. */
12691 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
12694 bdistance
= rn
->info
;
12695 bgp_unlock_node (rn
);
12699 bdistance
= bgp_distance_new ();
12700 rn
->info
= bdistance
;
12703 /* Set distance value. */
12704 bdistance
->distance
= distance
;
12706 /* Reset access-list configuration. */
12707 if (bdistance
->access_list
)
12709 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
12710 bdistance
->access_list
= NULL
;
12712 if (access_list_str
)
12713 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
12715 return CMD_SUCCESS
;
12719 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
12720 const char *ip_str
, const char *access_list_str
)
12723 struct prefix_ipv4 p
;
12724 struct bgp_node
*rn
;
12725 struct bgp_distance
*bdistance
;
12727 ret
= str2prefix_ipv4 (ip_str
, &p
);
12730 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
12731 return CMD_WARNING
;
12734 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
12737 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
12738 return CMD_WARNING
;
12741 bdistance
= rn
->info
;
12743 if (bdistance
->access_list
)
12744 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
12745 bgp_distance_free (bdistance
);
12748 bgp_unlock_node (rn
);
12749 bgp_unlock_node (rn
);
12751 return CMD_SUCCESS
;
12754 /* Apply BGP information to distance method. */
12756 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
12758 struct bgp_node
*rn
;
12759 struct prefix_ipv4 q
;
12761 struct bgp_distance
*bdistance
;
12762 struct access_list
*alist
;
12763 struct bgp_static
*bgp_static
;
12768 if (p
->family
!= AF_INET
)
12771 peer
= rinfo
->peer
;
12773 if (peer
->su
.sa
.sa_family
!= AF_INET
)
12776 memset (&q
, 0, sizeof (struct prefix_ipv4
));
12777 q
.family
= AF_INET
;
12778 q
.prefix
= peer
->su
.sin
.sin_addr
;
12779 q
.prefixlen
= IPV4_MAX_BITLEN
;
12781 /* Check source address. */
12782 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
12785 bdistance
= rn
->info
;
12786 bgp_unlock_node (rn
);
12788 if (bdistance
->access_list
)
12790 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
12791 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
12792 return bdistance
->distance
;
12795 return bdistance
->distance
;
12798 /* Backdoor check. */
12799 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
12802 bgp_static
= rn
->info
;
12803 bgp_unlock_node (rn
);
12805 if (bgp_static
->backdoor
)
12807 if (bgp
->distance_local
)
12808 return bgp
->distance_local
;
12810 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
12814 if (peer
->sort
== BGP_PEER_EBGP
)
12816 if (bgp
->distance_ebgp
)
12817 return bgp
->distance_ebgp
;
12818 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
12822 if (bgp
->distance_ibgp
)
12823 return bgp
->distance_ibgp
;
12824 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
12828 DEFUN (bgp_distance
,
12830 "distance bgp <1-255> <1-255> <1-255>",
12831 "Define an administrative distance\n"
12833 "Distance for routes external to the AS\n"
12834 "Distance for routes internal to the AS\n"
12835 "Distance for local routes\n")
12841 bgp
->distance_ebgp
= atoi (argv
[0]);
12842 bgp
->distance_ibgp
= atoi (argv
[1]);
12843 bgp
->distance_local
= atoi (argv
[2]);
12844 return CMD_SUCCESS
;
12847 DEFUN (no_bgp_distance
,
12848 no_bgp_distance_cmd
,
12849 "no distance bgp <1-255> <1-255> <1-255>",
12851 "Define an administrative distance\n"
12853 "Distance for routes external to the AS\n"
12854 "Distance for routes internal to the AS\n"
12855 "Distance for local routes\n")
12861 bgp
->distance_ebgp
= 0;
12862 bgp
->distance_ibgp
= 0;
12863 bgp
->distance_local
= 0;
12864 return CMD_SUCCESS
;
12867 ALIAS (no_bgp_distance
,
12868 no_bgp_distance2_cmd
,
12871 "Define an administrative distance\n"
12874 DEFUN (bgp_distance_source
,
12875 bgp_distance_source_cmd
,
12876 "distance <1-255> A.B.C.D/M",
12877 "Define an administrative distance\n"
12878 "Administrative distance\n"
12879 "IP source prefix\n")
12881 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
12882 return CMD_SUCCESS
;
12885 DEFUN (no_bgp_distance_source
,
12886 no_bgp_distance_source_cmd
,
12887 "no distance <1-255> A.B.C.D/M",
12889 "Define an administrative distance\n"
12890 "Administrative distance\n"
12891 "IP source prefix\n")
12893 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
12894 return CMD_SUCCESS
;
12897 DEFUN (bgp_distance_source_access_list
,
12898 bgp_distance_source_access_list_cmd
,
12899 "distance <1-255> A.B.C.D/M WORD",
12900 "Define an administrative distance\n"
12901 "Administrative distance\n"
12902 "IP source prefix\n"
12903 "Access list name\n")
12905 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
12906 return CMD_SUCCESS
;
12909 DEFUN (no_bgp_distance_source_access_list
,
12910 no_bgp_distance_source_access_list_cmd
,
12911 "no distance <1-255> A.B.C.D/M WORD",
12913 "Define an administrative distance\n"
12914 "Administrative distance\n"
12915 "IP source prefix\n"
12916 "Access list name\n")
12918 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
12919 return CMD_SUCCESS
;
12922 DEFUN (bgp_damp_set
,
12924 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
12925 "BGP Specific commands\n"
12926 "Enable route-flap dampening\n"
12927 "Half-life time for the penalty\n"
12928 "Value to start reusing a route\n"
12929 "Value to start suppressing a route\n"
12930 "Maximum duration to suppress a stable route\n")
12933 int half
= DEFAULT_HALF_LIFE
* 60;
12934 int reuse
= DEFAULT_REUSE
;
12935 int suppress
= DEFAULT_SUPPRESS
;
12936 int max
= 4 * half
;
12940 half
= atoi (argv
[0]) * 60;
12941 reuse
= atoi (argv
[1]);
12942 suppress
= atoi (argv
[2]);
12943 max
= atoi (argv
[3]) * 60;
12945 else if (argc
== 1)
12947 half
= atoi (argv
[0]) * 60;
12952 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
12953 half
, reuse
, suppress
, max
);
12956 ALIAS (bgp_damp_set
,
12958 "bgp dampening <1-45>",
12959 "BGP Specific commands\n"
12960 "Enable route-flap dampening\n"
12961 "Half-life time for the penalty\n")
12963 ALIAS (bgp_damp_set
,
12966 "BGP Specific commands\n"
12967 "Enable route-flap dampening\n")
12969 DEFUN (bgp_damp_unset
,
12970 bgp_damp_unset_cmd
,
12971 "no bgp dampening",
12973 "BGP Specific commands\n"
12974 "Enable route-flap dampening\n")
12979 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
12982 ALIAS (bgp_damp_unset
,
12983 bgp_damp_unset2_cmd
,
12984 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
12986 "BGP Specific commands\n"
12987 "Enable route-flap dampening\n"
12988 "Half-life time for the penalty\n"
12989 "Value to start reusing a route\n"
12990 "Value to start suppressing a route\n"
12991 "Maximum duration to suppress a stable route\n")
12993 DEFUN (show_ip_bgp_dampened_paths
,
12994 show_ip_bgp_dampened_paths_cmd
,
12995 "show ip bgp dampened-paths",
12999 "Display paths suppressed due to dampening\n")
13001 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
13005 DEFUN (show_ip_bgp_flap_statistics
,
13006 show_ip_bgp_flap_statistics_cmd
,
13007 "show ip bgp flap-statistics",
13011 "Display flap statistics of routes\n")
13013 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
13014 bgp_show_type_flap_statistics
, NULL
, 0);
13017 /* Display specified route of BGP table. */
13019 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
13020 const char *ip_str
, afi_t afi
, safi_t safi
,
13021 struct prefix_rd
*prd
, int prefix_check
)
13024 struct prefix match
;
13025 struct bgp_node
*rn
;
13026 struct bgp_node
*rm
;
13027 struct bgp_info
*ri
;
13028 struct bgp_info
*ri_temp
;
13030 struct bgp_table
*table
;
13032 /* BGP structure lookup. */
13035 bgp
= bgp_lookup_by_name (view_name
);
13038 vty_out (vty
, "%% Can't find BGP view %s%s", view_name
, VTY_NEWLINE
);
13039 return CMD_WARNING
;
13044 bgp
= bgp_get_default ();
13047 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
13048 return CMD_WARNING
;
13052 /* Check IP address argument. */
13053 ret
= str2prefix (ip_str
, &match
);
13056 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
13057 return CMD_WARNING
;
13060 match
.family
= afi2family (afi
);
13062 if (safi
== SAFI_MPLS_VPN
)
13064 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
13066 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
13069 if ((table
= rn
->info
) != NULL
)
13070 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
13072 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
13077 if (ri
->extra
&& ri
->extra
->damp_info
)
13079 ri_temp
= ri
->next
;
13080 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
13088 bgp_unlock_node (rm
);
13094 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
13096 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
13101 if (ri
->extra
&& ri
->extra
->damp_info
)
13103 ri_temp
= ri
->next
;
13104 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
13112 bgp_unlock_node (rn
);
13116 return CMD_SUCCESS
;
13119 DEFUN (clear_ip_bgp_dampening
,
13120 clear_ip_bgp_dampening_cmd
,
13121 "clear ip bgp dampening",
13125 "Clear route flap dampening information\n")
13127 bgp_damp_info_clean ();
13128 return CMD_SUCCESS
;
13131 DEFUN (clear_ip_bgp_dampening_prefix
,
13132 clear_ip_bgp_dampening_prefix_cmd
,
13133 "clear ip bgp dampening A.B.C.D/M",
13137 "Clear route flap dampening information\n"
13138 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13140 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
13141 SAFI_UNICAST
, NULL
, 1);
13144 DEFUN (clear_ip_bgp_dampening_address
,
13145 clear_ip_bgp_dampening_address_cmd
,
13146 "clear ip bgp dampening A.B.C.D",
13150 "Clear route flap dampening information\n"
13151 "Network to clear damping information\n")
13153 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
13154 SAFI_UNICAST
, NULL
, 0);
13157 DEFUN (clear_ip_bgp_dampening_address_mask
,
13158 clear_ip_bgp_dampening_address_mask_cmd
,
13159 "clear ip bgp dampening A.B.C.D A.B.C.D",
13163 "Clear route flap dampening information\n"
13164 "Network to clear damping information\n"
13168 char prefix_str
[BUFSIZ
];
13170 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
13173 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
13174 return CMD_WARNING
;
13177 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
13178 SAFI_UNICAST
, NULL
, 0);
13182 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
13183 afi_t afi
, safi_t safi
, int *write
)
13185 struct bgp_node
*prn
;
13186 struct bgp_node
*rn
;
13187 struct bgp_table
*table
;
13189 struct prefix_rd
*prd
;
13190 struct bgp_static
*bgp_static
;
13192 char buf
[SU_ADDRSTRLEN
];
13193 char rdbuf
[RD_ADDRSTRLEN
];
13195 /* Network configuration. */
13196 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
13197 if ((table
= prn
->info
) != NULL
)
13198 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
13199 if ((bgp_static
= rn
->info
) != NULL
)
13202 prd
= (struct prefix_rd
*) &prn
->p
;
13204 /* "address-family" display. */
13205 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13207 /* "network" configuration display. */
13208 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
13209 label
= decode_label (bgp_static
->tag
);
13211 vty_out (vty
, " network %s/%d rd %s tag %d",
13212 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13215 vty_out (vty
, "%s", VTY_NEWLINE
);
13220 /* Configuration of static route announcement and aggregate
13223 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
13224 afi_t afi
, safi_t safi
, int *write
)
13226 struct bgp_node
*rn
;
13228 struct bgp_static
*bgp_static
;
13229 struct bgp_aggregate
*bgp_aggregate
;
13230 char buf
[SU_ADDRSTRLEN
];
13232 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
13233 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
13235 /* Network configuration. */
13236 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
13237 if ((bgp_static
= rn
->info
) != NULL
)
13241 /* "address-family" display. */
13242 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13244 /* "network" configuration display. */
13245 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
13247 u_int32_t destination
;
13248 struct in_addr netmask
;
13250 destination
= ntohl (p
->u
.prefix4
.s_addr
);
13251 masklen2ip (p
->prefixlen
, &netmask
);
13252 vty_out (vty
, " network %s",
13253 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
13255 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
13256 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
13257 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
13258 || p
->u
.prefix4
.s_addr
== 0)
13260 /* Natural mask is not display. */
13263 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
13267 vty_out (vty
, " network %s/%d",
13268 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13272 if (bgp_static
->rmap
.name
)
13273 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
13276 if (bgp_static
->backdoor
)
13277 vty_out (vty
, " backdoor");
13280 vty_out (vty
, "%s", VTY_NEWLINE
);
13283 /* Aggregate-address configuration. */
13284 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
13285 if ((bgp_aggregate
= rn
->info
) != NULL
)
13289 /* "address-family" display. */
13290 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13292 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
13294 struct in_addr netmask
;
13296 masklen2ip (p
->prefixlen
, &netmask
);
13297 vty_out (vty
, " aggregate-address %s %s",
13298 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13299 inet_ntoa (netmask
));
13303 vty_out (vty
, " aggregate-address %s/%d",
13304 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13308 if (bgp_aggregate
->as_set
)
13309 vty_out (vty
, " as-set");
13311 if (bgp_aggregate
->summary_only
)
13312 vty_out (vty
, " summary-only");
13314 vty_out (vty
, "%s", VTY_NEWLINE
);
13321 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
13323 struct bgp_node
*rn
;
13324 struct bgp_distance
*bdistance
;
13326 /* Distance configuration. */
13327 if (bgp
->distance_ebgp
13328 && bgp
->distance_ibgp
13329 && bgp
->distance_local
13330 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
13331 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
13332 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
13333 vty_out (vty
, " distance bgp %d %d %d%s",
13334 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
13337 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
13338 if ((bdistance
= rn
->info
) != NULL
)
13340 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
13341 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
13342 bdistance
->access_list
? bdistance
->access_list
: "",
13349 /* Allocate routing table structure and install commands. */
13351 bgp_route_init (void)
13353 /* Init BGP distance table. */
13354 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
13356 /* IPv4 BGP commands. */
13357 install_element (BGP_NODE
, &bgp_table_map_cmd
);
13358 install_element (BGP_NODE
, &bgp_network_cmd
);
13359 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
13360 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
13361 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
13362 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
13363 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
13364 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
13365 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
13366 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
13367 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
13368 install_element (BGP_NODE
, &no_bgp_network_cmd
);
13369 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
13370 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
13371 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
13372 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
13373 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
13374 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
13375 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
13376 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
13378 install_element (BGP_NODE
, &aggregate_address_cmd
);
13379 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
13380 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
13381 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
13382 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
13383 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
13384 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
13385 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
13386 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
13387 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
13388 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
13389 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
13390 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
13391 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
13392 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
13393 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
13394 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
13395 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
13396 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
13397 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
13399 /* IPv4 unicast configuration. */
13400 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
13401 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
13402 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
13403 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
13404 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
13405 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
13406 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
13407 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
13408 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
13409 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
13410 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
13411 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
13412 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
13413 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
13415 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
13416 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
13417 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
13418 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
13419 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
13420 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
13421 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
13422 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
13423 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
13424 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
13425 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
13426 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
13427 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
13428 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
13429 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
13430 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
13431 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
13432 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
13433 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
13434 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
13436 /* IPv4 multicast configuration. */
13437 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
13438 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
13439 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
13440 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
13441 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
13442 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
13443 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
13444 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
13445 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
13446 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
13447 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
13448 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
13449 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
13450 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
13451 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
13452 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
13453 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
13454 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
13455 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
13456 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
13457 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
13458 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
13459 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
13460 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
13461 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
13462 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
13463 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
13464 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
13465 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
13466 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
13467 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
13468 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
13469 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
13470 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
13472 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
13473 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
13474 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
13475 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
13476 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
13477 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
13478 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
13479 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
13480 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
13481 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
13482 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
13483 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
13484 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
13485 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
13486 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
13487 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
13488 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
13489 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
13490 install_element (VIEW_NODE
, &show_ip_bgp_view_cmd
);
13491 install_element (VIEW_NODE
, &show_ip_bgp_view_route_cmd
);
13492 install_element (VIEW_NODE
, &show_ip_bgp_view_prefix_cmd
);
13493 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
13494 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
13495 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
13496 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
13497 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
13498 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
13499 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
13500 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
13501 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
13502 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
13503 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
13504 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
13505 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
13506 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
13507 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
13508 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
13509 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
13510 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
13511 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
13512 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
13513 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
13514 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community_cmd
);
13515 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
13516 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
13517 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
13518 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
13519 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
13520 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
13521 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
13522 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
13523 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
13524 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
13525 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
13526 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
13527 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
13528 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
13529 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
13530 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
13531 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
13532 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
13533 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
13534 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
13535 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
13536 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
13537 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
13538 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
13539 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
13540 install_element (VIEW_NODE
, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
);
13541 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
13542 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
13543 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
13544 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
13545 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
13546 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
13547 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
13548 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
13549 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
13550 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
13551 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
13552 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
13553 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
13554 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
13555 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
13556 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
13557 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
13558 install_element (VIEW_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
13560 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
13561 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
13562 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_pathtype_cmd
);
13563 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
13564 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
13565 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
13566 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
13567 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
13568 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
13569 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
13570 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
13571 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
13572 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
13573 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
13574 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
13575 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_route_cmd
);
13576 install_element (RESTRICTED_NODE
, &show_ip_bgp_view_prefix_cmd
);
13577 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
13578 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
13579 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
13580 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
13581 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
13582 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
13583 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
13584 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
13585 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
13586 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community_cmd
);
13587 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
13588 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
13589 install_element (RESTRICTED_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
13590 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
13591 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
13592 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
13593 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
13594 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
13595 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
13596 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
13597 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
13599 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
13600 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
13601 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
13602 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
13603 install_element (ENABLE_NODE
, &show_ip_bgp_route_pathtype_cmd
);
13604 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
13605 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
13606 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
13607 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
13608 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
13609 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
13610 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
13611 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
13612 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
13613 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
13614 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
13615 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
13616 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
13617 install_element (ENABLE_NODE
, &show_ip_bgp_view_cmd
);
13618 install_element (ENABLE_NODE
, &show_ip_bgp_view_route_cmd
);
13619 install_element (ENABLE_NODE
, &show_ip_bgp_view_prefix_cmd
);
13620 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
13621 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
13622 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
13623 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
13624 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
13625 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
13626 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
13627 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
13628 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
13629 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
13630 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
13631 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
13632 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
13633 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
13634 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
13635 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
13636 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
13637 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
13638 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
13639 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
13640 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community_all_cmd
);
13641 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community_cmd
);
13642 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community2_cmd
);
13643 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community3_cmd
);
13644 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_community4_cmd
);
13645 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
13646 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
13647 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
13648 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
13649 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
13650 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
13651 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
13652 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
13653 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
13654 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
13655 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
13656 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
13657 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
13658 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
13659 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
13660 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
13661 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
13662 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
13663 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
13664 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
13665 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
13666 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
13667 install_element (ENABLE_NODE
, &show_bgp_view_afi_safi_neighbor_adv_recd_routes_cmd
);
13668 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
13669 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
13670 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
13671 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
13672 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
13673 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
13674 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
13675 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
13676 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
13677 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
13678 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
13679 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
13680 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
13681 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
13682 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
13683 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
13684 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_advertised_route_cmd
);
13685 install_element (ENABLE_NODE
, &show_ip_bgp_view_neighbor_received_routes_cmd
);
13687 /* BGP dampening clear commands */
13688 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
13689 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
13690 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
13691 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
13694 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
13695 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
13696 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
13698 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
13700 /* New config IPv6 BGP commands. */
13701 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
13702 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
13703 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
13704 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
13705 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
13706 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
13708 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
13709 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
13710 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
13711 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
13713 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
13714 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
13716 /* Old config IPv6 BGP commands. */
13717 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
13718 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
13720 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
13721 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
13722 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
13723 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
13725 install_element (VIEW_NODE
, &show_bgp_cmd
);
13726 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
13727 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
13728 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
13729 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
13730 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
13731 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
13732 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
13733 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
13734 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
13735 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
13736 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
13737 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
13738 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
13739 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
13740 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
13741 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
13742 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
13743 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
13744 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
13745 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
13746 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
13747 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
13748 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
13749 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
13750 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
13751 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
13752 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
13753 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
13754 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
13755 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
13756 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
13757 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
13758 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
13759 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
13760 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
13761 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
13762 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
13763 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
13764 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
13765 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
13766 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
13767 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
13768 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
13769 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
13770 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
13771 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
13772 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
13773 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
13774 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
13775 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
13776 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
13777 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
13778 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
13779 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
13780 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
13781 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
13782 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
13783 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
13784 install_element (VIEW_NODE
, &show_bgp_view_cmd
);
13785 install_element (VIEW_NODE
, &show_bgp_view_ipv6_cmd
);
13786 install_element (VIEW_NODE
, &show_bgp_view_route_cmd
);
13787 install_element (VIEW_NODE
, &show_bgp_view_ipv6_route_cmd
);
13788 install_element (VIEW_NODE
, &show_bgp_view_prefix_cmd
);
13789 install_element (VIEW_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
13790 install_element (VIEW_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
13791 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
13792 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
13793 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
13794 install_element (VIEW_NODE
, &show_bgp_view_neighbor_routes_cmd
);
13795 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
13796 install_element (VIEW_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
13797 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
13798 install_element (VIEW_NODE
, &show_bgp_view_neighbor_flap_cmd
);
13799 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
13800 install_element (VIEW_NODE
, &show_bgp_view_neighbor_damp_cmd
);
13801 install_element (VIEW_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
13804 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
13806 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
13807 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
13808 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
13809 install_element (RESTRICTED_NODE
, &show_bgp_route_pathtype_cmd
);
13810 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
13811 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
13812 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
13813 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
13814 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
13815 install_element (RESTRICTED_NODE
, &show_bgp_prefix_pathtype_cmd
);
13816 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
13817 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
13818 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
13819 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
13820 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
13821 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
13822 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
13823 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
13824 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
13825 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
13826 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
13827 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
13828 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
13829 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
13830 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
13831 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
13832 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
13833 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
13834 install_element (RESTRICTED_NODE
, &show_bgp_view_route_cmd
);
13835 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_route_cmd
);
13836 install_element (RESTRICTED_NODE
, &show_bgp_view_prefix_cmd
);
13837 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
13838 install_element (RESTRICTED_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
13839 install_element (RESTRICTED_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
13841 install_element (ENABLE_NODE
, &show_bgp_cmd
);
13842 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
13843 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
13844 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
13845 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
13846 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
13847 install_element (ENABLE_NODE
, &show_bgp_route_pathtype_cmd
);
13848 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
13849 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
13850 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
13851 install_element (ENABLE_NODE
, &show_bgp_prefix_pathtype_cmd
);
13852 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
13853 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
13854 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
13855 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
13856 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
13857 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
13858 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
13859 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
13860 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
13861 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
13862 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
13863 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
13864 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
13865 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
13866 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
13867 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
13868 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
13869 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
13870 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
13871 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
13872 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
13873 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
13874 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
13875 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
13876 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
13877 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
13878 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
13879 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
13880 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
13881 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
13882 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
13883 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
13884 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
13885 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
13886 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
13887 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
13888 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
13889 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
13890 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
13891 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
13892 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
13893 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
13894 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
13895 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
13896 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
13897 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
13898 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
13899 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
13900 install_element (ENABLE_NODE
, &show_bgp_view_cmd
);
13901 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_cmd
);
13902 install_element (ENABLE_NODE
, &show_bgp_view_route_cmd
);
13903 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_route_cmd
);
13904 install_element (ENABLE_NODE
, &show_bgp_view_prefix_cmd
);
13905 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_prefix_cmd
);
13906 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_advertised_route_cmd
);
13907 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_advertised_route_cmd
);
13908 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_routes_cmd
);
13909 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_routes_cmd
);
13910 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_routes_cmd
);
13911 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_routes_cmd
);
13912 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_received_prefix_filter_cmd
);
13913 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd
);
13914 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_flap_cmd
);
13915 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_flap_cmd
);
13916 install_element (ENABLE_NODE
, &show_bgp_view_neighbor_damp_cmd
);
13917 install_element (ENABLE_NODE
, &show_bgp_view_ipv6_neighbor_damp_cmd
);
13920 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
13921 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
13922 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
13923 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
13926 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
13927 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
13928 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
13929 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
13930 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
13931 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
13932 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
13933 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
13934 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
13935 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
13936 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
13937 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
13938 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
13939 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
13940 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
13941 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
13942 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
13943 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
13944 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
13945 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
13946 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
13947 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
13948 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
13949 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
13950 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
13951 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
13952 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
13953 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
13954 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
13955 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
13956 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
13957 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
13958 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
13959 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
13960 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
13961 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
13964 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
13965 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
13966 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
13967 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
13968 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
13969 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
13970 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
13971 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
13972 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
13973 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
13974 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
13975 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
13976 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
13977 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
13978 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
13979 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
13980 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
13981 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
13982 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
13983 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
13984 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
13985 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
13986 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
13987 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
13988 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
13989 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
13990 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
13991 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
13992 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
13993 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
13994 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
13995 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
13996 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
13997 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
13998 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
13999 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14002 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14003 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14004 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14005 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14008 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14009 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14010 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14011 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14014 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14015 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14016 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14017 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14018 #endif /* HAVE_IPV6 */
14020 install_element (BGP_NODE
, &bgp_distance_cmd
);
14021 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
14022 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
14023 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
14024 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
14025 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
14026 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
14028 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
14029 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
14030 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
14031 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
14032 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
14033 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
14034 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
14035 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
14036 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
14037 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
14041 bgp_route_finish (void)
14043 bgp_table_unlock (bgp_distance_table
);
14044 bgp_distance_table
= NULL
;