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"
63 #include "bgpd/bgp_vty.h"
65 /* Extern from bgp_dump.c */
66 extern const char *bgp_origin_str
[];
67 extern const char *bgp_origin_long_str
[];
70 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
71 struct prefix_rd
*prd
)
74 struct bgp_node
*prn
= NULL
;
80 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
82 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
84 if (prn
->info
== NULL
)
85 prn
->info
= bgp_table_init (afi
, safi
);
87 bgp_unlock_node (prn
);
91 rn
= bgp_node_get (table
, p
);
93 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
99 /* Allocate bgp_info_extra */
100 static struct bgp_info_extra
*
101 bgp_info_extra_new (void)
103 struct bgp_info_extra
*new;
104 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
109 bgp_info_extra_free (struct bgp_info_extra
**extra
)
113 if ((*extra
)->damp_info
)
114 bgp_damp_info_free ((*extra
)->damp_info
, 0);
116 (*extra
)->damp_info
= NULL
;
118 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
124 /* Get bgp_info extra information for the given bgp_info, lazy allocated
127 struct bgp_info_extra
*
128 bgp_info_extra_get (struct bgp_info
*ri
)
131 ri
->extra
= bgp_info_extra_new();
135 /* Free bgp route information. */
137 bgp_info_free (struct bgp_info
*binfo
)
140 bgp_attr_unintern (&binfo
->attr
);
142 bgp_unlink_nexthop(binfo
);
143 bgp_info_extra_free (&binfo
->extra
);
144 bgp_info_mpath_free (&binfo
->mpath
);
146 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
148 XFREE (MTYPE_BGP_ROUTE
, binfo
);
152 bgp_info_lock (struct bgp_info
*binfo
)
159 bgp_info_unlock (struct bgp_info
*binfo
)
161 assert (binfo
&& binfo
->lock
> 0);
164 if (binfo
->lock
== 0)
167 zlog_debug ("%s: unlocked and freeing", __func__
);
168 zlog_backtrace (LOG_DEBUG
);
170 bgp_info_free (binfo
);
175 if (binfo
->lock
== 1)
177 zlog_debug ("%s: unlocked to 1", __func__
);
178 zlog_backtrace (LOG_DEBUG
);
186 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
188 struct bgp_info
*top
;
200 peer_lock (ri
->peer
); /* bgp_info peer reference */
203 /* Do the actual removal of info from RIB, for use by bgp_process
204 completion callback *only* */
206 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
209 ri
->next
->prev
= ri
->prev
;
211 ri
->prev
->next
= ri
->next
;
215 bgp_info_mpath_dequeue (ri
);
216 bgp_info_unlock (ri
);
217 bgp_unlock_node (rn
);
221 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
223 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
224 /* set of previous already took care of pcount */
225 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
228 /* undo the effects of a previous call to bgp_info_delete; typically
229 called when a route is deleted and then quickly re-added before the
230 deletion has been processed */
232 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
234 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
235 /* unset of previous already took care of pcount */
236 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
239 /* Adjust pcount as required */
241 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
243 struct bgp_table
*table
;
245 assert (rn
&& bgp_node_table (rn
));
246 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
248 table
= bgp_node_table (rn
);
250 if (ri
->peer
== ri
->peer
->bgp
->peer_self
)
253 if (!BGP_INFO_COUNTABLE (ri
)
254 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
257 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
259 /* slight hack, but more robust against errors. */
260 if (ri
->peer
->pcount
[table
->afi
][table
->safi
])
261 ri
->peer
->pcount
[table
->afi
][table
->safi
]--;
264 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
265 __func__
, ri
->peer
->host
);
266 zlog_backtrace (LOG_WARNING
);
267 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
270 else if (BGP_INFO_COUNTABLE (ri
)
271 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
273 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
274 ri
->peer
->pcount
[table
->afi
][table
->safi
]++;
279 /* Set/unset bgp_info flags, adjusting any other state as needed.
280 * This is here primarily to keep prefix-count in check.
283 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
285 SET_FLAG (ri
->flags
, flag
);
287 /* early bath if we know it's not a flag that changes countability state */
288 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
291 bgp_pcount_adjust (rn
, ri
);
295 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
297 UNSET_FLAG (ri
->flags
, flag
);
299 /* early bath if we know it's not a flag that changes countability state */
300 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
303 bgp_pcount_adjust (rn
, ri
);
306 /* Get MED value. If MED value is missing and "bgp bestpath
307 missing-as-worst" is specified, treat it as the worst value. */
309 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
311 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
315 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
323 bgp_info_path_with_addpath_rx_str (struct bgp_info
*ri
, char *buf
)
325 if (ri
->addpath_rx_id
)
326 sprintf(buf
, "path %s (addpath rxid %d)", ri
->peer
->host
, ri
->addpath_rx_id
);
328 sprintf(buf
, "path %s", ri
->peer
->host
);
331 /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */
333 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
334 int *paths_eq
, struct bgp_maxpaths_cfg
*mpath_cfg
, int debug
,
337 struct attr
*newattr
, *existattr
;
338 struct attr_extra
*newattre
, *existattre
;
339 bgp_peer_sort_t new_sort
;
340 bgp_peer_sort_t exist_sort
;
342 u_int32_t exist_pref
;
345 u_int32_t new_weight
;
346 u_int32_t exist_weight
;
347 uint32_t newm
, existm
;
348 struct in_addr new_id
;
349 struct in_addr exist_id
;
352 int internal_as_route
;
355 char new_buf
[PATH_ADDPATH_STR_BUFFER
];
356 char exist_buf
[PATH_ADDPATH_STR_BUFFER
];
364 zlog_debug("%s: new is NULL", pfx_buf
);
369 bgp_info_path_with_addpath_rx_str (new, new_buf
);
374 zlog_debug("%s: %s is the initial bestpath", pfx_buf
, new_buf
);
380 bgp_info_path_with_addpath_rx_str (exist
, exist_buf
);
381 zlog_debug("%s: Comparing %s flags 0x%x with %s flags 0x%x",
382 pfx_buf
, new_buf
, new->flags
, exist_buf
, exist
->flags
);
386 existattr
= exist
->attr
;
387 newattre
= newattr
->extra
;
388 existattre
= existattr
->extra
;
390 /* 1. Weight check. */
391 new_weight
= exist_weight
= 0;
394 new_weight
= newattre
->weight
;
396 exist_weight
= existattre
->weight
;
398 if (new_weight
> exist_weight
)
401 zlog_debug("%s: %s wins over %s due to weight %d > %d",
402 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
406 if (new_weight
< exist_weight
)
409 zlog_debug("%s: %s loses to %s due to weight %d < %d",
410 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
414 /* 2. Local preference check. */
415 new_pref
= exist_pref
= bgp
->default_local_pref
;
417 if (newattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
418 new_pref
= newattr
->local_pref
;
419 if (existattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
420 exist_pref
= existattr
->local_pref
;
422 if (new_pref
> exist_pref
)
425 zlog_debug("%s: %s wins over %s due to localpref %d > %d",
426 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
430 if (new_pref
< exist_pref
)
433 zlog_debug("%s: %s loses to %s due to localpref %d < %d",
434 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
438 /* 3. Local route check. We prefer:
440 * - BGP_ROUTE_AGGREGATE
441 * - BGP_ROUTE_REDISTRIBUTE
443 if (! (new->sub_type
== BGP_ROUTE_NORMAL
))
446 zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type",
447 pfx_buf
, new_buf
, exist_buf
);
451 if (! (exist
->sub_type
== BGP_ROUTE_NORMAL
))
454 zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type",
455 pfx_buf
, new_buf
, exist_buf
);
459 /* 4. AS path length check. */
460 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
462 int exist_hops
= aspath_count_hops (existattr
->aspath
);
463 int exist_confeds
= aspath_count_confeds (existattr
->aspath
);
465 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
469 aspath_hops
= aspath_count_hops (newattr
->aspath
);
470 aspath_hops
+= aspath_count_confeds (newattr
->aspath
);
472 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
475 zlog_debug("%s: %s wins over %s due to aspath (with confeds) hopcount %d < %d",
476 pfx_buf
, new_buf
, exist_buf
,
477 aspath_hops
, (exist_hops
+ exist_confeds
));
481 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
484 zlog_debug("%s: %s loses to %s due to aspath (with confeds) hopcount %d > %d",
485 pfx_buf
, new_buf
, exist_buf
,
486 aspath_hops
, (exist_hops
+ exist_confeds
));
492 int newhops
= aspath_count_hops (newattr
->aspath
);
494 if (newhops
< exist_hops
)
497 zlog_debug("%s: %s wins over %s due to aspath hopcount %d < %d",
498 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
502 if (newhops
> exist_hops
)
505 zlog_debug("%s: %s loses to %s due to aspath hopcount %d > %d",
506 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
512 /* 5. Origin check. */
513 if (newattr
->origin
< existattr
->origin
)
516 zlog_debug("%s: %s wins over %s due to ORIGIN %s < %s",
517 pfx_buf
, new_buf
, exist_buf
,
518 bgp_origin_long_str
[newattr
->origin
],
519 bgp_origin_long_str
[existattr
->origin
]);
523 if (newattr
->origin
> existattr
->origin
)
526 zlog_debug("%s: %s loses to %s due to ORIGIN %s > %s",
527 pfx_buf
, new_buf
, exist_buf
,
528 bgp_origin_long_str
[newattr
->origin
],
529 bgp_origin_long_str
[existattr
->origin
]);
534 internal_as_route
= (aspath_count_hops (newattr
->aspath
) == 0
535 && aspath_count_hops (existattr
->aspath
) == 0);
536 confed_as_route
= (aspath_count_confeds (newattr
->aspath
) > 0
537 && aspath_count_confeds (existattr
->aspath
) > 0
538 && aspath_count_hops (newattr
->aspath
) == 0
539 && aspath_count_hops (existattr
->aspath
) == 0);
541 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
542 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
544 || aspath_cmp_left (newattr
->aspath
, existattr
->aspath
)
545 || aspath_cmp_left_confed (newattr
->aspath
, existattr
->aspath
)
546 || internal_as_route
)
548 new_med
= bgp_med_value (new->attr
, bgp
);
549 exist_med
= bgp_med_value (exist
->attr
, bgp
);
551 if (new_med
< exist_med
)
554 zlog_debug("%s: %s wins over %s due to MED %d < %d",
555 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
559 if (new_med
> exist_med
)
562 zlog_debug("%s: %s loses to %s due to MED %d > %d",
563 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
568 /* 7. Peer type check. */
569 new_sort
= new->peer
->sort
;
570 exist_sort
= exist
->peer
->sort
;
572 if (new_sort
== BGP_PEER_EBGP
573 && (exist_sort
== BGP_PEER_IBGP
|| exist_sort
== BGP_PEER_CONFED
))
576 zlog_debug("%s: %s wins over %s due to eBGP peer > iBGP peer",
577 pfx_buf
, new_buf
, exist_buf
);
581 if (exist_sort
== BGP_PEER_EBGP
582 && (new_sort
== BGP_PEER_IBGP
|| new_sort
== BGP_PEER_CONFED
))
585 zlog_debug("%s: %s loses to %s due to iBGP peer < eBGP peer",
586 pfx_buf
, new_buf
, exist_buf
);
590 /* 8. IGP metric check. */
594 newm
= new->extra
->igpmetric
;
596 existm
= exist
->extra
->igpmetric
;
601 zlog_debug("%s: %s wins over %s due to IGP metric %d < %d",
602 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
609 zlog_debug("%s: %s loses to %s due to IGP metric %d > %d",
610 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
614 /* 9. Same IGP metric. Compare the cluster list length as
615 representative of IGP hops metric. Rewrite the metric value
616 pair (newm, existm) with the cluster list length. Prefer the
617 path with smaller cluster list length. */
620 if (peer_sort (new->peer
) == BGP_PEER_IBGP
621 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
622 && CHECK_FLAG (mpath_cfg
->ibgp_flags
,
623 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
625 newm
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
626 existm
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
631 zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
632 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
639 zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
640 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
646 /* 10. confed-external vs. confed-internal */
647 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
649 if (new_sort
== BGP_PEER_CONFED
&& exist_sort
== BGP_PEER_IBGP
)
652 zlog_debug("%s: %s wins over %s due to confed-external peer > confed-internal peer",
653 pfx_buf
, new_buf
, exist_buf
);
657 if (exist_sort
== BGP_PEER_CONFED
&& new_sort
== BGP_PEER_IBGP
)
660 zlog_debug("%s: %s loses to %s due to confed-internal peer < confed-external peer",
661 pfx_buf
, new_buf
, exist_buf
);
666 /* 11. Maximum path check. */
669 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
))
673 * For the two paths, all comparison steps till IGP metric
674 * have succeeded - including AS_PATH hop count. Since 'bgp
675 * bestpath as-path multipath-relax' knob is on, we don't need
676 * an exact match of AS_PATH. Thus, mark the paths are equal.
677 * That will trigger both these paths to get into the multipath
683 zlog_debug("%s: %s and %s are equal via multipath-relax",
684 pfx_buf
, new_buf
, exist_buf
);
686 else if (new->peer
->sort
== BGP_PEER_IBGP
)
688 if (aspath_cmp (new->attr
->aspath
, exist
->attr
->aspath
))
693 zlog_debug("%s: %s and %s are equal via matching aspaths",
694 pfx_buf
, new_buf
, exist_buf
);
697 else if (new->peer
->as
== exist
->peer
->as
)
702 zlog_debug("%s: %s and %s are equal via same remote-as",
703 pfx_buf
, new_buf
, exist_buf
);
709 * TODO: If unequal cost ibgp multipath is enabled we can
710 * mark the paths as equal here instead of returning
715 zlog_debug("%s: %s wins over %s after IGP metric comparison",
716 pfx_buf
, new_buf
, exist_buf
);
718 zlog_debug("%s: %s loses to %s after IGP metric comparison",
719 pfx_buf
, new_buf
, exist_buf
);
724 /* 12. If both paths are external, prefer the path that was received
725 first (the oldest one). This step minimizes route-flap, since a
726 newer path won't displace an older one, even if it was the
727 preferred route based on the additional decision criteria below. */
728 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
729 && new_sort
== BGP_PEER_EBGP
730 && exist_sort
== BGP_PEER_EBGP
)
732 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
735 zlog_debug("%s: %s wins over %s due to oldest external",
736 pfx_buf
, new_buf
, exist_buf
);
740 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
743 zlog_debug("%s: %s loses to %s due to oldest external",
744 pfx_buf
, new_buf
, exist_buf
);
749 /* 13. Router-ID comparision. */
750 /* If one of the paths is "stale", the corresponding peer router-id will
751 * be 0 and would always win over the other path. If originator id is
752 * used for the comparision, it will decide which path is better.
754 if (newattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
755 new_id
.s_addr
= newattre
->originator_id
.s_addr
;
757 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
758 if (existattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
759 exist_id
.s_addr
= existattre
->originator_id
.s_addr
;
761 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
763 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
766 zlog_debug("%s: %s wins over %s due to Router-ID comparison",
767 pfx_buf
, new_buf
, exist_buf
);
771 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
774 zlog_debug("%s: %s loses to %s due to Router-ID comparison",
775 pfx_buf
, new_buf
, exist_buf
);
779 /* 14. Cluster length comparision. */
780 new_cluster
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
781 exist_cluster
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
783 if (new_cluster
< exist_cluster
)
786 zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
787 pfx_buf
, new_buf
, exist_buf
, new_cluster
, exist_cluster
);
791 if (new_cluster
> exist_cluster
)
794 zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
795 pfx_buf
, new_buf
, exist_buf
, new_cluster
, exist_cluster
);
799 /* 15. Neighbor address comparision. */
800 /* Do this only if neither path is "stale" as stale paths do not have
801 * valid peer information (as the connection may or may not be up).
803 if (CHECK_FLAG (exist
->flags
, BGP_INFO_STALE
))
806 zlog_debug("%s: %s wins over %s due to latter path being STALE",
807 pfx_buf
, new_buf
, exist_buf
);
811 if (CHECK_FLAG (new->flags
, BGP_INFO_STALE
))
814 zlog_debug("%s: %s loses to %s due to former path being STALE",
815 pfx_buf
, new_buf
, exist_buf
);
819 /* locally configured routes to advertise do not have su_remote */
820 if (new->peer
->su_remote
== NULL
)
822 if (exist
->peer
->su_remote
== NULL
)
825 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
830 zlog_debug("%s: %s loses to %s due to Neighor IP comparison",
831 pfx_buf
, new_buf
, exist_buf
);
838 zlog_debug("%s: %s wins over %s due to Neighor IP comparison",
839 pfx_buf
, new_buf
, exist_buf
);
844 zlog_debug("%s: %s wins over %s due to nothing left to compare",
845 pfx_buf
, new_buf
, exist_buf
);
850 static enum filter_type
851 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
852 afi_t afi
, safi_t safi
)
854 struct bgp_filter
*filter
;
856 filter
= &peer
->filter
[afi
][safi
];
858 #define FILTER_EXIST_WARN(F,f,filter) \
859 if (BGP_DEBUG (update, UPDATE_IN) \
860 && !(F ## _IN (filter))) \
861 zlog_warn ("%s: Could not find configured input %s-list %s!", \
862 peer->host, #f, F ## _IN_NAME(filter));
864 if (DISTRIBUTE_IN_NAME (filter
)) {
865 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
867 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
871 if (PREFIX_LIST_IN_NAME (filter
)) {
872 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
874 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
878 if (FILTER_LIST_IN_NAME (filter
)) {
879 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
881 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
885 return FILTER_PERMIT
;
886 #undef FILTER_EXIST_WARN
889 static enum filter_type
890 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
891 afi_t afi
, safi_t safi
)
893 struct bgp_filter
*filter
;
895 filter
= &peer
->filter
[afi
][safi
];
897 #define FILTER_EXIST_WARN(F,f,filter) \
898 if (BGP_DEBUG (update, UPDATE_OUT) \
899 && !(F ## _OUT (filter))) \
900 zlog_warn ("%s: Could not find configured output %s-list %s!", \
901 peer->host, #f, F ## _OUT_NAME(filter));
903 if (DISTRIBUTE_OUT_NAME (filter
)) {
904 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
906 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
910 if (PREFIX_LIST_OUT_NAME (filter
)) {
911 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
913 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
917 if (FILTER_LIST_OUT_NAME (filter
)) {
918 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
920 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
924 return FILTER_PERMIT
;
925 #undef FILTER_EXIST_WARN
928 /* If community attribute includes no_export then return 1. */
930 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
934 /* NO_ADVERTISE check. */
935 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
938 /* NO_EXPORT check. */
939 if (peer
->sort
== BGP_PEER_EBGP
&&
940 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
943 /* NO_EXPORT_SUBCONFED check. */
944 if (peer
->sort
== BGP_PEER_EBGP
945 || peer
->sort
== BGP_PEER_CONFED
)
946 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
952 /* Route reflection loop check. */
954 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
956 struct in_addr cluster_id
;
958 if (attr
->extra
&& attr
->extra
->cluster
)
960 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
961 cluster_id
= peer
->bgp
->cluster_id
;
963 cluster_id
= peer
->bgp
->router_id
;
965 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
972 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
973 afi_t afi
, safi_t safi
, const char *rmap_name
)
975 struct bgp_filter
*filter
;
976 struct bgp_info info
;
977 route_map_result_t ret
;
978 struct route_map
*rmap
= NULL
;
980 filter
= &peer
->filter
[afi
][safi
];
982 /* Apply default weight value. */
984 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
988 rmap
= route_map_lookup_by_name(rmap_name
);
995 if (ROUTE_MAP_IN_NAME(filter
))
997 rmap
= ROUTE_MAP_IN (filter
);
1004 /* Route map apply. */
1007 /* Duplicate current value to new strucutre for modification. */
1011 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
1013 /* Apply BGP route map to the attribute. */
1014 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1016 peer
->rmap_type
= 0;
1018 if (ret
== RMAP_DENYMATCH
)
1020 /* Free newly generated AS path and community by route-map. */
1021 bgp_attr_flush (attr
);
1029 bgp_output_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1030 afi_t afi
, safi_t safi
, const char *rmap_name
)
1032 struct bgp_filter
*filter
;
1033 struct bgp_info info
;
1034 route_map_result_t ret
;
1035 struct route_map
*rmap
= NULL
;
1037 filter
= &peer
->filter
[afi
][safi
];
1039 /* Apply default weight value. */
1041 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
1045 rmap
= route_map_lookup_by_name(rmap_name
);
1052 if (ROUTE_MAP_OUT_NAME(filter
))
1054 rmap
= ROUTE_MAP_OUT (filter
);
1061 /* Route map apply. */
1064 /* Duplicate current value to new strucutre for modification. */
1068 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1070 /* Apply BGP route map to the attribute. */
1071 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1073 peer
->rmap_type
= 0;
1075 if (ret
== RMAP_DENYMATCH
)
1076 /* caller has multiple error paths with bgp_attr_flush() */
1082 /* If this is an EBGP peer with remove-private-AS */
1084 bgp_peer_remove_private_as(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1085 struct peer
*peer
, struct attr
*attr
)
1087 if (peer
->sort
== BGP_PEER_EBGP
&&
1088 (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1089 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
) ||
1090 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
) ||
1091 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)))
1093 // Take action on the entire aspath
1094 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1095 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
1097 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
1098 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1100 // The entire aspath consists of private ASNs so create an empty aspath
1101 else if (aspath_private_as_check (attr
->aspath
))
1102 attr
->aspath
= aspath_empty_get ();
1104 // There are some public and some private ASNs, remove the private ASNs
1106 attr
->aspath
= aspath_remove_private_asns (attr
->aspath
);
1109 // 'all' was not specified so the entire aspath must be private ASNs
1110 // for us to do anything
1111 else if (aspath_private_as_check (attr
->aspath
))
1113 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
1114 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1116 attr
->aspath
= aspath_empty_get ();
1121 /* If this is an EBGP peer with as-override */
1123 bgp_peer_as_override(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1124 struct peer
*peer
, struct attr
*attr
)
1126 if (peer
->sort
== BGP_PEER_EBGP
&&
1127 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
))
1129 if (aspath_single_asn_check (attr
->aspath
, peer
->as
))
1130 attr
->aspath
= aspath_replace_specific_asn (attr
->aspath
, peer
->as
, bgp
->as
);
1135 subgroup_announce_reset_nhop (u_char family
, struct attr
*attr
)
1137 if (family
== AF_INET
)
1138 attr
->nexthop
.s_addr
= 0;
1140 if (family
== AF_INET6
)
1141 memset (&attr
->extra
->mp_nexthop_global
, 0, IPV6_MAX_BYTELEN
);
1146 subgroup_announce_check (struct bgp_info
*ri
, struct update_subgroup
*subgrp
,
1147 struct prefix
*p
, struct attr
*attr
)
1149 struct bgp_filter
*filter
;
1152 struct peer
*onlypeer
;
1154 struct attr
*riattr
;
1155 struct peer_af
*paf
;
1156 char buf
[SU_ADDRSTRLEN
];
1163 if (DISABLE_BGP_ANNOUNCE
)
1166 afi
= SUBGRP_AFI(subgrp
);
1167 safi
= SUBGRP_SAFI(subgrp
);
1168 peer
= SUBGRP_PEER(subgrp
);
1170 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_LONESOUL
))
1171 onlypeer
= SUBGRP_PFIRST(subgrp
)->peer
;
1174 filter
= &peer
->filter
[afi
][safi
];
1175 bgp
= SUBGRP_INST(subgrp
);
1176 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
1178 /* With addpath we may be asked to TX all kinds of paths so make sure
1180 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
) ||
1181 CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
) ||
1182 CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
1187 /* If this is not the bestpath then check to see if there is an enabled addpath
1188 * feature that requires us to advertise it */
1189 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1191 if (! bgp_addpath_tx_path(peer
, afi
, safi
, ri
))
1197 /* Aggregate-address suppress check. */
1198 if (ri
->extra
&& ri
->extra
->suppress
)
1199 if (! UNSUPPRESS_MAP_NAME (filter
))
1204 /* Do not send back route to sender. */
1205 if (onlypeer
&& from
== onlypeer
)
1210 /* Do not send the default route in the BGP table if the neighbor is
1211 * configured for default-originate */
1212 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
1214 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1217 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1219 #endif /* HAVE_IPV6 */
1222 /* Transparency check. */
1223 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
1224 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
1229 /* If community is not disabled check the no-export and local. */
1230 if (! transparent
&& bgp_community_filter (peer
, riattr
))
1232 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1233 zlog_debug ("subgrpannouncecheck: community filter check fail");
1237 /* If the attribute has originator-id and it is same as remote
1240 riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
) &&
1241 (IPV4_ADDR_SAME (&onlypeer
->remote_id
, &riattr
->extra
->originator_id
)))
1243 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1244 zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as "
1247 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1252 /* ORF prefix-list filter check */
1253 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1254 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1255 || CHECK_FLAG (peer
->af_cap
[afi
][safi
],
1256 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1257 if (peer
->orf_plist
[afi
][safi
])
1259 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1261 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1262 zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF",
1264 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1270 /* Output filter check. */
1271 if (bgp_output_filter (peer
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
1273 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1274 zlog_debug ("%s [Update:SEND] %s/%d is filtered",
1276 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1281 #ifdef BGP_SEND_ASPATH_CHECK
1282 /* AS path loop check. */
1283 if (onlypeer
&& aspath_loop_check (riattr
->aspath
, onlypeer
->as
))
1285 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1286 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u "
1287 "that is part of AS path.",
1288 onlypeer
->host
, onlypeer
->as
);
1291 #endif /* BGP_SEND_ASPATH_CHECK */
1293 /* If we're a CONFED we need to loop check the CONFED ID too */
1294 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
1296 if (aspath_loop_check(riattr
->aspath
, bgp
->confed_id
))
1298 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1299 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u"
1307 /* Route-Reflect check. */
1308 if (from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1313 /* IBGP reflection check. */
1316 /* A route from a Client peer. */
1317 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
1319 /* Reflect to all the Non-Client peers and also to the
1320 Client peers other than the originator. Originator check
1321 is already done. So there is noting to do. */
1322 /* no bgp client-to-client reflection check. */
1323 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
1324 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1325 PEER_FLAG_REFLECTOR_CLIENT
))
1330 /* A route from a Non-client peer. Reflect to all other
1332 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1333 PEER_FLAG_REFLECTOR_CLIENT
))
1338 /* For modify attribute, copy it to temporary structure. */
1339 bgp_attr_dup (attr
, riattr
);
1341 /* If local-preference is not set. */
1342 if ((peer
->sort
== BGP_PEER_IBGP
1343 || peer
->sort
== BGP_PEER_CONFED
)
1344 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
1346 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1347 attr
->local_pref
= bgp
->default_local_pref
;
1350 /* If originator-id is not set and the route is to be reflected,
1351 set the originator id */
1352 if (reflect
&& (!(attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))))
1354 attr
->extra
= bgp_attr_extra_get(attr
);
1355 IPV4_ADDR_COPY(&(attr
->extra
->originator_id
), &(from
->remote_id
));
1356 SET_FLAG(attr
->flag
, BGP_ATTR_ORIGINATOR_ID
);
1359 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
1360 if (peer
->sort
== BGP_PEER_EBGP
1361 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
1363 if (from
!= bgp
->peer_self
&& ! transparent
1364 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
1365 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
1368 /* Since the nexthop attribute can vary per peer, it is not explicitly set
1369 * in announce check, only certain flags and length (or number of nexthops
1370 * -- for IPv6/MP_REACH) are set here in order to guide the update formation
1371 * code in setting the nexthop(s) on a per peer basis in reformat_peer().
1372 * Typically, the source nexthop in the attribute is preserved but in the
1373 * scenarios where we know it will always be overwritten, we reset the
1374 * nexthop to "0" in an attempt to achieve better Update packing. An
1375 * example of this is when a prefix from each of 2 IBGP peers needs to be
1376 * announced to an EBGP peer (and they have the same attributes barring
1380 SET_FLAG(attr
->rmap_change_flags
, BATTR_REFLECTED
);
1383 #define NEXTHOP_IS_V6 (\
1384 (safi != SAFI_ENCAP && \
1385 (p->family == AF_INET6 || peer_cap_enhe(peer))) || \
1386 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
1388 /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
1389 * the peer (group) is configured to receive link-local nexthop unchanged
1390 * and it is available in the prefix OR we're not reflecting the route and
1391 * the peer (group) to whom we're going to announce is on a shared network
1392 * and this is either a self-originated route or the peer is EBGP.
1396 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
1397 if ((CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1398 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) &&
1399 IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
)) ||
1400 (!reflect
&& peer
->shared_network
&&
1401 (from
== bgp
->peer_self
|| peer
->sort
== BGP_PEER_EBGP
)))
1403 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
1406 /* Clear off link-local nexthop in source, whenever it is not needed to
1407 * ensure more prefixes share the same attribute for announcement.
1409 if (!(CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1410 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)))
1411 memset (&attr
->extra
->mp_nexthop_local
, 0, IPV6_MAX_BYTELEN
);
1413 #endif /* HAVE_IPV6 */
1415 bgp_peer_remove_private_as(bgp
, afi
, safi
, peer
, attr
);
1416 bgp_peer_as_override(bgp
, afi
, safi
, peer
, attr
);
1418 /* Route map & unsuppress-map apply. */
1419 if (ROUTE_MAP_OUT_NAME (filter
)
1420 || (ri
->extra
&& ri
->extra
->suppress
) )
1422 struct bgp_info info
;
1423 struct attr dummy_attr
;
1424 struct attr_extra dummy_extra
;
1426 dummy_attr
.extra
= &dummy_extra
;
1430 /* don't confuse inbound and outbound setting */
1431 RESET_FLAG(attr
->rmap_change_flags
);
1434 * The route reflector is not allowed to modify the attributes
1435 * of the reflected IBGP routes unless explicitly allowed.
1437 if ((from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1438 && !bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
))
1440 bgp_attr_dup (&dummy_attr
, attr
);
1441 info
.attr
= &dummy_attr
;
1444 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1446 if (ri
->extra
&& ri
->extra
->suppress
)
1447 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1449 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1451 peer
->rmap_type
= 0;
1453 if (ret
== RMAP_DENYMATCH
)
1455 bgp_attr_flush (attr
);
1460 /* After route-map has been applied, we check to see if the nexthop to
1461 * be carried in the attribute (that is used for the announcement) can
1462 * be cleared off or not. We do this in all cases where we would be
1463 * setting the nexthop to "ourselves". For IPv6, we only need to consider
1464 * the global nexthop here; the link-local nexthop would have been cleared
1465 * already, and if not, it is required by the update formation code.
1466 * Also see earlier comments in this function.
1469 * If route-map has performed some operation on the nexthop or the peer
1470 * configuration says to pass it unchanged, we cannot reset the nexthop
1471 * here, so only attempt to do it if these aren't true. Note that the
1472 * route-map handler itself might have cleared the nexthop, if for example,
1473 * it is configured as 'peer-address'.
1475 if (!bgp_rmap_nhop_changed(attr
->rmap_change_flags
,
1476 riattr
->rmap_change_flags
) &&
1478 !CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
))
1480 /* We can reset the nexthop, if setting (or forcing) it to 'self' */
1481 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
) ||
1482 CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_FORCE_NEXTHOP_SELF
))
1485 CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1486 PEER_FLAG_FORCE_NEXTHOP_SELF
))
1487 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ?
1488 AF_INET6
: p
->family
), attr
);
1490 else if (peer
->sort
== BGP_PEER_EBGP
)
1492 /* Can also reset the nexthop if announcing to EBGP, but only if
1493 * no peer in the subgroup is on a shared subnet.
1494 * Note: 3rd party nexthop currently implemented for IPv4 only.
1496 SUBGRP_FOREACH_PEER (subgrp
, paf
)
1498 if (bgp_multiaccess_check_v4 (riattr
->nexthop
, paf
->peer
))
1502 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ? AF_INET6
: p
->family
), attr
);
1504 /* If IPv6/MP and nexthop does not have any override and happens to
1505 * be a link-local address, reset it so that we don't pass along the
1506 * source's link-local IPv6 address to recipients who may not be on
1507 * the same interface.
1509 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1511 if (IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_global
))
1512 subgroup_announce_reset_nhop (AF_INET6
, attr
);
1519 struct bgp_info_pair
1521 struct bgp_info
*old
;
1522 struct bgp_info
*new;
1526 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
,
1527 struct bgp_maxpaths_cfg
*mpath_cfg
,
1528 struct bgp_info_pair
*result
)
1530 struct bgp_info
*new_select
;
1531 struct bgp_info
*old_select
;
1532 struct bgp_info
*ri
;
1533 struct bgp_info
*ri1
;
1534 struct bgp_info
*ri2
;
1535 struct bgp_info
*nextri
= NULL
;
1536 int paths_eq
, do_mpath
, debug
;
1537 struct list mp_list
;
1538 char pfx_buf
[PREFIX2STR_BUFFER
];
1539 char path_buf
[PATH_ADDPATH_STR_BUFFER
];
1541 bgp_mp_list_init (&mp_list
);
1542 do_mpath
= (mpath_cfg
->maxpaths_ebgp
> 1 || mpath_cfg
->maxpaths_ibgp
> 1);
1544 debug
= bgp_debug_bestpath(&rn
->p
);
1547 prefix2str (&rn
->p
, pfx_buf
, sizeof (pfx_buf
));
1549 /* bgp deterministic-med */
1551 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1554 /* Clear BGP_INFO_DMED_SELECTED for all paths */
1555 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1556 bgp_info_unset_flag (rn
, ri1
, BGP_INFO_DMED_SELECTED
);
1558 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1560 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1562 if (BGP_INFO_HOLDDOWN (ri1
))
1564 if (ri1
->peer
&& ri1
->peer
!= bgp
->peer_self
)
1565 if (ri1
->peer
->status
!= Established
)
1571 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1573 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1575 if (BGP_INFO_HOLDDOWN (ri2
))
1578 ri2
->peer
!= bgp
->peer_self
&&
1579 !CHECK_FLAG (ri2
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1580 if (ri2
->peer
->status
!= Established
)
1583 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1584 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1587 if (bgp_info_cmp (bgp
, ri2
, new_select
, &paths_eq
,
1588 mpath_cfg
, debug
, pfx_buf
))
1590 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1594 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1598 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1599 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1603 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1604 zlog_debug("%s: %s is the bestpath from AS %d",
1605 pfx_buf
, path_buf
, aspath_get_firstas(new_select
->attr
->aspath
));
1610 /* Check old selected route and new selected route. */
1613 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1615 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1618 if (BGP_INFO_HOLDDOWN (ri
))
1620 /* reap REMOVED routes, if needs be
1621 * selected route must stay for a while longer though
1623 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1624 && (ri
!= old_select
))
1625 bgp_info_reap (rn
, ri
);
1631 ri
->peer
!= bgp
->peer_self
&&
1632 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1633 if (ri
->peer
->status
!= Established
)
1636 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1637 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1639 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1643 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1645 if (bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
))
1651 /* Now that we know which path is the bestpath see if any of the other paths
1652 * qualify as multipaths
1657 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1659 sprintf (path_buf
, "NONE");
1660 zlog_debug("%s: After path selection, newbest is %s oldbest was %s",
1662 old_select
? old_select
->peer
->host
: "NONE");
1665 if (do_mpath
&& new_select
)
1667 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1671 bgp_info_path_with_addpath_rx_str (ri
, path_buf
);
1673 if (ri
== new_select
)
1676 zlog_debug("%s: %s is the bestpath, add to the multipath list",
1678 bgp_mp_list_add (&mp_list
, ri
);
1682 if (BGP_INFO_HOLDDOWN (ri
))
1686 ri
->peer
!= bgp
->peer_self
&&
1687 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1688 if (ri
->peer
->status
!= Established
)
1691 if (!bgp_info_nexthop_cmp (ri
, new_select
))
1694 zlog_debug("%s: %s has the same nexthop as the bestpath, skip it",
1699 bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
);
1704 zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list",
1706 bgp_mp_list_add (&mp_list
, ri
);
1711 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1712 bgp_info_mpath_aggregate_update (new_select
, old_select
);
1713 bgp_mp_list_clear (&mp_list
);
1715 result
->old
= old_select
;
1716 result
->new = new_select
;
1722 * A new route/change in bestpath of an existing route. Evaluate the path
1723 * for advertisement to the subgroup.
1726 subgroup_process_announce_selected (struct update_subgroup
*subgrp
,
1727 struct bgp_info
*selected
,
1728 struct bgp_node
*rn
,
1729 u_int32_t addpath_tx_id
)
1732 struct peer
*onlypeer
;
1734 struct attr_extra extra
;
1739 afi
= SUBGRP_AFI(subgrp
);
1740 safi
= SUBGRP_SAFI(subgrp
);
1741 onlypeer
= ((SUBGRP_PCOUNT(subgrp
) == 1) ?
1742 (SUBGRP_PFIRST(subgrp
))->peer
: NULL
);
1744 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1745 if (onlypeer
&& CHECK_FLAG (onlypeer
->af_sflags
[afi
][safi
],
1746 PEER_STATUS_ORF_WAIT_REFRESH
))
1749 /* It's initialized in bgp_announce_check() */
1750 attr
.extra
= &extra
;
1752 /* Announcement to the subgroup. If the route is filtered withdraw it. */
1755 if (subgroup_announce_check(selected
, subgrp
, p
, &attr
))
1756 bgp_adj_out_set_subgroup(rn
, subgrp
, &attr
, selected
);
1758 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, selected
->addpath_tx_id
);
1761 /* If selected is NULL we must withdraw the path using addpath_tx_id */
1764 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, addpath_tx_id
);
1771 * Clear IGP changed flag and attribute changed flag for a route (all paths).
1772 * This is called at the end of route processing.
1775 bgp_zebra_clear_route_change_flags (struct bgp_node
*rn
)
1777 struct bgp_info
*ri
;
1779 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1781 if (BGP_INFO_HOLDDOWN (ri
))
1783 UNSET_FLAG (ri
->flags
, BGP_INFO_IGP_CHANGED
);
1784 UNSET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
1789 * Has the route changed from the RIB's perspective? This is invoked only
1790 * if the route selection returns the same best route as earlier - to
1791 * determine if we need to update zebra or not.
1794 bgp_zebra_has_route_changed (struct bgp_node
*rn
, struct bgp_info
*selected
)
1796 struct bgp_info
*mpinfo
;
1798 /* If this is multipath, check all selected paths for any nexthop change or
1799 * attribute change. Some attribute changes (e.g., community) aren't of
1800 * relevance to the RIB, but we'll update zebra to ensure we handle the
1801 * case of BGP nexthop change. This is the behavior when the best path has
1802 * an attribute change anyway.
1804 if (CHECK_FLAG (selected
->flags
, BGP_INFO_IGP_CHANGED
) ||
1805 CHECK_FLAG (selected
->flags
, BGP_INFO_MULTIPATH_CHG
))
1808 /* If this is multipath, check all selected paths for any nexthop change */
1809 for (mpinfo
= bgp_info_mpath_first (selected
); mpinfo
;
1810 mpinfo
= bgp_info_mpath_next (mpinfo
))
1812 if (CHECK_FLAG (mpinfo
->flags
, BGP_INFO_IGP_CHANGED
)
1813 || CHECK_FLAG (mpinfo
->flags
, BGP_INFO_ATTR_CHANGED
))
1817 /* Nothing has changed from the RIB's perspective. */
1821 struct bgp_process_queue
1824 struct bgp_node
*rn
;
1829 static wq_item_status
1830 bgp_process_main (struct work_queue
*wq
, void *data
)
1832 struct bgp_process_queue
*pq
= data
;
1833 struct bgp
*bgp
= pq
->bgp
;
1834 struct bgp_node
*rn
= pq
->rn
;
1835 afi_t afi
= pq
->afi
;
1836 safi_t safi
= pq
->safi
;
1837 struct prefix
*p
= &rn
->p
;
1838 struct bgp_info
*new_select
;
1839 struct bgp_info
*old_select
;
1840 struct bgp_info_pair old_and_new
;
1842 /* Is it end of initial update? (after startup) */
1845 quagga_timestamp(3, bgp
->update_delay_zebra_resume_time
,
1846 sizeof(bgp
->update_delay_zebra_resume_time
));
1848 bgp
->main_zebra_update_hold
= 0;
1849 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1850 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1852 bgp_zebra_announce_table(bgp
, afi
, safi
);
1854 bgp
->main_peers_update_hold
= 0;
1856 bgp_start_routeadv(bgp
);
1860 /* Best path selection. */
1861 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1862 old_select
= old_and_new
.old
;
1863 new_select
= old_and_new
.new;
1865 /* Nothing to do. */
1866 if (old_select
&& old_select
== new_select
&&
1867 !CHECK_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
) &&
1868 !CHECK_FLAG(old_select
->flags
, BGP_INFO_ATTR_CHANGED
) &&
1869 !bgp
->addpath_tx_used
[afi
][safi
])
1871 if (bgp_zebra_has_route_changed (rn
, old_select
))
1872 bgp_zebra_announce (p
, old_select
, bgp
, afi
, safi
);
1874 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1875 bgp_zebra_clear_route_change_flags (rn
);
1876 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1880 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1881 UNSET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
1883 /* bestpath has changed; bump version */
1884 if (old_select
|| new_select
)
1886 bgp_bump_version(rn
);
1888 if (!bgp
->t_rmap_def_originate_eval
)
1891 THREAD_TIMER_ON(bm
->master
, bgp
->t_rmap_def_originate_eval
,
1892 update_group_refresh_default_originate_route_map
,
1893 bgp
, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER
);
1898 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1901 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1902 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1903 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1906 group_announce_route(bgp
, afi
, safi
, rn
, new_select
);
1909 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) &&
1910 (bgp
->inst_type
!= BGP_INSTANCE_TYPE_VIEW
) &&
1911 !bgp_option_check (BGP_OPT_NO_FIB
))
1914 && new_select
->type
== ZEBRA_ROUTE_BGP
1915 && (new_select
->sub_type
== BGP_ROUTE_NORMAL
||
1916 new_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1917 bgp_zebra_announce (p
, new_select
, bgp
, afi
, safi
);
1920 /* Withdraw the route from the kernel. */
1922 && old_select
->type
== ZEBRA_ROUTE_BGP
1923 && (old_select
->sub_type
== BGP_ROUTE_NORMAL
||
1924 old_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1925 bgp_zebra_withdraw (p
, old_select
, safi
);
1929 /* Clear any route change flags. */
1930 bgp_zebra_clear_route_change_flags (rn
);
1932 /* Reap old select bgp_info, if it has been removed */
1933 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1934 bgp_info_reap (rn
, old_select
);
1936 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1941 bgp_processq_del (struct work_queue
*wq
, void *data
)
1943 struct bgp_process_queue
*pq
= data
;
1944 struct bgp_table
*table
;
1946 bgp_unlock (pq
->bgp
);
1949 table
= bgp_node_table (pq
->rn
);
1950 bgp_unlock_node (pq
->rn
);
1951 bgp_table_unlock (table
);
1953 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1957 bgp_process_queue_init (void)
1959 if (!bm
->process_main_queue
)
1961 bm
->process_main_queue
1962 = work_queue_new (bm
->master
, "process_main_queue");
1964 if ( !bm
->process_main_queue
)
1966 zlog_err ("%s: Failed to allocate work queue", __func__
);
1971 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1972 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1973 bm
->process_main_queue
->spec
.max_retries
= 0;
1974 bm
->process_main_queue
->spec
.hold
= 50;
1975 /* Use a higher yield value of 50ms for main queue processing */
1976 bm
->process_main_queue
->spec
.yield
= 50 * 1000L;
1980 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1982 struct bgp_process_queue
*pqnode
;
1984 /* already scheduled for processing? */
1985 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1988 if (bm
->process_main_queue
== NULL
)
1989 bgp_process_queue_init ();
1991 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1992 sizeof (struct bgp_process_queue
));
1996 /* all unlocked in bgp_processq_del */
1997 bgp_table_lock (bgp_node_table (rn
));
1998 pqnode
->rn
= bgp_lock_node (rn
);
2002 pqnode
->safi
= safi
;
2003 work_queue_add (bm
->process_main_queue
, pqnode
);
2004 SET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2009 bgp_add_eoiu_mark (struct bgp
*bgp
)
2011 struct bgp_process_queue
*pqnode
;
2013 if (bm
->process_main_queue
== NULL
)
2014 bgp_process_queue_init ();
2016 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2017 sizeof (struct bgp_process_queue
));
2024 work_queue_add (bm
->process_main_queue
, pqnode
);
2028 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
2032 peer
= THREAD_ARG (thread
);
2033 peer
->t_pmax_restart
= NULL
;
2035 if (bgp_debug_neighbor_events(peer
))
2036 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
2039 peer_clear (peer
, NULL
);
2045 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
2046 safi_t safi
, int always
)
2048 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
2051 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
2053 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
2057 zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
2058 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
2059 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
2060 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2062 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
2068 if (safi
== SAFI_MPLS_VPN
)
2069 safi
= SAFI_MPLS_LABELED_VPN
;
2071 ndata
[0] = (afi
>> 8);
2074 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
2075 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
2076 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
2077 ndata
[6] = (peer
->pmax
[afi
][safi
]);
2079 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
2080 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
2081 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
2084 /* Dynamic peers will just close their connection. */
2085 if (peer_dynamic_neighbor (peer
))
2088 /* restart timer start */
2089 if (peer
->pmax_restart
[afi
][safi
])
2091 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
2093 if (bgp_debug_neighbor_events(peer
))
2094 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
2095 peer
->host
, peer
->v_pmax_restart
);
2097 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
2098 peer
->v_pmax_restart
);
2104 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2106 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
2108 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
2112 zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
2113 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
2114 peer
->pmax
[afi
][safi
]);
2115 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2118 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2122 /* Unconditionally remove the route from the RIB, without taking
2123 * damping into consideration (eg, because the session went down)
2126 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2127 afi_t afi
, safi_t safi
)
2129 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2131 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2132 bgp_info_delete (rn
, ri
); /* keep historical info */
2134 bgp_process (peer
->bgp
, rn
, afi
, safi
);
2138 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2139 afi_t afi
, safi_t safi
)
2141 int status
= BGP_DAMP_NONE
;
2143 /* apply dampening, if result is suppressed, we'll be retaining
2144 * the bgp_info in the RIB for historical reference.
2146 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2147 && peer
->sort
== BGP_PEER_EBGP
)
2148 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
2149 == BGP_DAMP_SUPPRESSED
)
2151 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2155 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2158 static struct bgp_info
*
2159 info_make (int type
, int sub_type
, u_short instance
, struct peer
*peer
, struct attr
*attr
,
2160 struct bgp_node
*rn
)
2162 struct bgp_info
*new;
2164 /* Make new BGP info. */
2165 new = XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
2167 new->instance
= instance
;
2168 new->sub_type
= sub_type
;
2171 new->uptime
= bgp_clock ();
2173 new->addpath_tx_id
= ++peer
->bgp
->addpath_tx_id
;
2178 bgp_info_addpath_rx_str(u_int32_t addpath_id
, char *buf
)
2181 sprintf(buf
, " with addpath ID %d", addpath_id
);
2185 /* Check if received nexthop is valid or not. */
2187 bgp_update_martian_nexthop (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct attr
*attr
)
2189 struct attr_extra
*attre
= attr
->extra
;
2192 /* Only validated for unicast and multicast currently. */
2193 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2196 /* If NEXT_HOP is present, validate it. */
2197 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2199 if (attr
->nexthop
.s_addr
== 0 ||
2200 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2201 bgp_nexthop_self (bgp
, attr
))
2205 /* If MP_NEXTHOP is present, validate it. */
2206 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2207 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2208 * it is not an IPv6 link-local address.
2210 if (attre
&& attre
->mp_nexthop_len
)
2212 switch (attre
->mp_nexthop_len
)
2214 case BGP_ATTR_NHLEN_IPV4
:
2215 case BGP_ATTR_NHLEN_VPNV4
:
2216 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2217 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2221 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2222 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2223 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2224 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2225 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2227 #endif /* HAVE_IPV6 */
2239 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2240 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2241 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2245 int aspath_loop_count
= 0;
2246 struct bgp_node
*rn
;
2248 struct attr new_attr
;
2249 struct attr_extra new_extra
;
2250 struct attr
*attr_new
;
2251 struct bgp_info
*ri
;
2252 struct bgp_info
*new;
2254 char buf
[SU_ADDRSTRLEN
];
2259 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2261 /* When peer's soft reconfiguration enabled. Record input packet in
2263 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2264 && peer
!= bgp
->peer_self
)
2265 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2267 /* Check previously received route. */
2268 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2269 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2270 ri
->addpath_rx_id
== addpath_id
)
2273 /* AS path local-as loop check. */
2274 if (peer
->change_local_as
)
2276 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2277 aspath_loop_count
= 1;
2279 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2281 reason
= "as-path contains our own AS;";
2286 /* AS path loop check. */
2287 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2288 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2289 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2290 > peer
->allowas_in
[afi
][safi
]))
2292 reason
= "as-path contains our own AS;";
2296 /* Route reflector originator ID check. */
2297 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2298 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2300 reason
= "originator is us;";
2304 /* Route reflector cluster ID check. */
2305 if (bgp_cluster_filter (peer
, attr
))
2307 reason
= "reflected from the same cluster;";
2311 /* Apply incoming filter. */
2312 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2318 new_attr
.extra
= &new_extra
;
2319 bgp_attr_dup (&new_attr
, attr
);
2321 /* Apply incoming route-map.
2322 * NB: new_attr may now contain newly allocated values from route-map "set"
2323 * commands, so we need bgp_attr_flush in the error paths, until we intern
2324 * the attr (which takes over the memory references) */
2325 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2327 reason
= "route-map;";
2328 bgp_attr_flush (&new_attr
);
2332 /* next hop check. */
2333 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2335 reason
= "martian or self next-hop;";
2336 bgp_attr_flush (&new_attr
);
2340 attr_new
= bgp_attr_intern (&new_attr
);
2342 /* If the update is implicit withdraw. */
2345 ri
->uptime
= bgp_clock ();
2347 /* Same attribute comes in. */
2348 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2349 && attrhash_cmp (ri
->attr
, attr_new
))
2351 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2352 && peer
->sort
== BGP_PEER_EBGP
2353 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2355 if (bgp_debug_update(peer
, p
, NULL
, 1))
2357 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2358 zlog_debug ("%s rcvd %s/%d%s",
2360 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2361 p
->prefixlen
, buf2
);
2364 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2366 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2367 bgp_process (bgp
, rn
, afi
, safi
);
2370 else /* Duplicate - odd */
2372 if (bgp_debug_update(peer
, p
, NULL
, 1))
2374 if (!peer
->rcvd_attr_printed
)
2376 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2377 peer
->rcvd_attr_printed
= 1;
2380 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2381 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2383 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2384 p
->prefixlen
, buf2
);
2387 /* graceful restart STALE flag unset. */
2388 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2390 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2391 bgp_process (bgp
, rn
, afi
, safi
);
2395 bgp_unlock_node (rn
);
2396 bgp_attr_unintern (&attr_new
);
2401 /* Withdraw/Announce before we fully processed the withdraw */
2402 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2404 if (bgp_debug_update(peer
, p
, NULL
, 1))
2406 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2407 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2409 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2410 p
->prefixlen
, buf2
);
2412 bgp_info_restore (rn
, ri
);
2415 /* Received Logging. */
2416 if (bgp_debug_update(peer
, p
, NULL
, 1))
2418 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2419 zlog_debug ("%s rcvd %s/%d%s",
2421 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2422 p
->prefixlen
, buf2
);
2425 /* graceful restart STALE flag unset. */
2426 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2427 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2429 /* The attribute is changed. */
2430 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2432 /* implicit withdraw, decrement aggregate and pcount here.
2433 * only if update is accepted, they'll increment below.
2435 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2437 /* Update bgp route dampening information. */
2438 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2439 && peer
->sort
== BGP_PEER_EBGP
)
2441 /* This is implicit withdraw so we should update dampening
2443 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2444 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2447 /* Update to new attribute. */
2448 bgp_attr_unintern (&ri
->attr
);
2449 ri
->attr
= attr_new
;
2451 /* Update MPLS tag. */
2452 if (safi
== SAFI_MPLS_VPN
)
2453 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2455 /* Update bgp route dampening information. */
2456 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2457 && peer
->sort
== BGP_PEER_EBGP
)
2459 /* Now we do normal update dampening. */
2460 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2461 if (ret
== BGP_DAMP_SUPPRESSED
)
2463 bgp_unlock_node (rn
);
2468 /* Nexthop reachability check. */
2469 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2471 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2472 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2473 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2478 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2479 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2482 if (BGP_DEBUG(nht
, NHT
))
2484 char buf1
[INET6_ADDRSTRLEN
];
2485 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2486 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2488 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2492 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2494 /* Process change. */
2495 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2497 bgp_process (bgp
, rn
, afi
, safi
);
2498 bgp_unlock_node (rn
);
2501 } // End of implicit withdraw
2503 /* Received Logging. */
2504 if (bgp_debug_update(peer
, p
, NULL
, 1))
2506 if (!peer
->rcvd_attr_printed
)
2508 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2509 peer
->rcvd_attr_printed
= 1;
2512 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2513 zlog_debug ("%s rcvd %s/%d%s",
2515 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2516 p
->prefixlen
, buf2
);
2519 /* Make new BGP info. */
2520 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2522 /* Update MPLS tag. */
2523 if (safi
== SAFI_MPLS_VPN
)
2524 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2526 /* Nexthop reachability check. */
2527 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2529 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2530 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2531 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2536 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2537 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2540 if (BGP_DEBUG(nht
, NHT
))
2542 char buf1
[INET6_ADDRSTRLEN
];
2543 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2544 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2546 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2550 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2553 new->addpath_rx_id
= addpath_id
;
2555 /* Increment prefix */
2556 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2558 /* Register new BGP information. */
2559 bgp_info_add (rn
, new);
2561 /* route_node_get lock */
2562 bgp_unlock_node (rn
);
2564 /* If maximum prefix count is configured and current prefix
2566 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2569 /* Process change. */
2570 bgp_process (bgp
, rn
, afi
, safi
);
2574 /* This BGP update is filtered. Log the reason then update BGP
2577 if (bgp_debug_update(peer
, p
, NULL
, 1))
2579 if (!peer
->rcvd_attr_printed
)
2581 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2582 peer
->rcvd_attr_printed
= 1;
2585 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2586 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2588 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2589 p
->prefixlen
, buf2
, reason
);
2593 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2595 bgp_unlock_node (rn
);
2601 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2602 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2603 struct prefix_rd
*prd
, u_char
*tag
)
2606 char buf
[SU_ADDRSTRLEN
];
2608 struct bgp_node
*rn
;
2609 struct bgp_info
*ri
;
2614 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2616 /* If peer is soft reconfiguration enabled. Record input packet for
2617 * further calculation.
2619 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2620 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2621 * the iteration over all RS clients.
2622 * Since we need to remove the entry from adj_in anyway, do that first and
2623 * if there was no entry, we don't need to do anything more.
2625 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2626 && peer
!= bgp
->peer_self
)
2627 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2629 if (bgp_debug_update (peer
, p
, NULL
, 1))
2630 zlog_debug ("%s withdrawing route %s/%d "
2631 "not in adj-in", peer
->host
,
2632 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2634 bgp_unlock_node (rn
);
2638 /* Lookup withdrawn route. */
2639 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2640 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2641 ri
->addpath_rx_id
== addpath_id
)
2645 if (bgp_debug_update(peer
, p
, NULL
, 1))
2647 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2648 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2650 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2651 p
->prefixlen
, buf2
);
2654 /* Withdraw specified route from routing table. */
2655 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2656 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2657 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2658 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2659 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2662 /* Unlock bgp_node_get() lock. */
2663 bgp_unlock_node (rn
);
2669 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2671 struct update_subgroup
*subgrp
;
2672 subgrp
= peer_subgroup(peer
, afi
, safi
);
2673 subgroup_default_originate(subgrp
, withdraw
);
2678 * bgp_stop_announce_route_timer
2681 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2683 if (!paf
->t_announce_route
)
2686 THREAD_TIMER_OFF (paf
->t_announce_route
);
2690 * bgp_announce_route_timer_expired
2692 * Callback that is invoked when the route announcement timer for a
2696 bgp_announce_route_timer_expired (struct thread
*t
)
2698 struct peer_af
*paf
;
2701 paf
= THREAD_ARG (t
);
2704 assert (paf
->t_announce_route
);
2705 paf
->t_announce_route
= NULL
;
2707 if (peer
->status
!= Established
)
2710 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2713 peer_af_announce_route (paf
, 1);
2718 * bgp_announce_route
2720 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2723 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2725 struct peer_af
*paf
;
2726 struct update_subgroup
*subgrp
;
2728 paf
= peer_af_find (peer
, afi
, safi
);
2731 subgrp
= PAF_SUBGRP(paf
);
2734 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2735 * or a refresh has already been triggered.
2737 if (!subgrp
|| paf
->t_announce_route
)
2741 * Start a timer to stagger/delay the announce. This serves
2742 * two purposes - announcement can potentially be combined for
2743 * multiple peers and the announcement doesn't happen in the
2746 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2747 bgp_announce_route_timer_expired
, paf
,
2748 (subgrp
->peer_count
== 1) ?
2749 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2750 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2754 * Announce routes from all AF tables to a peer.
2756 * This should ONLY be called when there is a need to refresh the
2757 * routes to the peer based on a policy change for this peer alone
2758 * or a route refresh request received from the peer.
2759 * The operation will result in splitting the peer from its existing
2760 * subgroups and putting it in new subgroups.
2763 bgp_announce_route_all (struct peer
*peer
)
2768 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2769 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2770 bgp_announce_route (peer
, afi
, safi
);
2774 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2775 struct bgp_table
*table
, struct prefix_rd
*prd
)
2778 struct bgp_node
*rn
;
2779 struct bgp_adj_in
*ain
;
2782 table
= peer
->bgp
->rib
[afi
][safi
];
2784 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2785 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2787 if (ain
->peer
== peer
)
2789 struct bgp_info
*ri
= rn
->info
;
2790 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
2792 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
2793 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2798 bgp_unlock_node (rn
);
2806 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2808 struct bgp_node
*rn
;
2809 struct bgp_table
*table
;
2811 if (peer
->status
!= Established
)
2814 if ((safi
!= SAFI_MPLS_VPN
) && (safi
!= SAFI_ENCAP
))
2815 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
2817 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2818 rn
= bgp_route_next (rn
))
2819 if ((table
= rn
->info
) != NULL
)
2821 struct prefix_rd prd
;
2822 prd
.family
= AF_UNSPEC
;
2824 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
2826 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
2831 struct bgp_clear_node_queue
2833 struct bgp_node
*rn
;
2836 static wq_item_status
2837 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2839 struct bgp_clear_node_queue
*cnq
= data
;
2840 struct bgp_node
*rn
= cnq
->rn
;
2841 struct peer
*peer
= wq
->spec
.data
;
2842 struct bgp_info
*ri
;
2843 afi_t afi
= bgp_node_table (rn
)->afi
;
2844 safi_t safi
= bgp_node_table (rn
)->safi
;
2846 assert (rn
&& peer
);
2848 /* It is possible that we have multiple paths for a prefix from a peer
2849 * if that peer is using AddPath.
2851 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2852 if (ri
->peer
== peer
)
2854 /* graceful restart STALE flag set. */
2855 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2856 && peer
->nsf
[afi
][safi
]
2857 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2858 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2859 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2861 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2867 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2869 struct bgp_clear_node_queue
*cnq
= data
;
2870 struct bgp_node
*rn
= cnq
->rn
;
2871 struct bgp_table
*table
= bgp_node_table (rn
);
2873 bgp_unlock_node (rn
);
2874 bgp_table_unlock (table
);
2875 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2879 bgp_clear_node_complete (struct work_queue
*wq
)
2881 struct peer
*peer
= wq
->spec
.data
;
2883 /* Tickle FSM to start moving again */
2884 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2886 peer_unlock (peer
); /* bgp_clear_route */
2890 bgp_clear_node_queue_init (struct peer
*peer
)
2892 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2894 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2895 #undef CLEAR_QUEUE_NAME_LEN
2897 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2899 zlog_err ("%s: Failed to allocate work queue", __func__
);
2902 peer
->clear_node_queue
->spec
.hold
= 10;
2903 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2904 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2905 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2906 peer
->clear_node_queue
->spec
.max_retries
= 0;
2908 /* we only 'lock' this peer reference when the queue is actually active */
2909 peer
->clear_node_queue
->spec
.data
= peer
;
2913 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2914 struct bgp_table
*table
)
2916 struct bgp_node
*rn
;
2920 table
= peer
->bgp
->rib
[afi
][safi
];
2922 /* If still no table => afi/safi isn't configured at all or smth. */
2926 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2928 struct bgp_info
*ri
;
2929 struct bgp_adj_in
*ain
;
2930 struct bgp_adj_in
*ain_next
;
2932 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2933 * queued for every clearing peer, regardless of whether it is
2934 * relevant to the peer at hand.
2936 * Overview: There are 3 different indices which need to be
2937 * scrubbed, potentially, when a peer is removed:
2939 * 1 peer's routes visible via the RIB (ie accepted routes)
2940 * 2 peer's routes visible by the (optional) peer's adj-in index
2941 * 3 other routes visible by the peer's adj-out index
2943 * 3 there is no hurry in scrubbing, once the struct peer is
2944 * removed from bgp->peer, we could just GC such deleted peer's
2945 * adj-outs at our leisure.
2947 * 1 and 2 must be 'scrubbed' in some way, at least made
2948 * invisible via RIB index before peer session is allowed to be
2949 * brought back up. So one needs to know when such a 'search' is
2954 * - there'd be a single global queue or a single RIB walker
2955 * - rather than tracking which route_nodes still need to be
2956 * examined on a peer basis, we'd track which peers still
2959 * Given that our per-peer prefix-counts now should be reliable,
2960 * this may actually be achievable. It doesn't seem to be a huge
2961 * problem at this time,
2963 * It is possible that we have multiple paths for a prefix from a peer
2964 * if that peer is using AddPath.
2969 ain_next
= ain
->next
;
2971 if (ain
->peer
== peer
)
2973 bgp_adj_in_remove (rn
, ain
);
2974 bgp_unlock_node (rn
);
2980 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2981 if (ri
->peer
== peer
)
2983 struct bgp_clear_node_queue
*cnq
;
2985 /* both unlocked in bgp_clear_node_queue_del */
2986 bgp_table_lock (bgp_node_table (rn
));
2988 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2989 sizeof (struct bgp_clear_node_queue
));
2991 work_queue_add (peer
->clear_node_queue
, cnq
);
2999 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3001 struct bgp_node
*rn
;
3002 struct bgp_table
*table
;
3004 if (peer
->clear_node_queue
== NULL
)
3005 bgp_clear_node_queue_init (peer
);
3007 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3008 * Idle until it receives a Clearing_Completed event. This protects
3009 * against peers which flap faster than we can we clear, which could
3012 * a) race with routes from the new session being installed before
3013 * clear_route_node visits the node (to delete the route of that
3015 * b) resource exhaustion, clear_route_node likely leads to an entry
3016 * on the process_main queue. Fast-flapping could cause that queue
3020 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3021 * the unlock will happen upon work-queue completion; other wise, the
3022 * unlock happens at the end of this function.
3024 if (!peer
->clear_node_queue
->thread
)
3027 if (safi
!= SAFI_MPLS_VPN
&& safi
!= SAFI_ENCAP
)
3028 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
3030 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3031 rn
= bgp_route_next (rn
))
3032 if ((table
= rn
->info
) != NULL
)
3033 bgp_clear_route_table (peer
, afi
, safi
, table
);
3035 /* unlock if no nodes got added to the clear-node-queue. */
3036 if (!peer
->clear_node_queue
->thread
)
3042 bgp_clear_route_all (struct peer
*peer
)
3047 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3048 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3049 bgp_clear_route (peer
, afi
, safi
);
3053 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3055 struct bgp_table
*table
;
3056 struct bgp_node
*rn
;
3057 struct bgp_adj_in
*ain
;
3058 struct bgp_adj_in
*ain_next
;
3060 table
= peer
->bgp
->rib
[afi
][safi
];
3062 /* It is possible that we have multiple paths for a prefix from a peer
3063 * if that peer is using AddPath.
3065 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3071 ain_next
= ain
->next
;
3073 if (ain
->peer
== peer
)
3075 bgp_adj_in_remove (rn
, ain
);
3076 bgp_unlock_node (rn
);
3085 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3087 struct bgp_node
*rn
;
3088 struct bgp_info
*ri
;
3089 struct bgp_table
*table
;
3091 table
= peer
->bgp
->rib
[afi
][safi
];
3093 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3095 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3096 if (ri
->peer
== peer
)
3098 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3099 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3106 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3108 struct bgp_node
*rn
;
3109 struct bgp_info
*ri
;
3110 struct bgp_info
*next
;
3112 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3113 for (ri
= rn
->info
; ri
; ri
= next
)
3116 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3117 && ri
->type
== ZEBRA_ROUTE_BGP
3118 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3119 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3120 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3124 /* Delete all kernel routes. */
3126 bgp_cleanup_routes (void)
3129 struct listnode
*node
, *nnode
;
3132 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
3134 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3136 struct bgp_node
*rn
;
3138 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3141 * VPN and ENCAP tables are two-level (RD is top level)
3143 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3144 rn
= bgp_route_next (rn
))
3148 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3149 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3151 bgp_unlock_node(rn
);
3155 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_ENCAP
]); rn
;
3156 rn
= bgp_route_next (rn
))
3160 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_ENCAP
);
3161 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3163 bgp_unlock_node(rn
);
3174 bgp_zclient_reset ();
3175 access_list_reset ();
3176 prefix_list_reset ();
3180 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3182 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3183 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3186 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3189 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3198 int addpath_encoded
;
3199 u_int32_t addpath_id
;
3201 /* Check peer status. */
3202 if (peer
->status
!= Established
)
3206 lim
= pnt
+ packet
->length
;
3208 safi
= packet
->safi
;
3210 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3212 for (; pnt
< lim
; pnt
+= psize
)
3214 /* Clear prefix structure. */
3215 memset (&p
, 0, sizeof (struct prefix
));
3217 if (addpath_encoded
)
3220 /* When packet overflow occurs return immediately. */
3221 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3224 addpath_id
= ntohl(*((uint32_t*) pnt
));
3225 pnt
+= BGP_ADDPATH_ID_LEN
;
3228 /* Fetch prefix length. */
3229 p
.prefixlen
= *pnt
++;
3230 p
.family
= afi2family (afi
);
3232 /* Already checked in nlri_sanity_check(). We do double check
3234 if ((afi
== AFI_IP
&& p
.prefixlen
> 32)
3235 || (afi
== AFI_IP6
&& p
.prefixlen
> 128))
3238 /* Packet size overflow check. */
3239 psize
= PSIZE (p
.prefixlen
);
3241 /* When packet overflow occur return immediately. */
3242 if (pnt
+ psize
> lim
)
3245 /* Fetch prefix from NLRI packet. */
3246 memcpy (&p
.u
.prefix
, pnt
, psize
);
3248 /* Check address. */
3249 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3251 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3254 * From draft-ietf-idr-bgp4-22, Section 6.3:
3255 * If a BGP router receives an UPDATE message with a
3256 * semantically incorrect NLRI field, in which a prefix is
3257 * semantically incorrect (eg. an unexpected multicast IP
3258 * address), it should ignore the prefix.
3260 zlog_err ("IPv4 unicast NLRI is multicast address %s",
3261 inet_ntoa (p
.u
.prefix4
));
3268 /* Check address. */
3269 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3271 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3275 zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
3276 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3281 #endif /* HAVE_IPV6 */
3283 /* Normal process. */
3285 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3286 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3288 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3289 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3291 /* Address family configuration mismatch or maximum-prefix count
3297 /* Packet length consistency check. */
3304 /* NLRI encode syntax check routine. */
3306 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, safi_t safi
, u_char
*pnt
,
3307 bgp_size_t length
, int *numpfx
)
3312 int addpath_encoded
;
3316 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3318 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3319 syntactic validity. If the field is syntactically incorrect,
3320 then the Error Subcode is set to Invalid Network Field. */
3326 /* If the NLRI is encoded using addpath then the first 4 bytes are
3327 * the addpath ID. */
3328 if (addpath_encoded
)
3330 if (pnt
+ BGP_ADDPATH_ID_LEN
> end
)
3332 zlog_err ("%s [Error] Update packet error"
3333 " (prefix data addpath overflow)",
3335 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3336 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3339 pnt
+= BGP_ADDPATH_ID_LEN
;
3344 /* Prefix length check. */
3346 if (safi
== SAFI_ENCAP
) {
3347 if (prefixlen
> 128)
3350 if ((afi
== AFI_IP
&& prefixlen
> 32) ||
3351 (afi
== AFI_IP6
&& prefixlen
> 128)) {
3358 zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
3359 peer
->host
, prefixlen
);
3360 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3361 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3365 /* Packet size overflow check. */
3366 psize
= PSIZE (prefixlen
);
3368 if (pnt
+ psize
> end
)
3370 zlog_err ("%s [Error] Update packet error"
3371 " (prefix data overflow prefix size is %d)",
3373 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3374 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3382 /* Packet length consistency check. */
3385 zlog_err ("%s [Error] Update packet error"
3386 " (prefix length mismatch with total length)",
3388 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3389 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3395 static struct bgp_static
*
3396 bgp_static_new (void)
3398 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3402 bgp_static_free (struct bgp_static
*bgp_static
)
3404 if (bgp_static
->rmap
.name
)
3405 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3406 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3410 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3411 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3413 struct bgp_node
*rn
;
3414 struct bgp_info
*ri
;
3415 struct bgp_info
*new;
3416 struct bgp_info info
;
3418 struct attr
*attr_new
;
3421 assert (bgp_static
);
3425 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3427 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3429 attr
.nexthop
= bgp_static
->igpnexthop
;
3430 attr
.med
= bgp_static
->igpmetric
;
3431 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3433 if (bgp_static
->atomic
)
3434 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3436 /* Apply route-map. */
3437 if (bgp_static
->rmap
.name
)
3439 struct attr attr_tmp
= attr
;
3440 info
.peer
= bgp
->peer_self
;
3441 info
.attr
= &attr_tmp
;
3443 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3445 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3447 bgp
->peer_self
->rmap_type
= 0;
3449 if (ret
== RMAP_DENYMATCH
)
3451 /* Free uninterned attribute. */
3452 bgp_attr_flush (&attr_tmp
);
3454 /* Unintern original. */
3455 aspath_unintern (&attr
.aspath
);
3456 bgp_attr_extra_free (&attr
);
3457 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3460 attr_new
= bgp_attr_intern (&attr_tmp
);
3463 attr_new
= bgp_attr_intern (&attr
);
3465 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3466 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3467 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3472 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3473 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3474 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3476 bgp_unlock_node (rn
);
3477 bgp_attr_unintern (&attr_new
);
3478 aspath_unintern (&attr
.aspath
);
3479 bgp_attr_extra_free (&attr
);
3484 /* The attribute is changed. */
3485 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3487 /* Rewrite BGP route information. */
3488 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3489 bgp_info_restore(rn
, ri
);
3491 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3492 bgp_attr_unintern (&ri
->attr
);
3493 ri
->attr
= attr_new
;
3494 ri
->uptime
= bgp_clock ();
3496 /* Nexthop reachability check. */
3497 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3499 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3500 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3503 if (BGP_DEBUG(nht
, NHT
))
3505 char buf1
[INET6_ADDRSTRLEN
];
3506 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3508 zlog_debug("%s(%s): Route not in table, not advertising",
3509 __FUNCTION__
, buf1
);
3511 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3516 /* Delete the NHT structure if any, if we're toggling between
3517 * enabling/disabling import check. We deregister the route
3518 * from NHT to avoid overloading NHT and the process interaction
3520 bgp_unlink_nexthop(ri
);
3521 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3523 /* Process change. */
3524 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3525 bgp_process (bgp
, rn
, afi
, safi
);
3526 bgp_unlock_node (rn
);
3527 aspath_unintern (&attr
.aspath
);
3528 bgp_attr_extra_free (&attr
);
3533 /* Make new BGP info. */
3534 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3536 /* Nexthop reachability check. */
3537 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3539 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3540 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3543 if (BGP_DEBUG(nht
, NHT
))
3545 char buf1
[INET6_ADDRSTRLEN
];
3546 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3548 zlog_debug("%s(%s): Route not in table, not advertising",
3549 __FUNCTION__
, buf1
);
3551 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3556 /* Delete the NHT structure if any, if we're toggling between
3557 * enabling/disabling import check. We deregister the route
3558 * from NHT to avoid overloading NHT and the process interaction
3560 bgp_unlink_nexthop(new);
3562 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3565 /* Aggregate address increment. */
3566 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3568 /* Register new BGP information. */
3569 bgp_info_add (rn
, new);
3571 /* route_node_get lock */
3572 bgp_unlock_node (rn
);
3574 /* Process change. */
3575 bgp_process (bgp
, rn
, afi
, safi
);
3577 /* Unintern original. */
3578 aspath_unintern (&attr
.aspath
);
3579 bgp_attr_extra_free (&attr
);
3583 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3584 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3586 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3590 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3593 struct bgp_node
*rn
;
3594 struct bgp_info
*ri
;
3596 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3598 /* Check selected route and self inserted route. */
3599 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3600 if (ri
->peer
== bgp
->peer_self
3601 && ri
->type
== ZEBRA_ROUTE_BGP
3602 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3605 /* Withdraw static BGP route from routing table. */
3608 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3609 bgp_unlink_nexthop(ri
);
3610 bgp_info_delete (rn
, ri
);
3611 bgp_process (bgp
, rn
, afi
, safi
);
3614 /* Unlock bgp_node_lookup. */
3615 bgp_unlock_node (rn
);
3619 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3622 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3623 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3625 struct bgp_node
*rn
;
3626 struct bgp_info
*ri
;
3628 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3630 /* Check selected route and self inserted route. */
3631 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3632 if (ri
->peer
== bgp
->peer_self
3633 && ri
->type
== ZEBRA_ROUTE_BGP
3634 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3637 /* Withdraw static BGP route from routing table. */
3640 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3641 bgp_info_delete (rn
, ri
);
3642 bgp_process (bgp
, rn
, afi
, safi
);
3645 /* Unlock bgp_node_lookup. */
3646 bgp_unlock_node (rn
);
3650 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3651 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3653 struct bgp_node
*rn
;
3654 struct bgp_info
*new;
3655 struct attr
*attr_new
;
3656 struct attr attr
= { 0 };
3657 struct bgp_info
*ri
;
3659 assert (bgp_static
);
3661 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3663 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3665 attr
.nexthop
= bgp_static
->igpnexthop
;
3666 attr
.med
= bgp_static
->igpmetric
;
3667 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3669 /* Apply route-map. */
3670 if (bgp_static
->rmap
.name
)
3672 struct attr attr_tmp
= attr
;
3673 struct bgp_info info
;
3676 info
.peer
= bgp
->peer_self
;
3677 info
.attr
= &attr_tmp
;
3679 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3681 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3683 bgp
->peer_self
->rmap_type
= 0;
3685 if (ret
== RMAP_DENYMATCH
)
3687 /* Free uninterned attribute. */
3688 bgp_attr_flush (&attr_tmp
);
3690 /* Unintern original. */
3691 aspath_unintern (&attr
.aspath
);
3692 bgp_attr_extra_free (&attr
);
3693 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3698 attr_new
= bgp_attr_intern (&attr_tmp
);
3702 attr_new
= bgp_attr_intern (&attr
);
3705 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3706 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3707 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3712 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3713 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3715 bgp_unlock_node (rn
);
3716 bgp_attr_unintern (&attr_new
);
3717 aspath_unintern (&attr
.aspath
);
3718 bgp_attr_extra_free (&attr
);
3723 /* The attribute is changed. */
3724 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3726 /* Rewrite BGP route information. */
3727 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3728 bgp_info_restore(rn
, ri
);
3730 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3731 bgp_attr_unintern (&ri
->attr
);
3732 ri
->attr
= attr_new
;
3733 ri
->uptime
= bgp_clock ();
3735 /* Process change. */
3736 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3737 bgp_process (bgp
, rn
, afi
, safi
);
3738 bgp_unlock_node (rn
);
3739 aspath_unintern (&attr
.aspath
);
3740 bgp_attr_extra_free (&attr
);
3746 /* Make new BGP info. */
3747 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3749 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3750 new->extra
= bgp_info_extra_new();
3751 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
3753 /* Aggregate address increment. */
3754 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3756 /* Register new BGP information. */
3757 bgp_info_add (rn
, new);
3759 /* route_node_get lock */
3760 bgp_unlock_node (rn
);
3762 /* Process change. */
3763 bgp_process (bgp
, rn
, afi
, safi
);
3765 /* Unintern original. */
3766 aspath_unintern (&attr
.aspath
);
3767 bgp_attr_extra_free (&attr
);
3770 /* Configure static BGP network. When user don't run zebra, static
3771 route should be installed as valid. */
3773 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3774 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3778 struct bgp_static
*bgp_static
;
3779 struct bgp_node
*rn
;
3780 u_char need_update
= 0;
3782 /* Convert IP prefix string to struct prefix. */
3783 ret
= str2prefix (ip_str
, &p
);
3786 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3790 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3792 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3796 #endif /* HAVE_IPV6 */
3800 /* Set BGP static route configuration. */
3801 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3805 /* Configuration change. */
3806 bgp_static
= rn
->info
;
3808 /* Check previous routes are installed into BGP. */
3809 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3812 bgp_static
->backdoor
= backdoor
;
3816 if (bgp_static
->rmap
.name
)
3817 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3818 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3819 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3823 if (bgp_static
->rmap
.name
)
3824 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3825 bgp_static
->rmap
.name
= NULL
;
3826 bgp_static
->rmap
.map
= NULL
;
3827 bgp_static
->valid
= 0;
3829 bgp_unlock_node (rn
);
3833 /* New configuration. */
3834 bgp_static
= bgp_static_new ();
3835 bgp_static
->backdoor
= backdoor
;
3836 bgp_static
->valid
= 0;
3837 bgp_static
->igpmetric
= 0;
3838 bgp_static
->igpnexthop
.s_addr
= 0;
3842 if (bgp_static
->rmap
.name
)
3843 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3844 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3845 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3847 rn
->info
= bgp_static
;
3850 bgp_static
->valid
= 1;
3852 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3854 if (! bgp_static
->backdoor
)
3855 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3860 /* Configure static BGP network. */
3862 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3863 afi_t afi
, safi_t safi
)
3867 struct bgp_static
*bgp_static
;
3868 struct bgp_node
*rn
;
3870 /* Convert IP prefix string to struct prefix. */
3871 ret
= str2prefix (ip_str
, &p
);
3874 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3878 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3880 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3884 #endif /* HAVE_IPV6 */
3888 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3891 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3896 bgp_static
= rn
->info
;
3898 /* Update BGP RIB. */
3899 if (! bgp_static
->backdoor
)
3900 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3902 /* Clear configuration. */
3903 bgp_static_free (bgp_static
);
3905 bgp_unlock_node (rn
);
3906 bgp_unlock_node (rn
);
3912 bgp_static_add (struct bgp
*bgp
)
3916 struct bgp_node
*rn
;
3917 struct bgp_node
*rm
;
3918 struct bgp_table
*table
;
3919 struct bgp_static
*bgp_static
;
3921 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3922 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3923 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3924 if (rn
->info
!= NULL
)
3926 if (safi
== SAFI_MPLS_VPN
)
3930 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3932 bgp_static
= rn
->info
;
3933 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
3938 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
3943 /* Called from bgp_delete(). Delete all static routes from the BGP
3946 bgp_static_delete (struct bgp
*bgp
)
3950 struct bgp_node
*rn
;
3951 struct bgp_node
*rm
;
3952 struct bgp_table
*table
;
3953 struct bgp_static
*bgp_static
;
3955 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3956 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3957 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3958 if (rn
->info
!= NULL
)
3960 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
3964 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3966 bgp_static
= rn
->info
;
3967 bgp_static_withdraw_safi (bgp
, &rm
->p
,
3969 (struct prefix_rd
*)&rn
->p
,
3971 bgp_static_free (bgp_static
);
3973 bgp_unlock_node (rn
);
3978 bgp_static
= rn
->info
;
3979 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3980 bgp_static_free (bgp_static
);
3982 bgp_unlock_node (rn
);
3988 bgp_static_redo_import_check (struct bgp
*bgp
)
3992 struct bgp_node
*rn
;
3993 struct bgp_static
*bgp_static
;
3995 /* Use this flag to force reprocessing of the route */
3996 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3997 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3998 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3999 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4000 if (rn
->info
!= NULL
)
4002 bgp_static
= rn
->info
;
4003 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
4005 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4009 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
4011 struct bgp_table
*table
;
4012 struct bgp_node
*rn
;
4013 struct bgp_info
*ri
;
4015 table
= bgp
->rib
[afi
][safi
];
4016 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
4018 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4020 if (ri
->peer
== bgp
->peer_self
&&
4021 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
4022 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
4023 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
4024 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
4026 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4027 bgp_unlink_nexthop(ri
);
4028 bgp_info_delete (rn
, ri
);
4029 bgp_process (bgp
, rn
, afi
, safi
);
4036 * Purge all networks and redistributed routes from routing table.
4037 * Invoked upon the instance going down.
4040 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4045 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4046 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4047 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4052 * Currently this is used to set static routes for VPN and ENCAP.
4053 * I think it can probably be factored with bgp_static_set.
4056 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4057 const char *rd_str
, const char *tag_str
,
4058 const char *rmap_str
)
4062 struct prefix_rd prd
;
4064 struct bgp_node
*prn
;
4065 struct bgp_node
*rn
;
4066 struct bgp_table
*table
;
4067 struct bgp_static
*bgp_static
;
4072 ret
= str2prefix (ip_str
, &p
);
4075 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4080 ret
= str2prefix_rd (rd_str
, &prd
);
4083 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4087 ret
= str2tag (tag_str
, tag
);
4090 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4094 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4095 (struct prefix
*)&prd
);
4096 if (prn
->info
== NULL
)
4097 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4099 bgp_unlock_node (prn
);
4102 rn
= bgp_node_get (table
, &p
);
4106 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4107 bgp_unlock_node (rn
);
4111 /* New configuration. */
4112 bgp_static
= bgp_static_new ();
4113 bgp_static
->backdoor
= 0;
4114 bgp_static
->valid
= 0;
4115 bgp_static
->igpmetric
= 0;
4116 bgp_static
->igpnexthop
.s_addr
= 0;
4117 memcpy(bgp_static
->tag
, tag
, 3);
4118 bgp_static
->prd
= prd
;
4122 if (bgp_static
->rmap
.name
)
4123 free (bgp_static
->rmap
.name
);
4124 bgp_static
->rmap
.name
= strdup (rmap_str
);
4125 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4127 rn
->info
= bgp_static
;
4129 bgp_static
->valid
= 1;
4130 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4136 /* Configure static BGP network. */
4138 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4139 const char *rd_str
, const char *tag_str
)
4144 struct prefix_rd prd
;
4145 struct bgp_node
*prn
;
4146 struct bgp_node
*rn
;
4147 struct bgp_table
*table
;
4148 struct bgp_static
*bgp_static
;
4153 /* Convert IP prefix string to struct prefix. */
4154 ret
= str2prefix (ip_str
, &p
);
4157 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4162 ret
= str2prefix_rd (rd_str
, &prd
);
4165 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4169 ret
= str2tag (tag_str
, tag
);
4172 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4176 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4177 (struct prefix
*)&prd
);
4178 if (prn
->info
== NULL
)
4179 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4181 bgp_unlock_node (prn
);
4184 rn
= bgp_node_lookup (table
, &p
);
4188 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4190 bgp_static
= rn
->info
;
4191 bgp_static_free (bgp_static
);
4193 bgp_unlock_node (rn
);
4194 bgp_unlock_node (rn
);
4197 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4203 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4204 const char *rmap_name
)
4206 struct bgp_rmap
*rmap
;
4208 rmap
= &bgp
->table_map
[afi
][safi
];
4212 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4213 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4214 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4219 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4224 bgp_zebra_announce_table(bgp
, afi
, safi
);
4230 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4231 const char *rmap_name
)
4233 struct bgp_rmap
*rmap
;
4235 rmap
= &bgp
->table_map
[afi
][safi
];
4237 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4241 bgp_zebra_announce_table(bgp
, afi
, safi
);
4247 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4248 safi_t safi
, int *write
)
4250 if (bgp
->table_map
[afi
][safi
].name
)
4252 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4253 vty_out (vty
, " table-map %s%s",
4254 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4261 DEFUN (bgp_table_map
,
4264 "BGP table to RIB route download filter\n"
4265 "Name of the route map\n")
4267 return bgp_table_map_set (vty
, vty
->index
,
4268 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4270 DEFUN (no_bgp_table_map
,
4271 no_bgp_table_map_cmd
,
4272 "no table-map WORD",
4273 "BGP table to RIB route download filter\n"
4274 "Name of the route map\n")
4276 return bgp_table_map_unset (vty
, vty
->index
,
4277 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4282 "network A.B.C.D/M",
4283 "Specify a network to announce via BGP\n"
4284 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4286 return bgp_static_set (vty
, vty
->index
, argv
[0],
4287 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4290 DEFUN (bgp_network_route_map
,
4291 bgp_network_route_map_cmd
,
4292 "network A.B.C.D/M route-map WORD",
4293 "Specify a network to announce via BGP\n"
4294 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4295 "Route-map to modify the attributes\n"
4296 "Name of the route map\n")
4298 return bgp_static_set (vty
, vty
->index
, argv
[0],
4299 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4302 DEFUN (bgp_network_backdoor
,
4303 bgp_network_backdoor_cmd
,
4304 "network A.B.C.D/M backdoor",
4305 "Specify a network to announce via BGP\n"
4306 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4307 "Specify a BGP backdoor route\n")
4309 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4313 DEFUN (bgp_network_mask
,
4314 bgp_network_mask_cmd
,
4315 "network A.B.C.D mask A.B.C.D",
4316 "Specify a network to announce via BGP\n"
4322 char prefix_str
[BUFSIZ
];
4324 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4327 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4331 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4332 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4335 DEFUN (bgp_network_mask_route_map
,
4336 bgp_network_mask_route_map_cmd
,
4337 "network A.B.C.D mask A.B.C.D route-map WORD",
4338 "Specify a network to announce via BGP\n"
4342 "Route-map to modify the attributes\n"
4343 "Name of the route map\n")
4346 char prefix_str
[BUFSIZ
];
4348 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4351 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4355 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4356 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4359 DEFUN (bgp_network_mask_backdoor
,
4360 bgp_network_mask_backdoor_cmd
,
4361 "network A.B.C.D mask A.B.C.D backdoor",
4362 "Specify a network to announce via BGP\n"
4366 "Specify a BGP backdoor route\n")
4369 char prefix_str
[BUFSIZ
];
4371 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4374 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4378 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4382 DEFUN (bgp_network_mask_natural
,
4383 bgp_network_mask_natural_cmd
,
4385 "Specify a network to announce via BGP\n"
4389 char prefix_str
[BUFSIZ
];
4391 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4394 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4398 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4399 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4402 DEFUN (bgp_network_mask_natural_route_map
,
4403 bgp_network_mask_natural_route_map_cmd
,
4404 "network A.B.C.D route-map WORD",
4405 "Specify a network to announce via BGP\n"
4407 "Route-map to modify the attributes\n"
4408 "Name of the route map\n")
4411 char prefix_str
[BUFSIZ
];
4413 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4416 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4420 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4421 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4424 DEFUN (bgp_network_mask_natural_backdoor
,
4425 bgp_network_mask_natural_backdoor_cmd
,
4426 "network A.B.C.D backdoor",
4427 "Specify a network to announce via BGP\n"
4429 "Specify a BGP backdoor route\n")
4432 char prefix_str
[BUFSIZ
];
4434 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4437 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4441 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4445 DEFUN (no_bgp_network
,
4447 "no network A.B.C.D/M",
4449 "Specify a network to announce via BGP\n"
4450 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4452 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4453 bgp_node_safi (vty
));
4456 ALIAS (no_bgp_network
,
4457 no_bgp_network_route_map_cmd
,
4458 "no network A.B.C.D/M route-map WORD",
4460 "Specify a network to announce via BGP\n"
4461 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4462 "Route-map to modify the attributes\n"
4463 "Name of the route map\n")
4465 ALIAS (no_bgp_network
,
4466 no_bgp_network_backdoor_cmd
,
4467 "no network A.B.C.D/M backdoor",
4469 "Specify a network to announce via BGP\n"
4470 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4471 "Specify a BGP backdoor route\n")
4473 DEFUN (no_bgp_network_mask
,
4474 no_bgp_network_mask_cmd
,
4475 "no network A.B.C.D mask A.B.C.D",
4477 "Specify a network to announce via BGP\n"
4483 char prefix_str
[BUFSIZ
];
4485 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4488 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4492 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4493 bgp_node_safi (vty
));
4496 ALIAS (no_bgp_network_mask
,
4497 no_bgp_network_mask_route_map_cmd
,
4498 "no network A.B.C.D mask A.B.C.D route-map WORD",
4500 "Specify a network to announce via BGP\n"
4504 "Route-map to modify the attributes\n"
4505 "Name of the route map\n")
4507 ALIAS (no_bgp_network_mask
,
4508 no_bgp_network_mask_backdoor_cmd
,
4509 "no network A.B.C.D mask A.B.C.D backdoor",
4511 "Specify a network to announce via BGP\n"
4515 "Specify a BGP backdoor route\n")
4517 DEFUN (no_bgp_network_mask_natural
,
4518 no_bgp_network_mask_natural_cmd
,
4519 "no network A.B.C.D",
4521 "Specify a network to announce via BGP\n"
4525 char prefix_str
[BUFSIZ
];
4527 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4530 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4534 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4535 bgp_node_safi (vty
));
4538 ALIAS (no_bgp_network_mask_natural
,
4539 no_bgp_network_mask_natural_route_map_cmd
,
4540 "no network A.B.C.D route-map WORD",
4542 "Specify a network to announce via BGP\n"
4544 "Route-map to modify the attributes\n"
4545 "Name of the route map\n")
4547 ALIAS (no_bgp_network_mask_natural
,
4548 no_bgp_network_mask_natural_backdoor_cmd
,
4549 "no network A.B.C.D backdoor",
4551 "Specify a network to announce via BGP\n"
4553 "Specify a BGP backdoor route\n")
4556 DEFUN (ipv6_bgp_network
,
4557 ipv6_bgp_network_cmd
,
4558 "network X:X::X:X/M",
4559 "Specify a network to announce via BGP\n"
4560 "IPv6 prefix <network>/<length>\n")
4562 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4566 DEFUN (ipv6_bgp_network_route_map
,
4567 ipv6_bgp_network_route_map_cmd
,
4568 "network X:X::X:X/M route-map WORD",
4569 "Specify a network to announce via BGP\n"
4570 "IPv6 prefix <network>/<length>\n"
4571 "Route-map to modify the attributes\n"
4572 "Name of the route map\n")
4574 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4575 bgp_node_safi (vty
), argv
[1], 0);
4578 DEFUN (no_ipv6_bgp_network
,
4579 no_ipv6_bgp_network_cmd
,
4580 "no network X:X::X:X/M",
4582 "Specify a network to announce via BGP\n"
4583 "IPv6 prefix <network>/<length>\n")
4585 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4588 ALIAS (no_ipv6_bgp_network
,
4589 no_ipv6_bgp_network_route_map_cmd
,
4590 "no network X:X::X:X/M route-map WORD",
4592 "Specify a network to announce via BGP\n"
4593 "IPv6 prefix <network>/<length>\n"
4594 "Route-map to modify the attributes\n"
4595 "Name of the route map\n")
4597 ALIAS (ipv6_bgp_network
,
4598 old_ipv6_bgp_network_cmd
,
4599 "ipv6 bgp network X:X::X:X/M",
4602 "Specify a network to announce via BGP\n"
4603 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4605 ALIAS (no_ipv6_bgp_network
,
4606 old_no_ipv6_bgp_network_cmd
,
4607 "no ipv6 bgp network X:X::X:X/M",
4611 "Specify a network to announce via BGP\n"
4612 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4613 #endif /* HAVE_IPV6 */
4615 /* Aggreagete address:
4617 advertise-map Set condition to advertise attribute
4618 as-set Generate AS set path information
4619 attribute-map Set attributes of aggregate
4620 route-map Set parameters of aggregate
4621 summary-only Filter more specific routes from updates
4622 suppress-map Conditionally filter more specific routes from updates
4625 struct bgp_aggregate
4627 /* Summary-only flag. */
4628 u_char summary_only
;
4630 /* AS set generation. */
4633 /* Route-map for aggregated route. */
4634 struct route_map
*map
;
4636 /* Suppress-count. */
4637 unsigned long count
;
4639 /* SAFI configuration. */
4643 static struct bgp_aggregate
*
4644 bgp_aggregate_new (void)
4646 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4650 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4652 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4655 /* Update an aggregate as routes are added/removed from the BGP table */
4657 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4658 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4659 struct bgp_aggregate
*aggregate
)
4661 struct bgp_table
*table
;
4662 struct bgp_node
*top
;
4663 struct bgp_node
*rn
;
4665 struct aspath
*aspath
= NULL
;
4666 struct aspath
*asmerge
= NULL
;
4667 struct community
*community
= NULL
;
4668 struct community
*commerge
= NULL
;
4669 #if defined(AGGREGATE_NEXTHOP_CHECK)
4670 struct in_addr nexthop
;
4673 struct bgp_info
*ri
;
4674 struct bgp_info
*new;
4676 unsigned long match
= 0;
4677 u_char atomic_aggregate
= 0;
4679 /* Record adding route's nexthop and med. */
4682 #if defined(AGGREGATE_NEXTHOP_CHECK)
4683 nexthop
= rinew
->attr
->nexthop
;
4684 med
= rinew
->attr
->med
;
4688 /* ORIGIN attribute: If at least one route among routes that are
4689 aggregated has ORIGIN with the value INCOMPLETE, then the
4690 aggregated route must have the ORIGIN attribute with the value
4691 INCOMPLETE. Otherwise, if at least one route among routes that
4692 are aggregated has ORIGIN with the value EGP, then the aggregated
4693 route must have the origin attribute with the value EGP. In all
4694 other case the value of the ORIGIN attribute of the aggregated
4695 route is INTERNAL. */
4696 origin
= BGP_ORIGIN_IGP
;
4698 table
= bgp
->rib
[afi
][safi
];
4700 top
= bgp_node_get (table
, p
);
4701 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4702 if (rn
->p
.prefixlen
> p
->prefixlen
)
4706 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4708 if (BGP_INFO_HOLDDOWN (ri
))
4711 if (del
&& ri
== del
)
4714 if (! rinew
&& first
)
4716 #if defined(AGGREGATE_NEXTHOP_CHECK)
4717 nexthop
= ri
->attr
->nexthop
;
4718 med
= ri
->attr
->med
;
4723 #ifdef AGGREGATE_NEXTHOP_CHECK
4724 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4725 || ri
->attr
->med
!= med
)
4728 aspath_free (aspath
);
4730 community_free (community
);
4731 bgp_unlock_node (rn
);
4732 bgp_unlock_node (top
);
4735 #endif /* AGGREGATE_NEXTHOP_CHECK */
4737 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4738 atomic_aggregate
= 1;
4740 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4742 if (aggregate
->summary_only
)
4744 (bgp_info_extra_get (ri
))->suppress
++;
4745 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4751 if (origin
< ri
->attr
->origin
)
4752 origin
= ri
->attr
->origin
;
4754 if (aggregate
->as_set
)
4758 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4759 aspath_free (aspath
);
4763 aspath
= aspath_dup (ri
->attr
->aspath
);
4765 if (ri
->attr
->community
)
4769 commerge
= community_merge (community
,
4770 ri
->attr
->community
);
4771 community
= community_uniq_sort (commerge
);
4772 community_free (commerge
);
4775 community
= community_dup (ri
->attr
->community
);
4781 bgp_process (bgp
, rn
, afi
, safi
);
4783 bgp_unlock_node (top
);
4789 if (aggregate
->summary_only
)
4790 (bgp_info_extra_get (rinew
))->suppress
++;
4792 if (origin
< rinew
->attr
->origin
)
4793 origin
= rinew
->attr
->origin
;
4795 if (aggregate
->as_set
)
4799 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4800 aspath_free (aspath
);
4804 aspath
= aspath_dup (rinew
->attr
->aspath
);
4806 if (rinew
->attr
->community
)
4810 commerge
= community_merge (community
,
4811 rinew
->attr
->community
);
4812 community
= community_uniq_sort (commerge
);
4813 community_free (commerge
);
4816 community
= community_dup (rinew
->attr
->community
);
4821 if (aggregate
->count
> 0)
4823 rn
= bgp_node_get (table
, p
);
4824 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4825 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4827 atomic_aggregate
), rn
);
4828 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4830 bgp_info_add (rn
, new);
4831 bgp_unlock_node (rn
);
4832 bgp_process (bgp
, rn
, afi
, safi
);
4837 aspath_free (aspath
);
4839 community_free (community
);
4843 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4844 struct bgp_aggregate
*);
4847 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4848 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4850 struct bgp_node
*child
;
4851 struct bgp_node
*rn
;
4852 struct bgp_aggregate
*aggregate
;
4853 struct bgp_table
*table
;
4855 /* MPLS-VPN aggregation is not yet supported. */
4856 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4859 table
= bgp
->aggregate
[afi
][safi
];
4861 /* No aggregates configured. */
4862 if (bgp_table_top_nolock (table
) == NULL
)
4865 if (p
->prefixlen
== 0)
4868 if (BGP_INFO_HOLDDOWN (ri
))
4871 child
= bgp_node_get (table
, p
);
4873 /* Aggregate address configuration check. */
4874 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4875 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4877 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4878 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4880 bgp_unlock_node (child
);
4884 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4885 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4887 struct bgp_node
*child
;
4888 struct bgp_node
*rn
;
4889 struct bgp_aggregate
*aggregate
;
4890 struct bgp_table
*table
;
4892 /* MPLS-VPN aggregation is not yet supported. */
4893 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4896 table
= bgp
->aggregate
[afi
][safi
];
4898 /* No aggregates configured. */
4899 if (bgp_table_top_nolock (table
) == NULL
)
4902 if (p
->prefixlen
== 0)
4905 child
= bgp_node_get (table
, p
);
4907 /* Aggregate address configuration check. */
4908 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4909 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4911 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4912 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4914 bgp_unlock_node (child
);
4917 /* Called via bgp_aggregate_set when the user configures aggregate-address */
4919 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4920 struct bgp_aggregate
*aggregate
)
4922 struct bgp_table
*table
;
4923 struct bgp_node
*top
;
4924 struct bgp_node
*rn
;
4925 struct bgp_info
*new;
4926 struct bgp_info
*ri
;
4927 unsigned long match
;
4928 u_char origin
= BGP_ORIGIN_IGP
;
4929 struct aspath
*aspath
= NULL
;
4930 struct aspath
*asmerge
= NULL
;
4931 struct community
*community
= NULL
;
4932 struct community
*commerge
= NULL
;
4933 u_char atomic_aggregate
= 0;
4935 table
= bgp
->rib
[afi
][safi
];
4938 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4940 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4943 /* If routes exists below this node, generate aggregate routes. */
4944 top
= bgp_node_get (table
, p
);
4945 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4946 if (rn
->p
.prefixlen
> p
->prefixlen
)
4950 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4952 if (BGP_INFO_HOLDDOWN (ri
))
4955 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4956 atomic_aggregate
= 1;
4958 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4960 /* summary-only aggregate route suppress aggregated
4961 route announcement. */
4962 if (aggregate
->summary_only
)
4964 (bgp_info_extra_get (ri
))->suppress
++;
4965 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4969 /* If at least one route among routes that are aggregated has
4970 * ORIGIN with the value INCOMPLETE, then the aggregated route
4971 * MUST have the ORIGIN attribute with the value INCOMPLETE.
4972 * Otherwise, if at least one route among routes that are
4973 * aggregated has ORIGIN with the value EGP, then the aggregated
4974 * route MUST have the ORIGIN attribute with the value EGP.
4976 if (origin
< ri
->attr
->origin
)
4977 origin
= ri
->attr
->origin
;
4979 /* as-set aggregate route generate origin, as path,
4980 community aggregation. */
4981 if (aggregate
->as_set
)
4985 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4986 aspath_free (aspath
);
4990 aspath
= aspath_dup (ri
->attr
->aspath
);
4992 if (ri
->attr
->community
)
4996 commerge
= community_merge (community
,
4997 ri
->attr
->community
);
4998 community
= community_uniq_sort (commerge
);
4999 community_free (commerge
);
5002 community
= community_dup (ri
->attr
->community
);
5009 /* If this node is suppressed, process the change. */
5011 bgp_process (bgp
, rn
, afi
, safi
);
5013 bgp_unlock_node (top
);
5015 /* Add aggregate route to BGP table. */
5016 if (aggregate
->count
)
5018 rn
= bgp_node_get (table
, p
);
5019 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5020 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5022 atomic_aggregate
), rn
);
5023 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5025 bgp_info_add (rn
, new);
5026 bgp_unlock_node (rn
);
5028 /* Process change. */
5029 bgp_process (bgp
, rn
, afi
, safi
);
5034 aspath_free (aspath
);
5036 community_free (community
);
5041 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5042 safi_t safi
, struct bgp_aggregate
*aggregate
)
5044 struct bgp_table
*table
;
5045 struct bgp_node
*top
;
5046 struct bgp_node
*rn
;
5047 struct bgp_info
*ri
;
5048 unsigned long match
;
5050 table
= bgp
->rib
[afi
][safi
];
5052 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5054 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5057 /* If routes exists below this node, generate aggregate routes. */
5058 top
= bgp_node_get (table
, p
);
5059 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5060 if (rn
->p
.prefixlen
> p
->prefixlen
)
5064 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5066 if (BGP_INFO_HOLDDOWN (ri
))
5069 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5071 if (aggregate
->summary_only
&& ri
->extra
)
5073 ri
->extra
->suppress
--;
5075 if (ri
->extra
->suppress
== 0)
5077 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5085 /* If this node was suppressed, process the change. */
5087 bgp_process (bgp
, rn
, afi
, safi
);
5089 bgp_unlock_node (top
);
5091 /* Delete aggregate route from BGP table. */
5092 rn
= bgp_node_get (table
, p
);
5094 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5095 if (ri
->peer
== bgp
->peer_self
5096 && ri
->type
== ZEBRA_ROUTE_BGP
5097 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5100 /* Withdraw static BGP route from routing table. */
5103 bgp_info_delete (rn
, ri
);
5104 bgp_process (bgp
, rn
, afi
, safi
);
5107 /* Unlock bgp_node_lookup. */
5108 bgp_unlock_node (rn
);
5111 /* Aggregate route attribute. */
5112 #define AGGREGATE_SUMMARY_ONLY 1
5113 #define AGGREGATE_AS_SET 1
5116 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5117 afi_t afi
, safi_t safi
)
5121 struct bgp_node
*rn
;
5123 struct bgp_aggregate
*aggregate
;
5125 /* Convert string to prefix structure. */
5126 ret
= str2prefix (prefix_str
, &p
);
5129 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5134 /* Get BGP structure. */
5137 /* Old configuration check. */
5138 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5141 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5146 aggregate
= rn
->info
;
5147 if (aggregate
->safi
& SAFI_UNICAST
)
5148 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5149 if (aggregate
->safi
& SAFI_MULTICAST
)
5150 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5152 /* Unlock aggregate address configuration. */
5154 bgp_aggregate_free (aggregate
);
5155 bgp_unlock_node (rn
);
5156 bgp_unlock_node (rn
);
5162 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5163 afi_t afi
, safi_t safi
,
5164 u_char summary_only
, u_char as_set
)
5168 struct bgp_node
*rn
;
5170 struct bgp_aggregate
*aggregate
;
5172 /* Convert string to prefix structure. */
5173 ret
= str2prefix (prefix_str
, &p
);
5176 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5181 /* Get BGP structure. */
5184 /* Old configuration check. */
5185 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5189 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5190 /* try to remove the old entry */
5191 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5194 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5195 bgp_unlock_node (rn
);
5200 /* Make aggregate address structure. */
5201 aggregate
= bgp_aggregate_new ();
5202 aggregate
->summary_only
= summary_only
;
5203 aggregate
->as_set
= as_set
;
5204 aggregate
->safi
= safi
;
5205 rn
->info
= aggregate
;
5207 /* Aggregate address insert into BGP routing table. */
5208 if (safi
& SAFI_UNICAST
)
5209 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5210 if (safi
& SAFI_MULTICAST
)
5211 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5216 DEFUN (aggregate_address
,
5217 aggregate_address_cmd
,
5218 "aggregate-address A.B.C.D/M",
5219 "Configure BGP aggregate entries\n"
5220 "Aggregate prefix\n")
5222 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5225 DEFUN (aggregate_address_mask
,
5226 aggregate_address_mask_cmd
,
5227 "aggregate-address A.B.C.D A.B.C.D",
5228 "Configure BGP aggregate entries\n"
5229 "Aggregate address\n"
5233 char prefix_str
[BUFSIZ
];
5235 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5239 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5243 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5247 DEFUN (aggregate_address_summary_only
,
5248 aggregate_address_summary_only_cmd
,
5249 "aggregate-address A.B.C.D/M summary-only",
5250 "Configure BGP aggregate entries\n"
5251 "Aggregate prefix\n"
5252 "Filter more specific routes from updates\n")
5254 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5255 AGGREGATE_SUMMARY_ONLY
, 0);
5258 DEFUN (aggregate_address_mask_summary_only
,
5259 aggregate_address_mask_summary_only_cmd
,
5260 "aggregate-address A.B.C.D A.B.C.D summary-only",
5261 "Configure BGP aggregate entries\n"
5262 "Aggregate address\n"
5264 "Filter more specific routes from updates\n")
5267 char prefix_str
[BUFSIZ
];
5269 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5273 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5277 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5278 AGGREGATE_SUMMARY_ONLY
, 0);
5281 DEFUN (aggregate_address_as_set
,
5282 aggregate_address_as_set_cmd
,
5283 "aggregate-address A.B.C.D/M as-set",
5284 "Configure BGP aggregate entries\n"
5285 "Aggregate prefix\n"
5286 "Generate AS set path information\n")
5288 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5289 0, AGGREGATE_AS_SET
);
5292 DEFUN (aggregate_address_mask_as_set
,
5293 aggregate_address_mask_as_set_cmd
,
5294 "aggregate-address A.B.C.D A.B.C.D as-set",
5295 "Configure BGP aggregate entries\n"
5296 "Aggregate address\n"
5298 "Generate AS set path information\n")
5301 char prefix_str
[BUFSIZ
];
5303 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5307 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5311 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5312 0, AGGREGATE_AS_SET
);
5316 DEFUN (aggregate_address_as_set_summary
,
5317 aggregate_address_as_set_summary_cmd
,
5318 "aggregate-address A.B.C.D/M as-set summary-only",
5319 "Configure BGP aggregate entries\n"
5320 "Aggregate prefix\n"
5321 "Generate AS set path information\n"
5322 "Filter more specific routes from updates\n")
5324 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5325 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5328 ALIAS (aggregate_address_as_set_summary
,
5329 aggregate_address_summary_as_set_cmd
,
5330 "aggregate-address A.B.C.D/M summary-only as-set",
5331 "Configure BGP aggregate entries\n"
5332 "Aggregate prefix\n"
5333 "Filter more specific routes from updates\n"
5334 "Generate AS set path information\n")
5336 DEFUN (aggregate_address_mask_as_set_summary
,
5337 aggregate_address_mask_as_set_summary_cmd
,
5338 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5339 "Configure BGP aggregate entries\n"
5340 "Aggregate address\n"
5342 "Generate AS set path information\n"
5343 "Filter more specific routes from updates\n")
5346 char prefix_str
[BUFSIZ
];
5348 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5352 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5356 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5357 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5360 ALIAS (aggregate_address_mask_as_set_summary
,
5361 aggregate_address_mask_summary_as_set_cmd
,
5362 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5363 "Configure BGP aggregate entries\n"
5364 "Aggregate address\n"
5366 "Filter more specific routes from updates\n"
5367 "Generate AS set path information\n")
5369 DEFUN (no_aggregate_address
,
5370 no_aggregate_address_cmd
,
5371 "no aggregate-address A.B.C.D/M",
5373 "Configure BGP aggregate entries\n"
5374 "Aggregate prefix\n")
5376 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5379 ALIAS (no_aggregate_address
,
5380 no_aggregate_address_summary_only_cmd
,
5381 "no aggregate-address A.B.C.D/M summary-only",
5383 "Configure BGP aggregate entries\n"
5384 "Aggregate prefix\n"
5385 "Filter more specific routes from updates\n")
5387 ALIAS (no_aggregate_address
,
5388 no_aggregate_address_as_set_cmd
,
5389 "no aggregate-address A.B.C.D/M as-set",
5391 "Configure BGP aggregate entries\n"
5392 "Aggregate prefix\n"
5393 "Generate AS set path information\n")
5395 ALIAS (no_aggregate_address
,
5396 no_aggregate_address_as_set_summary_cmd
,
5397 "no aggregate-address A.B.C.D/M as-set summary-only",
5399 "Configure BGP aggregate entries\n"
5400 "Aggregate prefix\n"
5401 "Generate AS set path information\n"
5402 "Filter more specific routes from updates\n")
5404 ALIAS (no_aggregate_address
,
5405 no_aggregate_address_summary_as_set_cmd
,
5406 "no aggregate-address A.B.C.D/M summary-only as-set",
5408 "Configure BGP aggregate entries\n"
5409 "Aggregate prefix\n"
5410 "Filter more specific routes from updates\n"
5411 "Generate AS set path information\n")
5413 DEFUN (no_aggregate_address_mask
,
5414 no_aggregate_address_mask_cmd
,
5415 "no aggregate-address A.B.C.D A.B.C.D",
5417 "Configure BGP aggregate entries\n"
5418 "Aggregate address\n"
5422 char prefix_str
[BUFSIZ
];
5424 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5428 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5432 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5435 ALIAS (no_aggregate_address_mask
,
5436 no_aggregate_address_mask_summary_only_cmd
,
5437 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5439 "Configure BGP aggregate entries\n"
5440 "Aggregate address\n"
5442 "Filter more specific routes from updates\n")
5444 ALIAS (no_aggregate_address_mask
,
5445 no_aggregate_address_mask_as_set_cmd
,
5446 "no aggregate-address A.B.C.D A.B.C.D as-set",
5448 "Configure BGP aggregate entries\n"
5449 "Aggregate address\n"
5451 "Generate AS set path information\n")
5453 ALIAS (no_aggregate_address_mask
,
5454 no_aggregate_address_mask_as_set_summary_cmd
,
5455 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5457 "Configure BGP aggregate entries\n"
5458 "Aggregate address\n"
5460 "Generate AS set path information\n"
5461 "Filter more specific routes from updates\n")
5463 ALIAS (no_aggregate_address_mask
,
5464 no_aggregate_address_mask_summary_as_set_cmd
,
5465 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5467 "Configure BGP aggregate entries\n"
5468 "Aggregate address\n"
5470 "Filter more specific routes from updates\n"
5471 "Generate AS set path information\n")
5474 DEFUN (ipv6_aggregate_address
,
5475 ipv6_aggregate_address_cmd
,
5476 "aggregate-address X:X::X:X/M",
5477 "Configure BGP aggregate entries\n"
5478 "Aggregate prefix\n")
5480 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5483 DEFUN (ipv6_aggregate_address_summary_only
,
5484 ipv6_aggregate_address_summary_only_cmd
,
5485 "aggregate-address X:X::X:X/M summary-only",
5486 "Configure BGP aggregate entries\n"
5487 "Aggregate prefix\n"
5488 "Filter more specific routes from updates\n")
5490 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5491 AGGREGATE_SUMMARY_ONLY
, 0);
5494 DEFUN (no_ipv6_aggregate_address
,
5495 no_ipv6_aggregate_address_cmd
,
5496 "no aggregate-address X:X::X:X/M",
5498 "Configure BGP aggregate entries\n"
5499 "Aggregate prefix\n")
5501 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5504 DEFUN (no_ipv6_aggregate_address_summary_only
,
5505 no_ipv6_aggregate_address_summary_only_cmd
,
5506 "no aggregate-address X:X::X:X/M summary-only",
5508 "Configure BGP aggregate entries\n"
5509 "Aggregate prefix\n"
5510 "Filter more specific routes from updates\n")
5512 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5515 ALIAS (ipv6_aggregate_address
,
5516 old_ipv6_aggregate_address_cmd
,
5517 "ipv6 bgp aggregate-address X:X::X:X/M",
5520 "Configure BGP aggregate entries\n"
5521 "Aggregate prefix\n")
5523 ALIAS (ipv6_aggregate_address_summary_only
,
5524 old_ipv6_aggregate_address_summary_only_cmd
,
5525 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5528 "Configure BGP aggregate entries\n"
5529 "Aggregate prefix\n"
5530 "Filter more specific routes from updates\n")
5532 ALIAS (no_ipv6_aggregate_address
,
5533 old_no_ipv6_aggregate_address_cmd
,
5534 "no ipv6 bgp aggregate-address X:X::X:X/M",
5538 "Configure BGP aggregate entries\n"
5539 "Aggregate prefix\n")
5541 ALIAS (no_ipv6_aggregate_address_summary_only
,
5542 old_no_ipv6_aggregate_address_summary_only_cmd
,
5543 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5547 "Configure BGP aggregate entries\n"
5548 "Aggregate prefix\n"
5549 "Filter more specific routes from updates\n")
5550 #endif /* HAVE_IPV6 */
5552 /* Redistribute route treatment. */
5554 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5555 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5556 u_int32_t metric
, u_char type
, u_short instance
, u_short tag
)
5558 struct bgp_info
*new;
5559 struct bgp_info
*bi
;
5560 struct bgp_info info
;
5561 struct bgp_node
*bn
;
5563 struct attr
*new_attr
;
5566 struct bgp_redist
*red
;
5568 /* Make default attribute. */
5569 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5571 attr
.nexthop
= *nexthop
;
5572 attr
.nh_ifindex
= ifindex
;
5577 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5578 extra
->mp_nexthop_global
= *nexthop6
;
5579 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5584 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5585 attr
.extra
->tag
= tag
;
5587 afi
= family2afi (p
->family
);
5589 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5592 struct attr attr_new
;
5593 struct attr_extra extra_new
;
5595 /* Copy attribute for modification. */
5596 attr_new
.extra
= &extra_new
;
5597 bgp_attr_dup (&attr_new
, &attr
);
5599 if (red
->redist_metric_flag
)
5600 attr_new
.med
= red
->redist_metric
;
5602 /* Apply route-map. */
5605 info
.peer
= bgp
->peer_self
;
5606 info
.attr
= &attr_new
;
5608 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5610 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5612 bgp
->peer_self
->rmap_type
= 0;
5614 if (ret
== RMAP_DENYMATCH
)
5616 /* Free uninterned attribute. */
5617 bgp_attr_flush (&attr_new
);
5619 /* Unintern original. */
5620 aspath_unintern (&attr
.aspath
);
5621 bgp_attr_extra_free (&attr
);
5622 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5627 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5628 afi
, SAFI_UNICAST
, p
, NULL
);
5630 new_attr
= bgp_attr_intern (&attr_new
);
5632 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5633 if (bi
->peer
== bgp
->peer_self
5634 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5639 /* Ensure the (source route) type is updated. */
5641 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5642 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5644 bgp_attr_unintern (&new_attr
);
5645 aspath_unintern (&attr
.aspath
);
5646 bgp_attr_extra_free (&attr
);
5647 bgp_unlock_node (bn
);
5652 /* The attribute is changed. */
5653 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5655 /* Rewrite BGP route information. */
5656 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5657 bgp_info_restore(bn
, bi
);
5659 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5660 bgp_attr_unintern (&bi
->attr
);
5661 bi
->attr
= new_attr
;
5662 bi
->uptime
= bgp_clock ();
5664 /* Process change. */
5665 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5666 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5667 bgp_unlock_node (bn
);
5668 aspath_unintern (&attr
.aspath
);
5669 bgp_attr_extra_free (&attr
);
5674 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5676 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5678 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5679 bgp_info_add (bn
, new);
5680 bgp_unlock_node (bn
);
5681 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5684 /* Unintern original. */
5685 aspath_unintern (&attr
.aspath
);
5686 bgp_attr_extra_free (&attr
);
5690 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5693 struct bgp_node
*rn
;
5694 struct bgp_info
*ri
;
5695 struct bgp_redist
*red
;
5697 afi
= family2afi (p
->family
);
5699 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5702 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5704 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5705 if (ri
->peer
== bgp
->peer_self
5706 && ri
->type
== type
)
5711 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5712 bgp_info_delete (rn
, ri
);
5713 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5715 bgp_unlock_node (rn
);
5719 /* Withdraw specified route type's route. */
5721 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5723 struct bgp_node
*rn
;
5724 struct bgp_info
*ri
;
5725 struct bgp_table
*table
;
5727 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5729 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5731 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5732 if (ri
->peer
== bgp
->peer_self
5734 && ri
->instance
== instance
)
5739 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5740 bgp_info_delete (rn
, ri
);
5741 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5746 /* Static function to display route. */
5748 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5751 u_int32_t destination
;
5754 if (p
->family
== AF_INET
)
5756 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5757 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5759 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5760 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5761 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5762 || p
->u
.prefix4
.s_addr
== 0)
5764 /* When mask is natural, mask is not displayed. */
5767 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5770 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5775 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5777 vty_out (vty
, "%*s", len
, " ");
5780 enum bgp_display_type
5785 /* Print the short form route status for a bgp_info */
5787 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
5788 json_object
*json_path
)
5793 /* Route status display. */
5794 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5795 json_object_boolean_true_add(json_path
, "removed");
5797 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5798 json_object_boolean_true_add(json_path
, "stale");
5800 if (binfo
->extra
&& binfo
->extra
->suppress
)
5801 json_object_boolean_true_add(json_path
, "suppressed");
5803 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5804 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5805 json_object_boolean_true_add(json_path
, "valid");
5808 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5809 json_object_boolean_true_add(json_path
, "history");
5811 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5812 json_object_boolean_true_add(json_path
, "damped");
5814 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5815 json_object_boolean_true_add(json_path
, "bestpath");
5817 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5818 json_object_boolean_true_add(json_path
, "multipath");
5820 /* Internal route. */
5821 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5822 json_object_string_add(json_path
, "pathFrom", "internal");
5824 json_object_string_add(json_path
, "pathFrom", "external");
5829 /* Route status display. */
5830 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5832 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5834 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5836 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5837 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5843 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5845 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5847 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5849 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5854 /* Internal route. */
5855 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5861 /* called from terminal list command */
5863 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5864 struct bgp_info
*binfo
, int display
, safi_t safi
,
5865 json_object
*json_paths
)
5868 json_object
*json_path
= NULL
;
5869 json_object
*json_nexthops
= NULL
;
5870 json_object
*json_nexthop_global
= NULL
;
5871 json_object
*json_nexthop_ll
= NULL
;
5874 json_path
= json_object_new_object();
5876 /* short status lead text */
5877 route_vty_short_status_out (vty
, binfo
, json_path
);
5881 /* print prefix and mask */
5883 route_vty_out_route (p
, vty
);
5885 vty_out (vty
, "%*s", 17, " ");
5888 /* Print attribute */
5893 * For ENCAP routes, nexthop address family is not
5894 * neccessarily the same as the prefix address family.
5895 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5897 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
5902 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
5907 vty_out (vty
, "%s", inet_ntop(af
,
5908 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
5912 vty_out (vty
, "%s", inet_ntop(af
,
5913 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
5925 else if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5929 json_nexthop_global
= json_object_new_object();
5931 if (safi
== SAFI_MPLS_VPN
)
5932 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5934 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
5936 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
5937 json_object_boolean_true_add(json_nexthop_global
, "used");
5941 if (safi
== SAFI_MPLS_VPN
)
5942 vty_out (vty
, "%-16s",
5943 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5945 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5950 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5957 json_nexthop_global
= json_object_new_object();
5958 json_object_string_add(json_nexthop_global
, "ip",
5959 inet_ntop (AF_INET6
,
5960 &attr
->extra
->mp_nexthop_global
,
5962 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
5963 json_object_string_add(json_nexthop_global
, "scope", "global");
5965 /* We display both LL & GL if both have been received */
5966 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5968 json_nexthop_ll
= json_object_new_object();
5969 json_object_string_add(json_nexthop_ll
, "ip",
5970 inet_ntop (AF_INET6
,
5971 &attr
->extra
->mp_nexthop_local
,
5973 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
5974 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
5976 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
5977 &attr
->extra
->mp_nexthop_local
) != 0) &&
5978 !attr
->extra
->mp_nexthop_prefer_global
)
5979 json_object_boolean_true_add(json_nexthop_ll
, "used");
5981 json_object_boolean_true_add(json_nexthop_global
, "used");
5984 json_object_boolean_true_add(json_nexthop_global
, "used");
5988 /* Display LL if LL/Global both in table unless prefer-global is set */
5989 if (((attr
->extra
->mp_nexthop_len
== 32) &&
5990 !attr
->extra
->mp_nexthop_prefer_global
) ||
5991 (binfo
->peer
->conf_if
))
5993 if (binfo
->peer
->conf_if
)
5995 len
= vty_out (vty
, "%s",
5996 binfo
->peer
->conf_if
);
5997 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6000 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6002 vty_out (vty
, "%*s", len
, " ");
6006 len
= vty_out (vty
, "%s",
6007 inet_ntop (AF_INET6
,
6008 &attr
->extra
->mp_nexthop_local
,
6013 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6015 vty_out (vty
, "%*s", len
, " ");
6020 len
= vty_out (vty
, "%s",
6021 inet_ntop (AF_INET6
,
6022 &attr
->extra
->mp_nexthop_global
,
6027 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6029 vty_out (vty
, "%*s", len
, " ");
6035 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6037 json_object_int_add(json_path
, "med", attr
->med
);
6039 vty_out (vty
, "%10u", attr
->med
);
6045 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6047 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6049 vty_out (vty
, "%7u", attr
->local_pref
);
6057 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6059 json_object_int_add(json_path
, "weight", 0);
6062 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6066 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6073 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6075 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6080 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6082 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6087 json_object_string_add(json_path
, "alert", "No attributes");
6089 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6094 if (json_nexthop_global
|| json_nexthop_ll
)
6096 json_nexthops
= json_object_new_array();
6098 if (json_nexthop_global
)
6099 json_object_array_add(json_nexthops
, json_nexthop_global
);
6101 if (json_nexthop_ll
)
6102 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6104 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6107 json_object_array_add(json_paths
, json_path
);
6110 vty_out (vty
, "%s", VTY_NEWLINE
);
6113 /* called from terminal list command */
6115 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6116 u_char use_json
, json_object
*json_ar
)
6118 json_object
*json_status
= NULL
;
6119 json_object
*json_net
= NULL
;
6121 /* Route status display. */
6124 json_status
= json_object_new_object();
6125 json_net
= json_object_new_object();
6134 /* print prefix and mask */
6136 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6138 route_vty_out_route (p
, vty
);
6140 /* Print attribute */
6145 if (p
->family
== AF_INET
&&
6146 (safi
== SAFI_MPLS_VPN
||
6147 safi
== SAFI_ENCAP
||
6148 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6150 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6151 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6153 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6156 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6160 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6163 #endif /* HAVE_IPV6 */
6165 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6166 json_object_int_add(json_net
, "metric", attr
->med
);
6168 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6169 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6172 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6174 json_object_int_add(json_net
, "weight", 0);
6178 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6181 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6185 if (p
->family
== AF_INET
&&
6186 (safi
== SAFI_MPLS_VPN
||
6187 safi
== SAFI_ENCAP
||
6188 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6190 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6191 vty_out (vty
, "%-16s",
6192 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6194 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6197 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6202 assert (attr
->extra
);
6204 len
= vty_out (vty
, "%s",
6205 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6209 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6211 vty_out (vty
, "%*s", len
, " ");
6213 #endif /* HAVE_IPV6 */
6214 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6215 vty_out (vty
, "%10u", attr
->med
);
6219 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6220 vty_out (vty
, "%7u", attr
->local_pref
);
6224 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6228 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6231 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6236 json_object_boolean_true_add(json_status
, "*");
6237 json_object_boolean_true_add(json_status
, ">");
6238 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6239 char buf_cut
[BUFSIZ
];
6240 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6243 vty_out (vty
, "%s", VTY_NEWLINE
);
6247 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6248 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6250 json_object
*json_out
= NULL
;
6252 u_int32_t label
= 0;
6258 json_out
= json_object_new_object();
6260 /* short status lead text */
6261 route_vty_short_status_out (vty
, binfo
, json_out
);
6263 /* print prefix and mask */
6267 route_vty_out_route (p
, vty
);
6269 vty_out (vty
, "%*s", 17, " ");
6272 /* Print attribute */
6276 if (p
->family
== AF_INET
6277 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6279 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6282 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6284 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6289 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6291 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6295 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6297 assert (attr
->extra
);
6301 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6304 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6305 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6308 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6311 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6315 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6317 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6319 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6320 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6323 vty_out (vty
, "%s(%s)",
6324 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6326 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6331 #endif /* HAVE_IPV6 */
6334 label
= decode_label (binfo
->extra
->tag
);
6339 json_object_int_add(json_out
, "notag", label
);
6340 json_object_array_add(json
, json_out
);
6344 vty_out (vty
, "notag/%d", label
);
6345 vty_out (vty
, "%s", VTY_NEWLINE
);
6349 /* dampening route */
6351 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6352 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6356 char timebuf
[BGP_UPTIME_LEN
];
6358 /* short status lead text */
6359 route_vty_short_status_out (vty
, binfo
, json
);
6361 /* print prefix and mask */
6365 route_vty_out_route (p
, vty
);
6367 vty_out (vty
, "%*s", 17, " ");
6370 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6375 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6380 json_object_int_add(json
, "peerHost", len
);
6382 vty_out (vty
, "%*s", len
, " ");
6386 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6388 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6390 /* Print attribute */
6398 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6400 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6405 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6407 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6410 vty_out (vty
, "%s", VTY_NEWLINE
);
6415 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6416 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6419 struct bgp_damp_info
*bdi
;
6420 char timebuf
[BGP_UPTIME_LEN
];
6426 bdi
= binfo
->extra
->damp_info
;
6428 /* short status lead text */
6429 route_vty_short_status_out (vty
, binfo
, json
);
6431 /* print prefix and mask */
6435 route_vty_out_route (p
, vty
);
6437 vty_out (vty
, "%*s", 17, " ");
6440 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6445 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6450 json_object_int_add(json
, "peerHost", len
);
6452 vty_out (vty
, "%*s", len
, " ");
6455 len
= vty_out (vty
, "%d", bdi
->flap
);
6465 json_object_int_add(json
, "bdiFlap", len
);
6467 vty_out (vty
, "%*s", len
, " ");
6471 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6473 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6474 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6476 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6477 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6480 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6482 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6487 vty_out (vty
, "%*s ", 8, " ");
6490 /* Print attribute */
6498 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6500 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6505 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6507 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6510 vty_out (vty
, "%s", VTY_NEWLINE
);
6514 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6515 const char *header
, json_object
*json_adv_to
)
6517 char buf1
[INET6_ADDRSTRLEN
];
6518 json_object
*json_peer
= NULL
;
6522 /* 'advertised-to' is a dictionary of peers we have advertised this
6523 * prefix too. The key is the peer's IP or swpX, the value is the
6524 * hostname if we know it and "" if not.
6526 json_peer
= json_object_new_object();
6529 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6532 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6534 json_object_object_add(json_adv_to
,
6535 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6542 vty_out (vty
, "%s", header
);
6546 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6549 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6551 vty_out (vty
, " %s(%s)", peer
->hostname
,
6552 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6557 vty_out (vty
, " %s", peer
->conf_if
);
6559 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6565 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6566 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6567 json_object
*json_paths
)
6569 char buf
[INET6_ADDRSTRLEN
];
6572 int sockunion_vty_out (struct vty
*, union sockunion
*);
6573 #ifdef HAVE_CLOCK_MONOTONIC
6576 json_object
*json_bestpath
= NULL
;
6577 json_object
*json_cluster_list
= NULL
;
6578 json_object
*json_cluster_list_list
= NULL
;
6579 json_object
*json_ext_community
= NULL
;
6580 json_object
*json_last_update
= NULL
;
6581 json_object
*json_nexthop_global
= NULL
;
6582 json_object
*json_nexthop_ll
= NULL
;
6583 json_object
*json_nexthops
= NULL
;
6584 json_object
*json_path
= NULL
;
6585 json_object
*json_peer
= NULL
;
6586 json_object
*json_string
= NULL
;
6587 json_object
*json_adv_to
= NULL
;
6589 struct listnode
*node
, *nnode
;
6591 int addpath_capable
;
6597 json_path
= json_object_new_object();
6598 json_peer
= json_object_new_object();
6599 json_nexthop_global
= json_object_new_object();
6606 /* Line1 display AS-path, Aggregator */
6611 json_object_lock(attr
->aspath
->json
);
6612 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6616 if (attr
->aspath
->segments
)
6617 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6619 vty_out (vty
, " Local");
6623 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6626 json_object_boolean_true_add(json_path
, "removed");
6628 vty_out (vty
, ", (removed)");
6631 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6634 json_object_boolean_true_add(json_path
, "stale");
6636 vty_out (vty
, ", (stale)");
6639 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6643 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6644 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6648 vty_out (vty
, ", (aggregated by %u %s)",
6649 attr
->extra
->aggregator_as
,
6650 inet_ntoa (attr
->extra
->aggregator_addr
));
6654 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6657 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6659 vty_out (vty
, ", (Received from a RR-client)");
6662 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6665 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6667 vty_out (vty
, ", (Received from a RS-client)");
6670 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6673 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6675 vty_out (vty
, ", (history entry)");
6677 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6680 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6682 vty_out (vty
, ", (suppressed due to dampening)");
6686 vty_out (vty
, "%s", VTY_NEWLINE
);
6688 /* Line2 display Next-hop, Neighbor, Router-id */
6689 /* Display the nexthop */
6690 if (p
->family
== AF_INET
&&
6691 (safi
== SAFI_MPLS_VPN
||
6692 safi
== SAFI_ENCAP
||
6693 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6695 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6698 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6700 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6705 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6707 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6711 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6715 assert (attr
->extra
);
6718 json_object_string_add(json_nexthop_global
, "ip",
6719 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6720 buf
, INET6_ADDRSTRLEN
));
6721 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6722 json_object_string_add(json_nexthop_global
, "scope", "global");
6726 vty_out (vty
, " %s",
6727 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6728 buf
, INET6_ADDRSTRLEN
));
6732 /* Display the IGP cost or 'inaccessible' */
6733 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6736 json_object_boolean_false_add(json_nexthop_global
, "accessible");
6738 vty_out (vty
, " (inaccessible)");
6742 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6745 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
6747 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
6750 /* IGP cost is 0, display this only for json */
6754 json_object_int_add(json_nexthop_global
, "metric", 0);
6758 json_object_boolean_true_add(json_nexthop_global
, "accessible");
6761 /* Display peer "from" output */
6762 /* This path was originated locally */
6763 if (binfo
->peer
== bgp
->peer_self
)
6766 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6769 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
6771 vty_out (vty
, " from 0.0.0.0 ");
6776 json_object_string_add(json_peer
, "peerId", "::");
6778 vty_out (vty
, " from :: ");
6782 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
6784 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
6787 /* We RXed this path from one of our peers */
6793 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6794 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6796 if (binfo
->peer
->hostname
)
6797 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
6799 if (binfo
->peer
->domainname
)
6800 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
6802 if (binfo
->peer
->conf_if
)
6803 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
6807 if (binfo
->peer
->conf_if
)
6809 if (binfo
->peer
->hostname
&&
6810 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6811 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6812 binfo
->peer
->conf_if
);
6814 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
6818 if (binfo
->peer
->hostname
&&
6819 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6820 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6823 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6826 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6827 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6829 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6834 vty_out (vty
, "%s", VTY_NEWLINE
);
6836 /* display the link-local nexthop */
6837 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6841 json_nexthop_ll
= json_object_new_object();
6842 json_object_string_add(json_nexthop_ll
, "ip",
6843 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6844 buf
, INET6_ADDRSTRLEN
));
6845 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6846 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6848 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
6850 if (!attr
->extra
->mp_nexthop_prefer_global
)
6851 json_object_boolean_true_add(json_nexthop_ll
, "used");
6853 json_object_boolean_true_add(json_nexthop_global
, "used");
6857 vty_out (vty
, " (%s) %s%s",
6858 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6859 buf
, INET6_ADDRSTRLEN
),
6860 attr
->extra
->mp_nexthop_prefer_global
?
6861 "(prefer-global)" : "(used)",
6865 /* If we do not have a link-local nexthop then we must flag the global as "used" */
6869 json_object_boolean_true_add(json_nexthop_global
, "used");
6872 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
6874 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6876 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6878 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6881 json_object_int_add(json_path
, "med", attr
->med
);
6883 vty_out (vty
, ", metric %u", attr
->med
);
6886 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6889 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6891 vty_out (vty
, ", localpref %u", attr
->local_pref
);
6896 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
6898 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
6901 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6904 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6906 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
6909 if (attr
->extra
&& attr
->extra
->tag
!= 0)
6912 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
6914 vty_out (vty
, ", tag %d", attr
->extra
->tag
);
6917 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6920 json_object_boolean_false_add(json_path
, "valid");
6922 vty_out (vty
, ", invalid");
6924 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6927 json_object_boolean_true_add(json_path
, "valid");
6929 vty_out (vty
, ", valid");
6932 if (binfo
->peer
!= bgp
->peer_self
)
6934 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6936 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
6939 json_object_string_add(json_peer
, "type", "confed-internal");
6941 vty_out (vty
, ", confed-internal");
6946 json_object_string_add(json_peer
, "type", "internal");
6948 vty_out (vty
, ", internal");
6953 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
6956 json_object_string_add(json_peer
, "type", "confed-external");
6958 vty_out (vty
, ", confed-external");
6963 json_object_string_add(json_peer
, "type", "external");
6965 vty_out (vty
, ", external");
6969 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6973 json_object_boolean_true_add(json_path
, "aggregated");
6974 json_object_boolean_true_add(json_path
, "local");
6978 vty_out (vty
, ", aggregated, local");
6981 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
6984 json_object_boolean_true_add(json_path
, "sourced");
6986 vty_out (vty
, ", sourced");
6992 json_object_boolean_true_add(json_path
, "sourced");
6993 json_object_boolean_true_add(json_path
, "local");
6997 vty_out (vty
, ", sourced, local");
7001 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7004 json_object_boolean_true_add(json_path
, "atomicAggregate");
7006 vty_out (vty
, ", atomic-aggregate");
7009 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7010 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7011 bgp_info_mpath_count (binfo
)))
7014 json_object_boolean_true_add(json_path
, "multipath");
7016 vty_out (vty
, ", multipath");
7019 // Mark the bestpath(s)
7020 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7022 first_as
= aspath_get_firstas(attr
->aspath
);
7027 json_bestpath
= json_object_new_object();
7028 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7033 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7035 vty_out (vty
, ", bestpath-from-AS Local");
7039 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7044 json_bestpath
= json_object_new_object();
7045 json_object_boolean_true_add(json_bestpath
, "overall");
7048 vty_out (vty
, ", best");
7052 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7055 vty_out (vty
, "%s", VTY_NEWLINE
);
7057 /* Line 4 display Community */
7058 if (attr
->community
)
7062 json_object_lock(attr
->community
->json
);
7063 json_object_object_add(json_path
, "community", attr
->community
->json
);
7067 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7072 /* Line 5 display Extended-community */
7073 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7077 json_ext_community
= json_object_new_object();
7078 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7079 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7083 vty_out (vty
, " Extended Community: %s%s",
7084 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7088 /* Line 6 display Originator, Cluster-id */
7089 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7090 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7092 assert (attr
->extra
);
7093 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7096 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7098 vty_out (vty
, " Originator: %s",
7099 inet_ntoa (attr
->extra
->originator_id
));
7102 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7108 json_cluster_list
= json_object_new_object();
7109 json_cluster_list_list
= json_object_new_array();
7111 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7113 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7114 json_object_array_add(json_cluster_list_list
, json_string
);
7117 /* struct cluster_list does not have "str" variable like
7118 * aspath and community do. Add this someday if someone
7120 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7122 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7123 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7127 vty_out (vty
, ", Cluster list: ");
7129 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7131 vty_out (vty
, "%s ",
7132 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7138 vty_out (vty
, "%s", VTY_NEWLINE
);
7141 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7142 bgp_damp_info_vty (vty
, binfo
, json_path
);
7144 /* Line 7 display Addpath IDs */
7145 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7149 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7150 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7154 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7155 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7160 /* If we used addpath to TX a non-bestpath we need to display
7161 * "Advertised to" on a path-by-path basis */
7162 if (bgp
->addpath_tx_used
[afi
][safi
])
7166 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7168 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7169 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7171 if ((addpath_capable
&& has_adj
) ||
7172 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7174 if (json_path
&& !json_adv_to
)
7175 json_adv_to
= json_object_new_object();
7177 route_vty_out_advertised_to(vty
, peer
, &first
,
7187 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7194 vty_out (vty
, "%s", VTY_NEWLINE
);
7199 /* Line 8 display Uptime */
7200 #ifdef HAVE_CLOCK_MONOTONIC
7201 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7204 json_last_update
= json_object_new_object();
7205 json_object_int_add(json_last_update
, "epoch", tbuf
);
7206 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7207 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7210 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7214 json_last_update
= json_object_new_object();
7215 json_object_int_add(json_last_update
, "epoch", tbuf
);
7216 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7217 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7220 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7221 #endif /* HAVE_CLOCK_MONOTONIC */
7224 /* We've constructed the json object for this path, add it to the json
7229 if (json_nexthop_global
|| json_nexthop_ll
)
7231 json_nexthops
= json_object_new_array();
7233 if (json_nexthop_global
)
7234 json_object_array_add(json_nexthops
, json_nexthop_global
);
7236 if (json_nexthop_ll
)
7237 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7239 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7242 json_object_object_add(json_path
, "peer", json_peer
);
7243 json_object_array_add(json_paths
, json_path
);
7246 vty_out (vty
, "%s", VTY_NEWLINE
);
7249 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7250 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7251 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7255 bgp_show_type_normal
,
7256 bgp_show_type_regexp
,
7257 bgp_show_type_prefix_list
,
7258 bgp_show_type_filter_list
,
7259 bgp_show_type_route_map
,
7260 bgp_show_type_neighbor
,
7261 bgp_show_type_cidr_only
,
7262 bgp_show_type_prefix_longer
,
7263 bgp_show_type_community_all
,
7264 bgp_show_type_community
,
7265 bgp_show_type_community_exact
,
7266 bgp_show_type_community_list
,
7267 bgp_show_type_community_list_exact
,
7268 bgp_show_type_flap_statistics
,
7269 bgp_show_type_flap_address
,
7270 bgp_show_type_flap_prefix
,
7271 bgp_show_type_flap_cidr_only
,
7272 bgp_show_type_flap_regexp
,
7273 bgp_show_type_flap_filter_list
,
7274 bgp_show_type_flap_prefix_list
,
7275 bgp_show_type_flap_prefix_longer
,
7276 bgp_show_type_flap_route_map
,
7277 bgp_show_type_flap_neighbor
,
7278 bgp_show_type_dampend_paths
,
7279 bgp_show_type_damp_neighbor
7283 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7284 const char *prefix_list_str
, afi_t afi
,
7285 safi_t safi
, enum bgp_show_type type
);
7287 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7288 const char *filter
, afi_t afi
,
7289 safi_t safi
, enum bgp_show_type type
);
7291 bgp_show_route_map (struct vty
*vty
, const char *name
,
7292 const char *rmap_str
, afi_t afi
,
7293 safi_t safi
, enum bgp_show_type type
);
7295 bgp_show_community_list (struct vty
*vty
, const char *name
,
7296 const char *com
, int exact
,
7297 afi_t afi
, safi_t safi
);
7299 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7300 const char *prefix
, afi_t afi
,
7301 safi_t safi
, enum bgp_show_type type
);
7304 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
,
7305 struct in_addr
*router_id
, enum bgp_show_type type
,
7306 void *output_arg
, u_char use_json
, json_object
*json
)
7308 struct bgp_info
*ri
;
7309 struct bgp_node
*rn
;
7312 unsigned long output_count
;
7316 json_object
*json_paths
= NULL
;
7317 json_object
*json_routes
= NULL
;
7322 json
= json_object_new_object();
7324 json_object_int_add(json
, "tableVersion", table
->version
);
7325 json_object_string_add(json
, "routerId", inet_ntoa (*router_id
));
7326 json_routes
= json_object_new_object();
7329 /* This is first entry point, so reset total line. */
7332 /* Start processing of routes. */
7333 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7334 if (rn
->info
!= NULL
)
7339 json_paths
= json_object_new_array();
7343 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7345 if (type
== bgp_show_type_flap_statistics
7346 || type
== bgp_show_type_flap_address
7347 || type
== bgp_show_type_flap_prefix
7348 || type
== bgp_show_type_flap_cidr_only
7349 || type
== bgp_show_type_flap_regexp
7350 || type
== bgp_show_type_flap_filter_list
7351 || type
== bgp_show_type_flap_prefix_list
7352 || type
== bgp_show_type_flap_prefix_longer
7353 || type
== bgp_show_type_flap_route_map
7354 || type
== bgp_show_type_flap_neighbor
7355 || type
== bgp_show_type_dampend_paths
7356 || type
== bgp_show_type_damp_neighbor
)
7358 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7361 if (type
== bgp_show_type_regexp
7362 || type
== bgp_show_type_flap_regexp
)
7364 regex_t
*regex
= output_arg
;
7366 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7369 if (type
== bgp_show_type_prefix_list
7370 || type
== bgp_show_type_flap_prefix_list
)
7372 struct prefix_list
*plist
= output_arg
;
7374 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7377 if (type
== bgp_show_type_filter_list
7378 || type
== bgp_show_type_flap_filter_list
)
7380 struct as_list
*as_list
= output_arg
;
7382 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7385 if (type
== bgp_show_type_route_map
7386 || type
== bgp_show_type_flap_route_map
)
7388 struct route_map
*rmap
= output_arg
;
7389 struct bgp_info binfo
;
7390 struct attr dummy_attr
;
7391 struct attr_extra dummy_extra
;
7394 dummy_attr
.extra
= &dummy_extra
;
7395 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7397 binfo
.peer
= ri
->peer
;
7398 binfo
.attr
= &dummy_attr
;
7400 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7401 if (ret
== RMAP_DENYMATCH
)
7404 if (type
== bgp_show_type_neighbor
7405 || type
== bgp_show_type_flap_neighbor
7406 || type
== bgp_show_type_damp_neighbor
)
7408 union sockunion
*su
= output_arg
;
7410 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7413 if (type
== bgp_show_type_cidr_only
7414 || type
== bgp_show_type_flap_cidr_only
)
7416 u_int32_t destination
;
7418 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7419 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7421 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7423 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7426 if (type
== bgp_show_type_prefix_longer
7427 || type
== bgp_show_type_flap_prefix_longer
)
7429 struct prefix
*p
= output_arg
;
7431 if (! prefix_match (p
, &rn
->p
))
7434 if (type
== bgp_show_type_community_all
)
7436 if (! ri
->attr
->community
)
7439 if (type
== bgp_show_type_community
)
7441 struct community
*com
= output_arg
;
7443 if (! ri
->attr
->community
||
7444 ! community_match (ri
->attr
->community
, com
))
7447 if (type
== bgp_show_type_community_exact
)
7449 struct community
*com
= output_arg
;
7451 if (! ri
->attr
->community
||
7452 ! community_cmp (ri
->attr
->community
, com
))
7455 if (type
== bgp_show_type_community_list
)
7457 struct community_list
*list
= output_arg
;
7459 if (! community_list_match (ri
->attr
->community
, list
))
7462 if (type
== bgp_show_type_community_list_exact
)
7464 struct community_list
*list
= output_arg
;
7466 if (! community_list_exact_match (ri
->attr
->community
, list
))
7469 if (type
== bgp_show_type_flap_address
7470 || type
== bgp_show_type_flap_prefix
)
7472 struct prefix
*p
= output_arg
;
7474 if (! prefix_match (&rn
->p
, p
))
7477 if (type
== bgp_show_type_flap_prefix
)
7478 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7481 if (type
== bgp_show_type_dampend_paths
7482 || type
== bgp_show_type_damp_neighbor
)
7484 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7485 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7489 if (!use_json
&& header
)
7491 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (*router_id
), VTY_NEWLINE
);
7492 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7493 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7494 if (type
== bgp_show_type_dampend_paths
7495 || type
== bgp_show_type_damp_neighbor
)
7496 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7497 else if (type
== bgp_show_type_flap_statistics
7498 || type
== bgp_show_type_flap_address
7499 || type
== bgp_show_type_flap_prefix
7500 || type
== bgp_show_type_flap_cidr_only
7501 || type
== bgp_show_type_flap_regexp
7502 || type
== bgp_show_type_flap_filter_list
7503 || type
== bgp_show_type_flap_prefix_list
7504 || type
== bgp_show_type_flap_prefix_longer
7505 || type
== bgp_show_type_flap_route_map
7506 || type
== bgp_show_type_flap_neighbor
)
7507 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7509 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7513 if (type
== bgp_show_type_dampend_paths
7514 || type
== bgp_show_type_damp_neighbor
)
7515 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7516 else if (type
== bgp_show_type_flap_statistics
7517 || type
== bgp_show_type_flap_address
7518 || type
== bgp_show_type_flap_prefix
7519 || type
== bgp_show_type_flap_cidr_only
7520 || type
== bgp_show_type_flap_regexp
7521 || type
== bgp_show_type_flap_filter_list
7522 || type
== bgp_show_type_flap_prefix_list
7523 || type
== bgp_show_type_flap_prefix_longer
7524 || type
== bgp_show_type_flap_route_map
7525 || type
== bgp_show_type_flap_neighbor
)
7526 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7528 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7538 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7539 json_object_object_add(json_routes
, buf2
, json_paths
);
7546 json_object_object_add(json
, "routes", json_routes
);
7547 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7548 json_object_free(json
);
7552 /* No route is displayed */
7553 if (output_count
== 0)
7555 if (type
== bgp_show_type_normal
)
7556 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
7559 vty_out (vty
, "%sTotal number of prefixes %ld%s",
7560 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
7567 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7568 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7570 struct bgp_table
*table
;
7574 bgp
= bgp_get_default ();
7580 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7584 table
= bgp
->rib
[afi
][safi
];
7586 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
,
7591 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7594 struct listnode
*node
, *nnode
;
7596 struct bgp_table
*table
;
7597 json_object
*json
= NULL
;
7601 vty_out (vty
, "{%s", VTY_NEWLINE
);
7603 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7607 if (!(json
= json_object_new_object()))
7609 zlog_err("Unable to allocate memory for JSON object");
7611 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
7615 json_object_int_add(json
, "vrfId",
7616 (bgp
->vrf_id
== VRF_UNKNOWN
)
7617 ? -1 : bgp
->vrf_id
);
7618 json_object_string_add(json
, "vrfName",
7619 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7620 ? "Default" : bgp
->name
);
7622 vty_out (vty
, ",%s", VTY_NEWLINE
);
7626 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7627 ? "Default" : bgp
->name
);
7631 vty_out (vty
, "%sInstance %s:%s",
7633 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7634 ? "Default" : bgp
->name
,
7637 table
= bgp
->rib
[afi
][safi
];
7638 bgp_show_table (vty
, table
, &bgp
->router_id
,
7639 bgp_show_type_normal
, NULL
, use_json
, json
);
7644 vty_out (vty
, "}%s", VTY_NEWLINE
);
7647 /* Header of detailed BGP route information */
7649 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7650 struct bgp_node
*rn
,
7651 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7654 struct bgp_info
*ri
;
7657 struct listnode
*node
, *nnode
;
7658 char buf1
[INET6_ADDRSTRLEN
];
7659 char buf2
[INET6_ADDRSTRLEN
];
7664 int no_advertise
= 0;
7667 json_object
*json_adv_to
= NULL
;
7673 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7674 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7678 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7679 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7680 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7681 safi
== SAFI_MPLS_VPN
? ":" : "",
7682 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7683 p
->prefixlen
, VTY_NEWLINE
);
7686 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7689 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7692 if (ri
->extra
&& ri
->extra
->suppress
)
7694 if (ri
->attr
->community
!= NULL
)
7696 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7698 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7700 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7708 vty_out (vty
, "Paths: (%d available", count
);
7711 vty_out (vty
, ", best #%d", best
);
7712 if (safi
== SAFI_UNICAST
)
7713 vty_out (vty
, ", table %s",
7714 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7715 ? "Default-IP-Routing-Table" : bgp
->name
);
7718 vty_out (vty
, ", no best path");
7721 vty_out (vty
, ", not advertised to any peer");
7723 vty_out (vty
, ", not advertised to EBGP peer");
7725 vty_out (vty
, ", not advertised outside local AS");
7728 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7729 vty_out (vty
, ")%s", VTY_NEWLINE
);
7732 /* If we are not using addpath then we can display Advertised to and that will
7733 * show what peers we advertised the bestpath to. If we are using addpath
7734 * though then we must display Advertised to on a path-by-path basis. */
7735 if (!bgp
->addpath_tx_used
[afi
][safi
])
7737 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7739 if (bgp_adj_out_lookup (peer
, rn
, 0))
7741 if (json
&& !json_adv_to
)
7742 json_adv_to
= json_object_new_object();
7744 route_vty_out_advertised_to(vty
, peer
, &first
,
7745 " Advertised to non peer-group peers:\n ",
7754 json_object_object_add(json
, "advertisedTo", json_adv_to
);
7760 vty_out (vty
, " Not advertised to any peer");
7761 vty_out (vty
, "%s", VTY_NEWLINE
);
7766 /* Display specified route of BGP table. */
7768 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
7769 struct bgp_table
*rib
, const char *ip_str
,
7770 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7771 int prefix_check
, enum bgp_path_type pathtype
,
7777 struct prefix match
;
7778 struct bgp_node
*rn
;
7779 struct bgp_node
*rm
;
7780 struct bgp_info
*ri
;
7781 struct bgp_table
*table
;
7782 json_object
*json
= NULL
;
7783 json_object
*json_paths
= NULL
;
7785 /* Check IP address argument. */
7786 ret
= str2prefix (ip_str
, &match
);
7789 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
7793 match
.family
= afi2family (afi
);
7797 json
= json_object_new_object();
7798 json_paths
= json_object_new_array();
7801 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
7803 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
7805 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
7808 if ((table
= rn
->info
) != NULL
)
7812 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
7814 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
7816 bgp_unlock_node (rm
);
7820 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
7824 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
7825 AFI_IP
, safi
, json
);
7830 if (pathtype
== BGP_PATH_ALL
||
7831 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7832 (pathtype
== BGP_PATH_MULTIPATH
&&
7833 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7834 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
7837 bgp_unlock_node (rm
);
7846 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
7848 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
7850 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7854 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
7859 if (pathtype
== BGP_PATH_ALL
||
7860 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7861 (pathtype
== BGP_PATH_MULTIPATH
&&
7862 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7863 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
7867 bgp_unlock_node (rn
);
7874 json_object_object_add(json
, "paths", json_paths
);
7876 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7877 json_object_free(json
);
7883 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
7891 /* Display specified route of Main RIB */
7893 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
7894 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7895 int prefix_check
, enum bgp_path_type pathtype
,
7900 /* BGP structure lookup. */
7903 bgp
= bgp_lookup_by_name (view_name
);
7906 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
7912 bgp
= bgp_get_default ();
7915 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7920 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
7921 afi
, safi
, prd
, prefix_check
, pathtype
,
7925 /* BGP route print out function. */
7928 "show ip bgp {json}",
7932 "JavaScript Object Notation\n")
7934 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7937 DEFUN (show_ip_bgp_ipv4
,
7938 show_ip_bgp_ipv4_cmd
,
7939 "show ip bgp ipv4 (unicast|multicast) {json}",
7944 "Address Family modifier\n"
7945 "Address Family modifier\n"
7946 "JavaScript Object Notation\n")
7948 u_char uj
= use_json(argc
, argv
);
7950 if (strncmp (argv
[0], "m", 1) == 0)
7951 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
7954 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
7957 ALIAS (show_ip_bgp_ipv4
,
7958 show_bgp_ipv4_safi_cmd
,
7959 "show bgp ipv4 (unicast|multicast) {json}",
7963 "Address Family modifier\n"
7964 "Address Family modifier\n"
7965 "JavaScript Object Notation\n")
7967 DEFUN (show_ip_bgp_route
,
7968 show_ip_bgp_route_cmd
,
7969 "show ip bgp A.B.C.D {json}",
7973 "Network in the BGP routing table to display\n"
7974 "JavaScript Object Notation\n")
7976 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7979 DEFUN (show_ip_bgp_route_pathtype
,
7980 show_ip_bgp_route_pathtype_cmd
,
7981 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
7985 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7986 "Display only the bestpath\n"
7987 "Display only multipaths\n"
7988 "JavaScript Object Notation\n")
7990 u_char uj
= use_json(argc
, argv
);
7992 if (strncmp (argv
[1], "b", 1) == 0)
7993 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7995 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7998 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
7999 show_bgp_ipv4_safi_route_pathtype_cmd
,
8000 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
8004 "Address Family modifier\n"
8005 "Address Family modifier\n"
8006 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8007 "Display only the bestpath\n"
8008 "Display only multipaths\n"
8009 "JavaScript Object Notation\n")
8011 u_char uj
= use_json(argc
, argv
);
8013 if (strncmp (argv
[0], "m", 1) == 0)
8014 if (strncmp (argv
[2], "b", 1) == 0)
8015 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8017 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8019 if (strncmp (argv
[2], "b", 1) == 0)
8020 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8022 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8025 DEFUN (show_ip_bgp_ipv4_route
,
8026 show_ip_bgp_ipv4_route_cmd
,
8027 "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
8032 "Address Family modifier\n"
8033 "Address Family modifier\n"
8034 "Network in the BGP routing table to display\n"
8035 "JavaScript Object Notation\n")
8037 u_char uj
= use_json(argc
, argv
);
8039 if (strncmp (argv
[0], "m", 1) == 0)
8040 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8042 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8045 ALIAS (show_ip_bgp_ipv4_route
,
8046 show_bgp_ipv4_safi_route_cmd
,
8047 "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
8051 "Address Family modifier\n"
8052 "Address Family modifier\n"
8053 "Network in the BGP routing table to display\n"
8054 "JavaScript Object Notation\n")
8056 DEFUN (show_ip_bgp_vpnv4_all_route
,
8057 show_ip_bgp_vpnv4_all_route_cmd
,
8058 "show ip bgp vpnv4 all A.B.C.D {json}",
8062 "Display VPNv4 NLRI specific information\n"
8063 "Display information about all VPNv4 NLRIs\n"
8064 "Network in the BGP routing table to display\n"
8065 "JavaScript Object Notation\n")
8067 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8071 DEFUN (show_ip_bgp_vpnv4_rd_route
,
8072 show_ip_bgp_vpnv4_rd_route_cmd
,
8073 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8077 "Display VPNv4 NLRI specific information\n"
8078 "Display information for a route distinguisher\n"
8079 "VPN Route Distinguisher\n"
8080 "Network in the BGP routing table to display\n"
8081 "JavaScript Object Notation\n")
8084 struct prefix_rd prd
;
8085 u_char uj
= use_json(argc
, argv
);
8087 ret
= str2prefix_rd (argv
[0], &prd
);
8090 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8093 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, uj
);
8096 DEFUN (show_ip_bgp_prefix
,
8097 show_ip_bgp_prefix_cmd
,
8098 "show ip bgp A.B.C.D/M {json}",
8102 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8103 "JavaScript Object Notation\n")
8105 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8108 DEFUN (show_ip_bgp_prefix_pathtype
,
8109 show_ip_bgp_prefix_pathtype_cmd
,
8110 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8114 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8115 "Display only the bestpath\n"
8116 "Display only multipaths\n"
8117 "JavaScript Object Notation\n")
8119 u_char uj
= use_json(argc
, argv
);
8120 if (strncmp (argv
[1], "b", 1) == 0)
8121 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8123 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8126 DEFUN (show_ip_bgp_ipv4_prefix
,
8127 show_ip_bgp_ipv4_prefix_cmd
,
8128 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8133 "Address Family modifier\n"
8134 "Address Family modifier\n"
8135 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8136 "JavaScript Object Notation\n")
8138 u_char uj
= use_json(argc
, argv
);
8140 if (strncmp (argv
[0], "m", 1) == 0)
8141 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8143 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8146 ALIAS (show_ip_bgp_ipv4_prefix
,
8147 show_bgp_ipv4_safi_prefix_cmd
,
8148 "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8152 "Address Family modifier\n"
8153 "Address Family modifier\n"
8154 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8155 "JavaScript Object Notation\n")
8157 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8158 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8159 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8164 "Address Family modifier\n"
8165 "Address Family modifier\n"
8166 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8167 "Display only the bestpath\n"
8168 "Display only multipaths\n"
8169 "JavaScript Object Notation\n")
8171 u_char uj
= use_json(argc
, argv
);
8173 if (strncmp (argv
[0], "m", 1) == 0)
8174 if (strncmp (argv
[2], "b", 1) == 0)
8175 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8177 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8179 if (strncmp (argv
[2], "b", 1) == 0)
8180 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8182 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8185 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8186 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8187 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8191 "Address Family modifier\n"
8192 "Address Family modifier\n"
8193 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8194 "Display only the bestpath\n"
8195 "Display only multipaths\n"
8196 "JavaScript Object Notation\n")
8198 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
8199 show_ip_bgp_vpnv4_all_prefix_cmd
,
8200 "show ip bgp vpnv4 all A.B.C.D/M {json}",
8204 "Display VPNv4 NLRI specific information\n"
8205 "Display information about all VPNv4 NLRIs\n"
8206 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8207 "JavaScript Object Notation\n")
8209 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8212 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
8213 show_ip_bgp_vpnv4_rd_prefix_cmd
,
8214 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8218 "Display VPNv4 NLRI specific information\n"
8219 "Display information for a route distinguisher\n"
8220 "VPN Route Distinguisher\n"
8221 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8222 "JavaScript Object Notation\n")
8225 struct prefix_rd prd
;
8227 ret
= str2prefix_rd (argv
[0], &prd
);
8230 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8233 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8236 DEFUN (show_ip_bgp_view
,
8237 show_ip_bgp_instance_cmd
,
8238 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8242 BGP_INSTANCE_HELP_STR
8243 "JavaScript Object Notation\n")
8247 /* BGP structure lookup. */
8248 bgp
= bgp_lookup_by_name (argv
[1]);
8251 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8255 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8258 DEFUN (show_ip_bgp_instance_all
,
8259 show_ip_bgp_instance_all_cmd
,
8260 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8264 BGP_INSTANCE_ALL_HELP_STR
8265 "JavaScript Object Notation\n")
8267 u_char uj
= use_json(argc
, argv
);
8269 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8273 DEFUN (show_ip_bgp_instance_route
,
8274 show_ip_bgp_instance_route_cmd
,
8275 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8279 BGP_INSTANCE_HELP_STR
8280 "Network in the BGP routing table to display\n"
8281 "JavaScript Object Notation\n")
8283 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8286 DEFUN (show_ip_bgp_instance_route_pathtype
,
8287 show_ip_bgp_instance_route_pathtype_cmd
,
8288 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8292 BGP_INSTANCE_HELP_STR
8293 "Network in the BGP routing table to display\n"
8294 "Display only the bestpath\n"
8295 "Display only multipaths\n"
8296 "JavaScript Object Notation\n")
8298 u_char uj
= use_json(argc
, argv
);
8300 if (strncmp (argv
[3], "b", 1) == 0)
8301 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8303 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8306 DEFUN (show_ip_bgp_instance_prefix
,
8307 show_ip_bgp_instance_prefix_cmd
,
8308 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8312 BGP_INSTANCE_HELP_STR
8313 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8314 "JavaScript Object Notation\n")
8316 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8319 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8320 show_ip_bgp_instance_prefix_pathtype_cmd
,
8321 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8325 BGP_INSTANCE_HELP_STR
8326 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8327 "Display only the bestpath\n"
8328 "Display only multipaths\n"
8329 "JavaScript Object Notation\n")
8331 u_char uj
= use_json(argc
, argv
);
8332 if (strncmp (argv
[3], "b", 1) == 0)
8333 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8335 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8344 "JavaScript Object Notation\n")
8346 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8347 NULL
, use_json(argc
, argv
));
8352 "show bgp ipv6 {json}",
8356 "JavaScript Object Notation\n")
8358 DEFUN (show_bgp_ipv6_safi
,
8359 show_bgp_ipv6_safi_cmd
,
8360 "show bgp ipv6 (unicast|multicast) {json}",
8364 "Address Family modifier\n"
8365 "Address Family modifier\n"
8366 "JavaScript Object Notation\n")
8368 u_char uj
= use_json(argc
, argv
);
8369 if (strncmp (argv
[0], "m", 1) == 0)
8370 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8373 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8377 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8379 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8380 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8381 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8385 DEFUN (show_ipv6_bgp
,
8387 "show ipv6 bgp {json}",
8391 "JavaScript Object Notation\n")
8393 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8394 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8395 NULL
, use_json(argc
, argv
));
8398 DEFUN (show_bgp_route
,
8400 "show bgp X:X::X:X {json}",
8403 "Network in the BGP routing table to display\n"
8404 "JavaScript Object Notation\n")
8406 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8409 ALIAS (show_bgp_route
,
8410 show_bgp_ipv6_route_cmd
,
8411 "show bgp ipv6 X:X::X:X {json}",
8415 "Network in the BGP routing table to display\n"
8416 "JavaScript Object Notation\n")
8418 DEFUN (show_bgp_ipv6_safi_route
,
8419 show_bgp_ipv6_safi_route_cmd
,
8420 "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
8424 "Address Family modifier\n"
8425 "Address Family modifier\n"
8426 "Network in the BGP routing table to display\n"
8427 "JavaScript Object Notation\n")
8429 u_char uj
= use_json(argc
, argv
);
8430 if (strncmp (argv
[0], "m", 1) == 0)
8431 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8433 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8436 DEFUN (show_bgp_route_pathtype
,
8437 show_bgp_route_pathtype_cmd
,
8438 "show bgp X:X::X:X (bestpath|multipath) {json}",
8441 "Network in the BGP routing table to display\n"
8442 "Display only the bestpath\n"
8443 "Display only multipaths\n"
8444 "JavaScript Object Notation\n")
8446 u_char uj
= use_json(argc
, argv
);
8447 if (strncmp (argv
[1], "b", 1) == 0)
8448 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8450 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8453 ALIAS (show_bgp_route_pathtype
,
8454 show_bgp_ipv6_route_pathtype_cmd
,
8455 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8459 "Network in the BGP routing table to display\n"
8460 "Display only the bestpath\n"
8461 "Display only multipaths\n"
8462 "JavaScript Object Notation\n")
8464 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8465 show_bgp_ipv6_safi_route_pathtype_cmd
,
8466 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
8470 "Address Family modifier\n"
8471 "Address Family modifier\n"
8472 "Network in the BGP routing table to display\n"
8473 "Display only the bestpath\n"
8474 "Display only multipaths\n"
8475 "JavaScript Object Notation\n")
8477 u_char uj
= use_json(argc
, argv
);
8478 if (strncmp (argv
[0], "m", 1) == 0)
8479 if (strncmp (argv
[2], "b", 1) == 0)
8480 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8482 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8484 if (strncmp (argv
[2], "b", 1) == 0)
8485 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8487 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8491 DEFUN (show_ipv6_bgp_route
,
8492 show_ipv6_bgp_route_cmd
,
8493 "show ipv6 bgp X:X::X:X {json}",
8497 "Network in the BGP routing table to display\n"
8498 "JavaScript Object Notation\n")
8500 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8501 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8504 DEFUN (show_bgp_prefix
,
8505 show_bgp_prefix_cmd
,
8506 "show bgp X:X::X:X/M {json}",
8509 "IPv6 prefix <network>/<length>\n"
8510 "JavaScript Object Notation\n")
8512 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8515 ALIAS (show_bgp_prefix
,
8516 show_bgp_ipv6_prefix_cmd
,
8517 "show bgp ipv6 X:X::X:X/M {json}",
8521 "IPv6 prefix <network>/<length>\n"
8522 "JavaScript Object Notation\n")
8524 DEFUN (show_bgp_ipv6_safi_prefix
,
8525 show_bgp_ipv6_safi_prefix_cmd
,
8526 "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
8530 "Address Family modifier\n"
8531 "Address Family modifier\n"
8532 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8533 "JavaScript Object Notation\n")
8535 u_char uj
= use_json(argc
, argv
);
8536 if (strncmp (argv
[0], "m", 1) == 0)
8537 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8539 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8542 DEFUN (show_bgp_prefix_pathtype
,
8543 show_bgp_prefix_pathtype_cmd
,
8544 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8547 "IPv6 prefix <network>/<length>\n"
8548 "Display only the bestpath\n"
8549 "Display only multipaths\n"
8550 "JavaScript Object Notation\n")
8552 u_char uj
= use_json(argc
, argv
);
8553 if (strncmp (argv
[1], "b", 1) == 0)
8554 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8556 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8559 ALIAS (show_bgp_prefix_pathtype
,
8560 show_bgp_ipv6_prefix_pathtype_cmd
,
8561 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8565 "IPv6 prefix <network>/<length>\n"
8566 "Display only the bestpath\n"
8567 "Display only multipaths\n"
8568 "JavaScript Object Notation\n")
8570 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8571 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8572 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
8576 "Address Family modifier\n"
8577 "Address Family modifier\n"
8578 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8579 "Display only the bestpath\n"
8580 "Display only multipaths\n"
8581 "JavaScript Object Notation\n")
8583 u_char uj
= use_json(argc
, argv
);
8584 if (strncmp (argv
[0], "m", 1) == 0)
8585 if (strncmp (argv
[2], "b", 1) == 0)
8586 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8588 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8590 if (strncmp (argv
[2], "b", 1) == 0)
8591 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8593 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8597 DEFUN (show_ipv6_bgp_prefix
,
8598 show_ipv6_bgp_prefix_cmd
,
8599 "show ipv6 bgp X:X::X:X/M {json}",
8603 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8604 "JavaScript Object Notation\n")
8606 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8607 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8610 DEFUN (show_bgp_view
,
8611 show_bgp_instance_cmd
,
8612 "show bgp " BGP_INSTANCE_CMD
" {json}",
8615 BGP_INSTANCE_HELP_STR
8616 "JavaScript Object Notation\n")
8620 /* BGP structure lookup. */
8621 bgp
= bgp_lookup_by_name (argv
[1]);
8624 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8628 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8631 DEFUN (show_bgp_instance_all
,
8632 show_bgp_instance_all_cmd
,
8633 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8636 BGP_INSTANCE_ALL_HELP_STR
8637 "JavaScript Object Notation\n")
8639 u_char uj
= use_json(argc
, argv
);
8641 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8645 ALIAS (show_bgp_view
,
8646 show_bgp_instance_ipv6_cmd
,
8647 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8650 BGP_INSTANCE_HELP_STR
8652 "JavaScript Object Notation\n")
8654 DEFUN (show_bgp_instance_route
,
8655 show_bgp_instance_route_cmd
,
8656 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8659 BGP_INSTANCE_HELP_STR
8660 "Network in the BGP routing table to display\n"
8661 "JavaScript Object Notation\n")
8663 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8666 ALIAS (show_bgp_instance_route
,
8667 show_bgp_instance_ipv6_route_cmd
,
8668 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8671 BGP_INSTANCE_HELP_STR
8673 "Network in the BGP routing table to display\n"
8674 "JavaScript Object Notation\n")
8676 DEFUN (show_bgp_instance_route_pathtype
,
8677 show_bgp_instance_route_pathtype_cmd
,
8678 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8681 BGP_INSTANCE_HELP_STR
8682 "Network in the BGP routing table to display\n"
8683 "Display only the bestpath\n"
8684 "Display only multipaths\n"
8685 "JavaScript Object Notation\n")
8687 u_char uj
= use_json(argc
, argv
);
8688 if (strncmp (argv
[3], "b", 1) == 0)
8689 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8691 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8694 ALIAS (show_bgp_instance_route_pathtype
,
8695 show_bgp_instance_ipv6_route_pathtype_cmd
,
8696 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
8699 BGP_INSTANCE_HELP_STR
8701 "Network in the BGP routing table to display\n"
8702 "Display only the bestpath\n"
8703 "Display only multipaths\n"
8704 "JavaScript Object Notation\n")
8706 DEFUN (show_bgp_instance_prefix
,
8707 show_bgp_instance_prefix_cmd
,
8708 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
8711 BGP_INSTANCE_HELP_STR
8712 "IPv6 prefix <network>/<length>\n"
8713 "JavaScript Object Notation\n")
8715 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8718 ALIAS (show_bgp_instance_prefix
,
8719 show_bgp_instance_ipv6_prefix_cmd
,
8720 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
8723 BGP_INSTANCE_HELP_STR
8725 "IPv6 prefix <network>/<length>\n"
8726 "JavaScript Object Notation\n")
8728 DEFUN (show_bgp_instance_prefix_pathtype
,
8729 show_bgp_instance_prefix_pathtype_cmd
,
8730 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
8733 BGP_INSTANCE_HELP_STR
8734 "IPv6 prefix <network>/<length>\n"
8735 "Display only the bestpath\n"
8736 "Display only multipaths\n"
8737 "JavaScript Object Notation\n")
8739 u_char uj
= use_json(argc
, argv
);
8740 if (strncmp (argv
[3], "b", 1) == 0)
8741 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8743 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8746 ALIAS (show_bgp_instance_prefix_pathtype
,
8747 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
8748 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8751 BGP_INSTANCE_HELP_STR
8753 "IPv6 prefix <network>/<length>\n"
8754 "Display only the bestpath\n"
8755 "Display only multipaths\n"
8756 "JavaScript Object Notation\n")
8758 DEFUN (show_bgp_instance_prefix_list
,
8759 show_bgp_instance_prefix_list_cmd
,
8760 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
8763 BGP_INSTANCE_HELP_STR
8764 "Display routes conforming to the prefix-list\n"
8765 "IPv6 prefix-list name\n")
8767 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8768 bgp_show_type_prefix_list
);
8771 ALIAS (show_bgp_instance_prefix_list
,
8772 show_bgp_instance_ipv6_prefix_list_cmd
,
8773 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
8776 BGP_INSTANCE_HELP_STR
8778 "Display routes conforming to the prefix-list\n"
8779 "IPv6 prefix-list name\n")
8781 DEFUN (show_bgp_instance_filter_list
,
8782 show_bgp_instance_filter_list_cmd
,
8783 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
8786 BGP_INSTANCE_HELP_STR
8787 "Display routes conforming to the filter-list\n"
8788 "Regular expression access list name\n")
8790 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8791 bgp_show_type_filter_list
);
8794 ALIAS (show_bgp_instance_filter_list
,
8795 show_bgp_instance_ipv6_filter_list_cmd
,
8796 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
8799 BGP_INSTANCE_HELP_STR
8801 "Display routes conforming to the filter-list\n"
8802 "Regular expression access list name\n")
8804 DEFUN (show_bgp_instance_route_map
,
8805 show_bgp_instance_route_map_cmd
,
8806 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
8809 BGP_INSTANCE_HELP_STR
8810 "Display routes matching the route-map\n"
8811 "A route-map to match on\n")
8813 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8814 bgp_show_type_route_map
);
8817 ALIAS (show_bgp_instance_route_map
,
8818 show_bgp_instance_ipv6_route_map_cmd
,
8819 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
8822 BGP_INSTANCE_HELP_STR
8824 "Display routes matching the route-map\n"
8825 "A route-map to match on\n")
8827 DEFUN (show_bgp_instance_community_list
,
8828 show_bgp_instance_community_list_cmd
,
8829 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
8832 BGP_INSTANCE_HELP_STR
8833 "Display routes matching the community-list\n"
8834 "community-list number\n"
8835 "community-list name\n")
8837 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
8840 ALIAS (show_bgp_instance_community_list
,
8841 show_bgp_instance_ipv6_community_list_cmd
,
8842 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
8845 BGP_INSTANCE_HELP_STR
8847 "Display routes matching the community-list\n"
8848 "community-list number\n"
8849 "community-list name\n")
8851 DEFUN (show_bgp_instance_prefix_longer
,
8852 show_bgp_instance_prefix_longer_cmd
,
8853 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
8856 BGP_INSTANCE_HELP_STR
8857 "IPv6 prefix <network>/<length>\n"
8858 "Display route and more specific routes\n")
8860 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8861 bgp_show_type_prefix_longer
);
8864 ALIAS (show_bgp_instance_prefix_longer
,
8865 show_bgp_instance_ipv6_prefix_longer_cmd
,
8866 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
8869 BGP_INSTANCE_HELP_STR
8871 "IPv6 prefix <network>/<length>\n"
8872 "Display route and more specific routes\n")
8875 DEFUN (show_ipv6_mbgp
,
8877 "show ipv6 mbgp {json}",
8881 "JavaScript Object Notation\n")
8883 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8884 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8885 NULL
, use_json(argc
, argv
));
8889 DEFUN (show_ipv6_mbgp_route
,
8890 show_ipv6_mbgp_route_cmd
,
8891 "show ipv6 mbgp X:X::X:X {json}",
8895 "Network in the MBGP routing table to display\n"
8896 "JavaScript Object Notation\n")
8898 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8899 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8903 DEFUN (show_ipv6_mbgp_prefix
,
8904 show_ipv6_mbgp_prefix_cmd
,
8905 "show ipv6 mbgp X:X::X:X/M {json}",
8909 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8910 "JavaScript Object Notation\n")
8912 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8913 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8919 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
8920 safi_t safi
, enum bgp_show_type type
)
8930 b
= buffer_new (1024);
8931 for (i
= 0; i
< argc
; i
++)
8934 buffer_putc (b
, ' ');
8937 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
8942 buffer_putstr (b
, argv
[i
]);
8944 buffer_putc (b
, '\0');
8946 regstr
= buffer_getstr (b
);
8949 regex
= bgp_regcomp (regstr
);
8950 XFREE(MTYPE_TMP
, regstr
);
8953 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
8958 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
8959 bgp_regex_free (regex
);
8963 DEFUN (show_ip_bgp_regexp
,
8964 show_ip_bgp_regexp_cmd
,
8965 "show ip bgp regexp .LINE",
8969 "Display routes matching the AS path regular expression\n"
8970 "A regular-expression to match the BGP AS paths\n")
8972 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8973 bgp_show_type_regexp
);
8976 DEFUN (show_ip_bgp_flap_regexp
,
8977 show_ip_bgp_flap_regexp_cmd
,
8978 "show ip bgp flap-statistics regexp .LINE",
8982 "Display flap statistics of routes\n"
8983 "Display routes matching the AS path regular expression\n"
8984 "A regular-expression to match the BGP AS paths\n")
8986 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8987 bgp_show_type_flap_regexp
);
8990 ALIAS (show_ip_bgp_flap_regexp
,
8991 show_ip_bgp_damp_flap_regexp_cmd
,
8992 "show ip bgp dampening flap-statistics regexp .LINE",
8996 "Display detailed information about dampening\n"
8997 "Display flap statistics of routes\n"
8998 "Display routes matching the AS path regular expression\n"
8999 "A regular-expression to match the BGP AS paths\n")
9001 DEFUN (show_ip_bgp_ipv4_regexp
,
9002 show_ip_bgp_ipv4_regexp_cmd
,
9003 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
9008 "Address Family modifier\n"
9009 "Address Family modifier\n"
9010 "Display routes matching the AS path regular expression\n"
9011 "A regular-expression to match the BGP AS paths\n")
9013 if (strncmp (argv
[0], "m", 1) == 0)
9014 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
9015 bgp_show_type_regexp
);
9017 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9018 bgp_show_type_regexp
);
9022 DEFUN (show_bgp_regexp
,
9023 show_bgp_regexp_cmd
,
9024 "show bgp regexp .LINE",
9027 "Display routes matching the AS path regular expression\n"
9028 "A regular-expression to match the BGP AS paths\n")
9030 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9031 bgp_show_type_regexp
);
9034 ALIAS (show_bgp_regexp
,
9035 show_bgp_ipv6_regexp_cmd
,
9036 "show bgp ipv6 regexp .LINE",
9040 "Display routes matching the AS path regular expression\n"
9041 "A regular-expression to match the BGP AS paths\n")
9044 DEFUN (show_ipv6_bgp_regexp
,
9045 show_ipv6_bgp_regexp_cmd
,
9046 "show ipv6 bgp regexp .LINE",
9050 "Display routes matching the AS path regular expression\n"
9051 "A regular-expression to match the BGP AS paths\n")
9053 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9054 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9055 bgp_show_type_regexp
);
9059 DEFUN (show_ipv6_mbgp_regexp
,
9060 show_ipv6_mbgp_regexp_cmd
,
9061 "show ipv6 mbgp regexp .LINE",
9065 "Display routes matching the AS path regular expression\n"
9066 "A regular-expression to match the MBGP AS paths\n")
9068 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9069 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9070 bgp_show_type_regexp
);
9072 #endif /* HAVE_IPV6 */
9075 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9076 const char *prefix_list_str
, afi_t afi
,
9077 safi_t safi
, enum bgp_show_type type
)
9079 struct prefix_list
*plist
;
9080 struct bgp
*bgp
= NULL
;
9082 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9084 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9088 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9091 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9092 prefix_list_str
, VTY_NEWLINE
);
9096 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9099 DEFUN (show_ip_bgp_prefix_list
,
9100 show_ip_bgp_prefix_list_cmd
,
9101 "show ip bgp prefix-list WORD",
9105 "Display routes conforming to the prefix-list\n"
9106 "IP prefix-list name\n")
9108 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9109 bgp_show_type_prefix_list
);
9112 DEFUN (show_ip_bgp_instance_prefix_list
,
9113 show_ip_bgp_instance_prefix_list_cmd
,
9114 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9118 BGP_INSTANCE_HELP_STR
9119 "Display routes conforming to the prefix-list\n"
9120 "IP prefix-list name\n")
9122 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9123 bgp_show_type_prefix_list
);
9126 DEFUN (show_ip_bgp_flap_prefix_list
,
9127 show_ip_bgp_flap_prefix_list_cmd
,
9128 "show ip bgp flap-statistics prefix-list WORD",
9132 "Display flap statistics of routes\n"
9133 "Display routes conforming to the prefix-list\n"
9134 "IP prefix-list name\n")
9136 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9137 bgp_show_type_flap_prefix_list
);
9140 ALIAS (show_ip_bgp_flap_prefix_list
,
9141 show_ip_bgp_damp_flap_prefix_list_cmd
,
9142 "show ip bgp dampening flap-statistics prefix-list WORD",
9146 "Display detailed information about dampening\n"
9147 "Display flap statistics of routes\n"
9148 "Display routes conforming to the prefix-list\n"
9149 "IP prefix-list name\n")
9151 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9152 show_ip_bgp_ipv4_prefix_list_cmd
,
9153 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
9158 "Address Family modifier\n"
9159 "Address Family modifier\n"
9160 "Display routes conforming to the prefix-list\n"
9161 "IP prefix-list name\n")
9163 if (strncmp (argv
[0], "m", 1) == 0)
9164 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9165 bgp_show_type_prefix_list
);
9167 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9168 bgp_show_type_prefix_list
);
9172 DEFUN (show_bgp_prefix_list
,
9173 show_bgp_prefix_list_cmd
,
9174 "show bgp prefix-list WORD",
9177 "Display routes conforming to the prefix-list\n"
9178 "IPv6 prefix-list name\n")
9180 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9181 bgp_show_type_prefix_list
);
9184 ALIAS (show_bgp_prefix_list
,
9185 show_bgp_ipv6_prefix_list_cmd
,
9186 "show bgp ipv6 prefix-list WORD",
9190 "Display routes conforming to the prefix-list\n"
9191 "IPv6 prefix-list name\n")
9194 DEFUN (show_ipv6_bgp_prefix_list
,
9195 show_ipv6_bgp_prefix_list_cmd
,
9196 "show ipv6 bgp prefix-list WORD",
9200 "Display routes matching the prefix-list\n"
9201 "IPv6 prefix-list name\n")
9203 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9204 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9205 bgp_show_type_prefix_list
);
9209 DEFUN (show_ipv6_mbgp_prefix_list
,
9210 show_ipv6_mbgp_prefix_list_cmd
,
9211 "show ipv6 mbgp prefix-list WORD",
9215 "Display routes matching the prefix-list\n"
9216 "IPv6 prefix-list name\n")
9218 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9219 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9220 bgp_show_type_prefix_list
);
9222 #endif /* HAVE_IPV6 */
9225 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9226 const char *filter
, afi_t afi
,
9227 safi_t safi
, enum bgp_show_type type
)
9229 struct as_list
*as_list
;
9230 struct bgp
*bgp
= NULL
;
9232 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9234 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9238 as_list
= as_list_lookup (filter
);
9239 if (as_list
== NULL
)
9241 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9245 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9248 DEFUN (show_ip_bgp_filter_list
,
9249 show_ip_bgp_filter_list_cmd
,
9250 "show ip bgp filter-list WORD",
9254 "Display routes conforming to the filter-list\n"
9255 "Regular expression access list name\n")
9257 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9258 bgp_show_type_filter_list
);
9261 DEFUN (show_ip_bgp_instance_filter_list
,
9262 show_ip_bgp_instance_filter_list_cmd
,
9263 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9267 BGP_INSTANCE_HELP_STR
9268 "Display routes conforming to the filter-list\n"
9269 "Regular expression access list name\n")
9271 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9272 bgp_show_type_filter_list
);
9275 DEFUN (show_ip_bgp_flap_filter_list
,
9276 show_ip_bgp_flap_filter_list_cmd
,
9277 "show ip bgp flap-statistics filter-list WORD",
9281 "Display flap statistics of routes\n"
9282 "Display routes conforming to the filter-list\n"
9283 "Regular expression access list name\n")
9285 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9286 bgp_show_type_flap_filter_list
);
9289 ALIAS (show_ip_bgp_flap_filter_list
,
9290 show_ip_bgp_damp_flap_filter_list_cmd
,
9291 "show ip bgp dampening flap-statistics filter-list WORD",
9295 "Display detailed information about dampening\n"
9296 "Display flap statistics of routes\n"
9297 "Display routes conforming to the filter-list\n"
9298 "Regular expression access list name\n")
9300 DEFUN (show_ip_bgp_ipv4_filter_list
,
9301 show_ip_bgp_ipv4_filter_list_cmd
,
9302 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9307 "Address Family modifier\n"
9308 "Address Family modifier\n"
9309 "Display routes conforming to the filter-list\n"
9310 "Regular expression access list name\n")
9312 if (strncmp (argv
[0], "m", 1) == 0)
9313 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9314 bgp_show_type_filter_list
);
9316 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9317 bgp_show_type_filter_list
);
9321 DEFUN (show_bgp_filter_list
,
9322 show_bgp_filter_list_cmd
,
9323 "show bgp filter-list WORD",
9326 "Display routes conforming to the filter-list\n"
9327 "Regular expression access list name\n")
9329 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9330 bgp_show_type_filter_list
);
9333 ALIAS (show_bgp_filter_list
,
9334 show_bgp_ipv6_filter_list_cmd
,
9335 "show bgp ipv6 filter-list WORD",
9339 "Display routes conforming to the filter-list\n"
9340 "Regular expression access list name\n")
9343 DEFUN (show_ipv6_bgp_filter_list
,
9344 show_ipv6_bgp_filter_list_cmd
,
9345 "show ipv6 bgp filter-list WORD",
9349 "Display routes conforming to the filter-list\n"
9350 "Regular expression access list name\n")
9352 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9353 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9354 bgp_show_type_filter_list
);
9358 DEFUN (show_ipv6_mbgp_filter_list
,
9359 show_ipv6_mbgp_filter_list_cmd
,
9360 "show ipv6 mbgp filter-list WORD",
9364 "Display routes conforming to the filter-list\n"
9365 "Regular expression access list name\n")
9367 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9368 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9369 bgp_show_type_filter_list
);
9371 #endif /* HAVE_IPV6 */
9373 DEFUN (show_ip_bgp_dampening_info
,
9374 show_ip_bgp_dampening_params_cmd
,
9375 "show ip bgp dampening parameters",
9379 "Display detailed information about dampening\n"
9380 "Display detail of configured dampening parameters\n")
9382 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9386 bgp_show_route_map (struct vty
*vty
, const char *name
,
9387 const char *rmap_str
, afi_t afi
,
9388 safi_t safi
, enum bgp_show_type type
)
9390 struct route_map
*rmap
;
9391 struct bgp
*bgp
= NULL
;
9393 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9395 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9399 rmap
= route_map_lookup_by_name (rmap_str
);
9402 vty_out (vty
, "%% %s is not a valid route-map name%s",
9403 rmap_str
, VTY_NEWLINE
);
9407 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9410 DEFUN (show_ip_bgp_route_map
,
9411 show_ip_bgp_route_map_cmd
,
9412 "show ip bgp route-map WORD",
9416 "Display routes matching the route-map\n"
9417 "A route-map to match on\n")
9419 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9420 bgp_show_type_route_map
);
9423 DEFUN (show_ip_bgp_instance_route_map
,
9424 show_ip_bgp_instance_route_map_cmd
,
9425 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9429 BGP_INSTANCE_HELP_STR
9430 "Display routes matching the route-map\n"
9431 "A route-map to match on\n")
9433 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9434 bgp_show_type_route_map
);
9437 DEFUN (show_ip_bgp_flap_route_map
,
9438 show_ip_bgp_flap_route_map_cmd
,
9439 "show ip bgp flap-statistics route-map WORD",
9443 "Display flap statistics of routes\n"
9444 "Display routes matching the route-map\n"
9445 "A route-map to match on\n")
9447 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9448 bgp_show_type_flap_route_map
);
9451 ALIAS (show_ip_bgp_flap_route_map
,
9452 show_ip_bgp_damp_flap_route_map_cmd
,
9453 "show ip bgp dampening flap-statistics route-map WORD",
9457 "Display detailed information about dampening\n"
9458 "Display flap statistics of routes\n"
9459 "Display routes matching the route-map\n"
9460 "A route-map to match on\n")
9462 DEFUN (show_ip_bgp_ipv4_route_map
,
9463 show_ip_bgp_ipv4_route_map_cmd
,
9464 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9469 "Address Family modifier\n"
9470 "Address Family modifier\n"
9471 "Display routes matching the route-map\n"
9472 "A route-map to match on\n")
9474 if (strncmp (argv
[0], "m", 1) == 0)
9475 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9476 bgp_show_type_route_map
);
9478 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9479 bgp_show_type_route_map
);
9482 DEFUN (show_bgp_route_map
,
9483 show_bgp_route_map_cmd
,
9484 "show bgp route-map WORD",
9487 "Display routes matching the route-map\n"
9488 "A route-map to match on\n")
9490 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9491 bgp_show_type_route_map
);
9494 ALIAS (show_bgp_route_map
,
9495 show_bgp_ipv6_route_map_cmd
,
9496 "show bgp ipv6 route-map WORD",
9500 "Display routes matching the route-map\n"
9501 "A route-map to match on\n")
9503 DEFUN (show_ip_bgp_cidr_only
,
9504 show_ip_bgp_cidr_only_cmd
,
9505 "show ip bgp cidr-only",
9509 "Display only routes with non-natural netmasks\n")
9511 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9512 bgp_show_type_cidr_only
, NULL
, 0);
9515 DEFUN (show_ip_bgp_flap_cidr_only
,
9516 show_ip_bgp_flap_cidr_only_cmd
,
9517 "show ip bgp flap-statistics cidr-only",
9521 "Display flap statistics of routes\n"
9522 "Display only routes with non-natural netmasks\n")
9524 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9525 bgp_show_type_flap_cidr_only
, NULL
, 0);
9528 ALIAS (show_ip_bgp_flap_cidr_only
,
9529 show_ip_bgp_damp_flap_cidr_only_cmd
,
9530 "show ip bgp dampening flap-statistics cidr-only",
9534 "Display detailed information about dampening\n"
9535 "Display flap statistics of routes\n"
9536 "Display only routes with non-natural netmasks\n")
9538 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9539 show_ip_bgp_ipv4_cidr_only_cmd
,
9540 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9545 "Address Family modifier\n"
9546 "Address Family modifier\n"
9547 "Display only routes with non-natural netmasks\n")
9549 if (strncmp (argv
[0], "m", 1) == 0)
9550 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9551 bgp_show_type_cidr_only
, NULL
, 0);
9553 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9554 bgp_show_type_cidr_only
, NULL
, 0);
9557 DEFUN (show_ip_bgp_community_all
,
9558 show_ip_bgp_community_all_cmd
,
9559 "show ip bgp community",
9563 "Display routes matching the communities\n")
9565 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9566 bgp_show_type_community_all
, NULL
, 0);
9569 DEFUN (show_ip_bgp_ipv4_community_all
,
9570 show_ip_bgp_ipv4_community_all_cmd
,
9571 "show ip bgp ipv4 (unicast|multicast) community",
9576 "Address Family modifier\n"
9577 "Address Family modifier\n"
9578 "Display routes matching the communities\n")
9580 if (strncmp (argv
[0], "m", 1) == 0)
9581 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9582 bgp_show_type_community_all
, NULL
, 0);
9584 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9585 bgp_show_type_community_all
, NULL
, 0);
9589 DEFUN (show_bgp_community_all
,
9590 show_bgp_community_all_cmd
,
9591 "show bgp community",
9594 "Display routes matching the communities\n")
9596 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9597 bgp_show_type_community_all
, NULL
, 0);
9600 ALIAS (show_bgp_community_all
,
9601 show_bgp_ipv6_community_all_cmd
,
9602 "show bgp ipv6 community",
9606 "Display routes matching the communities\n")
9609 DEFUN (show_ipv6_bgp_community_all
,
9610 show_ipv6_bgp_community_all_cmd
,
9611 "show ipv6 bgp community",
9615 "Display routes matching the communities\n")
9617 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9618 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9619 bgp_show_type_community_all
, NULL
, 0);
9623 DEFUN (show_ipv6_mbgp_community_all
,
9624 show_ipv6_mbgp_community_all_cmd
,
9625 "show ipv6 mbgp community",
9629 "Display routes matching the communities\n")
9631 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9632 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9633 bgp_show_type_community_all
, NULL
, 0);
9635 #endif /* HAVE_IPV6 */
9638 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9639 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9641 struct community
*com
;
9648 /* BGP structure lookup */
9651 bgp
= bgp_lookup_by_name (view_name
);
9654 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
9660 bgp
= bgp_get_default ();
9663 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9668 b
= buffer_new (1024);
9669 for (i
= 0; i
< argc
; i
++)
9672 buffer_putc (b
, ' ');
9675 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9680 buffer_putstr (b
, argv
[i
]);
9682 buffer_putc (b
, '\0');
9684 str
= buffer_getstr (b
);
9687 com
= community_str2com (str
);
9688 XFREE (MTYPE_TMP
, str
);
9691 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
9695 return bgp_show (vty
, bgp
, afi
, safi
,
9696 (exact
? bgp_show_type_community_exact
:
9697 bgp_show_type_community
), com
, 0);
9700 DEFUN (show_ip_bgp_community
,
9701 show_ip_bgp_community_cmd
,
9702 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9706 "Display routes matching the communities\n"
9708 "Do not send outside local AS (well-known community)\n"
9709 "Do not advertise to any peer (well-known community)\n"
9710 "Do not export to next AS (well-known community)\n")
9712 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9715 ALIAS (show_ip_bgp_community
,
9716 show_ip_bgp_community2_cmd
,
9717 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9721 "Display routes matching the communities\n"
9723 "Do not send outside local AS (well-known community)\n"
9724 "Do not advertise to any peer (well-known community)\n"
9725 "Do not export to next AS (well-known community)\n"
9727 "Do not send outside local AS (well-known community)\n"
9728 "Do not advertise to any peer (well-known community)\n"
9729 "Do not export to next AS (well-known community)\n")
9731 ALIAS (show_ip_bgp_community
,
9732 show_ip_bgp_community3_cmd
,
9733 "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)",
9737 "Display routes matching the communities\n"
9739 "Do not send outside local AS (well-known community)\n"
9740 "Do not advertise to any peer (well-known community)\n"
9741 "Do not export to next AS (well-known community)\n"
9743 "Do not send outside local AS (well-known community)\n"
9744 "Do not advertise to any peer (well-known community)\n"
9745 "Do not export to next AS (well-known community)\n"
9747 "Do not send outside local AS (well-known community)\n"
9748 "Do not advertise to any peer (well-known community)\n"
9749 "Do not export to next AS (well-known community)\n")
9751 ALIAS (show_ip_bgp_community
,
9752 show_ip_bgp_community4_cmd
,
9753 "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)",
9757 "Display routes matching the communities\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"
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"
9767 "Do not send outside local AS (well-known community)\n"
9768 "Do not advertise to any peer (well-known community)\n"
9769 "Do not export to next AS (well-known community)\n"
9771 "Do not send outside local AS (well-known community)\n"
9772 "Do not advertise to any peer (well-known community)\n"
9773 "Do not export to next AS (well-known community)\n")
9775 DEFUN (show_ip_bgp_ipv4_community
,
9776 show_ip_bgp_ipv4_community_cmd
,
9777 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9782 "Address Family modifier\n"
9783 "Address Family modifier\n"
9784 "Display routes matching the communities\n"
9786 "Do not send outside local AS (well-known community)\n"
9787 "Do not advertise to any peer (well-known community)\n"
9788 "Do not export to next AS (well-known community)\n")
9790 if (strncmp (argv
[0], "m", 1) == 0)
9791 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
9793 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9796 ALIAS (show_ip_bgp_ipv4_community
,
9797 show_ip_bgp_ipv4_community2_cmd
,
9798 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9803 "Address Family modifier\n"
9804 "Address Family modifier\n"
9805 "Display routes matching the communities\n"
9807 "Do not send outside local AS (well-known community)\n"
9808 "Do not advertise to any peer (well-known community)\n"
9809 "Do not export to next AS (well-known community)\n"
9811 "Do not send outside local AS (well-known community)\n"
9812 "Do not advertise to any peer (well-known community)\n"
9813 "Do not export to next AS (well-known community)\n")
9815 ALIAS (show_ip_bgp_ipv4_community
,
9816 show_ip_bgp_ipv4_community3_cmd
,
9817 "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)",
9822 "Address Family modifier\n"
9823 "Address Family modifier\n"
9824 "Display routes matching the communities\n"
9826 "Do not send outside local AS (well-known community)\n"
9827 "Do not advertise to any peer (well-known community)\n"
9828 "Do not export to next AS (well-known community)\n"
9830 "Do not send outside local AS (well-known community)\n"
9831 "Do not advertise to any peer (well-known community)\n"
9832 "Do not export to next AS (well-known community)\n"
9834 "Do not send outside local AS (well-known community)\n"
9835 "Do not advertise to any peer (well-known community)\n"
9836 "Do not export to next AS (well-known community)\n")
9838 ALIAS (show_ip_bgp_ipv4_community
,
9839 show_ip_bgp_ipv4_community4_cmd
,
9840 "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)",
9845 "Address Family modifier\n"
9846 "Address Family modifier\n"
9847 "Display routes matching the communities\n"
9849 "Do not send outside local AS (well-known community)\n"
9850 "Do not advertise to any peer (well-known community)\n"
9851 "Do not export to next AS (well-known community)\n"
9853 "Do not send outside local AS (well-known community)\n"
9854 "Do not advertise to any peer (well-known community)\n"
9855 "Do not export to next AS (well-known community)\n"
9857 "Do not send outside local AS (well-known community)\n"
9858 "Do not advertise to any peer (well-known community)\n"
9859 "Do not export to next AS (well-known community)\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 DEFUN (show_bgp_instance_afi_safi_community_all
,
9866 show_bgp_instance_afi_safi_community_all_cmd
,
9867 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
9870 BGP_INSTANCE_HELP_STR
9873 "Address Family modifier\n"
9874 "Address Family modifier\n"
9875 "Display routes matching the communities\n")
9881 /* BGP structure lookup. */
9882 bgp
= bgp_lookup_by_name (argv
[1]);
9885 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
9889 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9890 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9891 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
9894 DEFUN (show_bgp_instance_afi_safi_community
,
9895 show_bgp_instance_afi_safi_community_cmd
,
9896 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9899 BGP_INSTANCE_HELP_STR
9902 "Address family modifier\n"
9903 "Address family modifier\n"
9904 "Display routes matching the communities\n"
9906 "Do not send outside local AS (well-known community)\n"
9907 "Do not advertise to any peer (well-known community)\n"
9908 "Do not export to next AS (well-known community)\n")
9913 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9914 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9915 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
9918 ALIAS (show_bgp_instance_afi_safi_community
,
9919 show_bgp_instance_afi_safi_community2_cmd
,
9920 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9923 BGP_INSTANCE_HELP_STR
9926 "Address family modifier\n"
9927 "Address family modifier\n"
9928 "Display routes matching the communities\n"
9930 "Do not send outside local AS (well-known community)\n"
9931 "Do not advertise to any peer (well-known community)\n"
9932 "Do not export to next AS (well-known community)\n"
9934 "Do not send outside local AS (well-known community)\n"
9935 "Do not advertise to any peer (well-known community)\n"
9936 "Do not export to next AS (well-known community)\n")
9938 ALIAS (show_bgp_instance_afi_safi_community
,
9939 show_bgp_instance_afi_safi_community3_cmd
,
9940 "show bgp " BGP_INSTANCE_CMD
" (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)",
9943 BGP_INSTANCE_HELP_STR
9946 "Address family modifier\n"
9947 "Address family modifier\n"
9948 "Display routes matching the communities\n"
9950 "Do not send outside local AS (well-known community)\n"
9951 "Do not advertise to any peer (well-known community)\n"
9952 "Do not export to next AS (well-known community)\n"
9954 "Do not send outside local AS (well-known community)\n"
9955 "Do not advertise to any peer (well-known community)\n"
9956 "Do not export to next AS (well-known community)\n"
9958 "Do not send outside local AS (well-known community)\n"
9959 "Do not advertise to any peer (well-known community)\n"
9960 "Do not export to next AS (well-known community)\n")
9962 ALIAS (show_bgp_instance_afi_safi_community
,
9963 show_bgp_instance_afi_safi_community4_cmd
,
9964 "show bgp " BGP_INSTANCE_CMD
" (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)",
9967 BGP_INSTANCE_HELP_STR
9970 "Address family modifier\n"
9971 "Address family modifier\n"
9972 "Display routes matching the communities\n"
9974 "Do not send outside local AS (well-known community)\n"
9975 "Do not advertise to any peer (well-known community)\n"
9976 "Do not export to next AS (well-known community)\n"
9978 "Do not send outside local AS (well-known community)\n"
9979 "Do not advertise to any peer (well-known community)\n"
9980 "Do not export to next AS (well-known community)\n"
9982 "Do not send outside local AS (well-known community)\n"
9983 "Do not advertise to any peer (well-known community)\n"
9984 "Do not export to next AS (well-known community)\n"
9986 "Do not send outside local AS (well-known community)\n"
9987 "Do not advertise to any peer (well-known community)\n"
9988 "Do not export to next AS (well-known community)\n")
9990 DEFUN (show_ip_bgp_community_exact
,
9991 show_ip_bgp_community_exact_cmd
,
9992 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9996 "Display routes matching the communities\n"
9998 "Do not send outside local AS (well-known community)\n"
9999 "Do not advertise to any peer (well-known community)\n"
10000 "Do not export to next AS (well-known community)\n"
10001 "Exact match of the communities")
10003 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10006 ALIAS (show_ip_bgp_community_exact
,
10007 show_ip_bgp_community2_exact_cmd
,
10008 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10012 "Display routes matching the communities\n"
10014 "Do not send outside local AS (well-known community)\n"
10015 "Do not advertise to any peer (well-known community)\n"
10016 "Do not export to next AS (well-known community)\n"
10018 "Do not send outside local AS (well-known community)\n"
10019 "Do not advertise to any peer (well-known community)\n"
10020 "Do not export to next AS (well-known community)\n"
10021 "Exact match of the communities")
10023 ALIAS (show_ip_bgp_community_exact
,
10024 show_ip_bgp_community3_exact_cmd
,
10025 "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",
10029 "Display routes matching the communities\n"
10031 "Do not send outside local AS (well-known community)\n"
10032 "Do not advertise to any peer (well-known community)\n"
10033 "Do not export to next AS (well-known community)\n"
10035 "Do not send outside local AS (well-known community)\n"
10036 "Do not advertise to any peer (well-known community)\n"
10037 "Do not export to next AS (well-known community)\n"
10039 "Do not send outside local AS (well-known community)\n"
10040 "Do not advertise to any peer (well-known community)\n"
10041 "Do not export to next AS (well-known community)\n"
10042 "Exact match of the communities")
10044 ALIAS (show_ip_bgp_community_exact
,
10045 show_ip_bgp_community4_exact_cmd
,
10046 "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",
10050 "Display routes matching the communities\n"
10052 "Do not send outside local AS (well-known community)\n"
10053 "Do not advertise to any peer (well-known community)\n"
10054 "Do not export to next AS (well-known community)\n"
10056 "Do not send outside local AS (well-known community)\n"
10057 "Do not advertise to any peer (well-known community)\n"
10058 "Do not export to next AS (well-known community)\n"
10060 "Do not send outside local AS (well-known community)\n"
10061 "Do not advertise to any peer (well-known community)\n"
10062 "Do not export to next AS (well-known community)\n"
10064 "Do not send outside local AS (well-known community)\n"
10065 "Do not advertise to any peer (well-known community)\n"
10066 "Do not export to next AS (well-known community)\n"
10067 "Exact match of the communities")
10069 DEFUN (show_ip_bgp_ipv4_community_exact
,
10070 show_ip_bgp_ipv4_community_exact_cmd
,
10071 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10076 "Address Family modifier\n"
10077 "Address Family modifier\n"
10078 "Display routes matching the communities\n"
10080 "Do not send outside local AS (well-known community)\n"
10081 "Do not advertise to any peer (well-known community)\n"
10082 "Do not export to next AS (well-known community)\n"
10083 "Exact match of the communities")
10085 if (strncmp (argv
[0], "m", 1) == 0)
10086 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
10088 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10091 ALIAS (show_ip_bgp_ipv4_community_exact
,
10092 show_ip_bgp_ipv4_community2_exact_cmd
,
10093 "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",
10098 "Address Family modifier\n"
10099 "Address Family modifier\n"
10100 "Display routes matching the communities\n"
10102 "Do not send outside local AS (well-known community)\n"
10103 "Do not advertise to any peer (well-known community)\n"
10104 "Do not export to next AS (well-known community)\n"
10106 "Do not send outside local AS (well-known community)\n"
10107 "Do not advertise to any peer (well-known community)\n"
10108 "Do not export to next AS (well-known community)\n"
10109 "Exact match of the communities")
10111 ALIAS (show_ip_bgp_ipv4_community_exact
,
10112 show_ip_bgp_ipv4_community3_exact_cmd
,
10113 "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",
10118 "Address Family modifier\n"
10119 "Address Family modifier\n"
10120 "Display routes matching the communities\n"
10122 "Do not send outside local AS (well-known community)\n"
10123 "Do not advertise to any peer (well-known community)\n"
10124 "Do not export to next AS (well-known community)\n"
10126 "Do not send outside local AS (well-known community)\n"
10127 "Do not advertise to any peer (well-known community)\n"
10128 "Do not export to next AS (well-known community)\n"
10130 "Do not send outside local AS (well-known community)\n"
10131 "Do not advertise to any peer (well-known community)\n"
10132 "Do not export to next AS (well-known community)\n"
10133 "Exact match of the communities")
10135 ALIAS (show_ip_bgp_ipv4_community_exact
,
10136 show_ip_bgp_ipv4_community4_exact_cmd
,
10137 "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",
10142 "Address Family modifier\n"
10143 "Address Family modifier\n"
10144 "Display routes matching the communities\n"
10146 "Do not send outside local AS (well-known community)\n"
10147 "Do not advertise to any peer (well-known community)\n"
10148 "Do not export to next AS (well-known community)\n"
10150 "Do not send outside local AS (well-known community)\n"
10151 "Do not advertise to any peer (well-known community)\n"
10152 "Do not export to next AS (well-known community)\n"
10154 "Do not send outside local AS (well-known community)\n"
10155 "Do not advertise to any peer (well-known community)\n"
10156 "Do not export to next AS (well-known community)\n"
10158 "Do not send outside local AS (well-known community)\n"
10159 "Do not advertise to any peer (well-known community)\n"
10160 "Do not export to next AS (well-known community)\n"
10161 "Exact match of the communities")
10164 DEFUN (show_bgp_community
,
10165 show_bgp_community_cmd
,
10166 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10169 "Display routes matching the communities\n"
10171 "Do not send outside local AS (well-known community)\n"
10172 "Do not advertise to any peer (well-known community)\n"
10173 "Do not export to next AS (well-known community)\n")
10175 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10178 ALIAS (show_bgp_community
,
10179 show_bgp_ipv6_community_cmd
,
10180 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10184 "Display routes matching the communities\n"
10186 "Do not send outside local AS (well-known community)\n"
10187 "Do not advertise to any peer (well-known community)\n"
10188 "Do not export to next AS (well-known community)\n")
10190 ALIAS (show_bgp_community
,
10191 show_bgp_community2_cmd
,
10192 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10195 "Display routes matching the communities\n"
10197 "Do not send outside local AS (well-known community)\n"
10198 "Do not advertise to any peer (well-known community)\n"
10199 "Do not export to next AS (well-known community)\n"
10201 "Do not send outside local AS (well-known community)\n"
10202 "Do not advertise to any peer (well-known community)\n"
10203 "Do not export to next AS (well-known community)\n")
10205 ALIAS (show_bgp_community
,
10206 show_bgp_ipv6_community2_cmd
,
10207 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10211 "Display routes matching the communities\n"
10213 "Do not send outside local AS (well-known community)\n"
10214 "Do not advertise to any peer (well-known community)\n"
10215 "Do not export to next AS (well-known community)\n"
10217 "Do not send outside local AS (well-known community)\n"
10218 "Do not advertise to any peer (well-known community)\n"
10219 "Do not export to next AS (well-known community)\n")
10221 ALIAS (show_bgp_community
,
10222 show_bgp_community3_cmd
,
10223 "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)",
10226 "Display routes matching the communities\n"
10228 "Do not send outside local AS (well-known community)\n"
10229 "Do not advertise to any peer (well-known community)\n"
10230 "Do not export to next AS (well-known community)\n"
10232 "Do not send outside local AS (well-known community)\n"
10233 "Do not advertise to any peer (well-known community)\n"
10234 "Do not export to next AS (well-known community)\n"
10236 "Do not send outside local AS (well-known community)\n"
10237 "Do not advertise to any peer (well-known community)\n"
10238 "Do not export to next AS (well-known community)\n")
10240 ALIAS (show_bgp_community
,
10241 show_bgp_ipv6_community3_cmd
,
10242 "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)",
10246 "Display routes matching the communities\n"
10248 "Do not send outside local AS (well-known community)\n"
10249 "Do not advertise to any peer (well-known community)\n"
10250 "Do not export to next AS (well-known community)\n"
10252 "Do not send outside local AS (well-known community)\n"
10253 "Do not advertise to any peer (well-known community)\n"
10254 "Do not export to next AS (well-known community)\n"
10256 "Do not send outside local AS (well-known community)\n"
10257 "Do not advertise to any peer (well-known community)\n"
10258 "Do not export to next AS (well-known community)\n")
10260 ALIAS (show_bgp_community
,
10261 show_bgp_community4_cmd
,
10262 "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)",
10265 "Display routes matching the communities\n"
10267 "Do not send outside local AS (well-known community)\n"
10268 "Do not advertise to any peer (well-known community)\n"
10269 "Do not export to next AS (well-known community)\n"
10271 "Do not send outside local AS (well-known community)\n"
10272 "Do not advertise to any peer (well-known community)\n"
10273 "Do not export to next AS (well-known community)\n"
10275 "Do not send outside local AS (well-known community)\n"
10276 "Do not advertise to any peer (well-known community)\n"
10277 "Do not export to next AS (well-known community)\n"
10279 "Do not send outside local AS (well-known community)\n"
10280 "Do not advertise to any peer (well-known community)\n"
10281 "Do not export to next AS (well-known community)\n")
10283 ALIAS (show_bgp_community
,
10284 show_bgp_ipv6_community4_cmd
,
10285 "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)",
10289 "Display routes matching the communities\n"
10291 "Do not send outside local AS (well-known community)\n"
10292 "Do not advertise to any peer (well-known community)\n"
10293 "Do not export to next AS (well-known community)\n"
10295 "Do not send outside local AS (well-known community)\n"
10296 "Do not advertise to any peer (well-known community)\n"
10297 "Do not export to next AS (well-known community)\n"
10299 "Do not send outside local AS (well-known community)\n"
10300 "Do not advertise to any peer (well-known community)\n"
10301 "Do not export to next AS (well-known community)\n"
10303 "Do not send outside local AS (well-known community)\n"
10304 "Do not advertise to any peer (well-known community)\n"
10305 "Do not export to next AS (well-known community)\n")
10308 DEFUN (show_ipv6_bgp_community
,
10309 show_ipv6_bgp_community_cmd
,
10310 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10314 "Display routes matching the communities\n"
10316 "Do not send outside local AS (well-known community)\n"
10317 "Do not advertise to any peer (well-known community)\n"
10318 "Do not export to next AS (well-known community)\n")
10320 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10321 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10325 ALIAS (show_ipv6_bgp_community
,
10326 show_ipv6_bgp_community2_cmd
,
10327 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10331 "Display routes matching the communities\n"
10333 "Do not send outside local AS (well-known community)\n"
10334 "Do not advertise to any peer (well-known community)\n"
10335 "Do not export to next AS (well-known community)\n"
10337 "Do not send outside local AS (well-known community)\n"
10338 "Do not advertise to any peer (well-known community)\n"
10339 "Do not export to next AS (well-known community)\n")
10342 ALIAS (show_ipv6_bgp_community
,
10343 show_ipv6_bgp_community3_cmd
,
10344 "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)",
10348 "Display routes matching the communities\n"
10350 "Do not send outside local AS (well-known community)\n"
10351 "Do not advertise to any peer (well-known community)\n"
10352 "Do not export to next AS (well-known community)\n"
10354 "Do not send outside local AS (well-known community)\n"
10355 "Do not advertise to any peer (well-known community)\n"
10356 "Do not export to next AS (well-known community)\n"
10358 "Do not send outside local AS (well-known community)\n"
10359 "Do not advertise to any peer (well-known community)\n"
10360 "Do not export to next AS (well-known community)\n")
10363 ALIAS (show_ipv6_bgp_community
,
10364 show_ipv6_bgp_community4_cmd
,
10365 "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)",
10369 "Display routes matching the communities\n"
10371 "Do not send outside local AS (well-known community)\n"
10372 "Do not advertise to any peer (well-known community)\n"
10373 "Do not export to next AS (well-known community)\n"
10375 "Do not send outside local AS (well-known community)\n"
10376 "Do not advertise to any peer (well-known community)\n"
10377 "Do not export to next AS (well-known community)\n"
10379 "Do not send outside local AS (well-known community)\n"
10380 "Do not advertise to any peer (well-known community)\n"
10381 "Do not export to next AS (well-known community)\n"
10383 "Do not send outside local AS (well-known community)\n"
10384 "Do not advertise to any peer (well-known community)\n"
10385 "Do not export to next AS (well-known community)\n")
10387 DEFUN (show_bgp_community_exact
,
10388 show_bgp_community_exact_cmd
,
10389 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10392 "Display routes matching the communities\n"
10394 "Do not send outside local AS (well-known community)\n"
10395 "Do not advertise to any peer (well-known community)\n"
10396 "Do not export to next AS (well-known community)\n"
10397 "Exact match of the communities")
10399 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10402 ALIAS (show_bgp_community_exact
,
10403 show_bgp_ipv6_community_exact_cmd
,
10404 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10408 "Display routes matching the communities\n"
10410 "Do not send outside local AS (well-known community)\n"
10411 "Do not advertise to any peer (well-known community)\n"
10412 "Do not export to next AS (well-known community)\n"
10413 "Exact match of the communities")
10415 ALIAS (show_bgp_community_exact
,
10416 show_bgp_community2_exact_cmd
,
10417 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10420 "Display routes matching the communities\n"
10422 "Do not send outside local AS (well-known community)\n"
10423 "Do not advertise to any peer (well-known community)\n"
10424 "Do not export to next AS (well-known community)\n"
10426 "Do not send outside local AS (well-known community)\n"
10427 "Do not advertise to any peer (well-known community)\n"
10428 "Do not export to next AS (well-known community)\n"
10429 "Exact match of the communities")
10431 ALIAS (show_bgp_community_exact
,
10432 show_bgp_ipv6_community2_exact_cmd
,
10433 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10437 "Display routes matching the communities\n"
10439 "Do not send outside local AS (well-known community)\n"
10440 "Do not advertise to any peer (well-known community)\n"
10441 "Do not export to next AS (well-known community)\n"
10443 "Do not send outside local AS (well-known community)\n"
10444 "Do not advertise to any peer (well-known community)\n"
10445 "Do not export to next AS (well-known community)\n"
10446 "Exact match of the communities")
10448 ALIAS (show_bgp_community_exact
,
10449 show_bgp_community3_exact_cmd
,
10450 "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",
10453 "Display routes matching the communities\n"
10455 "Do not send outside local AS (well-known community)\n"
10456 "Do not advertise to any peer (well-known community)\n"
10457 "Do not export to next AS (well-known community)\n"
10459 "Do not send outside local AS (well-known community)\n"
10460 "Do not advertise to any peer (well-known community)\n"
10461 "Do not export to next AS (well-known community)\n"
10463 "Do not send outside local AS (well-known community)\n"
10464 "Do not advertise to any peer (well-known community)\n"
10465 "Do not export to next AS (well-known community)\n"
10466 "Exact match of the communities")
10468 ALIAS (show_bgp_community_exact
,
10469 show_bgp_ipv6_community3_exact_cmd
,
10470 "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",
10474 "Display routes matching the communities\n"
10476 "Do not send outside local AS (well-known community)\n"
10477 "Do not advertise to any peer (well-known community)\n"
10478 "Do not export to next AS (well-known community)\n"
10480 "Do not send outside local AS (well-known community)\n"
10481 "Do not advertise to any peer (well-known community)\n"
10482 "Do not export to next AS (well-known community)\n"
10484 "Do not send outside local AS (well-known community)\n"
10485 "Do not advertise to any peer (well-known community)\n"
10486 "Do not export to next AS (well-known community)\n"
10487 "Exact match of the communities")
10489 ALIAS (show_bgp_community_exact
,
10490 show_bgp_community4_exact_cmd
,
10491 "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",
10494 "Display routes matching the communities\n"
10496 "Do not send outside local AS (well-known community)\n"
10497 "Do not advertise to any peer (well-known community)\n"
10498 "Do not export to next AS (well-known community)\n"
10500 "Do not send outside local AS (well-known community)\n"
10501 "Do not advertise to any peer (well-known community)\n"
10502 "Do not export to next AS (well-known community)\n"
10504 "Do not send outside local AS (well-known community)\n"
10505 "Do not advertise to any peer (well-known community)\n"
10506 "Do not export to next AS (well-known community)\n"
10508 "Do not send outside local AS (well-known community)\n"
10509 "Do not advertise to any peer (well-known community)\n"
10510 "Do not export to next AS (well-known community)\n"
10511 "Exact match of the communities")
10513 ALIAS (show_bgp_community_exact
,
10514 show_bgp_ipv6_community4_exact_cmd
,
10515 "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",
10519 "Display routes matching the communities\n"
10521 "Do not send outside local AS (well-known community)\n"
10522 "Do not advertise to any peer (well-known community)\n"
10523 "Do not export to next AS (well-known community)\n"
10525 "Do not send outside local AS (well-known community)\n"
10526 "Do not advertise to any peer (well-known community)\n"
10527 "Do not export to next AS (well-known community)\n"
10529 "Do not send outside local AS (well-known community)\n"
10530 "Do not advertise to any peer (well-known community)\n"
10531 "Do not export to next AS (well-known community)\n"
10533 "Do not send outside local AS (well-known community)\n"
10534 "Do not advertise to any peer (well-known community)\n"
10535 "Do not export to next AS (well-known community)\n"
10536 "Exact match of the communities")
10539 DEFUN (show_ipv6_bgp_community_exact
,
10540 show_ipv6_bgp_community_exact_cmd
,
10541 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10545 "Display routes matching the communities\n"
10547 "Do not send outside local AS (well-known community)\n"
10548 "Do not advertise to any peer (well-known community)\n"
10549 "Do not export to next AS (well-known community)\n"
10550 "Exact match of the communities")
10552 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10553 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10557 ALIAS (show_ipv6_bgp_community_exact
,
10558 show_ipv6_bgp_community2_exact_cmd
,
10559 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10563 "Display routes matching the communities\n"
10565 "Do not send outside local AS (well-known community)\n"
10566 "Do not advertise to any peer (well-known community)\n"
10567 "Do not export to next AS (well-known community)\n"
10569 "Do not send outside local AS (well-known community)\n"
10570 "Do not advertise to any peer (well-known community)\n"
10571 "Do not export to next AS (well-known community)\n"
10572 "Exact match of the communities")
10575 ALIAS (show_ipv6_bgp_community_exact
,
10576 show_ipv6_bgp_community3_exact_cmd
,
10577 "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",
10581 "Display routes matching the communities\n"
10583 "Do not send outside local AS (well-known community)\n"
10584 "Do not advertise to any peer (well-known community)\n"
10585 "Do not export to next AS (well-known community)\n"
10587 "Do not send outside local AS (well-known community)\n"
10588 "Do not advertise to any peer (well-known community)\n"
10589 "Do not export to next AS (well-known community)\n"
10591 "Do not send outside local AS (well-known community)\n"
10592 "Do not advertise to any peer (well-known community)\n"
10593 "Do not export to next AS (well-known community)\n"
10594 "Exact match of the communities")
10597 ALIAS (show_ipv6_bgp_community_exact
,
10598 show_ipv6_bgp_community4_exact_cmd
,
10599 "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",
10603 "Display routes matching the communities\n"
10605 "Do not send outside local AS (well-known community)\n"
10606 "Do not advertise to any peer (well-known community)\n"
10607 "Do not export to next AS (well-known community)\n"
10609 "Do not send outside local AS (well-known community)\n"
10610 "Do not advertise to any peer (well-known community)\n"
10611 "Do not export to next AS (well-known community)\n"
10613 "Do not send outside local AS (well-known community)\n"
10614 "Do not advertise to any peer (well-known community)\n"
10615 "Do not export to next AS (well-known community)\n"
10617 "Do not send outside local AS (well-known community)\n"
10618 "Do not advertise to any peer (well-known community)\n"
10619 "Do not export to next AS (well-known community)\n"
10620 "Exact match of the communities")
10623 DEFUN (show_ipv6_mbgp_community
,
10624 show_ipv6_mbgp_community_cmd
,
10625 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10629 "Display routes matching the communities\n"
10631 "Do not send outside local AS (well-known community)\n"
10632 "Do not advertise to any peer (well-known community)\n"
10633 "Do not export to next AS (well-known community)\n")
10635 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10636 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10640 ALIAS (show_ipv6_mbgp_community
,
10641 show_ipv6_mbgp_community2_cmd
,
10642 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10646 "Display routes matching the communities\n"
10648 "Do not send outside local AS (well-known community)\n"
10649 "Do not advertise to any peer (well-known community)\n"
10650 "Do not export to next AS (well-known community)\n"
10652 "Do not send outside local AS (well-known community)\n"
10653 "Do not advertise to any peer (well-known community)\n"
10654 "Do not export to next AS (well-known community)\n")
10657 ALIAS (show_ipv6_mbgp_community
,
10658 show_ipv6_mbgp_community3_cmd
,
10659 "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)",
10663 "Display routes matching the communities\n"
10665 "Do not send outside local AS (well-known community)\n"
10666 "Do not advertise to any peer (well-known community)\n"
10667 "Do not export to next AS (well-known community)\n"
10669 "Do not send outside local AS (well-known community)\n"
10670 "Do not advertise to any peer (well-known community)\n"
10671 "Do not export to next AS (well-known community)\n"
10673 "Do not send outside local AS (well-known community)\n"
10674 "Do not advertise to any peer (well-known community)\n"
10675 "Do not export to next AS (well-known community)\n")
10678 ALIAS (show_ipv6_mbgp_community
,
10679 show_ipv6_mbgp_community4_cmd
,
10680 "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)",
10684 "Display routes matching the communities\n"
10686 "Do not send outside local AS (well-known community)\n"
10687 "Do not advertise to any peer (well-known community)\n"
10688 "Do not export to next AS (well-known community)\n"
10690 "Do not send outside local AS (well-known community)\n"
10691 "Do not advertise to any peer (well-known community)\n"
10692 "Do not export to next AS (well-known community)\n"
10694 "Do not send outside local AS (well-known community)\n"
10695 "Do not advertise to any peer (well-known community)\n"
10696 "Do not export to next AS (well-known community)\n"
10698 "Do not send outside local AS (well-known community)\n"
10699 "Do not advertise to any peer (well-known community)\n"
10700 "Do not export to next AS (well-known community)\n")
10703 DEFUN (show_ipv6_mbgp_community_exact
,
10704 show_ipv6_mbgp_community_exact_cmd
,
10705 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10709 "Display routes matching the communities\n"
10711 "Do not send outside local AS (well-known community)\n"
10712 "Do not advertise to any peer (well-known community)\n"
10713 "Do not export to next AS (well-known community)\n"
10714 "Exact match of the communities")
10716 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10717 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
10721 ALIAS (show_ipv6_mbgp_community_exact
,
10722 show_ipv6_mbgp_community2_exact_cmd
,
10723 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10727 "Display routes matching the communities\n"
10729 "Do not send outside local AS (well-known community)\n"
10730 "Do not advertise to any peer (well-known community)\n"
10731 "Do not export to next AS (well-known community)\n"
10733 "Do not send outside local AS (well-known community)\n"
10734 "Do not advertise to any peer (well-known community)\n"
10735 "Do not export to next AS (well-known community)\n"
10736 "Exact match of the communities")
10739 ALIAS (show_ipv6_mbgp_community_exact
,
10740 show_ipv6_mbgp_community3_exact_cmd
,
10741 "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",
10745 "Display routes matching the communities\n"
10747 "Do not send outside local AS (well-known community)\n"
10748 "Do not advertise to any peer (well-known community)\n"
10749 "Do not export to next AS (well-known community)\n"
10751 "Do not send outside local AS (well-known community)\n"
10752 "Do not advertise to any peer (well-known community)\n"
10753 "Do not export to next AS (well-known community)\n"
10755 "Do not send outside local AS (well-known community)\n"
10756 "Do not advertise to any peer (well-known community)\n"
10757 "Do not export to next AS (well-known community)\n"
10758 "Exact match of the communities")
10761 ALIAS (show_ipv6_mbgp_community_exact
,
10762 show_ipv6_mbgp_community4_exact_cmd
,
10763 "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",
10767 "Display routes matching the communities\n"
10769 "Do not send outside local AS (well-known community)\n"
10770 "Do not advertise to any peer (well-known community)\n"
10771 "Do not export to next AS (well-known community)\n"
10773 "Do not send outside local AS (well-known community)\n"
10774 "Do not advertise to any peer (well-known community)\n"
10775 "Do not export to next AS (well-known community)\n"
10777 "Do not send outside local AS (well-known community)\n"
10778 "Do not advertise to any peer (well-known community)\n"
10779 "Do not export to next AS (well-known community)\n"
10781 "Do not send outside local AS (well-known community)\n"
10782 "Do not advertise to any peer (well-known community)\n"
10783 "Do not export to next AS (well-known community)\n"
10784 "Exact match of the communities")
10785 #endif /* HAVE_IPV6 */
10788 bgp_show_community_list (struct vty
*vty
, const char *name
,
10789 const char *com
, int exact
,
10790 afi_t afi
, safi_t safi
)
10792 struct community_list
*list
;
10793 struct bgp
*bgp
= NULL
;
10795 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
10797 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
10798 return CMD_WARNING
;
10801 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
10804 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
10806 return CMD_WARNING
;
10809 return bgp_show (vty
, bgp
, afi
, safi
,
10810 (exact
? bgp_show_type_community_list_exact
:
10811 bgp_show_type_community_list
), list
, 0);
10814 DEFUN (show_ip_bgp_community_list
,
10815 show_ip_bgp_community_list_cmd
,
10816 "show ip bgp community-list (<1-500>|WORD)",
10820 "Display routes matching the community-list\n"
10821 "community-list number\n"
10822 "community-list name\n")
10824 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
10827 DEFUN (show_ip_bgp_instance_community_list
,
10828 show_ip_bgp_instance_community_list_cmd
,
10829 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
10833 BGP_INSTANCE_HELP_STR
10834 "Display routes matching the community-list\n"
10835 "community-list number\n"
10836 "community-list name\n")
10838 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
10841 DEFUN (show_ip_bgp_ipv4_community_list
,
10842 show_ip_bgp_ipv4_community_list_cmd
,
10843 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10848 "Address Family modifier\n"
10849 "Address Family modifier\n"
10850 "Display routes matching the community-list\n"
10851 "community-list number\n"
10852 "community-list name\n")
10854 if (strncmp (argv
[0], "m", 1) == 0)
10855 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
10857 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
10860 DEFUN (show_ip_bgp_community_list_exact
,
10861 show_ip_bgp_community_list_exact_cmd
,
10862 "show ip bgp community-list (<1-500>|WORD) exact-match",
10866 "Display routes matching the community-list\n"
10867 "community-list number\n"
10868 "community-list name\n"
10869 "Exact match of the communities\n")
10871 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
10874 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
10875 show_ip_bgp_ipv4_community_list_exact_cmd
,
10876 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10881 "Address Family modifier\n"
10882 "Address Family modifier\n"
10883 "Display routes matching the community-list\n"
10884 "community-list number\n"
10885 "community-list name\n"
10886 "Exact match of the communities\n")
10888 if (strncmp (argv
[0], "m", 1) == 0)
10889 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
10891 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
10895 DEFUN (show_bgp_community_list
,
10896 show_bgp_community_list_cmd
,
10897 "show bgp community-list (<1-500>|WORD)",
10900 "Display routes matching the community-list\n"
10901 "community-list number\n"
10902 "community-list name\n")
10904 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10907 ALIAS (show_bgp_community_list
,
10908 show_bgp_ipv6_community_list_cmd
,
10909 "show bgp ipv6 community-list (<1-500>|WORD)",
10913 "Display routes matching the community-list\n"
10914 "community-list number\n"
10915 "community-list name\n")
10918 DEFUN (show_ipv6_bgp_community_list
,
10919 show_ipv6_bgp_community_list_cmd
,
10920 "show ipv6 bgp community-list WORD",
10924 "Display routes matching the community-list\n"
10925 "community-list name\n")
10927 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10928 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10932 DEFUN (show_ipv6_mbgp_community_list
,
10933 show_ipv6_mbgp_community_list_cmd
,
10934 "show ipv6 mbgp community-list WORD",
10938 "Display routes matching the community-list\n"
10939 "community-list name\n")
10941 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10942 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
10945 DEFUN (show_bgp_community_list_exact
,
10946 show_bgp_community_list_exact_cmd
,
10947 "show bgp community-list (<1-500>|WORD) exact-match",
10950 "Display routes matching the community-list\n"
10951 "community-list number\n"
10952 "community-list name\n"
10953 "Exact match of the communities\n")
10955 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10958 ALIAS (show_bgp_community_list_exact
,
10959 show_bgp_ipv6_community_list_exact_cmd
,
10960 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10964 "Display routes matching the community-list\n"
10965 "community-list number\n"
10966 "community-list name\n"
10967 "Exact match of the communities\n")
10970 DEFUN (show_ipv6_bgp_community_list_exact
,
10971 show_ipv6_bgp_community_list_exact_cmd
,
10972 "show ipv6 bgp community-list WORD exact-match",
10976 "Display routes matching the community-list\n"
10977 "community-list name\n"
10978 "Exact match of the communities\n")
10980 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10981 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10985 DEFUN (show_ipv6_mbgp_community_list_exact
,
10986 show_ipv6_mbgp_community_list_exact_cmd
,
10987 "show ipv6 mbgp community-list WORD exact-match",
10991 "Display routes matching the community-list\n"
10992 "community-list name\n"
10993 "Exact match of the communities\n")
10995 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10996 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
10998 #endif /* HAVE_IPV6 */
11001 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11002 const char *prefix
, afi_t afi
,
11003 safi_t safi
, enum bgp_show_type type
)
11007 struct bgp
*bgp
= NULL
;
11009 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11011 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11012 return CMD_WARNING
;
11017 ret
= str2prefix (prefix
, p
);
11020 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11021 return CMD_WARNING
;
11024 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11029 DEFUN (show_ip_bgp_prefix_longer
,
11030 show_ip_bgp_prefix_longer_cmd
,
11031 "show ip bgp A.B.C.D/M longer-prefixes",
11035 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11036 "Display route and more specific routes\n")
11038 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11039 bgp_show_type_prefix_longer
);
11042 DEFUN (show_ip_bgp_instance_prefix_longer
,
11043 show_ip_bgp_instance_prefix_longer_cmd
,
11044 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11048 BGP_INSTANCE_HELP_STR
11049 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11050 "Display route and more specific routes\n")
11052 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
11053 bgp_show_type_prefix_longer
);
11056 DEFUN (show_ip_bgp_flap_prefix_longer
,
11057 show_ip_bgp_flap_prefix_longer_cmd
,
11058 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11062 "Display flap statistics of routes\n"
11063 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11064 "Display route and more specific routes\n")
11066 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11067 bgp_show_type_flap_prefix_longer
);
11070 ALIAS (show_ip_bgp_flap_prefix_longer
,
11071 show_ip_bgp_damp_flap_prefix_longer_cmd
,
11072 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11076 "Display detailed information about dampening\n"
11077 "Display flap statistics of routes\n"
11078 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11079 "Display route and more specific routes\n")
11081 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11082 show_ip_bgp_ipv4_prefix_longer_cmd
,
11083 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11088 "Address Family modifier\n"
11089 "Address Family modifier\n"
11090 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11091 "Display route and more specific routes\n")
11093 if (strncmp (argv
[0], "m", 1) == 0)
11094 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
11095 bgp_show_type_prefix_longer
);
11097 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
11098 bgp_show_type_prefix_longer
);
11101 DEFUN (show_ip_bgp_flap_address
,
11102 show_ip_bgp_flap_address_cmd
,
11103 "show ip bgp flap-statistics A.B.C.D",
11107 "Display flap statistics of routes\n"
11108 "Network in the BGP routing table to display\n")
11110 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11111 bgp_show_type_flap_address
);
11114 ALIAS (show_ip_bgp_flap_address
,
11115 show_ip_bgp_damp_flap_address_cmd
,
11116 "show ip bgp dampening flap-statistics A.B.C.D",
11120 "Display detailed information about dampening\n"
11121 "Display flap statistics of routes\n"
11122 "Network in the BGP routing table to display\n")
11124 DEFUN (show_ip_bgp_flap_prefix
,
11125 show_ip_bgp_flap_prefix_cmd
,
11126 "show ip bgp flap-statistics A.B.C.D/M",
11130 "Display flap statistics of routes\n"
11131 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11133 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11134 bgp_show_type_flap_prefix
);
11137 ALIAS (show_ip_bgp_flap_prefix
,
11138 show_ip_bgp_damp_flap_prefix_cmd
,
11139 "show ip bgp dampening flap-statistics A.B.C.D/M",
11143 "Display detailed information about dampening\n"
11144 "Display flap statistics of routes\n"
11145 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11148 DEFUN (show_bgp_prefix_longer
,
11149 show_bgp_prefix_longer_cmd
,
11150 "show bgp X:X::X:X/M longer-prefixes",
11153 "IPv6 prefix <network>/<length>\n"
11154 "Display route and more specific routes\n")
11156 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11157 bgp_show_type_prefix_longer
);
11160 ALIAS (show_bgp_prefix_longer
,
11161 show_bgp_ipv6_prefix_longer_cmd
,
11162 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11166 "IPv6 prefix <network>/<length>\n"
11167 "Display route and more specific routes\n")
11170 DEFUN (show_ipv6_bgp_prefix_longer
,
11171 show_ipv6_bgp_prefix_longer_cmd
,
11172 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11176 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11177 "Display route and more specific routes\n")
11179 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11180 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11181 bgp_show_type_prefix_longer
);
11185 DEFUN (show_ipv6_mbgp_prefix_longer
,
11186 show_ipv6_mbgp_prefix_longer_cmd
,
11187 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11191 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11192 "Display route and more specific routes\n")
11194 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11195 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11196 bgp_show_type_prefix_longer
);
11198 #endif /* HAVE_IPV6 */
11200 static struct peer
*
11201 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11202 const char *ip_str
, u_char use_json
)
11207 union sockunion su
;
11209 /* BGP structure lookup. */
11212 bgp
= bgp_lookup_by_name (view_name
);
11217 json_object
*json_no
= NULL
;
11218 json_no
= json_object_new_object();
11219 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11220 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11221 json_object_free(json_no
);
11224 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11230 bgp
= bgp_get_default ();
11235 json_object
*json_no
= NULL
;
11236 json_no
= json_object_new_object();
11237 json_object_string_add(json_no
, "warning", "No BGP process configured");
11238 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11239 json_object_free(json_no
);
11242 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11247 /* Get peer sockunion. */
11248 ret
= str2sockunion (ip_str
, &su
);
11251 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11254 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11260 json_object
*json_no
= NULL
;
11261 json_no
= json_object_new_object();
11262 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11263 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11264 json_object_free(json_no
);
11267 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11274 /* Peer structure lookup. */
11275 peer
= peer_lookup (bgp
, &su
);
11280 json_object
*json_no
= NULL
;
11281 json_no
= json_object_new_object();
11282 json_object_string_add(json_no
, "warning","No such neighbor");
11283 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11284 json_object_free(json_no
);
11287 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11296 BGP_STATS_MAXBITLEN
= 0,
11298 BGP_STATS_PREFIXES
,
11300 BGP_STATS_UNAGGREGATEABLE
,
11301 BGP_STATS_MAX_AGGREGATEABLE
,
11302 BGP_STATS_AGGREGATES
,
11304 BGP_STATS_ASPATH_COUNT
,
11305 BGP_STATS_ASPATH_MAXHOPS
,
11306 BGP_STATS_ASPATH_TOTHOPS
,
11307 BGP_STATS_ASPATH_MAXSIZE
,
11308 BGP_STATS_ASPATH_TOTSIZE
,
11309 BGP_STATS_ASN_HIGHEST
,
11313 static const char *table_stats_strs
[] =
11315 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11316 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11317 [BGP_STATS_RIB
] = "Total Advertisements",
11318 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11319 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11320 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11321 [BGP_STATS_SPACE
] = "Address space advertised",
11322 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11323 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11324 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11325 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11326 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11327 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11328 [BGP_STATS_MAX
] = NULL
,
11331 struct bgp_table_stats
11333 struct bgp_table
*table
;
11334 unsigned long long counts
[BGP_STATS_MAX
];
11338 #define TALLY_SIGFIG 100000
11339 static unsigned long
11340 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11342 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11343 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11344 unsigned long ret
= newtot
/ count
;
11346 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11354 bgp_table_stats_walker (struct thread
*t
)
11356 struct bgp_node
*rn
;
11357 struct bgp_node
*top
;
11358 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11359 unsigned int space
= 0;
11361 if (!(top
= bgp_table_top (ts
->table
)))
11364 switch (top
->p
.family
)
11367 space
= IPV4_MAX_BITLEN
;
11370 space
= IPV6_MAX_BITLEN
;
11374 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11376 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11378 struct bgp_info
*ri
;
11379 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11380 unsigned int rinum
= 0;
11388 ts
->counts
[BGP_STATS_PREFIXES
]++;
11389 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11392 ts
->counts
[BGP_STATS_AVGPLEN
]
11393 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11394 ts
->counts
[BGP_STATS_AVGPLEN
],
11398 /* check if the prefix is included by any other announcements */
11399 while (prn
&& !prn
->info
)
11400 prn
= bgp_node_parent_nolock (prn
);
11402 if (prn
== NULL
|| prn
== top
)
11404 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11405 /* announced address space */
11407 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11409 else if (prn
->info
)
11410 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11412 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11415 ts
->counts
[BGP_STATS_RIB
]++;
11418 (CHECK_FLAG (ri
->attr
->flag
,
11419 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11420 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11422 /* as-path stats */
11423 if (ri
->attr
&& ri
->attr
->aspath
)
11425 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11426 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11427 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11429 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11431 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11432 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11434 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11435 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11437 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11438 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11440 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11441 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11442 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11444 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11445 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11446 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11449 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11450 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11458 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11460 struct bgp_table_stats ts
;
11463 if (!bgp
->rib
[afi
][safi
])
11465 vty_out (vty
, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s",
11466 afi
, safi
, VTY_NEWLINE
);
11467 return CMD_WARNING
;
11470 memset (&ts
, 0, sizeof (ts
));
11471 ts
.table
= bgp
->rib
[afi
][safi
];
11472 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11474 vty_out (vty
, "BGP %s RIB statistics%s%s",
11475 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11477 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11479 if (!table_stats_strs
[i
])
11485 case BGP_STATS_ASPATH_AVGHOPS
:
11486 case BGP_STATS_ASPATH_AVGSIZE
:
11487 case BGP_STATS_AVGPLEN
:
11488 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11489 vty_out (vty
, "%12.2f",
11490 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11493 case BGP_STATS_ASPATH_TOTHOPS
:
11494 case BGP_STATS_ASPATH_TOTSIZE
:
11495 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11496 vty_out (vty
, "%12.2f",
11498 (float)ts
.counts
[i
] /
11499 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11502 case BGP_STATS_TOTPLEN
:
11503 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11504 vty_out (vty
, "%12.2f",
11506 (float)ts
.counts
[i
] /
11507 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11510 case BGP_STATS_SPACE
:
11511 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11512 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11513 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11515 vty_out (vty
, "%30s: ", "%% announced ");
11516 vty_out (vty
, "%12.2f%s",
11517 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11518 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11520 vty_out (vty
, "%30s: ", "/8 equivalent ");
11521 vty_out (vty
, "%12.2f%s",
11522 (float)ts
.counts
[BGP_STATS_SPACE
] /
11523 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11525 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11527 vty_out (vty
, "%30s: ", "/24 equivalent ");
11528 vty_out (vty
, "%12.2f",
11529 (float)ts
.counts
[BGP_STATS_SPACE
] /
11530 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11533 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11534 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11537 vty_out (vty
, "%s", VTY_NEWLINE
);
11539 return CMD_SUCCESS
;
11543 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11544 const char *afi_str
, const char *safi_str
)
11551 bgp
= bgp_lookup_by_name (name
);
11553 bgp
= bgp_get_default ();
11557 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
11558 return CMD_WARNING
;
11560 if (strncmp (afi_str
, "ipv", 3) == 0)
11562 if (strncmp (afi_str
, "ipv4", 4) == 0)
11564 else if (strncmp (afi_str
, "ipv6", 4) == 0)
11568 vty_out (vty
, "%% Invalid address family %s%s",
11569 afi_str
, VTY_NEWLINE
);
11570 return CMD_WARNING
;
11572 if (strncmp (safi_str
, "m", 1) == 0)
11573 safi
= SAFI_MULTICAST
;
11574 else if (strncmp (safi_str
, "u", 1) == 0)
11575 safi
= SAFI_UNICAST
;
11576 else if (strncmp (safi_str
, "e", 1) == 0)
11578 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
11579 safi
= SAFI_MPLS_VPN
;
11582 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11583 safi_str
, VTY_NEWLINE
);
11584 return CMD_WARNING
;
11589 vty_out (vty
, "%% Invalid address family \"%s\"%s",
11590 afi_str
, VTY_NEWLINE
);
11591 return CMD_WARNING
;
11594 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11597 DEFUN (show_bgp_statistics
,
11598 show_bgp_statistics_cmd
,
11599 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
11604 "Address Family modifier\n"
11605 "Address Family modifier\n"
11606 "Address Family modifier\n"
11607 "Address Family modifier\n"
11608 "BGP RIB advertisement statistics\n")
11610 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11613 DEFUN (show_bgp_statistics_view
,
11614 show_bgp_statistics_view_cmd
,
11615 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics",
11618 BGP_INSTANCE_HELP_STR
11621 "Address Family modifier\n"
11622 "Address Family modifier\n"
11623 "Address Family modifier\n"
11624 "Address Family modifier\n"
11625 "BGP RIB advertisement statistics\n")
11627 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11640 PCOUNT_PFCNT
, /* the figure we display to users */
11644 static const char *pcount_strs
[] =
11646 [PCOUNT_ADJ_IN
] = "Adj-in",
11647 [PCOUNT_DAMPED
] = "Damped",
11648 [PCOUNT_REMOVED
] = "Removed",
11649 [PCOUNT_HISTORY
] = "History",
11650 [PCOUNT_STALE
] = "Stale",
11651 [PCOUNT_VALID
] = "Valid",
11652 [PCOUNT_ALL
] = "All RIB",
11653 [PCOUNT_COUNTED
] = "PfxCt counted",
11654 [PCOUNT_PFCNT
] = "Useable",
11655 [PCOUNT_MAX
] = NULL
,
11658 struct peer_pcounts
11660 unsigned int count
[PCOUNT_MAX
];
11661 const struct peer
*peer
;
11662 const struct bgp_table
*table
;
11666 bgp_peer_count_walker (struct thread
*t
)
11668 struct bgp_node
*rn
;
11669 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11670 const struct peer
*peer
= pc
->peer
;
11672 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11674 struct bgp_adj_in
*ain
;
11675 struct bgp_info
*ri
;
11677 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11678 if (ain
->peer
== peer
)
11679 pc
->count
[PCOUNT_ADJ_IN
]++;
11681 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11683 char buf
[SU_ADDRSTRLEN
];
11685 if (ri
->peer
!= peer
)
11688 pc
->count
[PCOUNT_ALL
]++;
11690 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11691 pc
->count
[PCOUNT_DAMPED
]++;
11692 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11693 pc
->count
[PCOUNT_HISTORY
]++;
11694 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
11695 pc
->count
[PCOUNT_REMOVED
]++;
11696 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
11697 pc
->count
[PCOUNT_STALE
]++;
11698 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
11699 pc
->count
[PCOUNT_VALID
]++;
11700 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11701 pc
->count
[PCOUNT_PFCNT
]++;
11703 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
11705 pc
->count
[PCOUNT_COUNTED
]++;
11706 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11707 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
11709 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11710 buf
, SU_ADDRSTRLEN
),
11716 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11717 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
11719 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11720 buf
, SU_ADDRSTRLEN
),
11730 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
11732 struct peer_pcounts pcounts
= { .peer
= peer
};
11734 json_object
*json
= NULL
;
11735 json_object
*json_loop
= NULL
;
11739 json
= json_object_new_object();
11740 json_loop
= json_object_new_object();
11743 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
11744 || !peer
->bgp
->rib
[afi
][safi
])
11748 json_object_string_add(json
, "warning", "No such neighbor or address family");
11749 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11750 json_object_free(json
);
11753 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11755 return CMD_WARNING
;
11758 memset (&pcounts
, 0, sizeof(pcounts
));
11759 pcounts
.peer
= peer
;
11760 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
11762 /* in-place call via thread subsystem so as to record execution time
11763 * * stats for the thread-walk (i.e. ensure this can't be blamed on
11764 * * on just vty_read()).
11766 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
11770 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
11771 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
11772 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
11774 for (i
= 0; i
< PCOUNT_MAX
; i
++)
11775 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
11777 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
11779 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
11781 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
11782 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
11784 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11785 json_object_free(json
);
11790 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
11792 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
11793 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
11798 vty_out (vty
, "Prefix counts for %s, %s%s",
11799 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
11802 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
11803 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
11804 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
11806 for (i
= 0; i
< PCOUNT_MAX
; i
++)
11807 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
11809 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
11811 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
11812 peer
->host
, VTY_NEWLINE
);
11813 vty_out (vty
, "Please report this bug, with the above command output%s",
11818 return CMD_SUCCESS
;
11821 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
11822 show_ip_bgp_neighbor_prefix_counts_cmd
,
11823 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11827 "Detailed information on TCP and BGP neighbor connections\n"
11828 "Neighbor to display information about\n"
11829 "Neighbor to display information about\n"
11830 "Neighbor on bgp configured interface\n"
11831 "Display detailed prefix count information\n"
11832 "JavaScript Object Notation\n")
11835 u_char uj
= use_json(argc
, argv
);
11837 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11839 return CMD_WARNING
;
11841 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11844 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
11845 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
11846 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11850 BGP_INSTANCE_HELP_STR
11851 "Detailed information on TCP and BGP neighbor connections\n"
11852 "Neighbor to display information about\n"
11853 "Neighbor to display information about\n"
11854 "Neighbor on bgp configured interface\n"
11855 "Display detailed prefix count information\n"
11856 "JavaScript Object Notation\n")
11859 u_char uj
= use_json(argc
, argv
);
11861 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11863 return CMD_WARNING
;
11865 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11868 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
11869 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
11870 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11874 "Detailed information on TCP and BGP neighbor connections\n"
11875 "Neighbor to display information about\n"
11876 "Neighbor to display information about\n"
11877 "Neighbor on bgp configured interface\n"
11878 "Display detailed prefix count information\n"
11879 "JavaScript Object Notation\n")
11882 u_char uj
= use_json(argc
, argv
);
11884 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11886 return CMD_WARNING
;
11888 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11891 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
11892 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
11893 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11896 BGP_INSTANCE_HELP_STR
11898 "Detailed information on TCP and BGP neighbor connections\n"
11899 "Neighbor to display information about\n"
11900 "Neighbor to display information about\n"
11901 "Neighbor on bgp configured interface\n"
11902 "Display detailed prefix count information\n"
11903 "JavaScript Object Notation\n")
11906 u_char uj
= use_json(argc
, argv
);
11908 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11910 return CMD_WARNING
;
11912 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11915 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
11916 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
11917 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11922 "Address Family modifier\n"
11923 "Address Family modifier\n"
11924 "Detailed information on TCP and BGP neighbor connections\n"
11925 "Neighbor to display information about\n"
11926 "Neighbor to display information about\n"
11927 "Neighbor on bgp configured interface\n"
11928 "Display detailed prefix count information\n"
11929 "JavaScript Object Notation\n")
11932 u_char uj
= use_json(argc
, argv
);
11934 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11936 return CMD_WARNING
;
11938 if (strncmp (argv
[0], "m", 1) == 0)
11939 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, uj
);
11941 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11944 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
11945 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
11946 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11951 "Address Family modifier\n"
11952 "Address Family modifier\n"
11953 "Detailed information on TCP and BGP neighbor connections\n"
11954 "Neighbor to display information about\n"
11955 "Neighbor to display information about\n"
11956 "Neighbor on bgp configured interface\n"
11957 "Display detailed prefix count information\n"
11958 "JavaScript Object Notation\n")
11961 u_char uj
= use_json(argc
, argv
);
11963 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11965 return CMD_WARNING
;
11967 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
, uj
);
11971 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
11972 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
11974 struct bgp_table
*table
;
11975 struct bgp_adj_in
*ain
;
11976 struct bgp_adj_out
*adj
;
11977 unsigned long output_count
;
11978 unsigned long filtered_count
;
11979 struct bgp_node
*rn
;
11984 struct attr_extra extra
;
11986 struct update_subgroup
*subgrp
;
11987 json_object
*json_scode
= NULL
;
11988 json_object
*json_ocode
= NULL
;
11989 json_object
*json_ar
= NULL
;
11990 struct peer_af
*paf
;
11994 json_scode
= json_object_new_object();
11995 json_ocode
= json_object_new_object();
11996 json_ar
= json_object_new_object();
11998 json_object_string_add(json_scode
, "suppressed", "s");
11999 json_object_string_add(json_scode
, "damped", "d");
12000 json_object_string_add(json_scode
, "history", "h");
12001 json_object_string_add(json_scode
, "valid", "*");
12002 json_object_string_add(json_scode
, "best", ">");
12003 json_object_string_add(json_scode
, "multipath", "=");
12004 json_object_string_add(json_scode
, "internal", "i");
12005 json_object_string_add(json_scode
, "ribFailure", "r");
12006 json_object_string_add(json_scode
, "stale", "S");
12007 json_object_string_add(json_scode
, "removed", "R");
12009 json_object_string_add(json_ocode
, "igp", "i");
12010 json_object_string_add(json_ocode
, "egp", "e");
12011 json_object_string_add(json_ocode
, "incomplete", "?");
12020 json_object_string_add(json
, "alert", "no BGP");
12021 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12022 json_object_free(json
);
12025 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12029 table
= bgp
->rib
[afi
][safi
];
12031 output_count
= filtered_count
= 0;
12032 subgrp
= peer_subgroup(peer
, afi
, safi
);
12034 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12038 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12039 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12040 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12041 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12042 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12046 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12047 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12048 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12050 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12051 VTY_NEWLINE
, VTY_NEWLINE
);
12056 attr
.extra
= &extra
;
12057 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12061 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12063 if (ain
->peer
== peer
)
12069 json_object_int_add(json
, "bgpTableVersion", 0);
12070 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12071 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12072 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12076 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12077 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12078 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12085 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12090 bgp_attr_dup(&attr
, ain
->attr
);
12091 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12093 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12104 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12105 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12106 if (paf
->peer
== peer
)
12112 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12113 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12114 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12115 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12119 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12120 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12121 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12122 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12130 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12136 bgp_attr_dup(&attr
, adj
->attr
);
12137 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12138 if (ret
!= RMAP_DENY
)
12140 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12150 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12152 if (output_count
!= 0)
12155 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12157 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12158 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12162 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12163 json_object_free(json
);
12169 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12170 int in
, const char *rmap_name
, u_char use_json
)
12172 json_object
*json
= NULL
;
12175 json
= json_object_new_object();
12177 if (!peer
|| !peer
->afc
[afi
][safi
])
12181 json_object_string_add(json
, "warning", "No such neighbor or address family");
12182 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12183 json_object_free(json
);
12186 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12188 return CMD_WARNING
;
12191 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12195 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12196 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12197 json_object_free(json
);
12200 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12202 return CMD_WARNING
;
12205 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12207 return CMD_SUCCESS
;
12210 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12211 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12212 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12216 BGP_INSTANCE_HELP_STR
12217 "Detailed information on TCP and BGP neighbor connections\n"
12218 "Neighbor to display information about\n"
12219 "Neighbor to display information about\n"
12220 "Display the routes advertised to a BGP neighbor\n"
12221 "JavaScript Object Notation\n")
12224 u_char uj
= use_json(argc
, argv
);
12226 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12227 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12229 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12232 return CMD_WARNING
;
12234 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12237 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12238 show_ip_bgp_neighbor_advertised_route_cmd
,
12239 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12243 "Detailed information on TCP and BGP neighbor connections\n"
12244 "Neighbor to display information about\n"
12245 "Neighbor to display information about\n"
12246 "Neighbor on bgp configured interface\n"
12247 "Display the routes advertised to a BGP neighbor\n"
12248 "JavaScript Object Notation\n")
12252 const char *rmap_name
= NULL
;
12253 u_char uj
= use_json(argc
, argv
);
12255 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12258 return CMD_WARNING
;
12260 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12262 rmap_name
= argv
[1];
12264 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12267 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12268 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12269 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12273 "Detailed information on TCP and BGP neighbor connections\n"
12274 "Neighbor to display information about\n"
12275 "Neighbor to display information about\n"
12276 "Neighbor on bgp configured interface\n"
12277 "Display the routes advertised to a BGP neighbor\n"
12278 "JavaScript Object Notation\n")
12280 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12281 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12282 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12286 BGP_INSTANCE_HELP_STR
12287 "Detailed information on TCP and BGP neighbor connections\n"
12288 "Neighbor to display information about\n"
12289 "Neighbor to display information about\n"
12290 "Neighbor on bgp configured interface\n"
12291 "Display the routes advertised to a BGP neighbor\n"
12292 "JavaScript Object Notation\n")
12293 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12294 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12295 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12300 "Address Family modifier\n"
12301 "Address Family modifier\n"
12302 "Detailed information on TCP and BGP neighbor connections\n"
12303 "Neighbor to display information about\n"
12304 "Neighbor to display information about\n"
12305 "Neighbor on bgp configured interface\n"
12306 "Display the routes advertised to a BGP neighbor\n"
12307 "JavaScript Object Notation\n")
12310 const char *rmap_name
= NULL
;
12311 u_char uj
= use_json(argc
, argv
);
12313 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12315 return CMD_WARNING
;
12317 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12318 rmap_name
= argv
[2];
12320 if (strncmp (argv
[0], "m", 1) == 0)
12321 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0, rmap_name
, uj
);
12323 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12326 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12327 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12328 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12333 "Address Family modifier\n"
12334 "Address Family modifier\n"
12335 "Detailed information on TCP and BGP neighbor connections\n"
12336 "Neighbor to display information about\n"
12337 "Neighbor to display information about\n"
12338 "Neighbor on bgp configured interface\n"
12339 "Display the routes advertised to a BGP neighbor\n"
12340 "Route-map to control what is displayed\n"
12341 "JavaScript Object Notation\n")
12344 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12345 show_bgp_instance_neighbor_advertised_route_cmd
,
12346 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12349 BGP_INSTANCE_HELP_STR
12350 "Detailed information on TCP and BGP neighbor connections\n"
12351 "Neighbor to display information about\n"
12352 "Neighbor to display information about\n"
12353 "Neighbor on bgp configured interface\n"
12354 "Display the routes advertised to a BGP neighbor\n"
12355 "JavaScript Object Notation\n")
12358 u_char uj
= use_json(argc
, argv
);
12360 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12361 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12363 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12366 return CMD_WARNING
;
12368 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12371 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12372 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12373 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12376 BGP_INSTANCE_HELP_STR
12378 "Detailed information on TCP and BGP neighbor connections\n"
12379 "Neighbor to display information about\n"
12380 "Neighbor to display information about\n"
12381 "Neighbor on bgp configured interface\n"
12382 "Display the routes advertised to a BGP neighbor\n"
12383 "JavaScript Object Notation\n")
12385 DEFUN (show_bgp_neighbor_advertised_route
,
12386 show_bgp_neighbor_advertised_route_cmd
,
12387 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12390 "Detailed information on TCP and BGP neighbor connections\n"
12391 "Neighbor to display information about\n"
12392 "Neighbor to display information about\n"
12393 "Neighbor on bgp configured interface\n"
12394 "Display the routes advertised to a BGP neighbor\n"
12395 "JavaScript Object Notation\n")
12399 const char *rmap_name
= NULL
;
12400 u_char uj
= use_json(argc
, argv
);
12402 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12405 return CMD_WARNING
;
12407 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12408 rmap_name
= argv
[1];
12410 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12413 ALIAS (show_bgp_neighbor_advertised_route
,
12414 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12415 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12419 "Detailed information on TCP and BGP neighbor connections\n"
12420 "Neighbor to display information about\n"
12421 "Neighbor to display information about\n"
12422 "Neighbor on bgp configured interface\n"
12423 "Display the routes advertised to a BGP neighbor\n"
12424 "JavaScript Object Notation\n")
12427 ALIAS (show_bgp_neighbor_advertised_route
,
12428 ipv6_bgp_neighbor_advertised_route_cmd
,
12429 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-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 the routes advertised to a BGP neighbor\n"
12438 "JavaScript Object Notation\n")
12441 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12442 ipv6_mbgp_neighbor_advertised_route_cmd
,
12443 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-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 "Neighbor on bgp configured interface\n"
12452 "Display the routes advertised to a BGP neighbor\n"
12453 "JavaScript Object Notation\n")
12456 u_char uj
= use_json(argc
, argv
);
12458 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12460 return CMD_WARNING
;
12462 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12463 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12465 #endif /* HAVE_IPV6 */
12467 DEFUN (show_bgp_instance_neighbor_received_routes
,
12468 show_bgp_instance_neighbor_received_routes_cmd
,
12469 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12472 BGP_INSTANCE_HELP_STR
12473 "Detailed information on TCP and BGP neighbor connections\n"
12474 "Neighbor to display information about\n"
12475 "Neighbor to display information about\n"
12476 "Neighbor on bgp configured interface\n"
12477 "Display the received routes from neighbor\n"
12478 "JavaScript Object Notation\n")
12481 u_char uj
= use_json(argc
, argv
);
12483 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12485 return CMD_WARNING
;
12487 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12490 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12491 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12492 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12496 BGP_INSTANCE_HELP_STR
12497 "Detailed information on TCP and BGP neighbor connections\n"
12498 "Neighbor to display information about\n"
12499 "Neighbor to display information about\n"
12500 "Neighbor on bgp configured interface\n"
12501 "Display the received routes from neighbor\n"
12502 "JavaScript Object Notation\n")
12505 u_char uj
= use_json(argc
, argv
);
12507 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12509 return CMD_WARNING
;
12511 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12514 ALIAS (show_bgp_instance_neighbor_received_routes
,
12515 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12516 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12519 BGP_INSTANCE_HELP_STR
12521 "Detailed information on TCP and BGP neighbor connections\n"
12522 "Neighbor to display information about\n"
12523 "Neighbor to display information about\n"
12524 "Neighbor on bgp configured interface\n"
12525 "Display the received routes from neighbor\n"
12526 "JavaScript Object Notation\n")
12528 DEFUN (show_ip_bgp_neighbor_received_routes
,
12529 show_ip_bgp_neighbor_received_routes_cmd
,
12530 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12534 "Detailed information on TCP and BGP neighbor connections\n"
12535 "Neighbor to display information about\n"
12536 "Neighbor to display information about\n"
12537 "Neighbor on bgp configured interface\n"
12538 "Display the received routes from neighbor\n"
12539 "JavaScript Object Notation\n")
12543 const char *rmap_name
= NULL
;
12544 u_char uj
= use_json(argc
, argv
);
12546 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12549 return CMD_WARNING
;
12551 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12552 rmap_name
= argv
[1];
12554 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12557 ALIAS (show_ip_bgp_neighbor_received_routes
,
12558 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12559 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {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 the received routes from neighbor\n"
12568 "JavaScript Object Notation\n")
12570 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12571 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12572 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12576 BGP_INSTANCE_HELP_STR
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 the received routes from neighbor\n"
12582 "JavaScript Object Notation\n")
12584 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12585 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12586 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12591 "Address Family modifier\n"
12592 "Address Family modifier\n"
12593 "Detailed information on TCP and BGP neighbor connections\n"
12594 "Neighbor to display information about\n"
12595 "Neighbor to display information about\n"
12596 "Neighbor on bgp configured interface\n"
12597 "Display the received routes from neighbor\n"
12598 "JavaScript Object Notation\n")
12601 const char *rmap_name
= NULL
;
12602 u_char uj
= use_json(argc
, argv
);
12604 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12606 return CMD_WARNING
;
12608 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12609 rmap_name
= argv
[2];
12611 if (strncmp (argv
[0], "m", 1) == 0)
12612 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1, rmap_name
, uj
);
12614 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12617 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12618 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12619 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12624 "Address Family modifier\n"
12625 "Address Family modifier\n"
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 received routes from neighbor\n"
12631 "JavaScript Object Notation\n")
12633 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12634 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12635 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12638 BGP_INSTANCE_HELP_STR
12641 "Address family modifier\n"
12642 "Address family modifier\n"
12643 "Detailed information on TCP and BGP neighbor connections\n"
12644 "Neighbor to display information about\n"
12645 "Neighbor to display information about\n"
12646 "Neighbor on bgp configured interface\n"
12647 "Display the advertised routes to neighbor\n"
12648 "Display the received routes from neighbor\n"
12649 "JavaScript Object Notation\n")
12655 u_char uj
= use_json(argc
, argv
);
12657 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12660 return CMD_WARNING
;
12662 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
12663 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
12664 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12666 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12669 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12670 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12671 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12675 "Detailed information on TCP and BGP neighbor connections\n"
12676 "Neighbor to display information about\n"
12677 "Neighbor to display information about\n"
12678 "Neighbor on bgp configured interface\n"
12679 "Display information received from a BGP neighbor\n"
12680 "Display the prefixlist filter\n"
12681 "JavaScript Object Notation\n")
12684 union sockunion su
;
12687 u_char uj
= use_json(argc
, argv
);
12689 ret
= str2sockunion (argv
[0], &su
);
12692 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12697 json_object
*json_no
= NULL
;
12698 json_object
*json_sub
= NULL
;
12699 json_no
= json_object_new_object();
12700 json_sub
= json_object_new_object();
12701 json_object_string_add(json_no
, "warning", "Malformed address or name");
12702 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12703 json_object_object_add(json_no
, "detail", json_sub
);
12704 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12705 json_object_free(json_no
);
12708 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12709 return CMD_WARNING
;
12714 peer
= peer_lookup (NULL
, &su
);
12719 json_object
*json_no
= NULL
;
12720 json_no
= json_object_new_object();
12721 json_object_string_add(json_no
, "warning", "Peer not found");
12722 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12723 json_object_free(json_no
);
12726 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12727 return CMD_WARNING
;
12731 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12732 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12736 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12737 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12743 json_object
*json_no
= NULL
;
12744 json_no
= json_object_new_object();
12745 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12746 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12747 json_object_free(json_no
);
12750 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12753 return CMD_SUCCESS
;
12756 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
12757 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
12758 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12763 "Address Family modifier\n"
12764 "Address Family modifier\n"
12765 "Detailed information on TCP and BGP neighbor connections\n"
12766 "Neighbor to display information about\n"
12767 "Neighbor to display information about\n"
12768 "Neighbor on bgp configured interface\n"
12769 "Display information received from a BGP neighbor\n"
12770 "Display the prefixlist filter\n"
12771 "JavaScript Object Notation\n")
12774 union sockunion su
;
12777 u_char uj
= use_json(argc
, argv
);
12779 ret
= str2sockunion (argv
[1], &su
);
12782 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
12787 json_object
*json_no
= NULL
;
12788 json_object
*json_sub
= NULL
;
12789 json_no
= json_object_new_object();
12790 json_sub
= json_object_new_object();
12791 json_object_string_add(json_no
, "warning", "Malformed address or name");
12792 json_object_string_add(json_sub
, "warningCause", argv
[1]);
12793 json_object_object_add(json_no
, "detail", json_sub
);
12794 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12795 json_object_free(json_no
);
12798 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
12799 return CMD_WARNING
;
12804 peer
= peer_lookup (NULL
, &su
);
12809 json_object
*json_no
= NULL
;
12810 json_no
= json_object_new_object();
12811 json_object_string_add(json_no
, "warning", "Peer not found");
12812 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12813 json_object_free(json_no
);
12816 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12817 return CMD_WARNING
;
12821 if (strncmp (argv
[0], "m", 1) == 0)
12823 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
12824 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12828 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
12829 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12835 json_object
*json_no
= NULL
;
12836 json_no
= json_object_new_object();
12837 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12838 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12839 json_object_free(json_no
);
12842 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12847 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12848 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12852 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12853 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12859 json_object
*json_no
= NULL
;
12860 json_no
= json_object_new_object();
12861 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12862 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12863 json_object_free(json_no
);
12866 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12870 return CMD_SUCCESS
;
12873 DEFUN (show_bgp_neighbor_received_routes
,
12874 show_bgp_neighbor_received_routes_cmd
,
12875 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12878 "Detailed information on TCP and BGP neighbor connections\n"
12879 "Neighbor to display information about\n"
12880 "Neighbor to display information about\n"
12881 "Neighbor on bgp configured interface\n"
12882 "Display the received routes from neighbor\n"
12883 "JavaScript Object Notation\n")
12886 const char *rmap_name
= NULL
;
12887 u_char uj
= use_json(argc
, argv
);
12889 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12892 return CMD_WARNING
;
12894 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12895 rmap_name
= argv
[1];
12897 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12900 ALIAS (show_bgp_neighbor_received_routes
,
12901 show_bgp_ipv6_neighbor_received_routes_cmd
,
12902 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12906 "Detailed information on TCP and BGP neighbor connections\n"
12907 "Neighbor to display information about\n"
12908 "Neighbor to display information about\n"
12909 "Neighbor on bgp configured interface\n"
12910 "Display the received routes from neighbor\n"
12911 "JavaScript Object Notation\n")
12913 DEFUN (show_bgp_neighbor_received_prefix_filter
,
12914 show_bgp_neighbor_received_prefix_filter_cmd
,
12915 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12918 "Detailed information on TCP and BGP neighbor connections\n"
12919 "Neighbor to display information about\n"
12920 "Neighbor to display information about\n"
12921 "Neighbor on bgp configured interface\n"
12922 "Display information received from a BGP neighbor\n"
12923 "Display the prefixlist filter\n"
12924 "JavaScript Object Notation\n")
12927 union sockunion su
;
12930 u_char uj
= use_json(argc
, argv
);
12932 ret
= str2sockunion (argv
[0], &su
);
12935 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12940 json_object
*json_no
= NULL
;
12941 json_object
*json_sub
= NULL
;
12942 json_no
= json_object_new_object();
12943 json_sub
= json_object_new_object();
12944 json_object_string_add(json_no
, "warning", "Malformed address or name");
12945 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12946 json_object_object_add(json_no
, "detail", json_sub
);
12947 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12948 json_object_free(json_no
);
12951 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12952 return CMD_WARNING
;
12957 peer
= peer_lookup (NULL
, &su
);
12962 json_object
*json_no
= NULL
;
12963 json_no
= json_object_new_object();
12964 json_object_string_add(json_no
, "warning", "No Peer");
12965 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12966 json_object_free(json_no
);
12969 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12970 return CMD_WARNING
;
12974 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
12975 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
12979 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
12980 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
12986 json_object
*json_no
= NULL
;
12987 json_no
= json_object_new_object();
12988 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12989 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12990 json_object_free(json_no
);
12993 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12996 return CMD_SUCCESS
;
12999 ALIAS (show_bgp_neighbor_received_prefix_filter
,
13000 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
13001 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13005 "Detailed information on TCP and BGP neighbor connections\n"
13006 "Neighbor to display information about\n"
13007 "Neighbor to display information about\n"
13008 "Neighbor on bgp configured interface\n"
13009 "Display information received from a BGP neighbor\n"
13010 "Display the prefixlist filter\n"
13011 "JavaScript Object Notation\n")
13014 ALIAS (show_bgp_neighbor_received_routes
,
13015 ipv6_bgp_neighbor_received_routes_cmd
,
13016 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13020 "Detailed information on TCP and BGP neighbor connections\n"
13021 "Neighbor to display information about\n"
13022 "Neighbor to display information about\n"
13023 "Neighbor on bgp configured interface\n"
13024 "Display the received routes from neighbor\n"
13025 "JavaScript Object Notation\n")
13028 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13029 ipv6_mbgp_neighbor_received_routes_cmd
,
13030 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13034 "Detailed information on TCP and BGP neighbor connections\n"
13035 "Neighbor to display information about\n"
13036 "Neighbor to display information about\n"
13037 "Neighbor on bgp configured interface\n"
13038 "Display the received routes from neighbor\n"
13039 "JavaScript Object Notation\n")
13042 u_char uj
= use_json(argc
, argv
);
13044 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13046 return CMD_WARNING
;
13048 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13049 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13052 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13053 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13054 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13057 BGP_INSTANCE_HELP_STR
13058 "Detailed information on TCP and BGP neighbor connections\n"
13059 "Neighbor to display information about\n"
13060 "Neighbor to display information about\n"
13061 "Neighbor on bgp configured interface\n"
13062 "Display information received from a BGP neighbor\n"
13063 "Display the prefixlist filter\n"
13064 "JavaScript Object Notation\n")
13067 union sockunion su
;
13071 u_char uj
= use_json(argc
, argv
);
13073 /* BGP structure lookup. */
13074 bgp
= bgp_lookup_by_name (argv
[1]);
13079 json_object
*json_no
= NULL
;
13080 json_no
= json_object_new_object();
13081 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13082 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13083 json_object_free(json_no
);
13086 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13087 return CMD_WARNING
;
13090 ret
= str2sockunion (argv
[2], &su
);
13093 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13098 json_object
*json_no
= NULL
;
13099 json_object
*json_sub
= NULL
;
13100 json_no
= json_object_new_object();
13101 json_sub
= json_object_new_object();
13102 json_object_string_add(json_no
, "warning", "Malformed address or name");
13103 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13104 json_object_object_add(json_no
, "detail", json_sub
);
13105 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13106 json_object_free(json_no
);
13109 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13110 return CMD_WARNING
;
13115 peer
= peer_lookup (bgp
, &su
);
13120 json_object
*json_no
= NULL
;
13121 json_no
= json_object_new_object();
13122 json_object_boolean_true_add(json_no
, "noPeer");
13123 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13124 json_object_free(json_no
);
13127 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13128 return CMD_WARNING
;
13133 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13134 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13138 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13139 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13142 return CMD_SUCCESS
;
13144 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13145 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13146 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13149 BGP_INSTANCE_HELP_STR
13151 "Detailed information on TCP and BGP neighbor connections\n"
13152 "Neighbor to display information about\n"
13153 "Neighbor to display information about\n"
13154 "Neighbor on bgp configured interface\n"
13155 "Display information received from a BGP neighbor\n"
13156 "Display the prefixlist filter\n"
13157 "JavaScript Object NOtation\n")
13158 #endif /* HAVE_IPV6 */
13161 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13162 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13164 if (! peer
|| ! peer
->afc
[afi
][safi
])
13168 json_object
*json_no
= NULL
;
13169 json_no
= json_object_new_object();
13170 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13171 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13172 json_object_free(json_no
);
13175 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13176 return CMD_WARNING
;
13179 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13182 DEFUN (show_ip_bgp_neighbor_routes
,
13183 show_ip_bgp_neighbor_routes_cmd
,
13184 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13188 "Detailed information on TCP and BGP neighbor connections\n"
13189 "Neighbor to display information about\n"
13190 "Neighbor to display information about\n"
13191 "Neighbor on bgp configured interface\n"
13192 "Display routes learned from neighbor\n"
13193 "JavaScript Object Notation\n")
13196 u_char uj
= use_json(argc
, argv
);
13198 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13200 return CMD_WARNING
;
13202 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13203 bgp_show_type_neighbor
, uj
);
13206 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13207 show_ip_bgp_instance_neighbor_routes_cmd
,
13208 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13212 BGP_INSTANCE_HELP_STR
13213 "Detailed information on TCP and BGP neighbor connections\n"
13214 "Neighbor to display information about\n"
13215 "Neighbor to display information about\n"
13216 "Neighbor on bgp configured interface\n"
13217 "Display routes learned from neighbor\n"
13218 "JavaScript Object Notation\n")
13221 u_char uj
= use_json(argc
, argv
);
13223 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13225 return CMD_WARNING
;
13227 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13228 bgp_show_type_neighbor
, uj
);
13231 DEFUN (show_ip_bgp_neighbor_flap
,
13232 show_ip_bgp_neighbor_flap_cmd
,
13233 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13237 "Detailed information on TCP and BGP neighbor connections\n"
13238 "Neighbor to display information about\n"
13239 "Neighbor to display information about\n"
13240 "Neighbor on bgp configured interface\n"
13241 "Display flap statistics of the routes learned from neighbor\n"
13242 "JavaScript Object Notation\n")
13245 u_char uj
= use_json(argc
, argv
);
13247 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13249 return CMD_WARNING
;
13251 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13252 bgp_show_type_flap_neighbor
, uj
);
13255 DEFUN (show_ip_bgp_neighbor_damp
,
13256 show_ip_bgp_neighbor_damp_cmd
,
13257 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13261 "Detailed information on TCP and BGP neighbor connections\n"
13262 "Neighbor to display information about\n"
13263 "Neighbor to display information about\n"
13264 "Neighbor on bgp configured interface\n"
13265 "Display the dampened routes received from neighbor\n"
13266 "JavaScript Object Notation\n")
13269 u_char uj
= use_json(argc
, argv
);
13271 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13273 return CMD_WARNING
;
13275 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13276 bgp_show_type_damp_neighbor
, uj
);
13279 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13280 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13281 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13286 "Address Family modifier\n"
13287 "Address Family modifier\n"
13288 "Detailed information on TCP and BGP neighbor connections\n"
13289 "Neighbor to display information about\n"
13290 "Neighbor to display information about\n"
13291 "Neighbor on bgp configured interface\n"
13292 "Display routes learned from neighbor\n"
13293 "JavaScript Object Notation\n")
13296 u_char uj
= use_json(argc
, argv
);
13298 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13300 return CMD_WARNING
;
13302 if (strncmp (argv
[0], "m", 1) == 0)
13303 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
13304 bgp_show_type_neighbor
, uj
);
13306 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13307 bgp_show_type_neighbor
, uj
);
13311 DEFUN (show_bgp_instance_neighbor_routes
,
13312 show_bgp_instance_neighbor_routes_cmd
,
13313 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13316 BGP_INSTANCE_HELP_STR
13317 "Detailed information on TCP and BGP neighbor connections\n"
13318 "Neighbor to display information about\n"
13319 "Neighbor to display information about\n"
13320 "Neighbor on bgp configured interface\n"
13321 "Display routes learned from neighbor\n"
13322 "JavaScript Object Notation\n")
13325 u_char uj
= use_json(argc
, argv
);
13327 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13329 return CMD_WARNING
;
13331 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13332 bgp_show_type_neighbor
, uj
);
13335 ALIAS (show_bgp_instance_neighbor_routes
,
13336 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13337 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13340 BGP_INSTANCE_HELP_STR
13342 "Detailed information on TCP and BGP neighbor connections\n"
13343 "Neighbor to display information about\n"
13344 "Neighbor to display information about\n"
13345 "Neighbor on bgp configured interface\n"
13346 "Display routes learned from neighbor\n"
13347 "JavaScript Object Notation\n")
13349 DEFUN (show_bgp_instance_neighbor_damp
,
13350 show_bgp_instance_neighbor_damp_cmd
,
13351 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13354 BGP_INSTANCE_HELP_STR
13355 "Detailed information on TCP and BGP neighbor connections\n"
13356 "Neighbor to display information about\n"
13357 "Neighbor to display information about\n"
13358 "Neighbor on bgp configured interface\n"
13359 "Display the dampened routes received from neighbor\n"
13360 "JavaScript Object Notation\n")
13363 u_char uj
= use_json(argc
, argv
);
13365 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13366 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13367 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13369 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13372 return CMD_WARNING
;
13374 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13375 bgp_show_type_damp_neighbor
, uj
);
13378 ALIAS (show_bgp_instance_neighbor_damp
,
13379 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13380 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13383 BGP_INSTANCE_HELP_STR
13385 "Detailed information on TCP and BGP neighbor connections\n"
13386 "Neighbor to display information about\n"
13387 "Neighbor to display information about\n"
13388 "Neighbor on bgp configured interface\n"
13389 "Display the dampened routes received from neighbor\n"
13390 "JavaScript Object Notation\n")
13392 DEFUN (show_bgp_instance_neighbor_flap
,
13393 show_bgp_instance_neighbor_flap_cmd
,
13394 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13397 BGP_INSTANCE_HELP_STR
13398 "Detailed information on TCP and BGP neighbor connections\n"
13399 "Neighbor to display information about\n"
13400 "Neighbor to display information about\n"
13401 "Neighbor on bgp configured interface\n"
13402 "Display flap statistics of the routes learned from neighbor\n"
13403 "JavaScript Object Notation\n")
13406 u_char uj
= use_json(argc
, argv
);
13408 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13409 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13410 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13412 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13415 return CMD_WARNING
;
13417 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13418 bgp_show_type_flap_neighbor
, uj
);
13421 ALIAS (show_bgp_instance_neighbor_flap
,
13422 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13423 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13426 BGP_INSTANCE_HELP_STR
13428 "Detailed information on TCP and BGP neighbor connections\n"
13429 "Neighbor to display information about\n"
13430 "Neighbor to display information about\n"
13431 "Neighbor on bgp configured interface\n"
13432 "Display flap statistics of the routes learned from neighbor\n"
13433 "JavaScript Object Notation\n")
13435 DEFUN (show_bgp_neighbor_routes
,
13436 show_bgp_neighbor_routes_cmd
,
13437 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13440 "Detailed information on TCP and BGP neighbor connections\n"
13441 "Neighbor to display information about\n"
13442 "Neighbor to display information about\n"
13443 "Neighbor on bgp configured interface\n"
13444 "Display routes learned from neighbor\n"
13445 "JavaScript Object Notation\n")
13448 u_char uj
= use_json(argc
, argv
);
13450 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13452 return CMD_WARNING
;
13454 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13455 bgp_show_type_neighbor
, uj
);
13459 ALIAS (show_bgp_neighbor_routes
,
13460 show_bgp_ipv6_neighbor_routes_cmd
,
13461 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13465 "Detailed information on TCP and BGP neighbor connections\n"
13466 "Neighbor to display information about\n"
13467 "Neighbor to display information about\n"
13468 "Neighbor on bgp configured interface\n"
13469 "Display routes learned from neighbor\n"
13470 "JavaScript Object Notation\n")
13473 ALIAS (show_bgp_neighbor_routes
,
13474 ipv6_bgp_neighbor_routes_cmd
,
13475 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13479 "Detailed information on TCP and BGP neighbor connections\n"
13480 "Neighbor to display information about\n"
13481 "Neighbor to display information about\n"
13482 "Neighbor on bgp configured interface\n"
13483 "Display routes learned from neighbor\n"
13484 "JavaScript Object Notation\n")
13487 DEFUN (ipv6_mbgp_neighbor_routes
,
13488 ipv6_mbgp_neighbor_routes_cmd
,
13489 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13493 "Detailed information on TCP and BGP neighbor connections\n"
13494 "Neighbor to display information about\n"
13495 "Neighbor to display information about\n"
13496 "Neighbor on bgp configured interface\n"
13497 "Display routes learned from neighbor\n"
13498 "JavaScript Object Notation\n")
13501 u_char uj
= use_json(argc
, argv
);
13503 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13505 return CMD_WARNING
;
13507 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13508 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13509 bgp_show_type_neighbor
, uj
);
13512 ALIAS (show_bgp_instance_neighbor_flap
,
13513 show_bgp_neighbor_flap_cmd
,
13514 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13517 "Detailed information on TCP and BGP neighbor connections\n"
13518 "Neighbor to display information about\n"
13519 "Neighbor to display information about\n"
13520 "Neighbor on bgp configured interface\n"
13521 "Display flap statistics of the routes learned from neighbor\n"
13522 "JavaScript Object Notation\n")
13524 ALIAS (show_bgp_instance_neighbor_flap
,
13525 show_bgp_ipv6_neighbor_flap_cmd
,
13526 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13530 "Detailed information on TCP and BGP neighbor connections\n"
13531 "Neighbor to display information about\n"
13532 "Neighbor to display information about\n"
13533 "Neighbor on bgp configured interface\n"
13534 "Display flap statistics of the routes learned from neighbor\n"
13535 "JavaScript Object Notation\n")
13537 ALIAS (show_bgp_instance_neighbor_damp
,
13538 show_bgp_neighbor_damp_cmd
,
13539 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13542 "Detailed information on TCP and BGP neighbor connections\n"
13543 "Neighbor to display information about\n"
13544 "Neighbor to display information about\n"
13545 "Neighbor on bgp configured interface\n"
13546 "Display the dampened routes received from neighbor\n"
13547 "JavaScript Object Notation\n")
13549 ALIAS (show_bgp_instance_neighbor_damp
,
13550 show_bgp_ipv6_neighbor_damp_cmd
,
13551 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13555 "Detailed information on TCP and BGP neighbor connections\n"
13556 "Neighbor to display information about\n"
13557 "Neighbor to display information about\n"
13558 "Neighbor on bgp configured interface\n"
13559 "Display the dampened routes received from neighbor\n"
13560 "JavaScript Object Notation\n")
13562 #endif /* HAVE_IPV6 */
13564 struct bgp_table
*bgp_distance_table
;
13566 struct bgp_distance
13568 /* Distance value for the IP source prefix. */
13571 /* Name of the access-list to be matched. */
13575 static struct bgp_distance
*
13576 bgp_distance_new (void)
13578 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13582 bgp_distance_free (struct bgp_distance
*bdistance
)
13584 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13588 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13589 const char *ip_str
, const char *access_list_str
)
13592 struct prefix_ipv4 p
;
13594 struct bgp_node
*rn
;
13595 struct bgp_distance
*bdistance
;
13597 ret
= str2prefix_ipv4 (ip_str
, &p
);
13600 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13601 return CMD_WARNING
;
13604 distance
= atoi (distance_str
);
13606 /* Get BGP distance node. */
13607 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
13610 bdistance
= rn
->info
;
13611 bgp_unlock_node (rn
);
13615 bdistance
= bgp_distance_new ();
13616 rn
->info
= bdistance
;
13619 /* Set distance value. */
13620 bdistance
->distance
= distance
;
13622 /* Reset access-list configuration. */
13623 if (bdistance
->access_list
)
13625 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13626 bdistance
->access_list
= NULL
;
13628 if (access_list_str
)
13629 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13631 return CMD_SUCCESS
;
13635 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13636 const char *ip_str
, const char *access_list_str
)
13640 struct prefix_ipv4 p
;
13641 struct bgp_node
*rn
;
13642 struct bgp_distance
*bdistance
;
13644 ret
= str2prefix_ipv4 (ip_str
, &p
);
13647 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13648 return CMD_WARNING
;
13651 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
13654 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13655 return CMD_WARNING
;
13658 bdistance
= rn
->info
;
13659 distance
= atoi(distance_str
);
13661 if (bdistance
->distance
!= distance
)
13663 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13664 return CMD_WARNING
;
13667 if (bdistance
->access_list
)
13668 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13669 bgp_distance_free (bdistance
);
13672 bgp_unlock_node (rn
);
13673 bgp_unlock_node (rn
);
13675 return CMD_SUCCESS
;
13678 /* Apply BGP information to distance method. */
13680 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
13682 struct bgp_node
*rn
;
13683 struct prefix_ipv4 q
;
13685 struct bgp_distance
*bdistance
;
13686 struct access_list
*alist
;
13687 struct bgp_static
*bgp_static
;
13692 if (p
->family
!= AF_INET
)
13695 peer
= rinfo
->peer
;
13697 if (peer
->su
.sa
.sa_family
!= AF_INET
)
13700 memset (&q
, 0, sizeof (struct prefix_ipv4
));
13701 q
.family
= AF_INET
;
13702 q
.prefix
= peer
->su
.sin
.sin_addr
;
13703 q
.prefixlen
= IPV4_MAX_BITLEN
;
13705 /* Check source address. */
13706 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
13709 bdistance
= rn
->info
;
13710 bgp_unlock_node (rn
);
13712 if (bdistance
->access_list
)
13714 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
13715 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13716 return bdistance
->distance
;
13719 return bdistance
->distance
;
13722 /* Backdoor check. */
13723 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
13726 bgp_static
= rn
->info
;
13727 bgp_unlock_node (rn
);
13729 if (bgp_static
->backdoor
)
13731 if (bgp
->distance_local
)
13732 return bgp
->distance_local
;
13734 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13738 if (peer
->sort
== BGP_PEER_EBGP
)
13740 if (bgp
->distance_ebgp
)
13741 return bgp
->distance_ebgp
;
13742 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
13746 if (bgp
->distance_ibgp
)
13747 return bgp
->distance_ibgp
;
13748 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13752 DEFUN (bgp_distance
,
13754 "distance bgp <1-255> <1-255> <1-255>",
13755 "Define an administrative distance\n"
13757 "Distance for routes external to the AS\n"
13758 "Distance for routes internal to the AS\n"
13759 "Distance for local routes\n")
13765 bgp
->distance_ebgp
= atoi (argv
[0]);
13766 bgp
->distance_ibgp
= atoi (argv
[1]);
13767 bgp
->distance_local
= atoi (argv
[2]);
13768 return CMD_SUCCESS
;
13771 DEFUN (no_bgp_distance
,
13772 no_bgp_distance_cmd
,
13773 "no distance bgp <1-255> <1-255> <1-255>",
13775 "Define an administrative distance\n"
13777 "Distance for routes external to the AS\n"
13778 "Distance for routes internal to the AS\n"
13779 "Distance for local routes\n")
13785 bgp
->distance_ebgp
= 0;
13786 bgp
->distance_ibgp
= 0;
13787 bgp
->distance_local
= 0;
13788 return CMD_SUCCESS
;
13791 ALIAS (no_bgp_distance
,
13792 no_bgp_distance2_cmd
,
13795 "Define an administrative distance\n"
13798 DEFUN (bgp_distance_source
,
13799 bgp_distance_source_cmd
,
13800 "distance <1-255> A.B.C.D/M",
13801 "Define an administrative distance\n"
13802 "Administrative distance\n"
13803 "IP source prefix\n")
13805 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
13806 return CMD_SUCCESS
;
13809 DEFUN (no_bgp_distance_source
,
13810 no_bgp_distance_source_cmd
,
13811 "no distance <1-255> A.B.C.D/M",
13813 "Define an administrative distance\n"
13814 "Administrative distance\n"
13815 "IP source prefix\n")
13817 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
13818 return CMD_SUCCESS
;
13821 DEFUN (bgp_distance_source_access_list
,
13822 bgp_distance_source_access_list_cmd
,
13823 "distance <1-255> A.B.C.D/M WORD",
13824 "Define an administrative distance\n"
13825 "Administrative distance\n"
13826 "IP source prefix\n"
13827 "Access list name\n")
13829 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
13830 return CMD_SUCCESS
;
13833 DEFUN (no_bgp_distance_source_access_list
,
13834 no_bgp_distance_source_access_list_cmd
,
13835 "no distance <1-255> A.B.C.D/M WORD",
13837 "Define an administrative distance\n"
13838 "Administrative distance\n"
13839 "IP source prefix\n"
13840 "Access list name\n")
13842 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
13843 return CMD_SUCCESS
;
13846 DEFUN (bgp_damp_set
,
13848 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
13849 "BGP Specific commands\n"
13850 "Enable route-flap dampening\n"
13851 "Half-life time for the penalty\n"
13852 "Value to start reusing a route\n"
13853 "Value to start suppressing a route\n"
13854 "Maximum duration to suppress a stable route\n")
13857 int half
= DEFAULT_HALF_LIFE
* 60;
13858 int reuse
= DEFAULT_REUSE
;
13859 int suppress
= DEFAULT_SUPPRESS
;
13860 int max
= 4 * half
;
13864 half
= atoi (argv
[0]) * 60;
13865 reuse
= atoi (argv
[1]);
13866 suppress
= atoi (argv
[2]);
13867 max
= atoi (argv
[3]) * 60;
13869 else if (argc
== 1)
13871 half
= atoi (argv
[0]) * 60;
13877 if (suppress
< reuse
)
13879 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
13884 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
13885 half
, reuse
, suppress
, max
);
13888 ALIAS (bgp_damp_set
,
13890 "bgp dampening <1-45>",
13891 "BGP Specific commands\n"
13892 "Enable route-flap dampening\n"
13893 "Half-life time for the penalty\n")
13895 ALIAS (bgp_damp_set
,
13898 "BGP Specific commands\n"
13899 "Enable route-flap dampening\n")
13901 DEFUN (bgp_damp_unset
,
13902 bgp_damp_unset_cmd
,
13903 "no bgp dampening",
13905 "BGP Specific commands\n"
13906 "Enable route-flap dampening\n")
13911 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
13914 ALIAS (bgp_damp_unset
,
13915 bgp_damp_unset2_cmd
,
13916 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
13918 "BGP Specific commands\n"
13919 "Enable route-flap dampening\n"
13920 "Half-life time for the penalty\n"
13921 "Value to start reusing a route\n"
13922 "Value to start suppressing a route\n"
13923 "Maximum duration to suppress a stable route\n")
13925 ALIAS (bgp_damp_unset
,
13926 bgp_damp_unset3_cmd
,
13927 "no bgp dampening <1-45>",
13929 "BGP Specific commands\n"
13930 "Enable route-flap dampening\n"
13931 "Half-life time for the penalty\n")
13933 DEFUN (show_ip_bgp_dampened_paths
,
13934 show_ip_bgp_dampened_paths_cmd
,
13935 "show ip bgp dampened-paths",
13939 "Display paths suppressed due to dampening\n")
13941 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
13945 ALIAS (show_ip_bgp_dampened_paths
,
13946 show_ip_bgp_damp_dampened_paths_cmd
,
13947 "show ip bgp dampening dampened-paths",
13951 "Display detailed information about dampening\n"
13952 "Display paths suppressed due to dampening\n")
13954 DEFUN (show_ip_bgp_flap_statistics
,
13955 show_ip_bgp_flap_statistics_cmd
,
13956 "show ip bgp flap-statistics",
13960 "Display flap statistics of routes\n")
13962 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
13963 bgp_show_type_flap_statistics
, NULL
, 0);
13966 ALIAS (show_ip_bgp_flap_statistics
,
13967 show_ip_bgp_damp_flap_statistics_cmd
,
13968 "show ip bgp dampening flap-statistics",
13972 "Display detailed information about dampening\n"
13973 "Display flap statistics of routes\n")
13975 /* Display specified route of BGP table. */
13977 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
13978 const char *ip_str
, afi_t afi
, safi_t safi
,
13979 struct prefix_rd
*prd
, int prefix_check
)
13982 struct prefix match
;
13983 struct bgp_node
*rn
;
13984 struct bgp_node
*rm
;
13985 struct bgp_info
*ri
;
13986 struct bgp_info
*ri_temp
;
13988 struct bgp_table
*table
;
13990 /* BGP structure lookup. */
13993 bgp
= bgp_lookup_by_name (view_name
);
13996 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
13997 return CMD_WARNING
;
14002 bgp
= bgp_get_default ();
14005 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14006 return CMD_WARNING
;
14010 /* Check IP address argument. */
14011 ret
= str2prefix (ip_str
, &match
);
14014 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14015 return CMD_WARNING
;
14018 match
.family
= afi2family (afi
);
14020 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14022 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14024 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14027 if ((table
= rn
->info
) != NULL
)
14028 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14030 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14035 if (ri
->extra
&& ri
->extra
->damp_info
)
14037 ri_temp
= ri
->next
;
14038 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14046 bgp_unlock_node (rm
);
14052 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14054 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14059 if (ri
->extra
&& ri
->extra
->damp_info
)
14061 ri_temp
= ri
->next
;
14062 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14070 bgp_unlock_node (rn
);
14074 return CMD_SUCCESS
;
14077 DEFUN (clear_ip_bgp_dampening
,
14078 clear_ip_bgp_dampening_cmd
,
14079 "clear ip bgp dampening",
14083 "Clear route flap dampening information\n")
14085 bgp_damp_info_clean ();
14086 return CMD_SUCCESS
;
14089 DEFUN (clear_ip_bgp_dampening_prefix
,
14090 clear_ip_bgp_dampening_prefix_cmd
,
14091 "clear ip bgp dampening A.B.C.D/M",
14095 "Clear route flap dampening information\n"
14096 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14098 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14099 SAFI_UNICAST
, NULL
, 1);
14102 DEFUN (clear_ip_bgp_dampening_address
,
14103 clear_ip_bgp_dampening_address_cmd
,
14104 "clear ip bgp dampening A.B.C.D",
14108 "Clear route flap dampening information\n"
14109 "Network to clear damping information\n")
14111 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14112 SAFI_UNICAST
, NULL
, 0);
14115 DEFUN (clear_ip_bgp_dampening_address_mask
,
14116 clear_ip_bgp_dampening_address_mask_cmd
,
14117 "clear ip bgp dampening A.B.C.D A.B.C.D",
14121 "Clear route flap dampening information\n"
14122 "Network to clear damping information\n"
14126 char prefix_str
[BUFSIZ
];
14128 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14131 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14132 return CMD_WARNING
;
14135 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14136 SAFI_UNICAST
, NULL
, 0);
14139 /* also used for encap safi */
14141 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14142 afi_t afi
, safi_t safi
, int *write
)
14144 struct bgp_node
*prn
;
14145 struct bgp_node
*rn
;
14146 struct bgp_table
*table
;
14148 struct prefix_rd
*prd
;
14149 struct bgp_static
*bgp_static
;
14151 char buf
[SU_ADDRSTRLEN
];
14152 char rdbuf
[RD_ADDRSTRLEN
];
14154 /* Network configuration. */
14155 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14156 if ((table
= prn
->info
) != NULL
)
14157 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14158 if ((bgp_static
= rn
->info
) != NULL
)
14161 prd
= (struct prefix_rd
*) &prn
->p
;
14163 /* "address-family" display. */
14164 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14166 /* "network" configuration display. */
14167 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14168 label
= decode_label (bgp_static
->tag
);
14170 vty_out (vty
, " network %s/%d rd %s tag %d",
14171 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14174 vty_out (vty
, "%s", VTY_NEWLINE
);
14179 /* Configuration of static route announcement and aggregate
14182 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14183 afi_t afi
, safi_t safi
, int *write
)
14185 struct bgp_node
*rn
;
14187 struct bgp_static
*bgp_static
;
14188 struct bgp_aggregate
*bgp_aggregate
;
14189 char buf
[SU_ADDRSTRLEN
];
14191 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14192 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14194 /* Network configuration. */
14195 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14196 if ((bgp_static
= rn
->info
) != NULL
)
14200 /* "address-family" display. */
14201 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14203 /* "network" configuration display. */
14204 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14206 u_int32_t destination
;
14207 struct in_addr netmask
;
14209 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14210 masklen2ip (p
->prefixlen
, &netmask
);
14211 vty_out (vty
, " network %s",
14212 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14214 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14215 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14216 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14217 || p
->u
.prefix4
.s_addr
== 0)
14219 /* Natural mask is not display. */
14222 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14226 vty_out (vty
, " network %s/%d",
14227 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14231 if (bgp_static
->rmap
.name
)
14232 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14235 if (bgp_static
->backdoor
)
14236 vty_out (vty
, " backdoor");
14239 vty_out (vty
, "%s", VTY_NEWLINE
);
14242 /* Aggregate-address configuration. */
14243 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14244 if ((bgp_aggregate
= rn
->info
) != NULL
)
14248 /* "address-family" display. */
14249 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14251 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14253 struct in_addr netmask
;
14255 masklen2ip (p
->prefixlen
, &netmask
);
14256 vty_out (vty
, " aggregate-address %s %s",
14257 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14258 inet_ntoa (netmask
));
14262 vty_out (vty
, " aggregate-address %s/%d",
14263 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14267 if (bgp_aggregate
->as_set
)
14268 vty_out (vty
, " as-set");
14270 if (bgp_aggregate
->summary_only
)
14271 vty_out (vty
, " summary-only");
14273 vty_out (vty
, "%s", VTY_NEWLINE
);
14280 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
14282 struct bgp_node
*rn
;
14283 struct bgp_distance
*bdistance
;
14285 /* Distance configuration. */
14286 if (bgp
->distance_ebgp
14287 && bgp
->distance_ibgp
14288 && bgp
->distance_local
14289 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
14290 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
14291 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
14292 vty_out (vty
, " distance bgp %d %d %d%s",
14293 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
14296 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
14297 if ((bdistance
= rn
->info
) != NULL
)
14299 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
14300 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
14301 bdistance
->access_list
? bdistance
->access_list
: "",
14308 /* Allocate routing table structure and install commands. */
14310 bgp_route_init (void)
14312 /* Init BGP distance table. */
14313 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
14315 /* IPv4 BGP commands. */
14316 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14317 install_element (BGP_NODE
, &bgp_network_cmd
);
14318 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14319 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14320 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14321 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14322 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14323 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14324 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14325 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14326 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14327 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14328 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14329 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14330 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14331 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14332 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14333 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14334 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14335 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14337 install_element (BGP_NODE
, &aggregate_address_cmd
);
14338 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14339 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14340 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14341 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14342 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14343 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14344 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14345 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14346 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14347 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14348 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14349 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14350 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14351 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14352 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14353 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14354 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14355 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14356 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14358 /* IPv4 unicast configuration. */
14359 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14360 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14361 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14362 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14363 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14364 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14365 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14366 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14367 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14368 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14369 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14370 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14371 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14372 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14374 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14375 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14376 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14377 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14378 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14379 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14380 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14381 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14382 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14383 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14384 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14385 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14386 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14387 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14388 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14389 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14390 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14391 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14392 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14393 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14395 /* IPv4 multicast configuration. */
14396 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14397 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14398 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14399 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14400 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14401 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14402 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14403 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14404 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14405 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14406 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14407 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14408 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14409 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14410 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14411 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14412 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14413 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14414 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14415 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14416 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14417 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14418 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14419 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14420 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14421 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14422 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14423 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14424 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14425 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14426 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14427 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14428 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14429 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14431 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14432 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14433 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14434 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14435 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14436 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14437 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14438 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14439 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14440 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14441 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14442 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14443 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14444 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14445 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14446 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14447 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14448 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14449 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14450 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14451 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14452 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14453 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14454 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14456 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14457 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14458 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14459 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14460 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14461 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14462 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14463 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14464 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14465 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14466 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14467 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14468 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14469 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14470 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14471 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14472 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14473 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14474 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14475 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14476 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14477 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14478 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14479 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14480 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14481 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14482 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14483 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14484 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14485 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14486 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14487 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14488 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14489 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14490 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14491 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14492 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14493 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14494 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14495 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14496 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14497 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14498 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14499 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14500 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14501 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14502 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14503 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14504 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14505 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14506 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14507 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14508 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14509 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14510 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14511 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14512 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14513 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14514 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14515 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14516 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14517 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14518 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14519 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14520 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14521 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14522 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14523 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14524 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14525 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14526 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14527 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14528 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14529 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14530 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14531 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14532 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14533 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14534 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14535 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14536 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14537 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14538 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14540 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
14541 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
14542 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14543 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14544 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14545 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14546 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14547 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14548 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14549 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
14550 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14551 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14552 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14553 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14554 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14555 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14556 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14557 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14558 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14559 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14560 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14561 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
14562 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
14563 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
14564 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
14565 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14566 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14567 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14568 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14569 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14570 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14571 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14572 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14573 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14574 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
14575 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
14576 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
14577 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
14578 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14579 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14580 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14581 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14583 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
14584 install_element (ENABLE_NODE
, &show_ip_bgp_instance_cmd
);
14585 install_element (ENABLE_NODE
, &show_ip_bgp_instance_all_cmd
);
14586 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
14587 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
14588 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
14589 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_cmd
);
14590 install_element (ENABLE_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14591 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14592 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14593 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14594 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14595 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14596 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14597 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
14598 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14599 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14600 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14601 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14602 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14603 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14604 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14605 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14606 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14608 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
14609 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14610 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
14611 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14612 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14613 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
14614 install_element (ENABLE_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14615 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14616 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
14617 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14618 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14619 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
14620 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14621 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
14622 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14623 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
14624 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
14625 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
14626 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
14627 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14628 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14629 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14630 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14631 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14632 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14633 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14634 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14635 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14636 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
14637 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
14638 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
14639 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
14640 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14641 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14642 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14643 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14644 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
14645 install_element (ENABLE_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14646 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14647 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14648 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14649 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14650 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14651 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14652 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14653 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14654 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14655 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14656 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14657 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14658 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14659 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14660 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14661 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14662 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14663 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14664 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14665 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14666 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14667 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14668 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14669 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14670 install_element (ENABLE_NODE
, &show_ip_bgp_dampening_params_cmd
);
14671 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14672 install_element (ENABLE_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14673 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14674 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14675 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
14676 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14677 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14678 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14679 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14680 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14681 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_regexp_cmd
);
14682 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14683 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14684 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14685 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14686 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14687 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14688 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14689 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14690 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14691 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14692 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14694 /* BGP dampening clear commands */
14695 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14696 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14697 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14698 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14701 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14702 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14703 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14704 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
14706 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14707 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14709 /* New config IPv6 BGP commands. */
14710 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14711 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14712 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14713 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14714 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14715 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14717 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14718 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14719 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14720 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14722 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14723 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14725 /* Old config IPv6 BGP commands. */
14726 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14727 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14729 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14730 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14731 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14732 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14734 install_element (VIEW_NODE
, &show_bgp_cmd
);
14735 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14736 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14737 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14738 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14739 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14740 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14741 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14742 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14743 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14744 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14745 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14746 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14747 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14748 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14749 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14750 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14751 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14752 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14753 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14754 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14755 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14756 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14757 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14758 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14759 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14760 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14761 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14762 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14763 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14764 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14765 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14766 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14767 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14768 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14769 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14770 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14771 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14772 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14773 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14774 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14775 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14776 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14777 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14778 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14779 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14780 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14781 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14782 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14783 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14784 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14785 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14786 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14787 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14788 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14789 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14790 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14791 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14792 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14793 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14794 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14795 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14796 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14797 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14798 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14799 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14800 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14801 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14802 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14803 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14804 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14805 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14806 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14807 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14808 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14809 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14810 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14811 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14812 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14813 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14814 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14815 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14816 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14817 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14818 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14819 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14820 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14821 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14822 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14823 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14824 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14825 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14828 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
14830 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
14831 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
14832 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14833 install_element (RESTRICTED_NODE
, &show_bgp_route_pathtype_cmd
);
14834 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14835 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14836 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
14837 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
14838 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14839 install_element (RESTRICTED_NODE
, &show_bgp_prefix_pathtype_cmd
);
14840 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14841 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14842 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
14843 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
14844 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
14845 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
14846 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
14847 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
14848 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
14849 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
14850 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
14851 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14852 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
14853 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14854 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
14855 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14856 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
14857 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14858 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_cmd
);
14859 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14860 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14861 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14862 install_element (RESTRICTED_NODE
, &show_bgp_instance_prefix_cmd
);
14863 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14864 install_element (RESTRICTED_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14865 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14867 install_element (ENABLE_NODE
, &show_bgp_cmd
);
14868 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
14869 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
14870 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
14871 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
14872 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14873 install_element (ENABLE_NODE
, &show_bgp_route_pathtype_cmd
);
14874 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14875 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14876 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
14877 install_element (ENABLE_NODE
, &show_bgp_prefix_pathtype_cmd
);
14878 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14879 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14880 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
14881 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14882 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
14883 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
14884 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
14885 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14886 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
14887 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14888 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
14889 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
14890 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
14891 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
14892 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
14893 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
14894 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
14895 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
14896 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
14897 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
14898 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
14899 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
14900 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
14901 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14902 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
14903 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14904 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
14905 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14906 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
14907 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14908 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
14909 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
14910 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
14911 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14912 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
14913 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14914 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14915 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14916 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14917 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14918 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
14919 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14920 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14921 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14922 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
14923 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14924 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
14925 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14926 install_element (ENABLE_NODE
, &show_bgp_instance_cmd
);
14927 install_element (ENABLE_NODE
, &show_bgp_instance_all_cmd
);
14928 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_cmd
);
14929 install_element (ENABLE_NODE
, &show_bgp_instance_route_cmd
);
14930 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14931 install_element (ENABLE_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14932 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14933 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_cmd
);
14934 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14935 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14936 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14937 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_list_cmd
);
14938 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14939 install_element (ENABLE_NODE
, &show_bgp_instance_filter_list_cmd
);
14940 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14941 install_element (ENABLE_NODE
, &show_bgp_instance_route_map_cmd
);
14942 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14943 install_element (ENABLE_NODE
, &show_bgp_instance_community_list_cmd
);
14944 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14945 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14946 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14947 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14948 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14949 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14950 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14951 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14952 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14953 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14954 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14955 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14956 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14957 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14958 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14961 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
14962 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
14963 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
14964 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
14967 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
14968 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
14969 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
14970 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
14971 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14972 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14973 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
14974 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
14975 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
14976 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
14977 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
14978 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14979 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14980 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14981 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14982 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
14983 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14984 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14985 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
14986 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
14987 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14988 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14989 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14990 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14991 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14992 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
14993 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
14994 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
14995 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
14996 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14997 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14998 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14999 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
15000 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15001 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15002 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15005 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
15006 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
15007 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
15008 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
15009 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
15010 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
15011 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
15012 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
15013 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
15014 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
15015 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
15016 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
15017 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
15018 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
15019 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
15020 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
15021 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15022 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15023 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
15024 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
15025 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15026 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15027 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15028 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15029 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15030 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
15031 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
15032 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
15033 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
15034 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15035 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
15036 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
15037 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
15038 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15039 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15040 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15043 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
15044 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
15045 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15046 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15049 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
15050 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
15051 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15052 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15055 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
15056 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
15057 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15058 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15059 #endif /* HAVE_IPV6 */
15061 install_element (BGP_NODE
, &bgp_distance_cmd
);
15062 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
15063 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
15064 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
15065 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
15066 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
15067 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
15069 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15070 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15071 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15072 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15073 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15074 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15075 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15076 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15077 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15078 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15079 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15080 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15084 bgp_route_finish (void)
15086 bgp_table_unlock (bgp_distance_table
);
15087 bgp_distance_table
= NULL
;