1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 #include "sockunion.h"
36 #include "workqueue.h"
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
[1]->arg
);
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
[2]->arg
);
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
[1]->arg
,
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
[1]->arg
,
4299 AFI_IP
, bgp_node_safi (vty
), argv
[3]->arg
, 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
[1]->arg
, 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
[1]->arg
, argv
[3]->arg
, 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
[1]->arg
, argv
[3]->arg
, 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
[5]->arg
, 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
[1]->arg
, argv
[3]->arg
, 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
[1]->arg
, 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
[1]->arg
, 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
[3]->arg
, 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
[1]->arg
, 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
,
4446 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
4447 * "no network A.B.C.D/M route-map WORD",
4449 * "Specify a network to announce via BGP\n"
4450 * "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4451 * "Route-map to modify the attributes\n"
4452 * "Name of the route map\n"
4454 * "no network A.B.C.D/M backdoor",
4456 * "Specify a network to announce via BGP\n"
4457 * "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4458 * "Specify a BGP backdoor route\n"
4461 DEFUN (no_bgp_network
,
4463 "no network A.B.C.D/M",
4465 "Specify a network to announce via BGP\n"
4466 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4468 return bgp_static_unset (vty
, vty
->index
, argv
[2]->arg
, AFI_IP
,
4469 bgp_node_safi (vty
));
4475 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
4476 * "no network A.B.C.D mask A.B.C.D backdoor",
4478 * "Specify a network to announce via BGP\n"
4479 * "Network number\n"
4482 * "Specify a BGP backdoor route\n"
4484 * "no network A.B.C.D mask A.B.C.D route-map WORD",
4486 * "Specify a network to announce via BGP\n"
4487 * "Network number\n"
4490 * "Route-map to modify the attributes\n"
4491 * "Name of the route map\n"
4494 DEFUN (no_bgp_network_mask
,
4495 no_bgp_network_mask_cmd
,
4496 "no network A.B.C.D mask A.B.C.D",
4498 "Specify a network to announce via BGP\n"
4504 char prefix_str
[BUFSIZ
];
4506 ret
= netmask_str2prefix_str (argv
[2]->arg
, argv
[4]->arg
, prefix_str
);
4509 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4513 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4514 bgp_node_safi (vty
));
4520 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
4521 * "no network A.B.C.D backdoor",
4523 * "Specify a network to announce via BGP\n"
4524 * "Network number\n"
4525 * "Specify a BGP backdoor route\n"
4527 * "no network A.B.C.D route-map WORD",
4529 * "Specify a network to announce via BGP\n"
4530 * "Network number\n"
4531 * "Route-map to modify the attributes\n"
4532 * "Name of the route map\n"
4535 DEFUN (no_bgp_network_mask_natural
,
4536 no_bgp_network_mask_natural_cmd
,
4537 "no network A.B.C.D",
4539 "Specify a network to announce via BGP\n"
4543 char prefix_str
[BUFSIZ
];
4545 ret
= netmask_str2prefix_str (argv
[2]->arg
, NULL
, prefix_str
);
4548 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4552 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4553 bgp_node_safi (vty
));
4560 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
4561 * "ipv6 bgp network X:X::X:X/M",
4564 * "Specify a network to announce via BGP\n"
4565 * "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
4568 DEFUN (ipv6_bgp_network
,
4569 ipv6_bgp_network_cmd
,
4570 "network X:X::X:X/M",
4571 "Specify a network to announce via BGP\n"
4572 "IPv6 prefix <network>/<length>\n")
4574 return bgp_static_set (vty
, vty
->index
, argv
[1]->arg
, AFI_IP6
, bgp_node_safi(vty
),
4578 DEFUN (ipv6_bgp_network_route_map
,
4579 ipv6_bgp_network_route_map_cmd
,
4580 "network X:X::X:X/M route-map WORD",
4581 "Specify a network to announce via BGP\n"
4582 "IPv6 prefix <network>/<length>\n"
4583 "Route-map to modify the attributes\n"
4584 "Name of the route map\n")
4586 return bgp_static_set (vty
, vty
->index
, argv
[1]->arg
, AFI_IP6
,
4587 bgp_node_safi (vty
), argv
[3]->arg
, 0);
4591 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
4592 * "no network X:X::X:X/M route-map WORD",
4594 * "Specify a network to announce via BGP\n"
4595 * "IPv6 prefix <network>/<length>\n"
4596 * "Route-map to modify the attributes\n"
4597 * "Name of the route map\n"
4599 * "no ipv6 bgp network X:X::X:X/M",
4603 * "Specify a network to announce via BGP\n"
4604 * "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
4607 DEFUN (no_ipv6_bgp_network
,
4608 no_ipv6_bgp_network_cmd
,
4609 "no network X:X::X:X/M",
4611 "Specify a network to announce via BGP\n"
4612 "IPv6 prefix <network>/<length>\n")
4614 return bgp_static_unset (vty
, vty
->index
, argv
[2]->arg
, AFI_IP6
, bgp_node_safi(vty
));
4619 #endif /* HAVE_IPV6 */
4621 /* Aggreagete address:
4623 advertise-map Set condition to advertise attribute
4624 as-set Generate AS set path information
4625 attribute-map Set attributes of aggregate
4626 route-map Set parameters of aggregate
4627 summary-only Filter more specific routes from updates
4628 suppress-map Conditionally filter more specific routes from updates
4631 struct bgp_aggregate
4633 /* Summary-only flag. */
4634 u_char summary_only
;
4636 /* AS set generation. */
4639 /* Route-map for aggregated route. */
4640 struct route_map
*map
;
4642 /* Suppress-count. */
4643 unsigned long count
;
4645 /* SAFI configuration. */
4649 static struct bgp_aggregate
*
4650 bgp_aggregate_new (void)
4652 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4656 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4658 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4661 /* Update an aggregate as routes are added/removed from the BGP table */
4663 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4664 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4665 struct bgp_aggregate
*aggregate
)
4667 struct bgp_table
*table
;
4668 struct bgp_node
*top
;
4669 struct bgp_node
*rn
;
4671 struct aspath
*aspath
= NULL
;
4672 struct aspath
*asmerge
= NULL
;
4673 struct community
*community
= NULL
;
4674 struct community
*commerge
= NULL
;
4675 #if defined(AGGREGATE_NEXTHOP_CHECK)
4676 struct in_addr nexthop
;
4679 struct bgp_info
*ri
;
4680 struct bgp_info
*new;
4682 unsigned long match
= 0;
4683 u_char atomic_aggregate
= 0;
4685 /* Record adding route's nexthop and med. */
4688 #if defined(AGGREGATE_NEXTHOP_CHECK)
4689 nexthop
= rinew
->attr
->nexthop
;
4690 med
= rinew
->attr
->med
;
4694 /* ORIGIN attribute: If at least one route among routes that are
4695 aggregated has ORIGIN with the value INCOMPLETE, then the
4696 aggregated route must have the ORIGIN attribute with the value
4697 INCOMPLETE. Otherwise, if at least one route among routes that
4698 are aggregated has ORIGIN with the value EGP, then the aggregated
4699 route must have the origin attribute with the value EGP. In all
4700 other case the value of the ORIGIN attribute of the aggregated
4701 route is INTERNAL. */
4702 origin
= BGP_ORIGIN_IGP
;
4704 table
= bgp
->rib
[afi
][safi
];
4706 top
= bgp_node_get (table
, p
);
4707 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4708 if (rn
->p
.prefixlen
> p
->prefixlen
)
4712 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4714 if (BGP_INFO_HOLDDOWN (ri
))
4717 if (del
&& ri
== del
)
4720 if (! rinew
&& first
)
4722 #if defined(AGGREGATE_NEXTHOP_CHECK)
4723 nexthop
= ri
->attr
->nexthop
;
4724 med
= ri
->attr
->med
;
4729 #ifdef AGGREGATE_NEXTHOP_CHECK
4730 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4731 || ri
->attr
->med
!= med
)
4734 aspath_free (aspath
);
4736 community_free (community
);
4737 bgp_unlock_node (rn
);
4738 bgp_unlock_node (top
);
4741 #endif /* AGGREGATE_NEXTHOP_CHECK */
4743 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4744 atomic_aggregate
= 1;
4746 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4748 if (aggregate
->summary_only
)
4750 (bgp_info_extra_get (ri
))->suppress
++;
4751 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4757 if (origin
< ri
->attr
->origin
)
4758 origin
= ri
->attr
->origin
;
4760 if (aggregate
->as_set
)
4764 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4765 aspath_free (aspath
);
4769 aspath
= aspath_dup (ri
->attr
->aspath
);
4771 if (ri
->attr
->community
)
4775 commerge
= community_merge (community
,
4776 ri
->attr
->community
);
4777 community
= community_uniq_sort (commerge
);
4778 community_free (commerge
);
4781 community
= community_dup (ri
->attr
->community
);
4787 bgp_process (bgp
, rn
, afi
, safi
);
4789 bgp_unlock_node (top
);
4795 if (aggregate
->summary_only
)
4796 (bgp_info_extra_get (rinew
))->suppress
++;
4798 if (origin
< rinew
->attr
->origin
)
4799 origin
= rinew
->attr
->origin
;
4801 if (aggregate
->as_set
)
4805 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4806 aspath_free (aspath
);
4810 aspath
= aspath_dup (rinew
->attr
->aspath
);
4812 if (rinew
->attr
->community
)
4816 commerge
= community_merge (community
,
4817 rinew
->attr
->community
);
4818 community
= community_uniq_sort (commerge
);
4819 community_free (commerge
);
4822 community
= community_dup (rinew
->attr
->community
);
4827 if (aggregate
->count
> 0)
4829 rn
= bgp_node_get (table
, p
);
4830 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4831 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4833 atomic_aggregate
), rn
);
4834 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4836 bgp_info_add (rn
, new);
4837 bgp_unlock_node (rn
);
4838 bgp_process (bgp
, rn
, afi
, safi
);
4843 aspath_free (aspath
);
4845 community_free (community
);
4849 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4850 struct bgp_aggregate
*);
4853 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4854 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4856 struct bgp_node
*child
;
4857 struct bgp_node
*rn
;
4858 struct bgp_aggregate
*aggregate
;
4859 struct bgp_table
*table
;
4861 /* MPLS-VPN aggregation is not yet supported. */
4862 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4865 table
= bgp
->aggregate
[afi
][safi
];
4867 /* No aggregates configured. */
4868 if (bgp_table_top_nolock (table
) == NULL
)
4871 if (p
->prefixlen
== 0)
4874 if (BGP_INFO_HOLDDOWN (ri
))
4877 child
= bgp_node_get (table
, p
);
4879 /* Aggregate address configuration check. */
4880 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4881 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4883 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4884 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4886 bgp_unlock_node (child
);
4890 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4891 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4893 struct bgp_node
*child
;
4894 struct bgp_node
*rn
;
4895 struct bgp_aggregate
*aggregate
;
4896 struct bgp_table
*table
;
4898 /* MPLS-VPN aggregation is not yet supported. */
4899 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4902 table
= bgp
->aggregate
[afi
][safi
];
4904 /* No aggregates configured. */
4905 if (bgp_table_top_nolock (table
) == NULL
)
4908 if (p
->prefixlen
== 0)
4911 child
= bgp_node_get (table
, p
);
4913 /* Aggregate address configuration check. */
4914 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4915 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4917 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4918 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4920 bgp_unlock_node (child
);
4923 /* Called via bgp_aggregate_set when the user configures aggregate-address */
4925 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4926 struct bgp_aggregate
*aggregate
)
4928 struct bgp_table
*table
;
4929 struct bgp_node
*top
;
4930 struct bgp_node
*rn
;
4931 struct bgp_info
*new;
4932 struct bgp_info
*ri
;
4933 unsigned long match
;
4934 u_char origin
= BGP_ORIGIN_IGP
;
4935 struct aspath
*aspath
= NULL
;
4936 struct aspath
*asmerge
= NULL
;
4937 struct community
*community
= NULL
;
4938 struct community
*commerge
= NULL
;
4939 u_char atomic_aggregate
= 0;
4941 table
= bgp
->rib
[afi
][safi
];
4944 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4946 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4949 /* If routes exists below this node, generate aggregate routes. */
4950 top
= bgp_node_get (table
, p
);
4951 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4952 if (rn
->p
.prefixlen
> p
->prefixlen
)
4956 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4958 if (BGP_INFO_HOLDDOWN (ri
))
4961 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4962 atomic_aggregate
= 1;
4964 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4966 /* summary-only aggregate route suppress aggregated
4967 route announcement. */
4968 if (aggregate
->summary_only
)
4970 (bgp_info_extra_get (ri
))->suppress
++;
4971 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4975 /* If at least one route among routes that are aggregated has
4976 * ORIGIN with the value INCOMPLETE, then the aggregated route
4977 * MUST have the ORIGIN attribute with the value INCOMPLETE.
4978 * Otherwise, if at least one route among routes that are
4979 * aggregated has ORIGIN with the value EGP, then the aggregated
4980 * route MUST have the ORIGIN attribute with the value EGP.
4982 if (origin
< ri
->attr
->origin
)
4983 origin
= ri
->attr
->origin
;
4985 /* as-set aggregate route generate origin, as path,
4986 community aggregation. */
4987 if (aggregate
->as_set
)
4991 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4992 aspath_free (aspath
);
4996 aspath
= aspath_dup (ri
->attr
->aspath
);
4998 if (ri
->attr
->community
)
5002 commerge
= community_merge (community
,
5003 ri
->attr
->community
);
5004 community
= community_uniq_sort (commerge
);
5005 community_free (commerge
);
5008 community
= community_dup (ri
->attr
->community
);
5015 /* If this node is suppressed, process the change. */
5017 bgp_process (bgp
, rn
, afi
, safi
);
5019 bgp_unlock_node (top
);
5021 /* Add aggregate route to BGP table. */
5022 if (aggregate
->count
)
5024 rn
= bgp_node_get (table
, p
);
5025 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5026 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5028 atomic_aggregate
), rn
);
5029 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5031 bgp_info_add (rn
, new);
5032 bgp_unlock_node (rn
);
5034 /* Process change. */
5035 bgp_process (bgp
, rn
, afi
, safi
);
5040 aspath_free (aspath
);
5042 community_free (community
);
5047 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5048 safi_t safi
, struct bgp_aggregate
*aggregate
)
5050 struct bgp_table
*table
;
5051 struct bgp_node
*top
;
5052 struct bgp_node
*rn
;
5053 struct bgp_info
*ri
;
5054 unsigned long match
;
5056 table
= bgp
->rib
[afi
][safi
];
5058 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5060 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5063 /* If routes exists below this node, generate aggregate routes. */
5064 top
= bgp_node_get (table
, p
);
5065 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5066 if (rn
->p
.prefixlen
> p
->prefixlen
)
5070 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5072 if (BGP_INFO_HOLDDOWN (ri
))
5075 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5077 if (aggregate
->summary_only
&& ri
->extra
)
5079 ri
->extra
->suppress
--;
5081 if (ri
->extra
->suppress
== 0)
5083 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5091 /* If this node was suppressed, process the change. */
5093 bgp_process (bgp
, rn
, afi
, safi
);
5095 bgp_unlock_node (top
);
5097 /* Delete aggregate route from BGP table. */
5098 rn
= bgp_node_get (table
, p
);
5100 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5101 if (ri
->peer
== bgp
->peer_self
5102 && ri
->type
== ZEBRA_ROUTE_BGP
5103 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5106 /* Withdraw static BGP route from routing table. */
5109 bgp_info_delete (rn
, ri
);
5110 bgp_process (bgp
, rn
, afi
, safi
);
5113 /* Unlock bgp_node_lookup. */
5114 bgp_unlock_node (rn
);
5117 /* Aggregate route attribute. */
5118 #define AGGREGATE_SUMMARY_ONLY 1
5119 #define AGGREGATE_AS_SET 1
5122 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5123 afi_t afi
, safi_t safi
)
5127 struct bgp_node
*rn
;
5129 struct bgp_aggregate
*aggregate
;
5131 /* Convert string to prefix structure. */
5132 ret
= str2prefix (prefix_str
, &p
);
5135 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5140 /* Get BGP structure. */
5143 /* Old configuration check. */
5144 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5147 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5152 aggregate
= rn
->info
;
5153 if (aggregate
->safi
& SAFI_UNICAST
)
5154 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5155 if (aggregate
->safi
& SAFI_MULTICAST
)
5156 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5158 /* Unlock aggregate address configuration. */
5160 bgp_aggregate_free (aggregate
);
5161 bgp_unlock_node (rn
);
5162 bgp_unlock_node (rn
);
5168 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5169 afi_t afi
, safi_t safi
,
5170 u_char summary_only
, u_char as_set
)
5174 struct bgp_node
*rn
;
5176 struct bgp_aggregate
*aggregate
;
5178 /* Convert string to prefix structure. */
5179 ret
= str2prefix (prefix_str
, &p
);
5182 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5187 /* Get BGP structure. */
5190 /* Old configuration check. */
5191 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5195 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5196 /* try to remove the old entry */
5197 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5200 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5201 bgp_unlock_node (rn
);
5206 /* Make aggregate address structure. */
5207 aggregate
= bgp_aggregate_new ();
5208 aggregate
->summary_only
= summary_only
;
5209 aggregate
->as_set
= as_set
;
5210 aggregate
->safi
= safi
;
5211 rn
->info
= aggregate
;
5213 /* Aggregate address insert into BGP routing table. */
5214 if (safi
& SAFI_UNICAST
)
5215 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5216 if (safi
& SAFI_MULTICAST
)
5217 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5222 DEFUN (aggregate_address
,
5223 aggregate_address_cmd
,
5224 "aggregate-address A.B.C.D/M",
5225 "Configure BGP aggregate entries\n"
5226 "Aggregate prefix\n")
5228 return bgp_aggregate_set (vty
, argv
[1]->arg
, AFI_IP
, bgp_node_safi (vty
), 0, 0);
5231 DEFUN (aggregate_address_mask
,
5232 aggregate_address_mask_cmd
,
5233 "aggregate-address A.B.C.D A.B.C.D",
5234 "Configure BGP aggregate entries\n"
5235 "Aggregate address\n"
5239 char prefix_str
[BUFSIZ
];
5241 ret
= netmask_str2prefix_str (argv
[1]->arg
, argv
[2]->arg
, prefix_str
);
5245 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5249 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5253 DEFUN (aggregate_address_summary_only
,
5254 aggregate_address_summary_only_cmd
,
5255 "aggregate-address A.B.C.D/M summary-only",
5256 "Configure BGP aggregate entries\n"
5257 "Aggregate prefix\n"
5258 "Filter more specific routes from updates\n")
5260 return bgp_aggregate_set (vty
, argv
[1]->arg
, AFI_IP
, bgp_node_safi (vty
),
5261 AGGREGATE_SUMMARY_ONLY
, 0);
5264 DEFUN (aggregate_address_mask_summary_only
,
5265 aggregate_address_mask_summary_only_cmd
,
5266 "aggregate-address A.B.C.D A.B.C.D summary-only",
5267 "Configure BGP aggregate entries\n"
5268 "Aggregate address\n"
5270 "Filter more specific routes from updates\n")
5273 char prefix_str
[BUFSIZ
];
5275 ret
= netmask_str2prefix_str (argv
[1]->arg
, argv
[2]->arg
, prefix_str
);
5279 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5283 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5284 AGGREGATE_SUMMARY_ONLY
, 0);
5287 DEFUN (aggregate_address_as_set
,
5288 aggregate_address_as_set_cmd
,
5289 "aggregate-address A.B.C.D/M as-set",
5290 "Configure BGP aggregate entries\n"
5291 "Aggregate prefix\n"
5292 "Generate AS set path information\n")
5294 return bgp_aggregate_set (vty
, argv
[1]->arg
, AFI_IP
, bgp_node_safi (vty
),
5295 0, AGGREGATE_AS_SET
);
5298 DEFUN (aggregate_address_mask_as_set
,
5299 aggregate_address_mask_as_set_cmd
,
5300 "aggregate-address A.B.C.D A.B.C.D as-set",
5301 "Configure BGP aggregate entries\n"
5302 "Aggregate address\n"
5304 "Generate AS set path information\n")
5307 char prefix_str
[BUFSIZ
];
5309 ret
= netmask_str2prefix_str (argv
[1]->arg
, argv
[2]->arg
, prefix_str
);
5313 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5317 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5318 0, AGGREGATE_AS_SET
);
5323 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
5324 * "aggregate-address A.B.C.D/M summary-only as-set",
5325 * "Configure BGP aggregate entries\n"
5326 * "Aggregate prefix\n"
5327 * "Filter more specific routes from updates\n"
5328 * "Generate AS set path information\n"
5331 DEFUN (aggregate_address_as_set_summary
,
5332 aggregate_address_as_set_summary_cmd
,
5333 "aggregate-address A.B.C.D/M as-set summary-only",
5334 "Configure BGP aggregate entries\n"
5335 "Aggregate prefix\n"
5336 "Generate AS set path information\n"
5337 "Filter more specific routes from updates\n")
5339 return bgp_aggregate_set (vty
, argv
[1]->arg
, AFI_IP
, bgp_node_safi (vty
),
5340 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5345 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
5346 * "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5347 * "Configure BGP aggregate entries\n"
5348 * "Aggregate address\n"
5349 * "Aggregate mask\n"
5350 * "Filter more specific routes from updates\n"
5351 * "Generate AS set path information\n"
5354 DEFUN (aggregate_address_mask_as_set_summary
,
5355 aggregate_address_mask_as_set_summary_cmd
,
5356 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5357 "Configure BGP aggregate entries\n"
5358 "Aggregate address\n"
5360 "Generate AS set path information\n"
5361 "Filter more specific routes from updates\n")
5364 char prefix_str
[BUFSIZ
];
5366 ret
= netmask_str2prefix_str (argv
[1]->arg
, argv
[2]->arg
, prefix_str
);
5370 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5374 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5375 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5380 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
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 * "no aggregate-address A.B.C.D/M as-set summary-only",
5389 * "Configure BGP aggregate entries\n"
5390 * "Aggregate prefix\n"
5391 * "Generate AS set path information\n"
5392 * "Filter more specific routes from updates\n"
5394 * "no aggregate-address A.B.C.D/M summary-only as-set",
5396 * "Configure BGP aggregate entries\n"
5397 * "Aggregate prefix\n"
5398 * "Filter more specific routes from updates\n"
5399 * "Generate AS set path information\n"
5401 * "no aggregate-address A.B.C.D/M as-set",
5403 * "Configure BGP aggregate entries\n"
5404 * "Aggregate prefix\n"
5405 * "Generate AS set path information\n"
5408 DEFUN (no_aggregate_address
,
5409 no_aggregate_address_cmd
,
5410 "no aggregate-address A.B.C.D/M",
5412 "Configure BGP aggregate entries\n"
5413 "Aggregate prefix\n")
5415 return bgp_aggregate_unset (vty
, argv
[2]->arg
, AFI_IP
, bgp_node_safi (vty
));
5423 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
5424 * "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5426 * "Configure BGP aggregate entries\n"
5427 * "Aggregate address\n"
5428 * "Aggregate mask\n"
5429 * "Filter more specific routes from updates\n"
5430 * "Generate AS set path information\n"
5432 * "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5434 * "Configure BGP aggregate entries\n"
5435 * "Aggregate address\n"
5436 * "Aggregate mask\n"
5437 * "Generate AS set path information\n"
5438 * "Filter more specific routes from updates\n"
5440 * "no aggregate-address A.B.C.D A.B.C.D summary-only",
5442 * "Configure BGP aggregate entries\n"
5443 * "Aggregate address\n"
5444 * "Aggregate mask\n"
5445 * "Filter more specific routes from updates\n"
5447 * "no aggregate-address A.B.C.D A.B.C.D as-set",
5449 * "Configure BGP aggregate entries\n"
5450 * "Aggregate address\n"
5451 * "Aggregate mask\n"
5452 * "Generate AS set path information\n"
5455 DEFUN (no_aggregate_address_mask
,
5456 no_aggregate_address_mask_cmd
,
5457 "no aggregate-address A.B.C.D A.B.C.D",
5459 "Configure BGP aggregate entries\n"
5460 "Aggregate address\n"
5464 char prefix_str
[BUFSIZ
];
5466 ret
= netmask_str2prefix_str (argv
[2]->arg
, argv
[3]->arg
, prefix_str
);
5470 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5474 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5483 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
5484 * "ipv6 bgp aggregate-address X:X::X:X/M",
5487 * "Configure BGP aggregate entries\n"
5488 * "Aggregate prefix\n"
5491 DEFUN (ipv6_aggregate_address
,
5492 ipv6_aggregate_address_cmd
,
5493 "aggregate-address X:X::X:X/M",
5494 "Configure BGP aggregate entries\n"
5495 "Aggregate prefix\n")
5497 return bgp_aggregate_set (vty
, argv
[1]->arg
, AFI_IP6
, SAFI_UNICAST
, 0, 0);
5501 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
5502 * "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5505 * "Configure BGP aggregate entries\n"
5506 * "Aggregate prefix\n"
5507 * "Filter more specific routes from updates\n"
5510 DEFUN (ipv6_aggregate_address_summary_only
,
5511 ipv6_aggregate_address_summary_only_cmd
,
5512 "aggregate-address X:X::X:X/M summary-only",
5513 "Configure BGP aggregate entries\n"
5514 "Aggregate prefix\n"
5515 "Filter more specific routes from updates\n")
5517 return bgp_aggregate_set (vty
, argv
[1]->arg
, AFI_IP6
, SAFI_UNICAST
,
5518 AGGREGATE_SUMMARY_ONLY
, 0);
5522 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
5523 * "no ipv6 bgp aggregate-address X:X::X:X/M",
5527 * "Configure BGP aggregate entries\n"
5528 * "Aggregate prefix\n"
5531 DEFUN (no_ipv6_aggregate_address
,
5532 no_ipv6_aggregate_address_cmd
,
5533 "no aggregate-address X:X::X:X/M",
5535 "Configure BGP aggregate entries\n"
5536 "Aggregate prefix\n")
5538 return bgp_aggregate_unset (vty
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
);
5542 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
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"
5552 DEFUN (no_ipv6_aggregate_address_summary_only
,
5553 no_ipv6_aggregate_address_summary_only_cmd
,
5554 "no aggregate-address X:X::X:X/M summary-only",
5556 "Configure BGP aggregate entries\n"
5557 "Aggregate prefix\n"
5558 "Filter more specific routes from updates\n")
5560 return bgp_aggregate_unset (vty
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
);
5566 #endif /* HAVE_IPV6 */
5568 /* Redistribute route treatment. */
5570 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5571 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5572 u_int32_t metric
, u_char type
, u_short instance
, u_short tag
)
5574 struct bgp_info
*new;
5575 struct bgp_info
*bi
;
5576 struct bgp_info info
;
5577 struct bgp_node
*bn
;
5579 struct attr
*new_attr
;
5582 struct bgp_redist
*red
;
5584 /* Make default attribute. */
5585 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5587 attr
.nexthop
= *nexthop
;
5588 attr
.nh_ifindex
= ifindex
;
5593 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5594 extra
->mp_nexthop_global
= *nexthop6
;
5595 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5600 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5601 attr
.extra
->tag
= tag
;
5603 afi
= family2afi (p
->family
);
5605 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5608 struct attr attr_new
;
5609 struct attr_extra extra_new
;
5611 /* Copy attribute for modification. */
5612 attr_new
.extra
= &extra_new
;
5613 bgp_attr_dup (&attr_new
, &attr
);
5615 if (red
->redist_metric_flag
)
5616 attr_new
.med
= red
->redist_metric
;
5618 /* Apply route-map. */
5621 info
.peer
= bgp
->peer_self
;
5622 info
.attr
= &attr_new
;
5624 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5626 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5628 bgp
->peer_self
->rmap_type
= 0;
5630 if (ret
== RMAP_DENYMATCH
)
5632 /* Free uninterned attribute. */
5633 bgp_attr_flush (&attr_new
);
5635 /* Unintern original. */
5636 aspath_unintern (&attr
.aspath
);
5637 bgp_attr_extra_free (&attr
);
5638 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5643 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5644 afi
, SAFI_UNICAST
, p
, NULL
);
5646 new_attr
= bgp_attr_intern (&attr_new
);
5648 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5649 if (bi
->peer
== bgp
->peer_self
5650 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5655 /* Ensure the (source route) type is updated. */
5657 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5658 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5660 bgp_attr_unintern (&new_attr
);
5661 aspath_unintern (&attr
.aspath
);
5662 bgp_attr_extra_free (&attr
);
5663 bgp_unlock_node (bn
);
5668 /* The attribute is changed. */
5669 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5671 /* Rewrite BGP route information. */
5672 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5673 bgp_info_restore(bn
, bi
);
5675 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5676 bgp_attr_unintern (&bi
->attr
);
5677 bi
->attr
= new_attr
;
5678 bi
->uptime
= bgp_clock ();
5680 /* Process change. */
5681 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5682 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5683 bgp_unlock_node (bn
);
5684 aspath_unintern (&attr
.aspath
);
5685 bgp_attr_extra_free (&attr
);
5690 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5692 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5694 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5695 bgp_info_add (bn
, new);
5696 bgp_unlock_node (bn
);
5697 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5700 /* Unintern original. */
5701 aspath_unintern (&attr
.aspath
);
5702 bgp_attr_extra_free (&attr
);
5706 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5709 struct bgp_node
*rn
;
5710 struct bgp_info
*ri
;
5711 struct bgp_redist
*red
;
5713 afi
= family2afi (p
->family
);
5715 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5718 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5720 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5721 if (ri
->peer
== bgp
->peer_self
5722 && ri
->type
== type
)
5727 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5728 bgp_info_delete (rn
, ri
);
5729 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5731 bgp_unlock_node (rn
);
5735 /* Withdraw specified route type's route. */
5737 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5739 struct bgp_node
*rn
;
5740 struct bgp_info
*ri
;
5741 struct bgp_table
*table
;
5743 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5745 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5747 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5748 if (ri
->peer
== bgp
->peer_self
5750 && ri
->instance
== instance
)
5755 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5756 bgp_info_delete (rn
, ri
);
5757 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5762 /* Static function to display route. */
5764 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5767 u_int32_t destination
;
5770 if (p
->family
== AF_INET
)
5772 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5773 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5775 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5776 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5777 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5778 || p
->u
.prefix4
.s_addr
== 0)
5780 /* When mask is natural, mask is not displayed. */
5783 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5786 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5791 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5793 vty_out (vty
, "%*s", len
, " ");
5796 enum bgp_display_type
5801 /* Print the short form route status for a bgp_info */
5803 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
5804 json_object
*json_path
)
5809 /* Route status display. */
5810 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5811 json_object_boolean_true_add(json_path
, "removed");
5813 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5814 json_object_boolean_true_add(json_path
, "stale");
5816 if (binfo
->extra
&& binfo
->extra
->suppress
)
5817 json_object_boolean_true_add(json_path
, "suppressed");
5819 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5820 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5821 json_object_boolean_true_add(json_path
, "valid");
5824 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5825 json_object_boolean_true_add(json_path
, "history");
5827 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5828 json_object_boolean_true_add(json_path
, "damped");
5830 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5831 json_object_boolean_true_add(json_path
, "bestpath");
5833 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5834 json_object_boolean_true_add(json_path
, "multipath");
5836 /* Internal route. */
5837 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5838 json_object_string_add(json_path
, "pathFrom", "internal");
5840 json_object_string_add(json_path
, "pathFrom", "external");
5845 /* Route status display. */
5846 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5848 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5850 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5852 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5853 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5859 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5861 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5863 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5865 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5870 /* Internal route. */
5871 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5877 /* called from terminal list command */
5879 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5880 struct bgp_info
*binfo
, int display
, safi_t safi
,
5881 json_object
*json_paths
)
5884 json_object
*json_path
= NULL
;
5885 json_object
*json_nexthops
= NULL
;
5886 json_object
*json_nexthop_global
= NULL
;
5887 json_object
*json_nexthop_ll
= NULL
;
5890 json_path
= json_object_new_object();
5892 /* short status lead text */
5893 route_vty_short_status_out (vty
, binfo
, json_path
);
5897 /* print prefix and mask */
5899 route_vty_out_route (p
, vty
);
5901 vty_out (vty
, "%*s", 17, " ");
5904 /* Print attribute */
5909 * For ENCAP routes, nexthop address family is not
5910 * neccessarily the same as the prefix address family.
5911 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
5913 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
5918 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
5923 vty_out (vty
, "%s", inet_ntop(af
,
5924 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
5928 vty_out (vty
, "%s", inet_ntop(af
,
5929 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
5941 else if (p
->family
== AF_INET
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5945 json_nexthop_global
= json_object_new_object();
5947 if (safi
== SAFI_MPLS_VPN
)
5948 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5950 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
5952 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
5953 json_object_boolean_true_add(json_nexthop_global
, "used");
5957 if (safi
== SAFI_MPLS_VPN
)
5958 vty_out (vty
, "%-16s",
5959 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5961 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5966 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5973 json_nexthop_global
= json_object_new_object();
5974 json_object_string_add(json_nexthop_global
, "ip",
5975 inet_ntop (AF_INET6
,
5976 &attr
->extra
->mp_nexthop_global
,
5978 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
5979 json_object_string_add(json_nexthop_global
, "scope", "global");
5981 /* We display both LL & GL if both have been received */
5982 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5984 json_nexthop_ll
= json_object_new_object();
5985 json_object_string_add(json_nexthop_ll
, "ip",
5986 inet_ntop (AF_INET6
,
5987 &attr
->extra
->mp_nexthop_local
,
5989 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
5990 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
5992 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
5993 &attr
->extra
->mp_nexthop_local
) != 0) &&
5994 !attr
->extra
->mp_nexthop_prefer_global
)
5995 json_object_boolean_true_add(json_nexthop_ll
, "used");
5997 json_object_boolean_true_add(json_nexthop_global
, "used");
6000 json_object_boolean_true_add(json_nexthop_global
, "used");
6004 /* Display LL if LL/Global both in table unless prefer-global is set */
6005 if (((attr
->extra
->mp_nexthop_len
== 32) &&
6006 !attr
->extra
->mp_nexthop_prefer_global
) ||
6007 (binfo
->peer
->conf_if
))
6009 if (binfo
->peer
->conf_if
)
6011 len
= vty_out (vty
, "%s",
6012 binfo
->peer
->conf_if
);
6013 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6016 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6018 vty_out (vty
, "%*s", len
, " ");
6022 len
= vty_out (vty
, "%s",
6023 inet_ntop (AF_INET6
,
6024 &attr
->extra
->mp_nexthop_local
,
6029 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6031 vty_out (vty
, "%*s", len
, " ");
6036 len
= vty_out (vty
, "%s",
6037 inet_ntop (AF_INET6
,
6038 &attr
->extra
->mp_nexthop_global
,
6043 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6045 vty_out (vty
, "%*s", len
, " ");
6051 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6053 json_object_int_add(json_path
, "med", attr
->med
);
6055 vty_out (vty
, "%10u", attr
->med
);
6061 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6063 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6065 vty_out (vty
, "%7u", attr
->local_pref
);
6073 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6075 json_object_int_add(json_path
, "weight", 0);
6078 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6082 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6089 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6091 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6096 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6098 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6103 json_object_string_add(json_path
, "alert", "No attributes");
6105 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6110 if (json_nexthop_global
|| json_nexthop_ll
)
6112 json_nexthops
= json_object_new_array();
6114 if (json_nexthop_global
)
6115 json_object_array_add(json_nexthops
, json_nexthop_global
);
6117 if (json_nexthop_ll
)
6118 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6120 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6123 json_object_array_add(json_paths
, json_path
);
6126 vty_out (vty
, "%s", VTY_NEWLINE
);
6129 /* called from terminal list command */
6131 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6132 u_char use_json
, json_object
*json_ar
)
6134 json_object
*json_status
= NULL
;
6135 json_object
*json_net
= NULL
;
6137 /* Route status display. */
6140 json_status
= json_object_new_object();
6141 json_net
= json_object_new_object();
6150 /* print prefix and mask */
6152 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6154 route_vty_out_route (p
, vty
);
6156 /* Print attribute */
6161 if (p
->family
== AF_INET
&&
6162 (safi
== SAFI_MPLS_VPN
||
6163 safi
== SAFI_ENCAP
||
6164 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6166 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6167 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6169 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6172 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6176 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6179 #endif /* HAVE_IPV6 */
6181 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6182 json_object_int_add(json_net
, "metric", attr
->med
);
6184 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6185 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6188 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6190 json_object_int_add(json_net
, "weight", 0);
6194 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6197 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6201 if (p
->family
== AF_INET
&&
6202 (safi
== SAFI_MPLS_VPN
||
6203 safi
== SAFI_ENCAP
||
6204 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6206 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6207 vty_out (vty
, "%-16s",
6208 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6210 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6213 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6218 assert (attr
->extra
);
6220 len
= vty_out (vty
, "%s",
6221 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6225 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6227 vty_out (vty
, "%*s", len
, " ");
6229 #endif /* HAVE_IPV6 */
6230 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6231 vty_out (vty
, "%10u", attr
->med
);
6235 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6236 vty_out (vty
, "%7u", attr
->local_pref
);
6240 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6244 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6247 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6252 json_object_boolean_true_add(json_status
, "*");
6253 json_object_boolean_true_add(json_status
, ">");
6254 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6255 char buf_cut
[BUFSIZ
];
6256 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6259 vty_out (vty
, "%s", VTY_NEWLINE
);
6263 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6264 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6266 json_object
*json_out
= NULL
;
6268 u_int32_t label
= 0;
6274 json_out
= json_object_new_object();
6276 /* short status lead text */
6277 route_vty_short_status_out (vty
, binfo
, json_out
);
6279 /* print prefix and mask */
6283 route_vty_out_route (p
, vty
);
6285 vty_out (vty
, "%*s", 17, " ");
6288 /* Print attribute */
6292 if (p
->family
== AF_INET
6293 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6295 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6298 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6300 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6305 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6307 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6311 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6313 assert (attr
->extra
);
6317 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6320 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6321 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6324 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6327 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6331 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6333 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6335 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6336 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6339 vty_out (vty
, "%s(%s)",
6340 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6342 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6347 #endif /* HAVE_IPV6 */
6350 label
= decode_label (binfo
->extra
->tag
);
6355 json_object_int_add(json_out
, "notag", label
);
6356 json_object_array_add(json
, json_out
);
6360 vty_out (vty
, "notag/%d", label
);
6361 vty_out (vty
, "%s", VTY_NEWLINE
);
6365 /* dampening route */
6367 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6368 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6372 char timebuf
[BGP_UPTIME_LEN
];
6374 /* short status lead text */
6375 route_vty_short_status_out (vty
, binfo
, json
);
6377 /* print prefix and mask */
6381 route_vty_out_route (p
, vty
);
6383 vty_out (vty
, "%*s", 17, " ");
6386 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6391 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6396 json_object_int_add(json
, "peerHost", len
);
6398 vty_out (vty
, "%*s", len
, " ");
6402 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6404 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6406 /* Print attribute */
6414 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6416 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6421 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6423 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6426 vty_out (vty
, "%s", VTY_NEWLINE
);
6431 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6432 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6435 struct bgp_damp_info
*bdi
;
6436 char timebuf
[BGP_UPTIME_LEN
];
6442 bdi
= binfo
->extra
->damp_info
;
6444 /* short status lead text */
6445 route_vty_short_status_out (vty
, binfo
, json
);
6447 /* print prefix and mask */
6451 route_vty_out_route (p
, vty
);
6453 vty_out (vty
, "%*s", 17, " ");
6456 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6461 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6466 json_object_int_add(json
, "peerHost", len
);
6468 vty_out (vty
, "%*s", len
, " ");
6471 len
= vty_out (vty
, "%d", bdi
->flap
);
6481 json_object_int_add(json
, "bdiFlap", len
);
6483 vty_out (vty
, "%*s", len
, " ");
6487 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6489 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6490 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6492 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6493 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6496 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6498 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6503 vty_out (vty
, "%*s ", 8, " ");
6506 /* Print attribute */
6514 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6516 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6521 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6523 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6526 vty_out (vty
, "%s", VTY_NEWLINE
);
6530 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6531 const char *header
, json_object
*json_adv_to
)
6533 char buf1
[INET6_ADDRSTRLEN
];
6534 json_object
*json_peer
= NULL
;
6538 /* 'advertised-to' is a dictionary of peers we have advertised this
6539 * prefix too. The key is the peer's IP or swpX, the value is the
6540 * hostname if we know it and "" if not.
6542 json_peer
= json_object_new_object();
6545 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6548 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6550 json_object_object_add(json_adv_to
,
6551 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6558 vty_out (vty
, "%s", header
);
6562 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6565 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6567 vty_out (vty
, " %s(%s)", peer
->hostname
,
6568 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6573 vty_out (vty
, " %s", peer
->conf_if
);
6575 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6581 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6582 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6583 json_object
*json_paths
)
6585 char buf
[INET6_ADDRSTRLEN
];
6588 int sockunion_vty_out (struct vty
*, union sockunion
*);
6589 #ifdef HAVE_CLOCK_MONOTONIC
6592 json_object
*json_bestpath
= NULL
;
6593 json_object
*json_cluster_list
= NULL
;
6594 json_object
*json_cluster_list_list
= NULL
;
6595 json_object
*json_ext_community
= NULL
;
6596 json_object
*json_last_update
= NULL
;
6597 json_object
*json_nexthop_global
= NULL
;
6598 json_object
*json_nexthop_ll
= NULL
;
6599 json_object
*json_nexthops
= NULL
;
6600 json_object
*json_path
= NULL
;
6601 json_object
*json_peer
= NULL
;
6602 json_object
*json_string
= NULL
;
6603 json_object
*json_adv_to
= NULL
;
6605 struct listnode
*node
, *nnode
;
6607 int addpath_capable
;
6613 json_path
= json_object_new_object();
6614 json_peer
= json_object_new_object();
6615 json_nexthop_global
= json_object_new_object();
6622 /* Line1 display AS-path, Aggregator */
6627 json_object_lock(attr
->aspath
->json
);
6628 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6632 if (attr
->aspath
->segments
)
6633 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6635 vty_out (vty
, " Local");
6639 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6642 json_object_boolean_true_add(json_path
, "removed");
6644 vty_out (vty
, ", (removed)");
6647 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6650 json_object_boolean_true_add(json_path
, "stale");
6652 vty_out (vty
, ", (stale)");
6655 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6659 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6660 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6664 vty_out (vty
, ", (aggregated by %u %s)",
6665 attr
->extra
->aggregator_as
,
6666 inet_ntoa (attr
->extra
->aggregator_addr
));
6670 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6673 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6675 vty_out (vty
, ", (Received from a RR-client)");
6678 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6681 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6683 vty_out (vty
, ", (Received from a RS-client)");
6686 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6689 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6691 vty_out (vty
, ", (history entry)");
6693 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6696 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6698 vty_out (vty
, ", (suppressed due to dampening)");
6702 vty_out (vty
, "%s", VTY_NEWLINE
);
6704 /* Line2 display Next-hop, Neighbor, Router-id */
6705 /* Display the nexthop */
6706 if (p
->family
== AF_INET
&&
6707 (safi
== SAFI_MPLS_VPN
||
6708 safi
== SAFI_ENCAP
||
6709 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6711 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6714 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6716 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6721 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6723 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6727 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6731 assert (attr
->extra
);
6734 json_object_string_add(json_nexthop_global
, "ip",
6735 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6736 buf
, INET6_ADDRSTRLEN
));
6737 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6738 json_object_string_add(json_nexthop_global
, "scope", "global");
6742 vty_out (vty
, " %s",
6743 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6744 buf
, INET6_ADDRSTRLEN
));
6748 /* Display the IGP cost or 'inaccessible' */
6749 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6752 json_object_boolean_false_add(json_nexthop_global
, "accessible");
6754 vty_out (vty
, " (inaccessible)");
6758 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6761 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
6763 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
6766 /* IGP cost is 0, display this only for json */
6770 json_object_int_add(json_nexthop_global
, "metric", 0);
6774 json_object_boolean_true_add(json_nexthop_global
, "accessible");
6777 /* Display peer "from" output */
6778 /* This path was originated locally */
6779 if (binfo
->peer
== bgp
->peer_self
)
6782 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6785 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
6787 vty_out (vty
, " from 0.0.0.0 ");
6792 json_object_string_add(json_peer
, "peerId", "::");
6794 vty_out (vty
, " from :: ");
6798 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
6800 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
6803 /* We RXed this path from one of our peers */
6809 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6810 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6812 if (binfo
->peer
->hostname
)
6813 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
6815 if (binfo
->peer
->domainname
)
6816 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
6818 if (binfo
->peer
->conf_if
)
6819 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
6823 if (binfo
->peer
->conf_if
)
6825 if (binfo
->peer
->hostname
&&
6826 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6827 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6828 binfo
->peer
->conf_if
);
6830 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
6834 if (binfo
->peer
->hostname
&&
6835 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6836 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6839 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6842 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6843 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6845 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6850 vty_out (vty
, "%s", VTY_NEWLINE
);
6852 /* display the link-local nexthop */
6853 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6857 json_nexthop_ll
= json_object_new_object();
6858 json_object_string_add(json_nexthop_ll
, "ip",
6859 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6860 buf
, INET6_ADDRSTRLEN
));
6861 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6862 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6864 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
6866 if (!attr
->extra
->mp_nexthop_prefer_global
)
6867 json_object_boolean_true_add(json_nexthop_ll
, "used");
6869 json_object_boolean_true_add(json_nexthop_global
, "used");
6873 vty_out (vty
, " (%s) %s%s",
6874 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6875 buf
, INET6_ADDRSTRLEN
),
6876 attr
->extra
->mp_nexthop_prefer_global
?
6877 "(prefer-global)" : "(used)",
6881 /* If we do not have a link-local nexthop then we must flag the global as "used" */
6885 json_object_boolean_true_add(json_nexthop_global
, "used");
6888 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
6890 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6892 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6894 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6897 json_object_int_add(json_path
, "med", attr
->med
);
6899 vty_out (vty
, ", metric %u", attr
->med
);
6902 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6905 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6907 vty_out (vty
, ", localpref %u", attr
->local_pref
);
6912 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
6914 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
6917 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6920 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6922 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
6925 if (attr
->extra
&& attr
->extra
->tag
!= 0)
6928 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
6930 vty_out (vty
, ", tag %d", attr
->extra
->tag
);
6933 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6936 json_object_boolean_false_add(json_path
, "valid");
6938 vty_out (vty
, ", invalid");
6940 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6943 json_object_boolean_true_add(json_path
, "valid");
6945 vty_out (vty
, ", valid");
6948 if (binfo
->peer
!= bgp
->peer_self
)
6950 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6952 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
6955 json_object_string_add(json_peer
, "type", "confed-internal");
6957 vty_out (vty
, ", confed-internal");
6962 json_object_string_add(json_peer
, "type", "internal");
6964 vty_out (vty
, ", internal");
6969 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
6972 json_object_string_add(json_peer
, "type", "confed-external");
6974 vty_out (vty
, ", confed-external");
6979 json_object_string_add(json_peer
, "type", "external");
6981 vty_out (vty
, ", external");
6985 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6989 json_object_boolean_true_add(json_path
, "aggregated");
6990 json_object_boolean_true_add(json_path
, "local");
6994 vty_out (vty
, ", aggregated, local");
6997 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
7000 json_object_boolean_true_add(json_path
, "sourced");
7002 vty_out (vty
, ", sourced");
7008 json_object_boolean_true_add(json_path
, "sourced");
7009 json_object_boolean_true_add(json_path
, "local");
7013 vty_out (vty
, ", sourced, local");
7017 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7020 json_object_boolean_true_add(json_path
, "atomicAggregate");
7022 vty_out (vty
, ", atomic-aggregate");
7025 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7026 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7027 bgp_info_mpath_count (binfo
)))
7030 json_object_boolean_true_add(json_path
, "multipath");
7032 vty_out (vty
, ", multipath");
7035 // Mark the bestpath(s)
7036 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7038 first_as
= aspath_get_firstas(attr
->aspath
);
7043 json_bestpath
= json_object_new_object();
7044 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7049 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7051 vty_out (vty
, ", bestpath-from-AS Local");
7055 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7060 json_bestpath
= json_object_new_object();
7061 json_object_boolean_true_add(json_bestpath
, "overall");
7064 vty_out (vty
, ", best");
7068 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7071 vty_out (vty
, "%s", VTY_NEWLINE
);
7073 /* Line 4 display Community */
7074 if (attr
->community
)
7078 json_object_lock(attr
->community
->json
);
7079 json_object_object_add(json_path
, "community", attr
->community
->json
);
7083 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7088 /* Line 5 display Extended-community */
7089 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7093 json_ext_community
= json_object_new_object();
7094 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7095 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7099 vty_out (vty
, " Extended Community: %s%s",
7100 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7104 /* Line 6 display Originator, Cluster-id */
7105 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7106 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7108 assert (attr
->extra
);
7109 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7112 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7114 vty_out (vty
, " Originator: %s",
7115 inet_ntoa (attr
->extra
->originator_id
));
7118 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7124 json_cluster_list
= json_object_new_object();
7125 json_cluster_list_list
= json_object_new_array();
7127 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7129 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7130 json_object_array_add(json_cluster_list_list
, json_string
);
7133 /* struct cluster_list does not have "str" variable like
7134 * aspath and community do. Add this someday if someone
7136 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7138 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7139 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7143 vty_out (vty
, ", Cluster list: ");
7145 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7147 vty_out (vty
, "%s ",
7148 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7154 vty_out (vty
, "%s", VTY_NEWLINE
);
7157 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7158 bgp_damp_info_vty (vty
, binfo
, json_path
);
7160 /* Line 7 display Addpath IDs */
7161 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7165 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7166 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7170 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7171 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7176 /* If we used addpath to TX a non-bestpath we need to display
7177 * "Advertised to" on a path-by-path basis */
7178 if (bgp
->addpath_tx_used
[afi
][safi
])
7182 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7184 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7185 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7187 if ((addpath_capable
&& has_adj
) ||
7188 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7190 if (json_path
&& !json_adv_to
)
7191 json_adv_to
= json_object_new_object();
7193 route_vty_out_advertised_to(vty
, peer
, &first
,
7203 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7210 vty_out (vty
, "%s", VTY_NEWLINE
);
7215 /* Line 8 display Uptime */
7216 #ifdef HAVE_CLOCK_MONOTONIC
7217 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7220 json_last_update
= json_object_new_object();
7221 json_object_int_add(json_last_update
, "epoch", tbuf
);
7222 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7223 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7226 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7230 json_last_update
= json_object_new_object();
7231 json_object_int_add(json_last_update
, "epoch", tbuf
);
7232 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7233 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7236 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7237 #endif /* HAVE_CLOCK_MONOTONIC */
7240 /* We've constructed the json object for this path, add it to the json
7245 if (json_nexthop_global
|| json_nexthop_ll
)
7247 json_nexthops
= json_object_new_array();
7249 if (json_nexthop_global
)
7250 json_object_array_add(json_nexthops
, json_nexthop_global
);
7252 if (json_nexthop_ll
)
7253 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7255 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7258 json_object_object_add(json_path
, "peer", json_peer
);
7259 json_object_array_add(json_paths
, json_path
);
7262 vty_out (vty
, "%s", VTY_NEWLINE
);
7265 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7266 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7267 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7271 bgp_show_type_normal
,
7272 bgp_show_type_regexp
,
7273 bgp_show_type_prefix_list
,
7274 bgp_show_type_filter_list
,
7275 bgp_show_type_route_map
,
7276 bgp_show_type_neighbor
,
7277 bgp_show_type_cidr_only
,
7278 bgp_show_type_prefix_longer
,
7279 bgp_show_type_community_all
,
7280 bgp_show_type_community
,
7281 bgp_show_type_community_exact
,
7282 bgp_show_type_community_list
,
7283 bgp_show_type_community_list_exact
,
7284 bgp_show_type_flap_statistics
,
7285 bgp_show_type_flap_address
,
7286 bgp_show_type_flap_prefix
,
7287 bgp_show_type_flap_cidr_only
,
7288 bgp_show_type_flap_regexp
,
7289 bgp_show_type_flap_filter_list
,
7290 bgp_show_type_flap_prefix_list
,
7291 bgp_show_type_flap_prefix_longer
,
7292 bgp_show_type_flap_route_map
,
7293 bgp_show_type_flap_neighbor
,
7294 bgp_show_type_dampend_paths
,
7295 bgp_show_type_damp_neighbor
7299 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7300 const char *prefix_list_str
, afi_t afi
,
7301 safi_t safi
, enum bgp_show_type type
);
7303 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7304 const char *filter
, afi_t afi
,
7305 safi_t safi
, enum bgp_show_type type
);
7307 bgp_show_route_map (struct vty
*vty
, const char *name
,
7308 const char *rmap_str
, afi_t afi
,
7309 safi_t safi
, enum bgp_show_type type
);
7311 bgp_show_community_list (struct vty
*vty
, const char *name
,
7312 const char *com
, int exact
,
7313 afi_t afi
, safi_t safi
);
7315 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7316 const char *prefix
, afi_t afi
,
7317 safi_t safi
, enum bgp_show_type type
);
7320 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
,
7321 struct in_addr
*router_id
, enum bgp_show_type type
,
7322 void *output_arg
, u_char use_json
, json_object
*json
)
7324 struct bgp_info
*ri
;
7325 struct bgp_node
*rn
;
7328 unsigned long output_count
;
7332 json_object
*json_paths
= NULL
;
7333 json_object
*json_routes
= NULL
;
7338 json
= json_object_new_object();
7340 json_object_int_add(json
, "tableVersion", table
->version
);
7341 json_object_string_add(json
, "routerId", inet_ntoa (*router_id
));
7342 json_routes
= json_object_new_object();
7345 /* This is first entry point, so reset total line. */
7348 /* Start processing of routes. */
7349 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7350 if (rn
->info
!= NULL
)
7355 json_paths
= json_object_new_array();
7359 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7361 if (type
== bgp_show_type_flap_statistics
7362 || type
== bgp_show_type_flap_address
7363 || type
== bgp_show_type_flap_prefix
7364 || type
== bgp_show_type_flap_cidr_only
7365 || type
== bgp_show_type_flap_regexp
7366 || type
== bgp_show_type_flap_filter_list
7367 || type
== bgp_show_type_flap_prefix_list
7368 || type
== bgp_show_type_flap_prefix_longer
7369 || type
== bgp_show_type_flap_route_map
7370 || type
== bgp_show_type_flap_neighbor
7371 || type
== bgp_show_type_dampend_paths
7372 || type
== bgp_show_type_damp_neighbor
)
7374 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7377 if (type
== bgp_show_type_regexp
7378 || type
== bgp_show_type_flap_regexp
)
7380 regex_t
*regex
= output_arg
;
7382 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7385 if (type
== bgp_show_type_prefix_list
7386 || type
== bgp_show_type_flap_prefix_list
)
7388 struct prefix_list
*plist
= output_arg
;
7390 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7393 if (type
== bgp_show_type_filter_list
7394 || type
== bgp_show_type_flap_filter_list
)
7396 struct as_list
*as_list
= output_arg
;
7398 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7401 if (type
== bgp_show_type_route_map
7402 || type
== bgp_show_type_flap_route_map
)
7404 struct route_map
*rmap
= output_arg
;
7405 struct bgp_info binfo
;
7406 struct attr dummy_attr
;
7407 struct attr_extra dummy_extra
;
7410 dummy_attr
.extra
= &dummy_extra
;
7411 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7413 binfo
.peer
= ri
->peer
;
7414 binfo
.attr
= &dummy_attr
;
7416 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7417 if (ret
== RMAP_DENYMATCH
)
7420 if (type
== bgp_show_type_neighbor
7421 || type
== bgp_show_type_flap_neighbor
7422 || type
== bgp_show_type_damp_neighbor
)
7424 union sockunion
*su
= output_arg
;
7426 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7429 if (type
== bgp_show_type_cidr_only
7430 || type
== bgp_show_type_flap_cidr_only
)
7432 u_int32_t destination
;
7434 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7435 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7437 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7439 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7442 if (type
== bgp_show_type_prefix_longer
7443 || type
== bgp_show_type_flap_prefix_longer
)
7445 struct prefix
*p
= output_arg
;
7447 if (! prefix_match (p
, &rn
->p
))
7450 if (type
== bgp_show_type_community_all
)
7452 if (! ri
->attr
->community
)
7455 if (type
== bgp_show_type_community
)
7457 struct community
*com
= output_arg
;
7459 if (! ri
->attr
->community
||
7460 ! community_match (ri
->attr
->community
, com
))
7463 if (type
== bgp_show_type_community_exact
)
7465 struct community
*com
= output_arg
;
7467 if (! ri
->attr
->community
||
7468 ! community_cmp (ri
->attr
->community
, com
))
7471 if (type
== bgp_show_type_community_list
)
7473 struct community_list
*list
= output_arg
;
7475 if (! community_list_match (ri
->attr
->community
, list
))
7478 if (type
== bgp_show_type_community_list_exact
)
7480 struct community_list
*list
= output_arg
;
7482 if (! community_list_exact_match (ri
->attr
->community
, list
))
7485 if (type
== bgp_show_type_flap_address
7486 || type
== bgp_show_type_flap_prefix
)
7488 struct prefix
*p
= output_arg
;
7490 if (! prefix_match (&rn
->p
, p
))
7493 if (type
== bgp_show_type_flap_prefix
)
7494 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7497 if (type
== bgp_show_type_dampend_paths
7498 || type
== bgp_show_type_damp_neighbor
)
7500 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7501 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7505 if (!use_json
&& header
)
7507 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (*router_id
), VTY_NEWLINE
);
7508 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7509 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7510 if (type
== bgp_show_type_dampend_paths
7511 || type
== bgp_show_type_damp_neighbor
)
7512 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7513 else if (type
== bgp_show_type_flap_statistics
7514 || type
== bgp_show_type_flap_address
7515 || type
== bgp_show_type_flap_prefix
7516 || type
== bgp_show_type_flap_cidr_only
7517 || type
== bgp_show_type_flap_regexp
7518 || type
== bgp_show_type_flap_filter_list
7519 || type
== bgp_show_type_flap_prefix_list
7520 || type
== bgp_show_type_flap_prefix_longer
7521 || type
== bgp_show_type_flap_route_map
7522 || type
== bgp_show_type_flap_neighbor
)
7523 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7525 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7529 if (type
== bgp_show_type_dampend_paths
7530 || type
== bgp_show_type_damp_neighbor
)
7531 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7532 else if (type
== bgp_show_type_flap_statistics
7533 || type
== bgp_show_type_flap_address
7534 || type
== bgp_show_type_flap_prefix
7535 || type
== bgp_show_type_flap_cidr_only
7536 || type
== bgp_show_type_flap_regexp
7537 || type
== bgp_show_type_flap_filter_list
7538 || type
== bgp_show_type_flap_prefix_list
7539 || type
== bgp_show_type_flap_prefix_longer
7540 || type
== bgp_show_type_flap_route_map
7541 || type
== bgp_show_type_flap_neighbor
)
7542 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7544 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7554 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7555 json_object_object_add(json_routes
, buf2
, json_paths
);
7562 json_object_object_add(json
, "routes", json_routes
);
7563 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7564 json_object_free(json
);
7568 /* No route is displayed */
7569 if (output_count
== 0)
7571 if (type
== bgp_show_type_normal
)
7572 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
7575 vty_out (vty
, "%sTotal number of prefixes %ld%s",
7576 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
7583 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7584 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7586 struct bgp_table
*table
;
7590 bgp
= bgp_get_default ();
7596 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7600 table
= bgp
->rib
[afi
][safi
];
7602 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
,
7607 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7610 struct listnode
*node
, *nnode
;
7612 struct bgp_table
*table
;
7613 json_object
*json
= NULL
;
7617 vty_out (vty
, "{%s", VTY_NEWLINE
);
7619 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7623 if (!(json
= json_object_new_object()))
7625 zlog_err("Unable to allocate memory for JSON object");
7627 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
7631 json_object_int_add(json
, "vrfId",
7632 (bgp
->vrf_id
== VRF_UNKNOWN
)
7633 ? -1 : bgp
->vrf_id
);
7634 json_object_string_add(json
, "vrfName",
7635 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7636 ? "Default" : bgp
->name
);
7638 vty_out (vty
, ",%s", VTY_NEWLINE
);
7642 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7643 ? "Default" : bgp
->name
);
7647 vty_out (vty
, "%sInstance %s:%s",
7649 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7650 ? "Default" : bgp
->name
,
7653 table
= bgp
->rib
[afi
][safi
];
7654 bgp_show_table (vty
, table
, &bgp
->router_id
,
7655 bgp_show_type_normal
, NULL
, use_json
, json
);
7660 vty_out (vty
, "}%s", VTY_NEWLINE
);
7663 /* Header of detailed BGP route information */
7665 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7666 struct bgp_node
*rn
,
7667 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7670 struct bgp_info
*ri
;
7673 struct listnode
*node
, *nnode
;
7674 char buf1
[INET6_ADDRSTRLEN
];
7675 char buf2
[INET6_ADDRSTRLEN
];
7680 int no_advertise
= 0;
7683 json_object
*json_adv_to
= NULL
;
7689 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7690 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7694 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7695 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7696 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7697 safi
== SAFI_MPLS_VPN
? ":" : "",
7698 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7699 p
->prefixlen
, VTY_NEWLINE
);
7702 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7705 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7708 if (ri
->extra
&& ri
->extra
->suppress
)
7710 if (ri
->attr
->community
!= NULL
)
7712 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7714 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7716 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7724 vty_out (vty
, "Paths: (%d available", count
);
7727 vty_out (vty
, ", best #%d", best
);
7728 if (safi
== SAFI_UNICAST
)
7729 vty_out (vty
, ", table %s",
7730 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7731 ? "Default-IP-Routing-Table" : bgp
->name
);
7734 vty_out (vty
, ", no best path");
7737 vty_out (vty
, ", not advertised to any peer");
7739 vty_out (vty
, ", not advertised to EBGP peer");
7741 vty_out (vty
, ", not advertised outside local AS");
7744 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7745 vty_out (vty
, ")%s", VTY_NEWLINE
);
7748 /* If we are not using addpath then we can display Advertised to and that will
7749 * show what peers we advertised the bestpath to. If we are using addpath
7750 * though then we must display Advertised to on a path-by-path basis. */
7751 if (!bgp
->addpath_tx_used
[afi
][safi
])
7753 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7755 if (bgp_adj_out_lookup (peer
, rn
, 0))
7757 if (json
&& !json_adv_to
)
7758 json_adv_to
= json_object_new_object();
7760 route_vty_out_advertised_to(vty
, peer
, &first
,
7761 " Advertised to non peer-group peers:\n ",
7770 json_object_object_add(json
, "advertisedTo", json_adv_to
);
7776 vty_out (vty
, " Not advertised to any peer");
7777 vty_out (vty
, "%s", VTY_NEWLINE
);
7782 /* Display specified route of BGP table. */
7784 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
7785 struct bgp_table
*rib
, const char *ip_str
,
7786 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7787 int prefix_check
, enum bgp_path_type pathtype
,
7793 struct prefix match
;
7794 struct bgp_node
*rn
;
7795 struct bgp_node
*rm
;
7796 struct bgp_info
*ri
;
7797 struct bgp_table
*table
;
7798 json_object
*json
= NULL
;
7799 json_object
*json_paths
= NULL
;
7801 /* Check IP address argument. */
7802 ret
= str2prefix (ip_str
, &match
);
7805 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
7809 match
.family
= afi2family (afi
);
7813 json
= json_object_new_object();
7814 json_paths
= json_object_new_array();
7817 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
7819 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
7821 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
7824 if ((table
= rn
->info
) != NULL
)
7828 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
7830 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
7832 bgp_unlock_node (rm
);
7836 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
7840 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
7841 AFI_IP
, safi
, json
);
7846 if (pathtype
== BGP_PATH_ALL
||
7847 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7848 (pathtype
== BGP_PATH_MULTIPATH
&&
7849 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7850 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
7853 bgp_unlock_node (rm
);
7862 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
7864 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
7866 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7870 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
7875 if (pathtype
== BGP_PATH_ALL
||
7876 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7877 (pathtype
== BGP_PATH_MULTIPATH
&&
7878 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7879 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
7883 bgp_unlock_node (rn
);
7890 json_object_object_add(json
, "paths", json_paths
);
7892 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7893 json_object_free(json
);
7899 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
7907 /* Display specified route of Main RIB */
7909 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
7910 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7911 int prefix_check
, enum bgp_path_type pathtype
,
7916 /* BGP structure lookup. */
7919 bgp
= bgp_lookup_by_name (view_name
);
7922 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
7928 bgp
= bgp_get_default ();
7931 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7936 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
7937 afi
, safi
, prd
, prefix_check
, pathtype
,
7941 /* BGP route print out function. */
7944 "show ip bgp {json}",
7948 "JavaScript Object Notation\n")
7950 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7954 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
7955 * "show bgp ipv4 (unicast|multicast) {json}",
7958 * "Address family\n"
7959 * "Address Family modifier\n"
7960 * "Address Family modifier\n"
7961 * "JavaScript Object Notation\n"
7964 DEFUN (show_ip_bgp_ipv4
,
7965 show_ip_bgp_ipv4_cmd
,
7966 "show ip bgp ipv4 (unicast|multicast) {json}",
7971 "Address Family modifier\n"
7972 "Address Family modifier\n"
7973 "JavaScript Object Notation\n")
7975 u_char uj
= use_json(argc
, argv
);
7977 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
7978 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
7981 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
7985 DEFUN (show_ip_bgp_route
,
7986 show_ip_bgp_route_cmd
,
7987 "show ip bgp A.B.C.D {json}",
7991 "Network in the BGP routing table to display\n"
7992 "JavaScript Object Notation\n")
7994 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7997 DEFUN (show_ip_bgp_route_pathtype
,
7998 show_ip_bgp_route_pathtype_cmd
,
7999 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
8003 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8004 "Display only the bestpath\n"
8005 "Display only multipaths\n"
8006 "JavaScript Object Notation\n")
8008 u_char uj
= use_json(argc
, argv
);
8010 if (strncmp (argv
[4]->arg
, "b", 1) == 0)
8011 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8013 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8016 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
8017 show_bgp_ipv4_safi_route_pathtype_cmd
,
8018 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
8022 "Address Family modifier\n"
8023 "Address Family modifier\n"
8024 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8025 "Display only the bestpath\n"
8026 "Display only multipaths\n"
8027 "JavaScript Object Notation\n")
8029 u_char uj
= use_json(argc
, argv
);
8031 if (strncmp (argv
[3]->arg
, "m", 1) == 0)
8032 if (strncmp (argv
[5]->arg
, "b", 1) == 0)
8033 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8035 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8037 if (strncmp (argv
[5]->arg
, "b", 1) == 0)
8038 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8040 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8043 DEFUN (show_bgp_ipv4_prefix
,
8044 show_bgp_ipv4_prefix_cmd
,
8045 "show bgp ipv4 A.B.C.D/M {json}",
8049 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8052 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8055 DEFUN (show_bgp_ipv6_route
,
8056 show_bgp_ipv6_route_cmd
,
8057 "show bgp ipv6 X:X::X:X {JSON}",
8061 "Network in the BGP routing table to display\n"
8064 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8067 DEFUN (show_bgp_ipv6_prefix
,
8068 show_bgp_ipv6_prefix_cmd
,
8069 "show bgp ipv6 X:X::X:X/M {json}",
8073 "IPv6 prefix <network>/<length>\n"
8076 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
,argv
));
8080 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8081 * "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
8084 * "Address family\n"
8085 * "Address Family modifier\n"
8086 * "Address Family modifier\n"
8087 * "Network in the BGP routing table to display\n"
8088 * "JavaScript Object Notation\n"
8091 DEFUN (show_ip_bgp_ipv4_route
,
8092 show_ip_bgp_ipv4_route_cmd
,
8093 "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
8098 "Address Family modifier\n"
8099 "Address Family modifier\n"
8100 "Network in the BGP routing table to display\n"
8101 "JavaScript Object Notation\n")
8103 u_char uj
= use_json(argc
, argv
);
8105 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
8106 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8108 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8112 DEFUN (show_ip_bgp_vpnv4_all_route
,
8113 show_ip_bgp_vpnv4_all_route_cmd
,
8114 "show ip bgp vpnv4 all A.B.C.D {json}",
8118 "Display VPNv4 NLRI specific information\n"
8119 "Display information about all VPNv4 NLRIs\n"
8120 "Network in the BGP routing table to display\n"
8121 "JavaScript Object Notation\n")
8123 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8126 DEFUN (show_bgp_ipv4_vpn_route
,
8127 show_bgp_ipv4_vpn_route_cmd
,
8128 "show bgp ipv4 vpn A.B.C.D {json}",
8132 "Display VPN NLRI specific information\n"
8133 "Network in the BGP routing table to display\n"
8136 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8139 DEFUN (show_bgp_ipv6_vpn_route
,
8140 show_bgp_ipv6_vpn_route_cmd
,
8141 "show bgp ipv6 vpn X:X::X:X {json}",
8145 "Display VPN NLRI specific information\n"
8146 "Network in the BGP routing table to display\n"
8149 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8152 DEFUN (show_bgp_ipv4_vpn_rd_route
,
8153 show_bgp_ipv4_vpn_rd_route_cmd
,
8154 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8158 "Display VPN NLRI specific information\n"
8159 "Display information for a route distinguisher\n"
8160 "VPN Route Distinguisher\n"
8161 "Network in the BGP routing table to display\n"
8165 struct prefix_rd prd
;
8167 ret
= str2prefix_rd (argv
[5]->arg
, &prd
);
8170 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8173 return bgp_show_route (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8176 DEFUN (show_bgp_ipv6_vpn_rd_route
,
8177 show_bgp_ipv6_vpn_rd_route_cmd
,
8178 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
8182 "Display VPN NLRI specific information\n"
8183 "Display information for a route distinguisher\n"
8184 "VPN Route Distinguisher\n"
8185 "Network in the BGP routing table to display\n"
8189 struct prefix_rd prd
;
8191 ret
= str2prefix_rd (argv
[5]->arg
, &prd
);
8194 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8197 return bgp_show_route (vty
, NULL
, argv
[6]->arg
, AFI_IP6
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8200 DEFUN (show_ip_bgp_vpnv4_rd_route
,
8201 show_ip_bgp_vpnv4_rd_route_cmd
,
8202 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8206 "Display VPNv4 NLRI specific information\n"
8207 "Display information for a route distinguisher\n"
8208 "VPN Route Distinguisher\n"
8209 "Network in the BGP routing table to display\n"
8210 "JavaScript Object Notation\n")
8213 struct prefix_rd prd
;
8214 u_char uj
= use_json(argc
, argv
);
8216 ret
= str2prefix_rd (argv
[5]->arg
, &prd
);
8219 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8222 return bgp_show_route (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, uj
);
8225 DEFUN (show_ip_bgp_prefix
,
8226 show_ip_bgp_prefix_cmd
,
8227 "show ip bgp A.B.C.D/M {json}",
8231 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8232 "JavaScript Object Notation\n")
8234 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8237 DEFUN (show_ip_bgp_prefix_pathtype
,
8238 show_ip_bgp_prefix_pathtype_cmd
,
8239 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8243 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8244 "Display only the bestpath\n"
8245 "Display only multipaths\n"
8246 "JavaScript Object Notation\n")
8248 u_char uj
= use_json(argc
, argv
);
8249 if (strncmp (argv
[4]->arg
, "b", 1) == 0)
8250 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8252 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8256 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8257 * "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8260 * "Address family\n"
8261 * "Address Family modifier\n"
8262 * "Address Family modifier\n"
8263 * "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8264 * "JavaScript Object Notation\n"
8267 DEFUN (show_ip_bgp_ipv4_prefix
,
8268 show_ip_bgp_ipv4_prefix_cmd
,
8269 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8274 "Address Family modifier\n"
8275 "Address Family modifier\n"
8276 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8277 "JavaScript Object Notation\n")
8279 u_char uj
= use_json(argc
, argv
);
8281 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
8282 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8284 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8289 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8290 * "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8293 * "Address family\n"
8294 * "Address Family modifier\n"
8295 * "Address Family modifier\n"
8296 * "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8297 * "Display only the bestpath\n"
8298 * "Display only multipaths\n"
8299 * "JavaScript Object Notation\n"
8302 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8303 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8304 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8309 "Address Family modifier\n"
8310 "Address Family modifier\n"
8311 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8312 "Display only the bestpath\n"
8313 "Display only multipaths\n"
8314 "JavaScript Object Notation\n")
8316 u_char uj
= use_json(argc
, argv
);
8318 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
8319 if (strncmp (argv
[6]->arg
, "b", 1) == 0)
8320 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8322 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8324 if (strncmp (argv
[6]->arg
, "b", 1) == 0)
8325 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8327 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8331 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
8332 show_ip_bgp_vpnv4_all_prefix_cmd
,
8333 "show ip bgp vpnv4 all A.B.C.D/M {json}",
8337 "Display VPNv4 NLRI specific information\n"
8338 "Display information about all VPNv4 NLRIs\n"
8339 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8340 "JavaScript Object Notation\n")
8342 return bgp_show_route (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8345 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
8346 show_ip_bgp_vpnv4_rd_prefix_cmd
,
8347 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8351 "Display VPNv4 NLRI specific information\n"
8352 "Display information for a route distinguisher\n"
8353 "VPN Route Distinguisher\n"
8354 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8355 "JavaScript Object Notation\n")
8358 struct prefix_rd prd
;
8360 ret
= str2prefix_rd (argv
[5]->arg
, &prd
);
8363 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8366 return bgp_show_route (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8369 DEFUN (show_ip_bgp_view
,
8370 show_ip_bgp_instance_cmd
,
8371 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8375 BGP_INSTANCE_HELP_STR
8376 "JavaScript Object Notation\n")
8380 /* BGP structure lookup. */
8381 bgp
= bgp_lookup_by_name (argv
[4]->arg
);
8384 vty_out (vty
, "Can't find BGP instance %s%s", argv
[4]->arg
, VTY_NEWLINE
);
8388 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8391 DEFUN (show_ip_bgp_instance_all
,
8392 show_ip_bgp_instance_all_cmd
,
8393 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8397 BGP_INSTANCE_ALL_HELP_STR
8398 "JavaScript Object Notation\n")
8400 u_char uj
= use_json(argc
, argv
);
8402 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8406 DEFUN (show_ip_bgp_instance_route
,
8407 show_ip_bgp_instance_route_cmd
,
8408 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8412 BGP_INSTANCE_HELP_STR
8413 "Network in the BGP routing table to display\n"
8414 "JavaScript Object Notation\n")
8416 return bgp_show_route (vty
, argv
[4]->arg
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8419 DEFUN (show_ip_bgp_instance_route_pathtype
,
8420 show_ip_bgp_instance_route_pathtype_cmd
,
8421 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8425 BGP_INSTANCE_HELP_STR
8426 "Network in the BGP routing table to display\n"
8427 "Display only the bestpath\n"
8428 "Display only multipaths\n"
8429 "JavaScript Object Notation\n")
8431 u_char uj
= use_json(argc
, argv
);
8433 if (strncmp (argv
[6]->arg
, "b", 1) == 0)
8434 return bgp_show_route (vty
, argv
[4]->arg
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8436 return bgp_show_route (vty
, argv
[4]->arg
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8439 DEFUN (show_ip_bgp_instance_prefix
,
8440 show_ip_bgp_instance_prefix_cmd
,
8441 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8445 BGP_INSTANCE_HELP_STR
8446 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8447 "JavaScript Object Notation\n")
8449 return bgp_show_route (vty
, argv
[4]->arg
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8452 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8453 show_ip_bgp_instance_prefix_pathtype_cmd
,
8454 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8458 BGP_INSTANCE_HELP_STR
8459 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8460 "Display only the bestpath\n"
8461 "Display only multipaths\n"
8462 "JavaScript Object Notation\n")
8464 u_char uj
= use_json(argc
, argv
);
8465 if (strncmp (argv
[6]->arg
, "b", 1) == 0)
8466 return bgp_show_route (vty
, argv
[4]->arg
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8468 return bgp_show_route (vty
, argv
[4]->arg
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8473 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8474 * "show bgp ipv6 {json}",
8477 * "Address family\n"
8478 * "JavaScript Object Notation\n"
8486 "JavaScript Object Notation\n")
8488 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8489 NULL
, use_json(argc
, argv
));
8493 DEFUN (show_bgp_ipv6_safi
,
8494 show_bgp_ipv6_safi_cmd
,
8495 "show bgp ipv6 (unicast|multicast) {json}",
8499 "Address Family modifier\n"
8500 "Address Family modifier\n"
8501 "JavaScript Object Notation\n")
8503 u_char uj
= use_json(argc
, argv
);
8504 if (strncmp (argv
[3]->arg
, "m", 1) == 0)
8505 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8508 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8512 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8514 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8515 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8516 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8520 DEFUN (show_ipv6_bgp
,
8522 "show ipv6 bgp {json}",
8526 "JavaScript Object Notation\n")
8528 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8529 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8530 NULL
, use_json(argc
, argv
));
8533 DEFUN (show_bgp_route
,
8535 "show bgp X:X::X:X {json}",
8538 "Network in the BGP routing table to display\n"
8539 "JavaScript Object Notation\n")
8541 return bgp_show_route (vty
, NULL
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8544 DEFUN (show_bgp_ipv6_safi_route
,
8545 show_bgp_ipv6_safi_route_cmd
,
8546 "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
8550 "Address Family modifier\n"
8551 "Address Family modifier\n"
8552 "Network in the BGP routing table to display\n"
8553 "JavaScript Object Notation\n")
8555 u_char uj
= use_json(argc
, argv
);
8556 if (strncmp (argv
[3]->arg
, "m", 1) == 0)
8557 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8559 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8563 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8564 * "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8567 * "Address family\n"
8568 * "Network in the BGP routing table to display\n"
8569 * "Display only the bestpath\n"
8570 * "Display only multipaths\n"
8571 * "JavaScript Object Notation\n"
8574 DEFUN (show_bgp_route_pathtype
,
8575 show_bgp_route_pathtype_cmd
,
8576 "show bgp X:X::X:X (bestpath|multipath) {json}",
8579 "Network in the BGP routing table to display\n"
8580 "Display only the bestpath\n"
8581 "Display only multipaths\n"
8582 "JavaScript Object Notation\n")
8584 u_char uj
= use_json(argc
, argv
);
8585 if (strncmp (argv
[3]->arg
, "b", 1) == 0)
8586 return bgp_show_route (vty
, NULL
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8588 return bgp_show_route (vty
, NULL
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8592 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8593 show_bgp_ipv6_safi_route_pathtype_cmd
,
8594 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
8598 "Address Family modifier\n"
8599 "Address Family modifier\n"
8600 "Network in the BGP routing table to display\n"
8601 "Display only the bestpath\n"
8602 "Display only multipaths\n"
8603 "JavaScript Object Notation\n")
8605 u_char uj
= use_json(argc
, argv
);
8606 if (strncmp (argv
[3]->arg
, "m", 1) == 0)
8607 if (strncmp (argv
[5]->arg
, "b", 1) == 0)
8608 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8610 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8612 if (strncmp (argv
[5]->arg
, "b", 1) == 0)
8613 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8615 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8619 DEFUN (show_ipv6_bgp_route
,
8620 show_ipv6_bgp_route_cmd
,
8621 "show ipv6 bgp X:X::X:X {json}",
8625 "Network in the BGP routing table to display\n"
8626 "JavaScript Object Notation\n")
8628 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8629 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8632 DEFUN (show_bgp_prefix
,
8633 show_bgp_prefix_cmd
,
8634 "show bgp X:X::X:X/M {json}",
8637 "IPv6 prefix <network>/<length>\n"
8638 "JavaScript Object Notation\n")
8640 return bgp_show_route (vty
, NULL
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8643 DEFUN (show_bgp_ipv6_safi_prefix
,
8644 show_bgp_ipv6_safi_prefix_cmd
,
8645 "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
8649 "Address Family modifier\n"
8650 "Address Family modifier\n"
8651 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8652 "JavaScript Object Notation\n")
8654 u_char uj
= use_json(argc
, argv
);
8655 if (strncmp (argv
[3]->arg
, "m", 1) == 0)
8656 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8658 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8662 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8663 * "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8666 * "Address family\n"
8667 * "IPv6 prefix <network>/<length>\n"
8668 * "Display only the bestpath\n"
8669 * "Display only multipaths\n"
8670 * "JavaScript Object Notation\n"
8673 DEFUN (show_bgp_prefix_pathtype
,
8674 show_bgp_prefix_pathtype_cmd
,
8675 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8678 "IPv6 prefix <network>/<length>\n"
8679 "Display only the bestpath\n"
8680 "Display only multipaths\n"
8681 "JavaScript Object Notation\n")
8683 u_char uj
= use_json(argc
, argv
);
8684 if (strncmp (argv
[3]->arg
, "b", 1) == 0)
8685 return bgp_show_route (vty
, NULL
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8687 return bgp_show_route (vty
, NULL
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8691 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8692 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8693 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
8697 "Address Family modifier\n"
8698 "Address Family modifier\n"
8699 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8700 "Display only the bestpath\n"
8701 "Display only multipaths\n"
8702 "JavaScript Object Notation\n")
8704 u_char uj
= use_json(argc
, argv
);
8705 if (strncmp (argv
[3]->arg
, "m", 1) == 0)
8706 if (strncmp (argv
[5]->arg
, "b", 1) == 0)
8707 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8709 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8711 if (strncmp (argv
[5]->arg
, "b", 1) == 0)
8712 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8714 return bgp_show_route (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8718 DEFUN (show_ipv6_bgp_prefix
,
8719 show_ipv6_bgp_prefix_cmd
,
8720 "show ipv6 bgp X:X::X:X/M {json}",
8724 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8725 "JavaScript Object Notation\n")
8727 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8728 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8732 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8733 * "show bgp " BGP_INSTANCE_CMD " ipv6 {json}",
8736 * BGP_INSTANCE_HELP_STR
8737 * "Address family\n"
8738 * "JavaScript Object Notation\n"
8741 DEFUN (show_bgp_view
,
8742 show_bgp_instance_cmd
,
8743 "show bgp " BGP_INSTANCE_CMD
" {json}",
8746 BGP_INSTANCE_HELP_STR
8747 "JavaScript Object Notation\n")
8751 /* BGP structure lookup. */
8752 bgp
= bgp_lookup_by_name (argv
[3]->arg
);
8755 vty_out (vty
, "Can't find BGP instance %s%s", argv
[3]->arg
, VTY_NEWLINE
);
8759 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8762 DEFUN (show_bgp_instance_all
,
8763 show_bgp_instance_all_cmd
,
8764 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8767 BGP_INSTANCE_ALL_HELP_STR
8768 "JavaScript Object Notation\n")
8770 u_char uj
= use_json(argc
, argv
);
8772 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8778 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8779 * "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X {json}",
8782 * BGP_INSTANCE_HELP_STR
8783 * "Address family\n"
8784 * "Network in the BGP routing table to display\n"
8785 * "JavaScript Object Notation\n"
8788 DEFUN (show_bgp_instance_route
,
8789 show_bgp_instance_route_cmd
,
8790 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8793 BGP_INSTANCE_HELP_STR
8794 "Network in the BGP routing table to display\n"
8795 "JavaScript Object Notation\n")
8797 return bgp_show_route (vty
, argv
[3]->arg
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8802 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8803 * "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X (bestpath|multipath) {json}",
8806 * BGP_INSTANCE_HELP_STR
8807 * "Address family\n"
8808 * "Network in the BGP routing table to display\n"
8809 * "Display only the bestpath\n"
8810 * "Display only multipaths\n"
8811 * "JavaScript Object Notation\n"
8814 DEFUN (show_bgp_instance_route_pathtype
,
8815 show_bgp_instance_route_pathtype_cmd
,
8816 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8819 BGP_INSTANCE_HELP_STR
8820 "Network in the BGP routing table to display\n"
8821 "Display only the bestpath\n"
8822 "Display only multipaths\n"
8823 "JavaScript Object Notation\n")
8825 u_char uj
= use_json(argc
, argv
);
8826 if (strncmp (argv
[5]->arg
, "b", 1) == 0)
8827 return bgp_show_route (vty
, argv
[3]->arg
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8829 return bgp_show_route (vty
, argv
[3]->arg
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8834 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8835 * "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M {json}",
8838 * BGP_INSTANCE_HELP_STR
8839 * "Address family\n"
8840 * "IPv6 prefix <network>/<length>\n"
8841 * "JavaScript Object Notation\n"
8844 DEFUN (show_bgp_instance_prefix
,
8845 show_bgp_instance_prefix_cmd
,
8846 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
8849 BGP_INSTANCE_HELP_STR
8850 "IPv6 prefix <network>/<length>\n"
8851 "JavaScript Object Notation\n")
8853 return bgp_show_route (vty
, argv
[3]->arg
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8858 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8859 * "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8862 * BGP_INSTANCE_HELP_STR
8863 * "Address family\n"
8864 * "IPv6 prefix <network>/<length>\n"
8865 * "Display only the bestpath\n"
8866 * "Display only multipaths\n"
8867 * "JavaScript Object Notation\n"
8870 DEFUN (show_bgp_instance_prefix_pathtype
,
8871 show_bgp_instance_prefix_pathtype_cmd
,
8872 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
8875 BGP_INSTANCE_HELP_STR
8876 "IPv6 prefix <network>/<length>\n"
8877 "Display only the bestpath\n"
8878 "Display only multipaths\n"
8879 "JavaScript Object Notation\n")
8881 u_char uj
= use_json(argc
, argv
);
8882 if (strncmp (argv
[5]->arg
, "b", 1) == 0)
8883 return bgp_show_route (vty
, argv
[3]->arg
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8885 return bgp_show_route (vty
, argv
[3]->arg
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8890 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8891 * "show bgp " BGP_INSTANCE_CMD " ipv6 prefix-list WORD",
8894 * BGP_INSTANCE_HELP_STR
8895 * "Address family\n"
8896 * "Display routes conforming to the prefix-list\n"
8897 * "IPv6 prefix-list name\n"
8900 DEFUN (show_bgp_instance_prefix_list
,
8901 show_bgp_instance_prefix_list_cmd
,
8902 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
8905 BGP_INSTANCE_HELP_STR
8906 "Display routes conforming to the prefix-list\n"
8907 "IPv6 prefix-list name\n")
8909 return bgp_show_prefix_list (vty
, argv
[3]->arg
, argv
[5]->arg
, AFI_IP6
, SAFI_UNICAST
,
8910 bgp_show_type_prefix_list
);
8915 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8916 * "show bgp " BGP_INSTANCE_CMD " ipv6 filter-list WORD",
8919 * BGP_INSTANCE_HELP_STR
8920 * "Address family\n"
8921 * "Display routes conforming to the filter-list\n"
8922 * "Regular expression access list name\n"
8925 DEFUN (show_bgp_instance_filter_list
,
8926 show_bgp_instance_filter_list_cmd
,
8927 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
8930 BGP_INSTANCE_HELP_STR
8931 "Display routes conforming to the filter-list\n"
8932 "Regular expression access list name\n")
8934 return bgp_show_filter_list (vty
, argv
[3]->arg
, argv
[5]->arg
, AFI_IP6
, SAFI_UNICAST
,
8935 bgp_show_type_filter_list
);
8940 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8941 * "show bgp " BGP_INSTANCE_CMD " ipv6 route-map WORD",
8944 * BGP_INSTANCE_HELP_STR
8945 * "Address family\n"
8946 * "Display routes matching the route-map\n"
8947 * "A route-map to match on\n"
8950 DEFUN (show_bgp_instance_route_map
,
8951 show_bgp_instance_route_map_cmd
,
8952 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
8955 BGP_INSTANCE_HELP_STR
8956 "Display routes matching the route-map\n"
8957 "A route-map to match on\n")
8959 return bgp_show_route_map (vty
, argv
[3]->arg
, argv
[5]->arg
, AFI_IP6
, SAFI_UNICAST
,
8960 bgp_show_type_route_map
);
8965 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8966 * "show bgp " BGP_INSTANCE_CMD " ipv6 community-list (<1-500>|WORD)",
8969 * BGP_INSTANCE_HELP_STR
8970 * "Address family\n"
8971 * "Display routes matching the community-list\n"
8972 * "community-list number\n"
8973 * "community-list name\n"
8976 DEFUN (show_bgp_instance_community_list
,
8977 show_bgp_instance_community_list_cmd
,
8978 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
8981 BGP_INSTANCE_HELP_STR
8982 "Display routes matching the community-list\n"
8983 "community-list number\n"
8984 "community-list name\n")
8986 return bgp_show_community_list (vty
, argv
[3]->arg
, argv
[5]->arg
, 0, AFI_IP6
, SAFI_UNICAST
);
8991 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
8992 * "show bgp " BGP_INSTANCE_CMD " ipv6 X:X::X:X/M longer-prefixes",
8995 * BGP_INSTANCE_HELP_STR
8996 * "Address family\n"
8997 * "IPv6 prefix <network>/<length>\n"
8998 * "Display route and more specific routes\n"
9001 DEFUN (show_bgp_instance_prefix_longer
,
9002 show_bgp_instance_prefix_longer_cmd
,
9003 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
9006 BGP_INSTANCE_HELP_STR
9007 "IPv6 prefix <network>/<length>\n"
9008 "Display route and more specific routes\n")
9010 return bgp_show_prefix_longer (vty
, argv
[3]->arg
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
,
9011 bgp_show_type_prefix_longer
);
9016 DEFUN (show_ipv6_mbgp
,
9018 "show ipv6 mbgp {json}",
9022 "JavaScript Object Notation\n")
9024 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9025 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
9026 NULL
, use_json(argc
, argv
));
9030 DEFUN (show_ipv6_mbgp_route
,
9031 show_ipv6_mbgp_route_cmd
,
9032 "show ipv6 mbgp X:X::X:X {json}",
9036 "Network in the MBGP routing table to display\n"
9037 "JavaScript Object Notation\n")
9039 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9040 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9044 DEFUN (show_ipv6_mbgp_prefix
,
9045 show_ipv6_mbgp_prefix_cmd
,
9046 "show ipv6 mbgp X:X::X:X/M {json}",
9050 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9051 "JavaScript Object Notation\n")
9053 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9054 return bgp_show_route (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9060 bgp_show_regexp (struct vty
*vty
, int argc
, struct cmd_token
**argv
, afi_t afi
,
9061 safi_t safi
, enum bgp_show_type type
)
9071 b
= buffer_new (1024);
9072 for (i
= 0; i
< argc
; i
++)
9075 buffer_putc (b
, ' ');
9078 if ((strcmp (argv
[i
]->arg
, "unicast") == 0) || (strcmp (argv
[i
]->arg
, "multicast") == 0))
9083 buffer_putstr (b
, argv
[i
]->arg
);
9085 buffer_putc (b
, '\0');
9087 regstr
= buffer_getstr (b
);
9090 regex
= bgp_regcomp (regstr
);
9091 XFREE(MTYPE_TMP
, regstr
);
9094 vty_out (vty
, "Can't compile regexp %s%s", argv
[0]->arg
,
9099 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
9100 bgp_regex_free (regex
);
9104 DEFUN (show_ip_bgp_regexp
,
9105 show_ip_bgp_regexp_cmd
,
9106 "show ip bgp regexp .LINE",
9110 "Display routes matching the AS path regular expression\n"
9111 "A regular-expression to match the BGP AS paths\n")
9113 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9114 bgp_show_type_regexp
);
9118 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9119 * "show ip bgp dampening flap-statistics regexp .LINE",
9123 * "Display detailed information about dampening\n"
9124 * "Display flap statistics of routes\n"
9125 * "Display routes matching the AS path regular expression\n"
9126 * "A regular-expression to match the BGP AS paths\n"
9129 DEFUN (show_ip_bgp_flap_regexp
,
9130 show_ip_bgp_flap_regexp_cmd
,
9131 "show ip bgp flap-statistics regexp .LINE",
9135 "Display flap statistics of routes\n"
9136 "Display routes matching the AS path regular expression\n"
9137 "A regular-expression to match the BGP AS paths\n")
9139 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9140 bgp_show_type_flap_regexp
);
9144 DEFUN (show_ip_bgp_ipv4_regexp
,
9145 show_ip_bgp_ipv4_regexp_cmd
,
9146 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
9151 "Address Family modifier\n"
9152 "Address Family modifier\n"
9153 "Display routes matching the AS path regular expression\n"
9154 "A regular-expression to match the BGP AS paths\n")
9156 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
9157 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
9158 bgp_show_type_regexp
);
9160 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9161 bgp_show_type_regexp
);
9166 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9167 * "show bgp ipv6 regexp .LINE",
9170 * "Address family\n"
9171 * "Display routes matching the AS path regular expression\n"
9172 * "A regular-expression to match the BGP AS paths\n"
9175 DEFUN (show_bgp_regexp
,
9176 show_bgp_regexp_cmd
,
9177 "show bgp regexp .LINE",
9180 "Display routes matching the AS path regular expression\n"
9181 "A regular-expression to match the BGP AS paths\n")
9183 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9184 bgp_show_type_regexp
);
9189 DEFUN (show_ipv6_bgp_regexp
,
9190 show_ipv6_bgp_regexp_cmd
,
9191 "show ipv6 bgp regexp .LINE",
9195 "Display routes matching the AS path regular expression\n"
9196 "A regular-expression to match the BGP AS paths\n")
9198 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9199 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9200 bgp_show_type_regexp
);
9204 DEFUN (show_ipv6_mbgp_regexp
,
9205 show_ipv6_mbgp_regexp_cmd
,
9206 "show ipv6 mbgp regexp .LINE",
9210 "Display routes matching the AS path regular expression\n"
9211 "A regular-expression to match the MBGP AS paths\n")
9213 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9214 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9215 bgp_show_type_regexp
);
9217 #endif /* HAVE_IPV6 */
9220 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9221 const char *prefix_list_str
, afi_t afi
,
9222 safi_t safi
, enum bgp_show_type type
)
9224 struct prefix_list
*plist
;
9225 struct bgp
*bgp
= NULL
;
9227 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9229 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9233 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9236 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9237 prefix_list_str
, VTY_NEWLINE
);
9241 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9244 DEFUN (show_ip_bgp_prefix_list
,
9245 show_ip_bgp_prefix_list_cmd
,
9246 "show ip bgp prefix-list WORD",
9250 "Display routes conforming to the prefix-list\n"
9251 "IP prefix-list name\n")
9253 return bgp_show_prefix_list (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_UNICAST
,
9254 bgp_show_type_prefix_list
);
9257 DEFUN (show_ip_bgp_instance_prefix_list
,
9258 show_ip_bgp_instance_prefix_list_cmd
,
9259 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9263 BGP_INSTANCE_HELP_STR
9264 "Display routes conforming to the prefix-list\n"
9265 "IP prefix-list name\n")
9267 return bgp_show_prefix_list (vty
, argv
[4]->arg
, argv
[6]->arg
, AFI_IP
, SAFI_UNICAST
,
9268 bgp_show_type_prefix_list
);
9272 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9273 * "show ip bgp dampening flap-statistics prefix-list WORD",
9277 * "Display detailed information about dampening\n"
9278 * "Display flap statistics of routes\n"
9279 * "Display routes conforming to the prefix-list\n"
9280 * "IP prefix-list name\n"
9283 DEFUN (show_ip_bgp_flap_prefix_list
,
9284 show_ip_bgp_flap_prefix_list_cmd
,
9285 "show ip bgp flap-statistics prefix-list WORD",
9289 "Display flap statistics of routes\n"
9290 "Display routes conforming to the prefix-list\n"
9291 "IP prefix-list name\n")
9293 return bgp_show_prefix_list (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
,
9294 bgp_show_type_flap_prefix_list
);
9298 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9299 show_ip_bgp_ipv4_prefix_list_cmd
,
9300 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
9305 "Address Family modifier\n"
9306 "Address Family modifier\n"
9307 "Display routes conforming to the prefix-list\n"
9308 "IP prefix-list name\n")
9310 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
9311 return bgp_show_prefix_list (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_MULTICAST
,
9312 bgp_show_type_prefix_list
);
9314 return bgp_show_prefix_list (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_UNICAST
,
9315 bgp_show_type_prefix_list
);
9320 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9321 * "show bgp ipv6 prefix-list WORD",
9324 * "Address family\n"
9325 * "Display routes conforming to the prefix-list\n"
9326 * "IPv6 prefix-list name\n"
9329 DEFUN (show_bgp_prefix_list
,
9330 show_bgp_prefix_list_cmd
,
9331 "show bgp prefix-list WORD",
9334 "Display routes conforming to the prefix-list\n"
9335 "IPv6 prefix-list name\n")
9337 return bgp_show_prefix_list (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_UNICAST
,
9338 bgp_show_type_prefix_list
);
9343 DEFUN (show_ipv6_bgp_prefix_list
,
9344 show_ipv6_bgp_prefix_list_cmd
,
9345 "show ipv6 bgp prefix-list WORD",
9349 "Display routes matching the prefix-list\n"
9350 "IPv6 prefix-list name\n")
9352 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9353 return bgp_show_prefix_list (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
,
9354 bgp_show_type_prefix_list
);
9358 DEFUN (show_ipv6_mbgp_prefix_list
,
9359 show_ipv6_mbgp_prefix_list_cmd
,
9360 "show ipv6 mbgp prefix-list WORD",
9364 "Display routes matching the prefix-list\n"
9365 "IPv6 prefix-list name\n")
9367 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9368 return bgp_show_prefix_list (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MULTICAST
,
9369 bgp_show_type_prefix_list
);
9371 #endif /* HAVE_IPV6 */
9374 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9375 const char *filter
, afi_t afi
,
9376 safi_t safi
, enum bgp_show_type type
)
9378 struct as_list
*as_list
;
9379 struct bgp
*bgp
= NULL
;
9381 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9383 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9387 as_list
= as_list_lookup (filter
);
9388 if (as_list
== NULL
)
9390 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9394 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9397 DEFUN (show_ip_bgp_filter_list
,
9398 show_ip_bgp_filter_list_cmd
,
9399 "show ip bgp filter-list WORD",
9403 "Display routes conforming to the filter-list\n"
9404 "Regular expression access list name\n")
9406 return bgp_show_filter_list (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_UNICAST
,
9407 bgp_show_type_filter_list
);
9410 DEFUN (show_ip_bgp_instance_filter_list
,
9411 show_ip_bgp_instance_filter_list_cmd
,
9412 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9416 BGP_INSTANCE_HELP_STR
9417 "Display routes conforming to the filter-list\n"
9418 "Regular expression access list name\n")
9420 return bgp_show_filter_list (vty
, argv
[4]->arg
, argv
[6]->arg
, AFI_IP
, SAFI_UNICAST
,
9421 bgp_show_type_filter_list
);
9425 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9426 * "show ip bgp dampening flap-statistics filter-list WORD",
9430 * "Display detailed information about dampening\n"
9431 * "Display flap statistics of routes\n"
9432 * "Display routes conforming to the filter-list\n"
9433 * "Regular expression access list name\n"
9436 DEFUN (show_ip_bgp_flap_filter_list
,
9437 show_ip_bgp_flap_filter_list_cmd
,
9438 "show ip bgp flap-statistics filter-list WORD",
9442 "Display flap statistics of routes\n"
9443 "Display routes conforming to the filter-list\n"
9444 "Regular expression access list name\n")
9446 return bgp_show_filter_list (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
,
9447 bgp_show_type_flap_filter_list
);
9451 DEFUN (show_ip_bgp_ipv4_filter_list
,
9452 show_ip_bgp_ipv4_filter_list_cmd
,
9453 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9458 "Address Family modifier\n"
9459 "Address Family modifier\n"
9460 "Display routes conforming to the filter-list\n"
9461 "Regular expression access list name\n")
9463 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
9464 return bgp_show_filter_list (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_MULTICAST
,
9465 bgp_show_type_filter_list
);
9467 return bgp_show_filter_list (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_UNICAST
,
9468 bgp_show_type_filter_list
);
9473 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9474 * "show bgp ipv6 filter-list WORD",
9477 * "Address family\n"
9478 * "Display routes conforming to the filter-list\n"
9479 * "Regular expression access list name\n"
9482 DEFUN (show_bgp_filter_list
,
9483 show_bgp_filter_list_cmd
,
9484 "show bgp filter-list WORD",
9487 "Display routes conforming to the filter-list\n"
9488 "Regular expression access list name\n")
9490 return bgp_show_filter_list (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_UNICAST
,
9491 bgp_show_type_filter_list
);
9496 DEFUN (show_ipv6_bgp_filter_list
,
9497 show_ipv6_bgp_filter_list_cmd
,
9498 "show ipv6 bgp filter-list WORD",
9502 "Display routes conforming to the filter-list\n"
9503 "Regular expression access list name\n")
9505 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9506 return bgp_show_filter_list (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_UNICAST
,
9507 bgp_show_type_filter_list
);
9511 DEFUN (show_ipv6_mbgp_filter_list
,
9512 show_ipv6_mbgp_filter_list_cmd
,
9513 "show ipv6 mbgp filter-list WORD",
9517 "Display routes conforming to the filter-list\n"
9518 "Regular expression access list name\n")
9520 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9521 return bgp_show_filter_list (vty
, NULL
, argv
[4]->arg
, AFI_IP6
, SAFI_MULTICAST
,
9522 bgp_show_type_filter_list
);
9524 #endif /* HAVE_IPV6 */
9526 DEFUN (show_ip_bgp_dampening_info
,
9527 show_ip_bgp_dampening_params_cmd
,
9528 "show ip bgp dampening parameters",
9532 "Display detailed information about dampening\n"
9533 "Display detail of configured dampening parameters\n")
9535 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9539 DEFUN (show_ip_bgp_ipv4_dampening_parameters
,
9540 show_ip_bgp_ipv4_dampening_parameters_cmd
,
9541 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
9546 "Address Family modifier\n"
9547 "Address Family modifier\n"
9548 "Display detailed information about dampening\n"
9549 "Display detail of configured dampening parameters\n")
9551 if (strncmp(argv
[4]->arg
, "m", 1) == 0)
9552 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_MULTICAST
);
9554 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9558 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats
,
9559 show_ip_bgp_ipv4_dampening_flap_stats_cmd
,
9560 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
9565 "Address Family modifier\n"
9566 "Address Family modifier\n"
9567 "Display detailed information about dampening\n"
9568 "Display flap statistics of routes\n")
9570 if (strncmp(argv
[4]->arg
, "m", 1) == 0)
9571 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9572 bgp_show_type_flap_statistics
, NULL
, 0);
9574 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9575 bgp_show_type_flap_statistics
, NULL
, 0);
9578 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths
,
9579 show_ip_bgp_ipv4_dampening_dampd_paths_cmd
,
9580 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
9585 "Address Family modifier\n"
9586 "Address Family modifier\n"
9587 "Display detailed information about dampening\n"
9588 "Display paths suppressed due to dampening\n")
9590 if (strncmp(argv
[4]->arg
, "m", 1) == 0)
9591 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9592 bgp_show_type_dampend_paths
, NULL
, 0);
9594 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9595 bgp_show_type_dampend_paths
, NULL
, 0);
9599 bgp_show_route_map (struct vty
*vty
, const char *name
,
9600 const char *rmap_str
, afi_t afi
,
9601 safi_t safi
, enum bgp_show_type type
)
9603 struct route_map
*rmap
;
9604 struct bgp
*bgp
= NULL
;
9606 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9608 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9612 rmap
= route_map_lookup_by_name (rmap_str
);
9615 vty_out (vty
, "%% %s is not a valid route-map name%s",
9616 rmap_str
, VTY_NEWLINE
);
9620 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9623 DEFUN (show_ip_bgp_route_map
,
9624 show_ip_bgp_route_map_cmd
,
9625 "show ip bgp route-map WORD",
9629 "Display routes matching the route-map\n"
9630 "A route-map to match on\n")
9632 return bgp_show_route_map (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_UNICAST
,
9633 bgp_show_type_route_map
);
9636 DEFUN (show_ip_bgp_instance_route_map
,
9637 show_ip_bgp_instance_route_map_cmd
,
9638 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9642 BGP_INSTANCE_HELP_STR
9643 "Display routes matching the route-map\n"
9644 "A route-map to match on\n")
9646 return bgp_show_route_map (vty
, argv
[4]->arg
, argv
[6]->arg
, AFI_IP
, SAFI_UNICAST
,
9647 bgp_show_type_route_map
);
9651 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9652 * "show ip bgp dampening flap-statistics route-map WORD",
9656 * "Display detailed information about dampening\n"
9657 * "Display flap statistics of routes\n"
9658 * "Display routes matching the route-map\n"
9659 * "A route-map to match on\n"
9662 DEFUN (show_ip_bgp_flap_route_map
,
9663 show_ip_bgp_flap_route_map_cmd
,
9664 "show ip bgp flap-statistics route-map WORD",
9668 "Display flap statistics of routes\n"
9669 "Display routes matching the route-map\n"
9670 "A route-map to match on\n")
9672 return bgp_show_route_map (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
,
9673 bgp_show_type_flap_route_map
);
9677 DEFUN (show_ip_bgp_ipv4_route_map
,
9678 show_ip_bgp_ipv4_route_map_cmd
,
9679 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9684 "Address Family modifier\n"
9685 "Address Family modifier\n"
9686 "Display routes matching the route-map\n"
9687 "A route-map to match on\n")
9689 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
9690 return bgp_show_route_map (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_MULTICAST
,
9691 bgp_show_type_route_map
);
9693 return bgp_show_route_map (vty
, NULL
, argv
[6]->arg
, AFI_IP
, SAFI_UNICAST
,
9694 bgp_show_type_route_map
);
9698 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9699 * "show bgp ipv6 route-map WORD",
9702 * "Address family\n"
9703 * "Display routes matching the route-map\n"
9704 * "A route-map to match on\n"
9707 DEFUN (show_bgp_route_map
,
9708 show_bgp_route_map_cmd
,
9709 "show bgp route-map WORD",
9712 "Display routes matching the route-map\n"
9713 "A route-map to match on\n")
9715 return bgp_show_route_map (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_UNICAST
,
9716 bgp_show_type_route_map
);
9720 DEFUN (show_ip_bgp_cidr_only
,
9721 show_ip_bgp_cidr_only_cmd
,
9722 "show ip bgp cidr-only",
9726 "Display only routes with non-natural netmasks\n")
9728 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9729 bgp_show_type_cidr_only
, NULL
, 0);
9733 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9734 * "show ip bgp dampening flap-statistics cidr-only",
9738 * "Display detailed information about dampening\n"
9739 * "Display flap statistics of routes\n"
9740 * "Display only routes with non-natural netmasks\n"
9743 DEFUN (show_ip_bgp_flap_cidr_only
,
9744 show_ip_bgp_flap_cidr_only_cmd
,
9745 "show ip bgp flap-statistics cidr-only",
9749 "Display flap statistics of routes\n"
9750 "Display only routes with non-natural netmasks\n")
9752 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9753 bgp_show_type_flap_cidr_only
, NULL
, 0);
9757 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9758 show_ip_bgp_ipv4_cidr_only_cmd
,
9759 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9764 "Address Family modifier\n"
9765 "Address Family modifier\n"
9766 "Display only routes with non-natural netmasks\n")
9768 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
9769 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9770 bgp_show_type_cidr_only
, NULL
, 0);
9772 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9773 bgp_show_type_cidr_only
, NULL
, 0);
9776 DEFUN (show_ip_bgp_community_all
,
9777 show_ip_bgp_community_all_cmd
,
9778 "show ip bgp community",
9782 "Display routes matching the communities\n")
9784 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9785 bgp_show_type_community_all
, NULL
, 0);
9788 DEFUN (show_ip_bgp_ipv4_community_all
,
9789 show_ip_bgp_ipv4_community_all_cmd
,
9790 "show ip bgp ipv4 (unicast|multicast) community",
9795 "Address Family modifier\n"
9796 "Address Family modifier\n"
9797 "Display routes matching the communities\n")
9799 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
9800 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9801 bgp_show_type_community_all
, NULL
, 0);
9803 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9804 bgp_show_type_community_all
, NULL
, 0);
9809 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9810 * "show bgp ipv6 community",
9813 * "Address family\n"
9814 * "Display routes matching the communities\n"
9817 DEFUN (show_bgp_community_all
,
9818 show_bgp_community_all_cmd
,
9819 "show bgp community",
9822 "Display routes matching the communities\n")
9824 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9825 bgp_show_type_community_all
, NULL
, 0);
9830 DEFUN (show_ipv6_bgp_community_all
,
9831 show_ipv6_bgp_community_all_cmd
,
9832 "show ipv6 bgp community",
9836 "Display routes matching the communities\n")
9838 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9839 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9840 bgp_show_type_community_all
, NULL
, 0);
9844 DEFUN (show_ipv6_mbgp_community_all
,
9845 show_ipv6_mbgp_community_all_cmd
,
9846 "show ipv6 mbgp community",
9850 "Display routes matching the communities\n")
9852 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9853 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9854 bgp_show_type_community_all
, NULL
, 0);
9856 #endif /* HAVE_IPV6 */
9859 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9860 struct cmd_token
**argv
, int exact
, afi_t afi
, safi_t safi
)
9862 struct community
*com
;
9869 /* BGP structure lookup */
9872 bgp
= bgp_lookup_by_name (view_name
);
9875 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
9881 bgp
= bgp_get_default ();
9884 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9889 b
= buffer_new (1024);
9890 for (i
= 0; i
< argc
; i
++)
9893 buffer_putc (b
, ' ');
9896 if ((strcmp (argv
[i
]->arg
, "unicast") == 0) || (strcmp (argv
[i
]->arg
, "multicast") == 0))
9901 buffer_putstr (b
, argv
[i
]->arg
);
9903 buffer_putc (b
, '\0');
9905 str
= buffer_getstr (b
);
9908 com
= community_str2com (str
);
9909 XFREE (MTYPE_TMP
, str
);
9912 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
9916 return bgp_show (vty
, bgp
, afi
, safi
,
9917 (exact
? bgp_show_type_community_exact
:
9918 bgp_show_type_community
), com
, 0);
9922 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9923 * "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)",
9927 * "Display routes matching the communities\n"
9928 * COMMUNITY_AANN_STR
9929 * "Do not send outside local AS (well-known community)\n"
9930 * "Do not advertise to any peer (well-known community)\n"
9931 * "Do not export to next AS (well-known community)\n"
9932 * COMMUNITY_AANN_STR
9933 * "Do not send outside local AS (well-known community)\n"
9934 * "Do not advertise to any peer (well-known community)\n"
9935 * "Do not export to next AS (well-known community)\n"
9936 * COMMUNITY_AANN_STR
9937 * "Do not send outside local AS (well-known community)\n"
9938 * "Do not advertise to any peer (well-known community)\n"
9939 * "Do not export to next AS (well-known community)\n"
9941 * "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)",
9945 * "Display routes matching the communities\n"
9946 * COMMUNITY_AANN_STR
9947 * "Do not send outside local AS (well-known community)\n"
9948 * "Do not advertise to any peer (well-known community)\n"
9949 * "Do not export to next AS (well-known community)\n"
9950 * COMMUNITY_AANN_STR
9951 * "Do not send outside local AS (well-known community)\n"
9952 * "Do not advertise to any peer (well-known community)\n"
9953 * "Do not export to next AS (well-known community)\n"
9954 * COMMUNITY_AANN_STR
9955 * "Do not send outside local AS (well-known community)\n"
9956 * "Do not advertise to any peer (well-known community)\n"
9957 * "Do not export to next AS (well-known community)\n"
9958 * COMMUNITY_AANN_STR
9959 * "Do not send outside local AS (well-known community)\n"
9960 * "Do not advertise to any peer (well-known community)\n"
9961 * "Do not export to next AS (well-known community)\n"
9963 * "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9967 * "Display routes matching the communities\n"
9968 * COMMUNITY_AANN_STR
9969 * "Do not send outside local AS (well-known community)\n"
9970 * "Do not advertise to any peer (well-known community)\n"
9971 * "Do not export to next AS (well-known community)\n"
9972 * COMMUNITY_AANN_STR
9973 * "Do not send outside local AS (well-known community)\n"
9974 * "Do not advertise to any peer (well-known community)\n"
9975 * "Do not export to next AS (well-known community)\n"
9978 DEFUN (show_ip_bgp_community
,
9979 show_ip_bgp_community_cmd
,
9980 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9984 "Display routes matching the communities\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 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9997 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
9998 * "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)",
10002 * "Address family\n"
10003 * "Address Family modifier\n"
10004 * "Address Family modifier\n"
10005 * "Display routes matching the communities\n"
10006 * COMMUNITY_AANN_STR
10007 * "Do not send outside local AS (well-known community)\n"
10008 * "Do not advertise to any peer (well-known community)\n"
10009 * "Do not export to next AS (well-known community)\n"
10010 * COMMUNITY_AANN_STR
10011 * "Do not send outside local AS (well-known community)\n"
10012 * "Do not advertise to any peer (well-known community)\n"
10013 * "Do not export to next AS (well-known community)\n"
10014 * COMMUNITY_AANN_STR
10015 * "Do not send outside local AS (well-known community)\n"
10016 * "Do not advertise to any peer (well-known community)\n"
10017 * "Do not export to next AS (well-known community)\n"
10019 * "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10023 * "Address family\n"
10024 * "Address Family modifier\n"
10025 * "Address Family modifier\n"
10026 * "Display routes matching the communities\n"
10027 * COMMUNITY_AANN_STR
10028 * "Do not send outside local AS (well-known community)\n"
10029 * "Do not advertise to any peer (well-known community)\n"
10030 * "Do not export to next AS (well-known community)\n"
10031 * COMMUNITY_AANN_STR
10032 * "Do not send outside local AS (well-known community)\n"
10033 * "Do not advertise to any peer (well-known community)\n"
10034 * "Do not export to next AS (well-known community)\n"
10036 * "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)",
10040 * "Address family\n"
10041 * "Address Family modifier\n"
10042 * "Address Family modifier\n"
10043 * "Display routes matching the communities\n"
10044 * COMMUNITY_AANN_STR
10045 * "Do not send outside local AS (well-known community)\n"
10046 * "Do not advertise to any peer (well-known community)\n"
10047 * "Do not export to next AS (well-known community)\n"
10048 * COMMUNITY_AANN_STR
10049 * "Do not send outside local AS (well-known community)\n"
10050 * "Do not advertise to any peer (well-known community)\n"
10051 * "Do not export to next AS (well-known community)\n"
10052 * COMMUNITY_AANN_STR
10053 * "Do not send outside local AS (well-known community)\n"
10054 * "Do not advertise to any peer (well-known community)\n"
10055 * "Do not export to next AS (well-known community)\n"
10056 * COMMUNITY_AANN_STR
10057 * "Do not send outside local AS (well-known community)\n"
10058 * "Do not advertise to any peer (well-known community)\n"
10059 * "Do not export to next AS (well-known community)\n"
10062 DEFUN (show_ip_bgp_ipv4_community
,
10063 show_ip_bgp_ipv4_community_cmd
,
10064 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10069 "Address Family modifier\n"
10070 "Address Family modifier\n"
10071 "Display routes matching the communities\n"
10073 "Do not send outside local AS (well-known community)\n"
10074 "Do not advertise to any peer (well-known community)\n"
10075 "Do not export to next AS (well-known community)\n")
10077 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
10078 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
10080 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
10086 DEFUN (show_bgp_instance_afi_safi_community_all
,
10087 show_bgp_instance_afi_safi_community_all_cmd
,
10088 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
10091 BGP_INSTANCE_HELP_STR
10094 "Address Family modifier\n"
10095 "Address Family modifier\n"
10096 "Display routes matching the communities\n")
10102 /* BGP structure lookup. */
10103 bgp
= bgp_lookup_by_name (argv
[3]->arg
);
10106 vty_out (vty
, "Can't find BGP instance %s%s", argv
[3]->arg
, VTY_NEWLINE
);
10107 return CMD_WARNING
;
10110 afi
= (strncmp (argv
[4]->arg
, "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10111 safi
= (strncmp (argv
[5]->arg
, "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10112 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
10116 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10117 * "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)",
10120 * BGP_INSTANCE_HELP_STR
10121 * "Address family\n"
10122 * "Address family\n"
10123 * "Address family modifier\n"
10124 * "Address family modifier\n"
10125 * "Display routes matching the communities\n"
10126 * COMMUNITY_AANN_STR
10127 * "Do not send outside local AS (well-known community)\n"
10128 * "Do not advertise to any peer (well-known community)\n"
10129 * "Do not export to next AS (well-known community)\n"
10130 * COMMUNITY_AANN_STR
10131 * "Do not send outside local AS (well-known community)\n"
10132 * "Do not advertise to any peer (well-known community)\n"
10133 * "Do not export to next AS (well-known community)\n"
10134 * COMMUNITY_AANN_STR
10135 * "Do not send outside local AS (well-known community)\n"
10136 * "Do not advertise to any peer (well-known community)\n"
10137 * "Do not export to next AS (well-known community)\n"
10139 * "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)",
10142 * BGP_INSTANCE_HELP_STR
10143 * "Address family\n"
10144 * "Address family\n"
10145 * "Address family modifier\n"
10146 * "Address family modifier\n"
10147 * "Display routes matching the communities\n"
10148 * COMMUNITY_AANN_STR
10149 * "Do not send outside local AS (well-known community)\n"
10150 * "Do not advertise to any peer (well-known community)\n"
10151 * "Do not export to next AS (well-known community)\n"
10152 * COMMUNITY_AANN_STR
10153 * "Do not send outside local AS (well-known community)\n"
10154 * "Do not advertise to any peer (well-known community)\n"
10155 * "Do not export to next AS (well-known community)\n"
10156 * COMMUNITY_AANN_STR
10157 * "Do not send outside local AS (well-known community)\n"
10158 * "Do not advertise to any peer (well-known community)\n"
10159 * "Do not export to next AS (well-known community)\n"
10160 * COMMUNITY_AANN_STR
10161 * "Do not send outside local AS (well-known community)\n"
10162 * "Do not advertise to any peer (well-known community)\n"
10163 * "Do not export to next AS (well-known community)\n"
10165 * "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)",
10168 * BGP_INSTANCE_HELP_STR
10169 * "Address family\n"
10170 * "Address family\n"
10171 * "Address family modifier\n"
10172 * "Address family modifier\n"
10173 * "Display routes matching the communities\n"
10174 * COMMUNITY_AANN_STR
10175 * "Do not send outside local AS (well-known community)\n"
10176 * "Do not advertise to any peer (well-known community)\n"
10177 * "Do not export to next AS (well-known community)\n"
10178 * COMMUNITY_AANN_STR
10179 * "Do not send outside local AS (well-known community)\n"
10180 * "Do not advertise to any peer (well-known community)\n"
10181 * "Do not export to next AS (well-known community)\n"
10184 DEFUN (show_bgp_instance_afi_safi_community
,
10185 show_bgp_instance_afi_safi_community_cmd
,
10186 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10189 BGP_INSTANCE_HELP_STR
10192 "Address family modifier\n"
10193 "Address family modifier\n"
10194 "Display routes matching the communities\n"
10196 "Do not send outside local AS (well-known community)\n"
10197 "Do not advertise to any peer (well-known community)\n"
10198 "Do not export to next AS (well-known community)\n")
10203 afi
= (strncmp (argv
[4]->arg
, "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10204 safi
= (strncmp (argv
[5]->arg
, "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10205 return bgp_show_community (vty
, argv
[3]->arg
, argc
, argv
, 0, afi
, safi
);
10212 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10213 * "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",
10217 * "Display routes matching the communities\n"
10218 * COMMUNITY_AANN_STR
10219 * "Do not send outside local AS (well-known community)\n"
10220 * "Do not advertise to any peer (well-known community)\n"
10221 * "Do not export to next AS (well-known community)\n"
10222 * COMMUNITY_AANN_STR
10223 * "Do not send outside local AS (well-known community)\n"
10224 * "Do not advertise to any peer (well-known community)\n"
10225 * "Do not export to next AS (well-known community)\n"
10226 * COMMUNITY_AANN_STR
10227 * "Do not send outside local AS (well-known community)\n"
10228 * "Do not advertise to any peer (well-known community)\n"
10229 * "Do not export to next AS (well-known community)\n"
10230 * "Exact match of the communities"
10232 * "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",
10236 * "Display routes matching the communities\n"
10237 * COMMUNITY_AANN_STR
10238 * "Do not send outside local AS (well-known community)\n"
10239 * "Do not advertise to any peer (well-known community)\n"
10240 * "Do not export to next AS (well-known community)\n"
10241 * COMMUNITY_AANN_STR
10242 * "Do not send outside local AS (well-known community)\n"
10243 * "Do not advertise to any peer (well-known community)\n"
10244 * "Do not export to next AS (well-known community)\n"
10245 * COMMUNITY_AANN_STR
10246 * "Do not send outside local AS (well-known community)\n"
10247 * "Do not advertise to any peer (well-known community)\n"
10248 * "Do not export to next AS (well-known community)\n"
10249 * COMMUNITY_AANN_STR
10250 * "Do not send outside local AS (well-known community)\n"
10251 * "Do not advertise to any peer (well-known community)\n"
10252 * "Do not export to next AS (well-known community)\n"
10253 * "Exact match of the communities"
10255 * "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10259 * "Display routes matching the communities\n"
10260 * COMMUNITY_AANN_STR
10261 * "Do not send outside local AS (well-known community)\n"
10262 * "Do not advertise to any peer (well-known community)\n"
10263 * "Do not export to next AS (well-known community)\n"
10264 * COMMUNITY_AANN_STR
10265 * "Do not send outside local AS (well-known community)\n"
10266 * "Do not advertise to any peer (well-known community)\n"
10267 * "Do not export to next AS (well-known community)\n"
10268 * "Exact match of the communities"
10271 DEFUN (show_ip_bgp_community_exact
,
10272 show_ip_bgp_community_exact_cmd
,
10273 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10277 "Display routes matching the communities\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"
10282 "Exact match of the communities")
10284 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10291 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10292 * "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",
10296 * "Address family\n"
10297 * "Address Family modifier\n"
10298 * "Address Family modifier\n"
10299 * "Display routes matching the communities\n"
10300 * COMMUNITY_AANN_STR
10301 * "Do not send outside local AS (well-known community)\n"
10302 * "Do not advertise to any peer (well-known community)\n"
10303 * "Do not export to next AS (well-known community)\n"
10304 * COMMUNITY_AANN_STR
10305 * "Do not send outside local AS (well-known community)\n"
10306 * "Do not advertise to any peer (well-known community)\n"
10307 * "Do not export to next AS (well-known community)\n"
10308 * COMMUNITY_AANN_STR
10309 * "Do not send outside local AS (well-known community)\n"
10310 * "Do not advertise to any peer (well-known community)\n"
10311 * "Do not export to next AS (well-known community)\n"
10312 * "Exact match of the communities"
10314 * "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",
10318 * "Address family\n"
10319 * "Address Family modifier\n"
10320 * "Address Family modifier\n"
10321 * "Display routes matching the communities\n"
10322 * COMMUNITY_AANN_STR
10323 * "Do not send outside local AS (well-known community)\n"
10324 * "Do not advertise to any peer (well-known community)\n"
10325 * "Do not export to next AS (well-known community)\n"
10326 * COMMUNITY_AANN_STR
10327 * "Do not send outside local AS (well-known community)\n"
10328 * "Do not advertise to any peer (well-known community)\n"
10329 * "Do not export to next AS (well-known community)\n"
10330 * "Exact match of the communities"
10332 * "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",
10336 * "Address family\n"
10337 * "Address Family modifier\n"
10338 * "Address Family modifier\n"
10339 * "Display routes matching the communities\n"
10340 * COMMUNITY_AANN_STR
10341 * "Do not send outside local AS (well-known community)\n"
10342 * "Do not advertise to any peer (well-known community)\n"
10343 * "Do not export to next AS (well-known community)\n"
10344 * COMMUNITY_AANN_STR
10345 * "Do not send outside local AS (well-known community)\n"
10346 * "Do not advertise to any peer (well-known community)\n"
10347 * "Do not export to next AS (well-known community)\n"
10348 * COMMUNITY_AANN_STR
10349 * "Do not send outside local AS (well-known community)\n"
10350 * "Do not advertise to any peer (well-known community)\n"
10351 * "Do not export to next AS (well-known community)\n"
10352 * COMMUNITY_AANN_STR
10353 * "Do not send outside local AS (well-known community)\n"
10354 * "Do not advertise to any peer (well-known community)\n"
10355 * "Do not export to next AS (well-known community)\n"
10356 * "Exact match of the communities"
10359 DEFUN (show_ip_bgp_ipv4_community_exact
,
10360 show_ip_bgp_ipv4_community_exact_cmd
,
10361 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10366 "Address Family modifier\n"
10367 "Address Family modifier\n"
10368 "Display routes matching the communities\n"
10370 "Do not send outside local AS (well-known community)\n"
10371 "Do not advertise to any peer (well-known community)\n"
10372 "Do not export to next AS (well-known community)\n"
10373 "Exact match of the communities")
10375 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
10376 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
10378 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10386 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10387 * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10390 * "Address family\n"
10391 * "Display routes matching the communities\n"
10392 * COMMUNITY_AANN_STR
10393 * "Do not send outside local AS (well-known community)\n"
10394 * "Do not advertise to any peer (well-known community)\n"
10395 * "Do not export to next AS (well-known community)\n"
10397 * "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)",
10400 * "Address family\n"
10401 * "Display routes matching the communities\n"
10402 * COMMUNITY_AANN_STR
10403 * "Do not send outside local AS (well-known community)\n"
10404 * "Do not advertise to any peer (well-known community)\n"
10405 * "Do not export to next AS (well-known community)\n"
10406 * COMMUNITY_AANN_STR
10407 * "Do not send outside local AS (well-known community)\n"
10408 * "Do not advertise to any peer (well-known community)\n"
10409 * "Do not export to next AS (well-known community)\n"
10410 * COMMUNITY_AANN_STR
10411 * "Do not send outside local AS (well-known community)\n"
10412 * "Do not advertise to any peer (well-known community)\n"
10413 * "Do not export to next AS (well-known community)\n"
10414 * COMMUNITY_AANN_STR
10415 * "Do not send outside local AS (well-known community)\n"
10416 * "Do not advertise to any peer (well-known community)\n"
10417 * "Do not export to next AS (well-known community)\n"
10419 * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10422 * "Address family\n"
10423 * "Display routes matching the communities\n"
10424 * COMMUNITY_AANN_STR
10425 * "Do not send outside local AS (well-known community)\n"
10426 * "Do not advertise to any peer (well-known community)\n"
10427 * "Do not export to next AS (well-known community)\n"
10428 * COMMUNITY_AANN_STR
10429 * "Do not send outside local AS (well-known community)\n"
10430 * "Do not advertise to any peer (well-known community)\n"
10431 * "Do not export to next AS (well-known community)\n"
10433 * "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)",
10436 * "Display routes matching the communities\n"
10437 * COMMUNITY_AANN_STR
10438 * "Do not send outside local AS (well-known community)\n"
10439 * "Do not advertise to any peer (well-known community)\n"
10440 * "Do not export to next AS (well-known community)\n"
10441 * COMMUNITY_AANN_STR
10442 * "Do not send outside local AS (well-known community)\n"
10443 * "Do not advertise to any peer (well-known community)\n"
10444 * "Do not export to next AS (well-known community)\n"
10445 * COMMUNITY_AANN_STR
10446 * "Do not send outside local AS (well-known community)\n"
10447 * "Do not advertise to any peer (well-known community)\n"
10448 * "Do not export to next AS (well-known community)\n"
10450 * "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10453 * "Display routes matching the communities\n"
10454 * COMMUNITY_AANN_STR
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"
10458 * COMMUNITY_AANN_STR
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 * "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)",
10466 * "Address family\n"
10467 * "Display routes matching the communities\n"
10468 * COMMUNITY_AANN_STR
10469 * "Do not send outside local AS (well-known community)\n"
10470 * "Do not advertise to any peer (well-known community)\n"
10471 * "Do not export to next AS (well-known community)\n"
10472 * COMMUNITY_AANN_STR
10473 * "Do not send outside local AS (well-known community)\n"
10474 * "Do not advertise to any peer (well-known community)\n"
10475 * "Do not export to next AS (well-known community)\n"
10476 * COMMUNITY_AANN_STR
10477 * "Do not send outside local AS (well-known community)\n"
10478 * "Do not advertise to any peer (well-known community)\n"
10479 * "Do not export to next AS (well-known community)\n"
10481 * "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)",
10484 * "Display routes matching the communities\n"
10485 * COMMUNITY_AANN_STR
10486 * "Do not send outside local AS (well-known community)\n"
10487 * "Do not advertise to any peer (well-known community)\n"
10488 * "Do not export to next AS (well-known community)\n"
10489 * COMMUNITY_AANN_STR
10490 * "Do not send outside local AS (well-known community)\n"
10491 * "Do not advertise to any peer (well-known community)\n"
10492 * "Do not export to next AS (well-known community)\n"
10493 * COMMUNITY_AANN_STR
10494 * "Do not send outside local AS (well-known community)\n"
10495 * "Do not advertise to any peer (well-known community)\n"
10496 * "Do not export to next AS (well-known community)\n"
10497 * COMMUNITY_AANN_STR
10498 * "Do not send outside local AS (well-known community)\n"
10499 * "Do not advertise to any peer (well-known community)\n"
10500 * "Do not export to next AS (well-known community)\n"
10503 DEFUN (show_bgp_community
,
10504 show_bgp_community_cmd
,
10505 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10508 "Display routes matching the communities\n"
10510 "Do not send outside local AS (well-known community)\n"
10511 "Do not advertise to any peer (well-known community)\n"
10512 "Do not export to next AS (well-known community)\n")
10514 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10526 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10527 * "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)",
10531 * "Display routes matching the communities\n"
10532 * COMMUNITY_AANN_STR
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 * COMMUNITY_AANN_STR
10537 * "Do not send outside local AS (well-known community)\n"
10538 * "Do not advertise to any peer (well-known community)\n"
10539 * "Do not export to next AS (well-known community)\n"
10540 * COMMUNITY_AANN_STR
10541 * "Do not send outside local AS (well-known community)\n"
10542 * "Do not advertise to any peer (well-known community)\n"
10543 * "Do not export to next AS (well-known community)\n"
10545 * "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)",
10549 * "Display routes matching the communities\n"
10550 * COMMUNITY_AANN_STR
10551 * "Do not send outside local AS (well-known community)\n"
10552 * "Do not advertise to any peer (well-known community)\n"
10553 * "Do not export to next AS (well-known community)\n"
10554 * COMMUNITY_AANN_STR
10555 * "Do not send outside local AS (well-known community)\n"
10556 * "Do not advertise to any peer (well-known community)\n"
10557 * "Do not export to next AS (well-known community)\n"
10558 * COMMUNITY_AANN_STR
10559 * "Do not send outside local AS (well-known community)\n"
10560 * "Do not advertise to any peer (well-known community)\n"
10561 * "Do not export to next AS (well-known community)\n"
10562 * COMMUNITY_AANN_STR
10563 * "Do not send outside local AS (well-known community)\n"
10564 * "Do not advertise to any peer (well-known community)\n"
10565 * "Do not export to next AS (well-known community)\n"
10567 * "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10571 * "Display routes matching the communities\n"
10572 * COMMUNITY_AANN_STR
10573 * "Do not send outside local AS (well-known community)\n"
10574 * "Do not advertise to any peer (well-known community)\n"
10575 * "Do not export to next AS (well-known community)\n"
10576 * COMMUNITY_AANN_STR
10577 * "Do not send outside local AS (well-known community)\n"
10578 * "Do not advertise to any peer (well-known community)\n"
10579 * "Do not export to next AS (well-known community)\n"
10582 DEFUN (show_ipv6_bgp_community
,
10583 show_ipv6_bgp_community_cmd
,
10584 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10588 "Display routes matching the communities\n"
10590 "Do not send outside local AS (well-known community)\n"
10591 "Do not advertise to any peer (well-known community)\n"
10592 "Do not export to next AS (well-known community)\n")
10594 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10595 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10605 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10606 * "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10609 * "Display routes matching the communities\n"
10610 * COMMUNITY_AANN_STR
10611 * "Do not send outside local AS (well-known community)\n"
10612 * "Do not advertise to any peer (well-known community)\n"
10613 * "Do not export to next AS (well-known community)\n"
10614 * COMMUNITY_AANN_STR
10615 * "Do not send outside local AS (well-known community)\n"
10616 * "Do not advertise to any peer (well-known community)\n"
10617 * "Do not export to next AS (well-known community)\n"
10618 * "Exact match of the communities"
10620 * "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",
10623 * "Address family\n"
10624 * "Display routes matching the communities\n"
10625 * COMMUNITY_AANN_STR
10626 * "Do not send outside local AS (well-known community)\n"
10627 * "Do not advertise to any peer (well-known community)\n"
10628 * "Do not export to next AS (well-known community)\n"
10629 * COMMUNITY_AANN_STR
10630 * "Do not send outside local AS (well-known community)\n"
10631 * "Do not advertise to any peer (well-known community)\n"
10632 * "Do not export to next AS (well-known community)\n"
10633 * COMMUNITY_AANN_STR
10634 * "Do not send outside local AS (well-known community)\n"
10635 * "Do not advertise to any peer (well-known community)\n"
10636 * "Do not export to next AS (well-known community)\n"
10637 * COMMUNITY_AANN_STR
10638 * "Do not send outside local AS (well-known community)\n"
10639 * "Do not advertise to any peer (well-known community)\n"
10640 * "Do not export to next AS (well-known community)\n"
10641 * "Exact match of the communities"
10643 * "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",
10646 * "Address family\n"
10647 * "Display routes matching the communities\n"
10648 * COMMUNITY_AANN_STR
10649 * "Do not send outside local AS (well-known community)\n"
10650 * "Do not advertise to any peer (well-known community)\n"
10651 * "Do not export to next AS (well-known community)\n"
10652 * COMMUNITY_AANN_STR
10653 * "Do not send outside local AS (well-known community)\n"
10654 * "Do not advertise to any peer (well-known community)\n"
10655 * "Do not export to next AS (well-known community)\n"
10656 * COMMUNITY_AANN_STR
10657 * "Do not send outside local AS (well-known community)\n"
10658 * "Do not advertise to any peer (well-known community)\n"
10659 * "Do not export to next AS (well-known community)\n"
10660 * "Exact match of the communities"
10662 * "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",
10665 * "Display routes matching the communities\n"
10666 * COMMUNITY_AANN_STR
10667 * "Do not send outside local AS (well-known community)\n"
10668 * "Do not advertise to any peer (well-known community)\n"
10669 * "Do not export to next AS (well-known community)\n"
10670 * COMMUNITY_AANN_STR
10671 * "Do not send outside local AS (well-known community)\n"
10672 * "Do not advertise to any peer (well-known community)\n"
10673 * "Do not export to next AS (well-known community)\n"
10674 * COMMUNITY_AANN_STR
10675 * "Do not send outside local AS (well-known community)\n"
10676 * "Do not advertise to any peer (well-known community)\n"
10677 * "Do not export to next AS (well-known community)\n"
10678 * "Exact match of the communities"
10680 * "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",
10683 * "Display routes matching the communities\n"
10684 * COMMUNITY_AANN_STR
10685 * "Do not send outside local AS (well-known community)\n"
10686 * "Do not advertise to any peer (well-known community)\n"
10687 * "Do not export to next AS (well-known community)\n"
10688 * COMMUNITY_AANN_STR
10689 * "Do not send outside local AS (well-known community)\n"
10690 * "Do not advertise to any peer (well-known community)\n"
10691 * "Do not export to next AS (well-known community)\n"
10692 * COMMUNITY_AANN_STR
10693 * "Do not send outside local AS (well-known community)\n"
10694 * "Do not advertise to any peer (well-known community)\n"
10695 * "Do not export to next AS (well-known community)\n"
10696 * COMMUNITY_AANN_STR
10697 * "Do not send outside local AS (well-known community)\n"
10698 * "Do not advertise to any peer (well-known community)\n"
10699 * "Do not export to next AS (well-known community)\n"
10700 * "Exact match of the communities"
10702 * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10705 * "Address family\n"
10706 * "Display routes matching the communities\n"
10707 * COMMUNITY_AANN_STR
10708 * "Do not send outside local AS (well-known community)\n"
10709 * "Do not advertise to any peer (well-known community)\n"
10710 * "Do not export to next AS (well-known community)\n"
10711 * "Exact match of the communities"
10713 * "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10716 * "Address family\n"
10717 * "Display routes matching the communities\n"
10718 * COMMUNITY_AANN_STR
10719 * "Do not send outside local AS (well-known community)\n"
10720 * "Do not advertise to any peer (well-known community)\n"
10721 * "Do not export to next AS (well-known community)\n"
10722 * COMMUNITY_AANN_STR
10723 * "Do not send outside local AS (well-known community)\n"
10724 * "Do not advertise to any peer (well-known community)\n"
10725 * "Do not export to next AS (well-known community)\n"
10726 * "Exact match of the communities"
10729 DEFUN (show_bgp_community_exact
,
10730 show_bgp_community_exact_cmd
,
10731 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10734 "Display routes matching the communities\n"
10736 "Do not send outside local AS (well-known community)\n"
10737 "Do not advertise to any peer (well-known community)\n"
10738 "Do not export to next AS (well-known community)\n"
10739 "Exact match of the communities")
10741 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10753 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10754 * "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",
10758 * "Display routes matching the communities\n"
10759 * COMMUNITY_AANN_STR
10760 * "Do not send outside local AS (well-known community)\n"
10761 * "Do not advertise to any peer (well-known community)\n"
10762 * "Do not export to next AS (well-known community)\n"
10763 * COMMUNITY_AANN_STR
10764 * "Do not send outside local AS (well-known community)\n"
10765 * "Do not advertise to any peer (well-known community)\n"
10766 * "Do not export to next AS (well-known community)\n"
10767 * COMMUNITY_AANN_STR
10768 * "Do not send outside local AS (well-known community)\n"
10769 * "Do not advertise to any peer (well-known community)\n"
10770 * "Do not export to next AS (well-known community)\n"
10771 * COMMUNITY_AANN_STR
10772 * "Do not send outside local AS (well-known community)\n"
10773 * "Do not advertise to any peer (well-known community)\n"
10774 * "Do not export to next AS (well-known community)\n"
10775 * "Exact match of the communities"
10777 * "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10781 * "Display routes matching the communities\n"
10782 * COMMUNITY_AANN_STR
10783 * "Do not send outside local AS (well-known community)\n"
10784 * "Do not advertise to any peer (well-known community)\n"
10785 * "Do not export to next AS (well-known community)\n"
10786 * COMMUNITY_AANN_STR
10787 * "Do not send outside local AS (well-known community)\n"
10788 * "Do not advertise to any peer (well-known community)\n"
10789 * "Do not export to next AS (well-known community)\n"
10790 * "Exact match of the communities"
10792 * "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",
10796 * "Display routes matching the communities\n"
10797 * COMMUNITY_AANN_STR
10798 * "Do not send outside local AS (well-known community)\n"
10799 * "Do not advertise to any peer (well-known community)\n"
10800 * "Do not export to next AS (well-known community)\n"
10801 * COMMUNITY_AANN_STR
10802 * "Do not send outside local AS (well-known community)\n"
10803 * "Do not advertise to any peer (well-known community)\n"
10804 * "Do not export to next AS (well-known community)\n"
10805 * COMMUNITY_AANN_STR
10806 * "Do not send outside local AS (well-known community)\n"
10807 * "Do not advertise to any peer (well-known community)\n"
10808 * "Do not export to next AS (well-known community)\n"
10809 * "Exact match of the communities"
10812 DEFUN (show_ipv6_bgp_community_exact
,
10813 show_ipv6_bgp_community_exact_cmd
,
10814 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10818 "Display routes matching the communities\n"
10820 "Do not send outside local AS (well-known community)\n"
10821 "Do not advertise to any peer (well-known community)\n"
10822 "Do not export to next AS (well-known community)\n"
10823 "Exact match of the communities")
10825 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10826 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10837 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10838 * "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10842 * "Display routes matching the communities\n"
10843 * COMMUNITY_AANN_STR
10844 * "Do not send outside local AS (well-known community)\n"
10845 * "Do not advertise to any peer (well-known community)\n"
10846 * "Do not export to next AS (well-known community)\n"
10847 * COMMUNITY_AANN_STR
10848 * "Do not send outside local AS (well-known community)\n"
10849 * "Do not advertise to any peer (well-known community)\n"
10850 * "Do not export to next AS (well-known community)\n"
10852 * "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)",
10856 * "Display routes matching the communities\n"
10857 * COMMUNITY_AANN_STR
10858 * "Do not send outside local AS (well-known community)\n"
10859 * "Do not advertise to any peer (well-known community)\n"
10860 * "Do not export to next AS (well-known community)\n"
10861 * COMMUNITY_AANN_STR
10862 * "Do not send outside local AS (well-known community)\n"
10863 * "Do not advertise to any peer (well-known community)\n"
10864 * "Do not export to next AS (well-known community)\n"
10865 * COMMUNITY_AANN_STR
10866 * "Do not send outside local AS (well-known community)\n"
10867 * "Do not advertise to any peer (well-known community)\n"
10868 * "Do not export to next AS (well-known community)\n"
10870 * "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)",
10874 * "Display routes matching the communities\n"
10875 * COMMUNITY_AANN_STR
10876 * "Do not send outside local AS (well-known community)\n"
10877 * "Do not advertise to any peer (well-known community)\n"
10878 * "Do not export to next AS (well-known community)\n"
10879 * COMMUNITY_AANN_STR
10880 * "Do not send outside local AS (well-known community)\n"
10881 * "Do not advertise to any peer (well-known community)\n"
10882 * "Do not export to next AS (well-known community)\n"
10883 * COMMUNITY_AANN_STR
10884 * "Do not send outside local AS (well-known community)\n"
10885 * "Do not advertise to any peer (well-known community)\n"
10886 * "Do not export to next AS (well-known community)\n"
10887 * COMMUNITY_AANN_STR
10888 * "Do not send outside local AS (well-known community)\n"
10889 * "Do not advertise to any peer (well-known community)\n"
10890 * "Do not export to next AS (well-known community)\n"
10893 DEFUN (show_ipv6_mbgp_community
,
10894 show_ipv6_mbgp_community_cmd
,
10895 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10899 "Display routes matching the communities\n"
10901 "Do not send outside local AS (well-known community)\n"
10902 "Do not advertise to any peer (well-known community)\n"
10903 "Do not export to next AS (well-known community)\n")
10905 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10906 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10917 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
10918 * "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",
10922 * "Display routes matching the communities\n"
10923 * COMMUNITY_AANN_STR
10924 * "Do not send outside local AS (well-known community)\n"
10925 * "Do not advertise to any peer (well-known community)\n"
10926 * "Do not export to next AS (well-known community)\n"
10927 * COMMUNITY_AANN_STR
10928 * "Do not send outside local AS (well-known community)\n"
10929 * "Do not advertise to any peer (well-known community)\n"
10930 * "Do not export to next AS (well-known community)\n"
10931 * COMMUNITY_AANN_STR
10932 * "Do not send outside local AS (well-known community)\n"
10933 * "Do not advertise to any peer (well-known community)\n"
10934 * "Do not export to next AS (well-known community)\n"
10935 * "Exact match of the communities"
10937 * "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",
10941 * "Display routes matching the communities\n"
10942 * COMMUNITY_AANN_STR
10943 * "Do not send outside local AS (well-known community)\n"
10944 * "Do not advertise to any peer (well-known community)\n"
10945 * "Do not export to next AS (well-known community)\n"
10946 * COMMUNITY_AANN_STR
10947 * "Do not send outside local AS (well-known community)\n"
10948 * "Do not advertise to any peer (well-known community)\n"
10949 * "Do not export to next AS (well-known community)\n"
10950 * COMMUNITY_AANN_STR
10951 * "Do not send outside local AS (well-known community)\n"
10952 * "Do not advertise to any peer (well-known community)\n"
10953 * "Do not export to next AS (well-known community)\n"
10954 * COMMUNITY_AANN_STR
10955 * "Do not send outside local AS (well-known community)\n"
10956 * "Do not advertise to any peer (well-known community)\n"
10957 * "Do not export to next AS (well-known community)\n"
10958 * "Exact match of the communities"
10960 * "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10964 * "Display routes matching the communities\n"
10965 * COMMUNITY_AANN_STR
10966 * "Do not send outside local AS (well-known community)\n"
10967 * "Do not advertise to any peer (well-known community)\n"
10968 * "Do not export to next AS (well-known community)\n"
10969 * COMMUNITY_AANN_STR
10970 * "Do not send outside local AS (well-known community)\n"
10971 * "Do not advertise to any peer (well-known community)\n"
10972 * "Do not export to next AS (well-known community)\n"
10973 * "Exact match of the communities"
10976 DEFUN (show_ipv6_mbgp_community_exact
,
10977 show_ipv6_mbgp_community_exact_cmd
,
10978 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10982 "Display routes matching the communities\n"
10984 "Do not send outside local AS (well-known community)\n"
10985 "Do not advertise to any peer (well-known community)\n"
10986 "Do not export to next AS (well-known community)\n"
10987 "Exact match of the communities")
10989 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10990 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
10998 #endif /* HAVE_IPV6 */
11001 bgp_show_community_list (struct vty
*vty
, const char *name
,
11002 const char *com
, int exact
,
11003 afi_t afi
, safi_t safi
)
11005 struct community_list
*list
;
11006 struct bgp
*bgp
= NULL
;
11008 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11010 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11011 return CMD_WARNING
;
11014 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
11017 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
11019 return CMD_WARNING
;
11022 return bgp_show (vty
, bgp
, afi
, safi
,
11023 (exact
? bgp_show_type_community_list_exact
:
11024 bgp_show_type_community_list
), list
, 0);
11027 DEFUN (show_ip_bgp_community_list
,
11028 show_ip_bgp_community_list_cmd
,
11029 "show ip bgp community-list (<1-500>|WORD)",
11033 "Display routes matching the community-list\n"
11034 "community-list number\n"
11035 "community-list name\n")
11037 return bgp_show_community_list (vty
, NULL
, argv
[4]->arg
, 0, AFI_IP
, SAFI_UNICAST
);
11040 DEFUN (show_ip_bgp_instance_community_list
,
11041 show_ip_bgp_instance_community_list_cmd
,
11042 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
11046 BGP_INSTANCE_HELP_STR
11047 "Display routes matching the community-list\n"
11048 "community-list number\n"
11049 "community-list name\n")
11051 return bgp_show_community_list (vty
, argv
[4]->arg
, argv
[6]->arg
, 0, AFI_IP
, SAFI_UNICAST
);
11054 DEFUN (show_ip_bgp_ipv4_community_list
,
11055 show_ip_bgp_ipv4_community_list_cmd
,
11056 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11061 "Address Family modifier\n"
11062 "Address Family modifier\n"
11063 "Display routes matching the community-list\n"
11064 "community-list number\n"
11065 "community-list name\n")
11067 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
11068 return bgp_show_community_list (vty
, NULL
, argv
[6]->arg
, 0, AFI_IP
, SAFI_MULTICAST
);
11070 return bgp_show_community_list (vty
, NULL
, argv
[6]->arg
, 0, AFI_IP
, SAFI_UNICAST
);
11073 DEFUN (show_ip_bgp_community_list_exact
,
11074 show_ip_bgp_community_list_exact_cmd
,
11075 "show ip bgp community-list (<1-500>|WORD) exact-match",
11079 "Display routes matching the community-list\n"
11080 "community-list number\n"
11081 "community-list name\n"
11082 "Exact match of the communities\n")
11084 return bgp_show_community_list (vty
, NULL
, argv
[4]->arg
, 1, AFI_IP
, SAFI_UNICAST
);
11087 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
11088 show_ip_bgp_ipv4_community_list_exact_cmd
,
11089 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11094 "Address Family modifier\n"
11095 "Address Family modifier\n"
11096 "Display routes matching the community-list\n"
11097 "community-list number\n"
11098 "community-list name\n"
11099 "Exact match of the communities\n")
11101 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
11102 return bgp_show_community_list (vty
, NULL
, argv
[6]->arg
, 1, AFI_IP
, SAFI_MULTICAST
);
11104 return bgp_show_community_list (vty
, NULL
, argv
[6]->arg
, 1, AFI_IP
, SAFI_UNICAST
);
11109 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
11110 * "show bgp ipv6 community-list (<1-500>|WORD)",
11113 * "Address family\n"
11114 * "Display routes matching the community-list\n"
11115 * "community-list number\n"
11116 * "community-list name\n"
11119 DEFUN (show_bgp_community_list
,
11120 show_bgp_community_list_cmd
,
11121 "show bgp community-list (<1-500>|WORD)",
11124 "Display routes matching the community-list\n"
11125 "community-list number\n"
11126 "community-list name\n")
11128 return bgp_show_community_list (vty
, NULL
, argv
[3]->arg
, 0, AFI_IP6
, SAFI_UNICAST
);
11133 DEFUN (show_ipv6_bgp_community_list
,
11134 show_ipv6_bgp_community_list_cmd
,
11135 "show ipv6 bgp community-list WORD",
11139 "Display routes matching the community-list\n"
11140 "community-list name\n")
11142 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11143 return bgp_show_community_list (vty
, NULL
, argv
[4]->arg
, 0, AFI_IP6
, SAFI_UNICAST
);
11147 DEFUN (show_ipv6_mbgp_community_list
,
11148 show_ipv6_mbgp_community_list_cmd
,
11149 "show ipv6 mbgp community-list WORD",
11153 "Display routes matching the community-list\n"
11154 "community-list name\n")
11156 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11157 return bgp_show_community_list (vty
, NULL
, argv
[4]->arg
, 0, AFI_IP6
, SAFI_MULTICAST
);
11161 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
11162 * "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11165 * "Address family\n"
11166 * "Display routes matching the community-list\n"
11167 * "community-list number\n"
11168 * "community-list name\n"
11169 * "Exact match of the communities\n"
11172 DEFUN (show_bgp_community_list_exact
,
11173 show_bgp_community_list_exact_cmd
,
11174 "show bgp community-list (<1-500>|WORD) exact-match",
11177 "Display routes matching the community-list\n"
11178 "community-list number\n"
11179 "community-list name\n"
11180 "Exact match of the communities\n")
11182 return bgp_show_community_list (vty
, NULL
, argv
[3]->arg
, 1, AFI_IP6
, SAFI_UNICAST
);
11187 DEFUN (show_ipv6_bgp_community_list_exact
,
11188 show_ipv6_bgp_community_list_exact_cmd
,
11189 "show ipv6 bgp community-list WORD exact-match",
11193 "Display routes matching the community-list\n"
11194 "community-list name\n"
11195 "Exact match of the communities\n")
11197 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11198 return bgp_show_community_list (vty
, NULL
, argv
[4]->arg
, 1, AFI_IP6
, SAFI_UNICAST
);
11202 DEFUN (show_ipv6_mbgp_community_list_exact
,
11203 show_ipv6_mbgp_community_list_exact_cmd
,
11204 "show ipv6 mbgp community-list WORD exact-match",
11208 "Display routes matching the community-list\n"
11209 "community-list name\n"
11210 "Exact match of the communities\n")
11212 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11213 return bgp_show_community_list (vty
, NULL
, argv
[4]->arg
, 1, AFI_IP6
, SAFI_MULTICAST
);
11215 #endif /* HAVE_IPV6 */
11218 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11219 const char *prefix
, afi_t afi
,
11220 safi_t safi
, enum bgp_show_type type
)
11224 struct bgp
*bgp
= NULL
;
11226 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11228 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11229 return CMD_WARNING
;
11234 ret
= str2prefix (prefix
, p
);
11237 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11238 return CMD_WARNING
;
11241 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11246 DEFUN (show_ip_bgp_prefix_longer
,
11247 show_ip_bgp_prefix_longer_cmd
,
11248 "show ip bgp A.B.C.D/M longer-prefixes",
11252 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11253 "Display route and more specific routes\n")
11255 return bgp_show_prefix_longer (vty
, NULL
, argv
[3]->arg
, AFI_IP
, SAFI_UNICAST
,
11256 bgp_show_type_prefix_longer
);
11259 DEFUN (show_ip_bgp_instance_prefix_longer
,
11260 show_ip_bgp_instance_prefix_longer_cmd
,
11261 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11265 BGP_INSTANCE_HELP_STR
11266 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11267 "Display route and more specific routes\n")
11269 return bgp_show_prefix_longer (vty
, argv
[4]->arg
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
,
11270 bgp_show_type_prefix_longer
);
11274 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
11275 * "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11279 * "Display detailed information about dampening\n"
11280 * "Display flap statistics of routes\n"
11281 * "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11282 * "Display route and more specific routes\n"
11285 DEFUN (show_ip_bgp_flap_prefix_longer
,
11286 show_ip_bgp_flap_prefix_longer_cmd
,
11287 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11291 "Display flap statistics of routes\n"
11292 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11293 "Display route and more specific routes\n")
11295 return bgp_show_prefix_longer (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_UNICAST
,
11296 bgp_show_type_flap_prefix_longer
);
11300 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11301 show_ip_bgp_ipv4_prefix_longer_cmd
,
11302 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11307 "Address Family modifier\n"
11308 "Address Family modifier\n"
11309 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11310 "Display route and more specific routes\n")
11312 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
11313 return bgp_show_prefix_longer (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_MULTICAST
,
11314 bgp_show_type_prefix_longer
);
11316 return bgp_show_prefix_longer (vty
, NULL
, argv
[5]->arg
, AFI_IP
, SAFI_UNICAST
,
11317 bgp_show_type_prefix_longer
);
11321 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
11322 * "show ip bgp dampening flap-statistics A.B.C.D",
11326 * "Display detailed information about dampening\n"
11327 * "Display flap statistics of routes\n"
11328 * "Network in the BGP routing table to display\n"
11331 DEFUN (show_ip_bgp_flap_address
,
11332 show_ip_bgp_flap_address_cmd
,
11333 "show ip bgp flap-statistics A.B.C.D",
11337 "Display flap statistics of routes\n"
11338 "Network in the BGP routing table to display\n")
11340 return bgp_show_prefix_longer (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_UNICAST
,
11341 bgp_show_type_flap_address
);
11346 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
11347 * "show ip bgp dampening flap-statistics A.B.C.D/M",
11351 * "Display detailed information about dampening\n"
11352 * "Display flap statistics of routes\n"
11353 * "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11356 DEFUN (show_ip_bgp_flap_prefix
,
11357 show_ip_bgp_flap_prefix_cmd
,
11358 "show ip bgp flap-statistics A.B.C.D/M",
11362 "Display flap statistics of routes\n"
11363 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11365 return bgp_show_prefix_longer (vty
, NULL
, argv
[4]->arg
, AFI_IP
, SAFI_UNICAST
,
11366 bgp_show_type_flap_prefix
);
11372 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
11373 * "show bgp ipv6 X:X::X:X/M longer-prefixes",
11376 * "Address family\n"
11377 * "IPv6 prefix <network>/<length>\n"
11378 * "Display route and more specific routes\n"
11381 DEFUN (show_bgp_prefix_longer
,
11382 show_bgp_prefix_longer_cmd
,
11383 "show bgp X:X::X:X/M longer-prefixes",
11386 "IPv6 prefix <network>/<length>\n"
11387 "Display route and more specific routes\n")
11389 return bgp_show_prefix_longer (vty
, NULL
, argv
[2]->arg
, AFI_IP6
, SAFI_UNICAST
,
11390 bgp_show_type_prefix_longer
);
11395 DEFUN (show_ipv6_bgp_prefix_longer
,
11396 show_ipv6_bgp_prefix_longer_cmd
,
11397 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11401 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11402 "Display route and more specific routes\n")
11404 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11405 return bgp_show_prefix_longer (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_UNICAST
,
11406 bgp_show_type_prefix_longer
);
11410 DEFUN (show_ipv6_mbgp_prefix_longer
,
11411 show_ipv6_mbgp_prefix_longer_cmd
,
11412 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11416 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11417 "Display route and more specific routes\n")
11419 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11420 return bgp_show_prefix_longer (vty
, NULL
, argv
[3]->arg
, AFI_IP6
, SAFI_MULTICAST
,
11421 bgp_show_type_prefix_longer
);
11423 #endif /* HAVE_IPV6 */
11425 static struct peer
*
11426 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11427 const char *ip_str
, u_char use_json
)
11432 union sockunion su
;
11434 /* BGP structure lookup. */
11437 bgp
= bgp_lookup_by_name (view_name
);
11442 json_object
*json_no
= NULL
;
11443 json_no
= json_object_new_object();
11444 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11445 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11446 json_object_free(json_no
);
11449 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11455 bgp
= bgp_get_default ();
11460 json_object
*json_no
= NULL
;
11461 json_no
= json_object_new_object();
11462 json_object_string_add(json_no
, "warning", "No BGP process configured");
11463 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11464 json_object_free(json_no
);
11467 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11472 /* Get peer sockunion. */
11473 ret
= str2sockunion (ip_str
, &su
);
11476 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11479 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11485 json_object
*json_no
= NULL
;
11486 json_no
= json_object_new_object();
11487 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11488 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11489 json_object_free(json_no
);
11492 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11499 /* Peer structure lookup. */
11500 peer
= peer_lookup (bgp
, &su
);
11505 json_object
*json_no
= NULL
;
11506 json_no
= json_object_new_object();
11507 json_object_string_add(json_no
, "warning","No such neighbor");
11508 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11509 json_object_free(json_no
);
11512 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11521 BGP_STATS_MAXBITLEN
= 0,
11523 BGP_STATS_PREFIXES
,
11525 BGP_STATS_UNAGGREGATEABLE
,
11526 BGP_STATS_MAX_AGGREGATEABLE
,
11527 BGP_STATS_AGGREGATES
,
11529 BGP_STATS_ASPATH_COUNT
,
11530 BGP_STATS_ASPATH_MAXHOPS
,
11531 BGP_STATS_ASPATH_TOTHOPS
,
11532 BGP_STATS_ASPATH_MAXSIZE
,
11533 BGP_STATS_ASPATH_TOTSIZE
,
11534 BGP_STATS_ASN_HIGHEST
,
11538 static const char *table_stats_strs
[] =
11540 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11541 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11542 [BGP_STATS_RIB
] = "Total Advertisements",
11543 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11544 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11545 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11546 [BGP_STATS_SPACE
] = "Address space advertised",
11547 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11548 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11549 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11550 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11551 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11552 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11553 [BGP_STATS_MAX
] = NULL
,
11556 struct bgp_table_stats
11558 struct bgp_table
*table
;
11559 unsigned long long counts
[BGP_STATS_MAX
];
11563 #define TALLY_SIGFIG 100000
11564 static unsigned long
11565 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11567 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11568 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11569 unsigned long ret
= newtot
/ count
;
11571 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11579 bgp_table_stats_walker (struct thread
*t
)
11581 struct bgp_node
*rn
;
11582 struct bgp_node
*top
;
11583 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11584 unsigned int space
= 0;
11586 if (!(top
= bgp_table_top (ts
->table
)))
11589 switch (top
->p
.family
)
11592 space
= IPV4_MAX_BITLEN
;
11595 space
= IPV6_MAX_BITLEN
;
11599 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11601 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11603 struct bgp_info
*ri
;
11604 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11605 unsigned int rinum
= 0;
11613 ts
->counts
[BGP_STATS_PREFIXES
]++;
11614 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11617 ts
->counts
[BGP_STATS_AVGPLEN
]
11618 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11619 ts
->counts
[BGP_STATS_AVGPLEN
],
11623 /* check if the prefix is included by any other announcements */
11624 while (prn
&& !prn
->info
)
11625 prn
= bgp_node_parent_nolock (prn
);
11627 if (prn
== NULL
|| prn
== top
)
11629 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11630 /* announced address space */
11632 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11634 else if (prn
->info
)
11635 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11637 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11640 ts
->counts
[BGP_STATS_RIB
]++;
11643 (CHECK_FLAG (ri
->attr
->flag
,
11644 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11645 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11647 /* as-path stats */
11648 if (ri
->attr
&& ri
->attr
->aspath
)
11650 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11651 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11652 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11654 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11656 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11657 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11659 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11660 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11662 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11663 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11665 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11666 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11667 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11669 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11670 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11671 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11674 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11675 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11683 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11685 struct bgp_table_stats ts
;
11688 if (!bgp
->rib
[afi
][safi
])
11690 vty_out (vty
, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s",
11691 afi
, safi
, VTY_NEWLINE
);
11692 return CMD_WARNING
;
11695 memset (&ts
, 0, sizeof (ts
));
11696 ts
.table
= bgp
->rib
[afi
][safi
];
11697 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11699 vty_out (vty
, "BGP %s RIB statistics%s%s",
11700 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11702 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11704 if (!table_stats_strs
[i
])
11710 case BGP_STATS_ASPATH_AVGHOPS
:
11711 case BGP_STATS_ASPATH_AVGSIZE
:
11712 case BGP_STATS_AVGPLEN
:
11713 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11714 vty_out (vty
, "%12.2f",
11715 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11718 case BGP_STATS_ASPATH_TOTHOPS
:
11719 case BGP_STATS_ASPATH_TOTSIZE
:
11720 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11721 vty_out (vty
, "%12.2f",
11723 (float)ts
.counts
[i
] /
11724 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11727 case BGP_STATS_TOTPLEN
:
11728 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11729 vty_out (vty
, "%12.2f",
11731 (float)ts
.counts
[i
] /
11732 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11735 case BGP_STATS_SPACE
:
11736 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11737 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11738 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11740 vty_out (vty
, "%30s: ", "%% announced ");
11741 vty_out (vty
, "%12.2f%s",
11742 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11743 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11745 vty_out (vty
, "%30s: ", "/8 equivalent ");
11746 vty_out (vty
, "%12.2f%s",
11747 (float)ts
.counts
[BGP_STATS_SPACE
] /
11748 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11750 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11752 vty_out (vty
, "%30s: ", "/24 equivalent ");
11753 vty_out (vty
, "%12.2f",
11754 (float)ts
.counts
[BGP_STATS_SPACE
] /
11755 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11758 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11759 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11762 vty_out (vty
, "%s", VTY_NEWLINE
);
11764 return CMD_SUCCESS
;
11768 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11769 const char *afi_str
, const char *safi_str
)
11776 bgp
= bgp_lookup_by_name (name
);
11778 bgp
= bgp_get_default ();
11782 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
11783 return CMD_WARNING
;
11785 if (strncmp (afi_str
, "ipv", 3) == 0)
11787 if (strncmp (afi_str
, "ipv4", 4) == 0)
11789 else if (strncmp (afi_str
, "ipv6", 4) == 0)
11793 vty_out (vty
, "%% Invalid address family %s%s",
11794 afi_str
, VTY_NEWLINE
);
11795 return CMD_WARNING
;
11797 if (strncmp (safi_str
, "m", 1) == 0)
11798 safi
= SAFI_MULTICAST
;
11799 else if (strncmp (safi_str
, "u", 1) == 0)
11800 safi
= SAFI_UNICAST
;
11801 else if (strncmp (safi_str
, "e", 1) == 0)
11803 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
11804 safi
= SAFI_MPLS_VPN
;
11807 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11808 safi_str
, VTY_NEWLINE
);
11809 return CMD_WARNING
;
11814 vty_out (vty
, "%% Invalid address family \"%s\"%s",
11815 afi_str
, VTY_NEWLINE
);
11816 return CMD_WARNING
;
11819 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11822 DEFUN (show_bgp_statistics
,
11823 show_bgp_statistics_cmd
,
11824 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
11829 "Address Family modifier\n"
11830 "Address Family modifier\n"
11831 "Address Family modifier\n"
11832 "Address Family modifier\n"
11833 "BGP RIB advertisement statistics\n")
11835 return bgp_table_stats_vty (vty
, NULL
, argv
[2]->arg
, argv
[3]->arg
);
11838 DEFUN (show_bgp_statistics_view
,
11839 show_bgp_statistics_view_cmd
,
11840 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics",
11843 BGP_INSTANCE_HELP_STR
11846 "Address Family modifier\n"
11847 "Address Family modifier\n"
11848 "Address Family modifier\n"
11849 "Address Family modifier\n"
11850 "BGP RIB advertisement statistics\n")
11852 return bgp_table_stats_vty (vty
, NULL
, argv
[3]->arg
, argv
[4]->arg
);
11865 PCOUNT_PFCNT
, /* the figure we display to users */
11869 static const char *pcount_strs
[] =
11871 [PCOUNT_ADJ_IN
] = "Adj-in",
11872 [PCOUNT_DAMPED
] = "Damped",
11873 [PCOUNT_REMOVED
] = "Removed",
11874 [PCOUNT_HISTORY
] = "History",
11875 [PCOUNT_STALE
] = "Stale",
11876 [PCOUNT_VALID
] = "Valid",
11877 [PCOUNT_ALL
] = "All RIB",
11878 [PCOUNT_COUNTED
] = "PfxCt counted",
11879 [PCOUNT_PFCNT
] = "Useable",
11880 [PCOUNT_MAX
] = NULL
,
11883 struct peer_pcounts
11885 unsigned int count
[PCOUNT_MAX
];
11886 const struct peer
*peer
;
11887 const struct bgp_table
*table
;
11891 bgp_peer_count_walker (struct thread
*t
)
11893 struct bgp_node
*rn
;
11894 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11895 const struct peer
*peer
= pc
->peer
;
11897 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11899 struct bgp_adj_in
*ain
;
11900 struct bgp_info
*ri
;
11902 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11903 if (ain
->peer
== peer
)
11904 pc
->count
[PCOUNT_ADJ_IN
]++;
11906 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11908 char buf
[SU_ADDRSTRLEN
];
11910 if (ri
->peer
!= peer
)
11913 pc
->count
[PCOUNT_ALL
]++;
11915 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11916 pc
->count
[PCOUNT_DAMPED
]++;
11917 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11918 pc
->count
[PCOUNT_HISTORY
]++;
11919 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
11920 pc
->count
[PCOUNT_REMOVED
]++;
11921 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
11922 pc
->count
[PCOUNT_STALE
]++;
11923 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
11924 pc
->count
[PCOUNT_VALID
]++;
11925 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11926 pc
->count
[PCOUNT_PFCNT
]++;
11928 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
11930 pc
->count
[PCOUNT_COUNTED
]++;
11931 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11932 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
11934 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11935 buf
, SU_ADDRSTRLEN
),
11941 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11942 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
11944 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11945 buf
, SU_ADDRSTRLEN
),
11955 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
11957 struct peer_pcounts pcounts
= { .peer
= peer
};
11959 json_object
*json
= NULL
;
11960 json_object
*json_loop
= NULL
;
11964 json
= json_object_new_object();
11965 json_loop
= json_object_new_object();
11968 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
11969 || !peer
->bgp
->rib
[afi
][safi
])
11973 json_object_string_add(json
, "warning", "No such neighbor or address family");
11974 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11975 json_object_free(json
);
11978 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11980 return CMD_WARNING
;
11983 memset (&pcounts
, 0, sizeof(pcounts
));
11984 pcounts
.peer
= peer
;
11985 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
11987 /* in-place call via thread subsystem so as to record execution time
11988 * * stats for the thread-walk (i.e. ensure this can't be blamed on
11989 * * on just vty_read()).
11991 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
11995 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
11996 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
11997 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
11999 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12000 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
12002 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
12004 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12006 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
12007 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
12009 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12010 json_object_free(json
);
12015 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
12017 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
12018 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
12023 vty_out (vty
, "Prefix counts for %s, %s%s",
12024 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
12027 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
12028 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
12029 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
12031 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12032 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
12034 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12036 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
12037 peer
->host
, VTY_NEWLINE
);
12038 vty_out (vty
, "Please report this bug, with the above command output%s",
12043 return CMD_SUCCESS
;
12046 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
12047 show_ip_bgp_neighbor_prefix_counts_cmd
,
12048 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12052 "Detailed information on TCP and BGP neighbor connections\n"
12053 "Neighbor to display information about\n"
12054 "Neighbor to display information about\n"
12055 "Neighbor on bgp configured interface\n"
12056 "Display detailed prefix count information\n"
12057 "JavaScript Object Notation\n")
12060 u_char uj
= use_json(argc
, argv
);
12062 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
12064 return CMD_WARNING
;
12066 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12069 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
12070 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
12071 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12075 BGP_INSTANCE_HELP_STR
12076 "Detailed information on TCP and BGP neighbor connections\n"
12077 "Neighbor to display information about\n"
12078 "Neighbor to display information about\n"
12079 "Neighbor on bgp configured interface\n"
12080 "Display detailed prefix count information\n"
12081 "JavaScript Object Notation\n")
12084 u_char uj
= use_json(argc
, argv
);
12086 peer
= peer_lookup_in_view (vty
, argv
[4]->arg
, argv
[6]->arg
, uj
);
12088 return CMD_WARNING
;
12090 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12093 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
12094 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
12095 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12099 "Detailed information on TCP and BGP neighbor connections\n"
12100 "Neighbor to display information about\n"
12101 "Neighbor to display information about\n"
12102 "Neighbor on bgp configured interface\n"
12103 "Display detailed prefix count information\n"
12104 "JavaScript Object Notation\n")
12107 u_char uj
= use_json(argc
, argv
);
12109 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
12111 return CMD_WARNING
;
12113 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12116 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
12117 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
12118 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12121 BGP_INSTANCE_HELP_STR
12123 "Detailed information on TCP and BGP neighbor connections\n"
12124 "Neighbor to display information about\n"
12125 "Neighbor to display information about\n"
12126 "Neighbor on bgp configured interface\n"
12127 "Display detailed prefix count information\n"
12128 "JavaScript Object Notation\n")
12131 u_char uj
= use_json(argc
, argv
);
12133 peer
= peer_lookup_in_view (vty
, argv
[3]->arg
, argv
[6]->arg
, uj
);
12135 return CMD_WARNING
;
12137 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12140 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
12141 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
12142 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12147 "Address Family modifier\n"
12148 "Address Family modifier\n"
12149 "Detailed information on TCP and BGP neighbor connections\n"
12150 "Neighbor to display information about\n"
12151 "Neighbor to display information about\n"
12152 "Neighbor on bgp configured interface\n"
12153 "Display detailed prefix count information\n"
12154 "JavaScript Object Notation\n")
12157 u_char uj
= use_json(argc
, argv
);
12159 peer
= peer_lookup_in_view (vty
, NULL
, argv
[6]->arg
, uj
);
12161 return CMD_WARNING
;
12163 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
12164 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, uj
);
12166 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12169 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
12170 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
12171 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12176 "Address Family modifier\n"
12177 "Address Family modifier\n"
12178 "Detailed information on TCP and BGP neighbor connections\n"
12179 "Neighbor to display information about\n"
12180 "Neighbor to display information about\n"
12181 "Neighbor on bgp configured interface\n"
12182 "Display detailed prefix count information\n"
12183 "JavaScript Object Notation\n")
12186 u_char uj
= use_json(argc
, argv
);
12188 peer
= peer_lookup_in_view (vty
, NULL
, argv
[6]->arg
, uj
);
12190 return CMD_WARNING
;
12192 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
, uj
);
12196 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12197 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
12199 struct bgp_table
*table
;
12200 struct bgp_adj_in
*ain
;
12201 struct bgp_adj_out
*adj
;
12202 unsigned long output_count
;
12203 unsigned long filtered_count
;
12204 struct bgp_node
*rn
;
12209 struct attr_extra extra
;
12211 struct update_subgroup
*subgrp
;
12212 json_object
*json_scode
= NULL
;
12213 json_object
*json_ocode
= NULL
;
12214 json_object
*json_ar
= NULL
;
12215 struct peer_af
*paf
;
12219 json_scode
= json_object_new_object();
12220 json_ocode
= json_object_new_object();
12221 json_ar
= json_object_new_object();
12223 json_object_string_add(json_scode
, "suppressed", "s");
12224 json_object_string_add(json_scode
, "damped", "d");
12225 json_object_string_add(json_scode
, "history", "h");
12226 json_object_string_add(json_scode
, "valid", "*");
12227 json_object_string_add(json_scode
, "best", ">");
12228 json_object_string_add(json_scode
, "multipath", "=");
12229 json_object_string_add(json_scode
, "internal", "i");
12230 json_object_string_add(json_scode
, "ribFailure", "r");
12231 json_object_string_add(json_scode
, "stale", "S");
12232 json_object_string_add(json_scode
, "removed", "R");
12234 json_object_string_add(json_ocode
, "igp", "i");
12235 json_object_string_add(json_ocode
, "egp", "e");
12236 json_object_string_add(json_ocode
, "incomplete", "?");
12245 json_object_string_add(json
, "alert", "no BGP");
12246 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12247 json_object_free(json
);
12250 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12254 table
= bgp
->rib
[afi
][safi
];
12256 output_count
= filtered_count
= 0;
12257 subgrp
= peer_subgroup(peer
, afi
, safi
);
12259 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12263 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12264 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12265 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12266 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12267 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12271 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12272 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12273 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12275 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12276 VTY_NEWLINE
, VTY_NEWLINE
);
12281 attr
.extra
= &extra
;
12282 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12286 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12288 if (ain
->peer
== peer
)
12294 json_object_int_add(json
, "bgpTableVersion", 0);
12295 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12296 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12297 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12301 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12302 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12303 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12310 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12315 bgp_attr_dup(&attr
, ain
->attr
);
12316 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12318 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12329 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12330 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12331 if (paf
->peer
== peer
)
12337 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12338 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12339 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12340 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12344 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12345 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12346 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12347 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12355 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12361 bgp_attr_dup(&attr
, adj
->attr
);
12362 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12363 if (ret
!= RMAP_DENY
)
12365 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12375 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12377 if (output_count
!= 0)
12380 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12382 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12383 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12387 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12388 json_object_free(json
);
12394 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12395 int in
, const char *rmap_name
, u_char use_json
)
12397 json_object
*json
= NULL
;
12400 json
= json_object_new_object();
12402 if (!peer
|| !peer
->afc
[afi
][safi
])
12406 json_object_string_add(json
, "warning", "No such neighbor or address family");
12407 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12408 json_object_free(json
);
12411 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12413 return CMD_WARNING
;
12416 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12420 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12421 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12422 json_object_free(json
);
12425 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12427 return CMD_WARNING
;
12430 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12432 return CMD_SUCCESS
;
12436 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12437 * "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12441 * BGP_INSTANCE_HELP_STR
12442 * "Detailed information on TCP and BGP neighbor connections\n"
12443 * "Neighbor to display information about\n"
12444 * "Neighbor to display information about\n"
12445 * "Neighbor on bgp configured interface\n"
12446 * "Display the routes advertised to a BGP neighbor\n"
12447 * "JavaScript Object Notation\n"
12450 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12451 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12452 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12456 BGP_INSTANCE_HELP_STR
12457 "Detailed information on TCP and BGP neighbor connections\n"
12458 "Neighbor to display information about\n"
12459 "Neighbor to display information about\n"
12460 "Display the routes advertised to a BGP neighbor\n"
12461 "JavaScript Object Notation\n")
12464 u_char uj
= use_json(argc
, argv
);
12466 if (argc
== 4 || (argc
== 3 && argv
[6]->arg
&& strcmp(argv
[6]->arg
, "json") != 0))
12467 peer
= peer_lookup_in_view (vty
, argv
[4]->arg
, argv
[6]->arg
, uj
);
12469 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
12472 return CMD_WARNING
;
12474 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12478 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12479 * "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12483 * "Detailed information on TCP and BGP neighbor connections\n"
12484 * "Neighbor to display information about\n"
12485 * "Neighbor to display information about\n"
12486 * "Neighbor on bgp configured interface\n"
12487 * "Display the routes advertised to a BGP neighbor\n"
12488 * "JavaScript Object Notation\n"
12491 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12492 show_ip_bgp_neighbor_advertised_route_cmd
,
12493 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
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 routes advertised to a BGP neighbor\n"
12502 "JavaScript Object Notation\n")
12506 const char *rmap_name
= NULL
;
12507 u_char uj
= use_json(argc
, argv
);
12509 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
12512 return CMD_WARNING
;
12514 if ((argc
== 2 && argv
[6]->arg
&& strcmp(argv
[6]->arg
, "json") != 0)
12516 rmap_name
= argv
[6]->arg
;
12518 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12523 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12524 * "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12528 * "Address family\n"
12529 * "Address Family modifier\n"
12530 * "Address Family modifier\n"
12531 * "Detailed information on TCP and BGP neighbor connections\n"
12532 * "Neighbor to display information about\n"
12533 * "Neighbor to display information about\n"
12534 * "Neighbor on bgp configured interface\n"
12535 * "Display the routes advertised to a BGP neighbor\n"
12536 * "Route-map to control what is displayed\n"
12537 * "JavaScript Object Notation\n"
12540 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12541 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12542 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12547 "Address Family modifier\n"
12548 "Address Family modifier\n"
12549 "Detailed information on TCP and BGP neighbor connections\n"
12550 "Neighbor to display information about\n"
12551 "Neighbor to display information about\n"
12552 "Neighbor on bgp configured interface\n"
12553 "Display the routes advertised to a BGP neighbor\n"
12554 "JavaScript Object Notation\n")
12557 const char *rmap_name
= NULL
;
12558 u_char uj
= use_json(argc
, argv
);
12560 peer
= peer_lookup_in_view (vty
, NULL
, argv
[6]->arg
, uj
);
12562 return CMD_WARNING
;
12564 if ((argc
== 4) || (argc
== 3 && argv
[8]->arg
&& strcmp(argv
[8]->arg
, "json") != 0))
12565 rmap_name
= argv
[8]->arg
;
12567 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
12568 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0, rmap_name
, uj
);
12570 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12576 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12577 * "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12580 * BGP_INSTANCE_HELP_STR
12581 * "Address family\n"
12582 * "Detailed information on TCP and BGP neighbor connections\n"
12583 * "Neighbor to display information about\n"
12584 * "Neighbor to display information about\n"
12585 * "Neighbor on bgp configured interface\n"
12586 * "Display the routes advertised to a BGP neighbor\n"
12587 * "JavaScript Object Notation\n"
12590 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12591 show_bgp_instance_neighbor_advertised_route_cmd
,
12592 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12595 BGP_INSTANCE_HELP_STR
12596 "Detailed information on TCP and BGP neighbor connections\n"
12597 "Neighbor to display information about\n"
12598 "Neighbor to display information about\n"
12599 "Neighbor on bgp configured interface\n"
12600 "Display the routes advertised to a BGP neighbor\n"
12601 "JavaScript Object Notation\n")
12604 u_char uj
= use_json(argc
, argv
);
12606 if (argc
== 4 || (argc
== 3 && argv
[5]->arg
&& strcmp(argv
[5]->arg
, "json") != 0))
12607 peer
= peer_lookup_in_view (vty
, argv
[3]->arg
, argv
[5]->arg
, uj
);
12609 peer
= peer_lookup_in_view (vty
, NULL
, argv
[3]->arg
, uj
);
12612 return CMD_WARNING
;
12614 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12619 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12620 * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12623 * "Address family\n"
12624 * "Detailed information on TCP and BGP neighbor connections\n"
12625 * "Neighbor to display information about\n"
12626 * "Neighbor to display information about\n"
12627 * "Neighbor on bgp configured interface\n"
12628 * "Display the routes advertised to a BGP neighbor\n"
12629 * "JavaScript Object Notation\n"
12631 * "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12635 * "Detailed information on TCP and BGP neighbor connections\n"
12636 * "Neighbor to display information about\n"
12637 * "Neighbor to display information about\n"
12638 * "Neighbor on bgp configured interface\n"
12639 * "Display the routes advertised to a BGP neighbor\n"
12640 * "JavaScript Object Notation\n"
12643 DEFUN (show_bgp_neighbor_advertised_route
,
12644 show_bgp_neighbor_advertised_route_cmd
,
12645 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12648 "Detailed information on TCP and BGP neighbor connections\n"
12649 "Neighbor to display information about\n"
12650 "Neighbor to display information about\n"
12651 "Neighbor on bgp configured interface\n"
12652 "Display the routes advertised to a BGP neighbor\n"
12653 "JavaScript Object Notation\n")
12657 const char *rmap_name
= NULL
;
12658 u_char uj
= use_json(argc
, argv
);
12660 peer
= peer_lookup_in_view (vty
, NULL
, argv
[3]->arg
, uj
);
12663 return CMD_WARNING
;
12665 if (argc
== 3 || (argc
== 2 && argv
[5]->arg
&& strcmp(argv
[5]->arg
, "json") != 0))
12666 rmap_name
= argv
[5]->arg
;
12668 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12675 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12676 ipv6_mbgp_neighbor_advertised_route_cmd
,
12677 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12681 "Detailed information on TCP and BGP neighbor connections\n"
12682 "Neighbor to display information about\n"
12683 "Neighbor to display information about\n"
12684 "Neighbor on bgp configured interface\n"
12685 "Neighbor on bgp configured interface\n"
12686 "Display the routes advertised to a BGP neighbor\n"
12687 "JavaScript Object Notation\n")
12690 u_char uj
= use_json(argc
, argv
);
12692 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
12694 return CMD_WARNING
;
12696 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12697 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12699 #endif /* HAVE_IPV6 */
12702 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12703 * "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12706 * BGP_INSTANCE_HELP_STR
12707 * "Address family\n"
12708 * "Detailed information on TCP and BGP neighbor connections\n"
12709 * "Neighbor to display information about\n"
12710 * "Neighbor to display information about\n"
12711 * "Neighbor on bgp configured interface\n"
12712 * "Display the received routes from neighbor\n"
12713 * "JavaScript Object Notation\n"
12716 DEFUN (show_bgp_instance_neighbor_received_routes
,
12717 show_bgp_instance_neighbor_received_routes_cmd
,
12718 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12721 BGP_INSTANCE_HELP_STR
12722 "Detailed information on TCP and BGP neighbor connections\n"
12723 "Neighbor to display information about\n"
12724 "Neighbor to display information about\n"
12725 "Neighbor on bgp configured interface\n"
12726 "Display the received routes from neighbor\n"
12727 "JavaScript Object Notation\n")
12730 u_char uj
= use_json(argc
, argv
);
12732 peer
= peer_lookup_in_view (vty
, argv
[3]->arg
, argv
[5]->arg
, uj
);
12734 return CMD_WARNING
;
12736 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12740 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12741 * "show ip bgp " BGP_INSTANCE_CMD " neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12745 * BGP_INSTANCE_HELP_STR
12746 * "Detailed information on TCP and BGP neighbor connections\n"
12747 * "Neighbor to display information about\n"
12748 * "Neighbor to display information about\n"
12749 * "Neighbor on bgp configured interface\n"
12750 * "Display the received routes from neighbor\n"
12751 * "JavaScript Object Notation\n"
12754 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12755 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12756 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12760 BGP_INSTANCE_HELP_STR
12761 "Detailed information on TCP and BGP neighbor connections\n"
12762 "Neighbor to display information about\n"
12763 "Neighbor to display information about\n"
12764 "Neighbor on bgp configured interface\n"
12765 "Display the received routes from neighbor\n"
12766 "JavaScript Object Notation\n")
12769 u_char uj
= use_json(argc
, argv
);
12771 peer
= peer_lookup_in_view (vty
, argv
[4]->arg
, argv
[6]->arg
, uj
);
12773 return CMD_WARNING
;
12775 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12780 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12781 * "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12785 * "Detailed information on TCP and BGP neighbor connections\n"
12786 * "Neighbor to display information about\n"
12787 * "Neighbor to display information about\n"
12788 * "Neighbor on bgp configured interface\n"
12789 * "Display the received routes from neighbor\n"
12790 * "JavaScript Object Notation\n"
12793 DEFUN (show_ip_bgp_neighbor_received_routes
,
12794 show_ip_bgp_neighbor_received_routes_cmd
,
12795 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12799 "Detailed information on TCP and BGP neighbor connections\n"
12800 "Neighbor to display information about\n"
12801 "Neighbor to display information about\n"
12802 "Neighbor on bgp configured interface\n"
12803 "Display the received routes from neighbor\n"
12804 "JavaScript Object Notation\n")
12808 const char *rmap_name
= NULL
;
12809 u_char uj
= use_json(argc
, argv
);
12811 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
12814 return CMD_WARNING
;
12816 if (argc
== 3 || (argc
== 2 && argv
[6]->arg
&& strcmp(argv
[6]->arg
, "json") != 0))
12817 rmap_name
= argv
[6]->arg
;
12819 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12825 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
12826 * "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12830 * "Address family\n"
12831 * "Address Family modifier\n"
12832 * "Address Family modifier\n"
12833 * "Detailed information on TCP and BGP neighbor connections\n"
12834 * "Neighbor to display information about\n"
12835 * "Neighbor to display information about\n"
12836 * "Neighbor on bgp configured interface\n"
12837 * "Display the received routes from neighbor\n"
12838 * "JavaScript Object Notation\n"
12841 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12842 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12843 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12848 "Address Family modifier\n"
12849 "Address Family modifier\n"
12850 "Detailed information on TCP and BGP neighbor connections\n"
12851 "Neighbor to display information about\n"
12852 "Neighbor to display information about\n"
12853 "Neighbor on bgp configured interface\n"
12854 "Display the received routes from neighbor\n"
12855 "JavaScript Object Notation\n")
12858 const char *rmap_name
= NULL
;
12859 u_char uj
= use_json(argc
, argv
);
12861 peer
= peer_lookup_in_view (vty
, NULL
, argv
[6]->arg
, uj
);
12863 return CMD_WARNING
;
12865 if (argc
== 4 || (argc
== 3 && argv
[8]->arg
&& strcmp(argv
[8]->arg
, "json") != 0))
12866 rmap_name
= argv
[8]->arg
;
12868 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
12869 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1, rmap_name
, uj
);
12871 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12875 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12876 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12877 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12880 BGP_INSTANCE_HELP_STR
12883 "Address family modifier\n"
12884 "Address family modifier\n"
12885 "Detailed information on TCP and BGP neighbor connections\n"
12886 "Neighbor to display information about\n"
12887 "Neighbor to display information about\n"
12888 "Neighbor on bgp configured interface\n"
12889 "Display the advertised routes to neighbor\n"
12890 "Display the received routes from neighbor\n"
12891 "JavaScript Object Notation\n")
12897 u_char uj
= use_json(argc
, argv
);
12899 peer
= peer_lookup_in_view (vty
, argv
[3]->arg
, argv
[7]->arg
, uj
);
12902 return CMD_WARNING
;
12904 afi
= (strncmp (argv
[4]->arg
, "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
12905 safi
= (strncmp (argv
[5]->arg
, "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
12906 in
= (strncmp (argv
[8]->arg
, "r", 1) == 0) ? 1 : 0;
12908 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12911 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12912 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12913 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12917 "Detailed information on TCP and BGP neighbor connections\n"
12918 "Neighbor to display information about\n"
12919 "Neighbor to display information about\n"
12920 "Neighbor on bgp configured interface\n"
12921 "Display information received from a BGP neighbor\n"
12922 "Display the prefixlist filter\n"
12923 "JavaScript Object Notation\n")
12926 union sockunion su
;
12929 u_char uj
= use_json(argc
, argv
);
12931 ret
= str2sockunion (argv
[4]->arg
, &su
);
12934 peer
= peer_lookup_by_conf_if (NULL
, argv
[4]->arg
);
12939 json_object
*json_no
= NULL
;
12940 json_object
*json_sub
= NULL
;
12941 json_no
= json_object_new_object();
12942 json_sub
= json_object_new_object();
12943 json_object_string_add(json_no
, "warning", "Malformed address or name");
12944 json_object_string_add(json_sub
, "warningCause", argv
[4]->arg
);
12945 json_object_object_add(json_no
, "detail", json_sub
);
12946 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12947 json_object_free(json_no
);
12950 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[4]->arg
, VTY_NEWLINE
);
12951 return CMD_WARNING
;
12956 peer
= peer_lookup (NULL
, &su
);
12961 json_object
*json_no
= NULL
;
12962 json_no
= json_object_new_object();
12963 json_object_string_add(json_no
, "warning", "Peer not found");
12964 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12965 json_object_free(json_no
);
12968 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12969 return CMD_WARNING
;
12973 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12974 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12978 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12979 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12985 json_object
*json_no
= NULL
;
12986 json_no
= json_object_new_object();
12987 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12988 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12989 json_object_free(json_no
);
12992 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12995 return CMD_SUCCESS
;
12998 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
12999 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
13000 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13005 "Address Family modifier\n"
13006 "Address Family modifier\n"
13007 "Detailed information on TCP and BGP neighbor connections\n"
13008 "Neighbor to display information about\n"
13009 "Neighbor to display information about\n"
13010 "Neighbor on bgp configured interface\n"
13011 "Display information received from a BGP neighbor\n"
13012 "Display the prefixlist filter\n"
13013 "JavaScript Object Notation\n")
13016 union sockunion su
;
13019 u_char uj
= use_json(argc
, argv
);
13021 ret
= str2sockunion (argv
[6]->arg
, &su
);
13024 peer
= peer_lookup_by_conf_if (NULL
, argv
[6]->arg
);
13029 json_object
*json_no
= NULL
;
13030 json_object
*json_sub
= NULL
;
13031 json_no
= json_object_new_object();
13032 json_sub
= json_object_new_object();
13033 json_object_string_add(json_no
, "warning", "Malformed address or name");
13034 json_object_string_add(json_sub
, "warningCause", argv
[6]->arg
);
13035 json_object_object_add(json_no
, "detail", json_sub
);
13036 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13037 json_object_free(json_no
);
13040 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[6]->arg
, VTY_NEWLINE
);
13041 return CMD_WARNING
;
13046 peer
= peer_lookup (NULL
, &su
);
13051 json_object
*json_no
= NULL
;
13052 json_no
= json_object_new_object();
13053 json_object_string_add(json_no
, "warning", "Peer not found");
13054 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13055 json_object_free(json_no
);
13058 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13059 return CMD_WARNING
;
13063 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
13065 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
13066 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13070 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
13071 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13077 json_object
*json_no
= NULL
;
13078 json_no
= json_object_new_object();
13079 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13080 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13081 json_object_free(json_no
);
13084 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13089 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
13090 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13094 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
13095 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13101 json_object
*json_no
= NULL
;
13102 json_no
= json_object_new_object();
13103 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13104 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13105 json_object_free(json_no
);
13108 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13112 return CMD_SUCCESS
;
13116 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
13117 * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13120 * "Address family\n"
13121 * "Detailed information on TCP and BGP neighbor connections\n"
13122 * "Neighbor to display information about\n"
13123 * "Neighbor to display information about\n"
13124 * "Neighbor on bgp configured interface\n"
13125 * "Display the received routes from neighbor\n"
13126 * "JavaScript Object Notation\n"
13128 * "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13132 * "Detailed information on TCP and BGP neighbor connections\n"
13133 * "Neighbor to display information about\n"
13134 * "Neighbor to display information about\n"
13135 * "Neighbor on bgp configured interface\n"
13136 * "Display the received routes from neighbor\n"
13137 * "JavaScript Object Notation\n"
13140 DEFUN (show_bgp_neighbor_received_routes
,
13141 show_bgp_neighbor_received_routes_cmd
,
13142 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13145 "Detailed information on TCP and BGP neighbor connections\n"
13146 "Neighbor to display information about\n"
13147 "Neighbor to display information about\n"
13148 "Neighbor on bgp configured interface\n"
13149 "Display the received routes from neighbor\n"
13150 "JavaScript Object Notation\n")
13153 const char *rmap_name
= NULL
;
13154 u_char uj
= use_json(argc
, argv
);
13156 peer
= peer_lookup_in_view (vty
, NULL
, argv
[3]->arg
, uj
);
13159 return CMD_WARNING
;
13161 if (argc
== 3 || (argc
== 2 && argv
[5]->arg
&& strcmp(argv
[5]->arg
, "json") != 0))
13162 rmap_name
= argv
[5]->arg
;
13164 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13169 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
13170 * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13173 * "Address family\n"
13174 * "Detailed information on TCP and BGP neighbor connections\n"
13175 * "Neighbor to display information about\n"
13176 * "Neighbor to display information about\n"
13177 * "Neighbor on bgp configured interface\n"
13178 * "Display information received from a BGP neighbor\n"
13179 * "Display the prefixlist filter\n"
13180 * "JavaScript Object Notation\n"
13183 DEFUN (show_bgp_neighbor_received_prefix_filter
,
13184 show_bgp_neighbor_received_prefix_filter_cmd
,
13185 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {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 information received from a BGP neighbor\n"
13193 "Display the prefixlist filter\n"
13194 "JavaScript Object Notation\n")
13197 union sockunion su
;
13200 u_char uj
= use_json(argc
, argv
);
13202 ret
= str2sockunion (argv
[3]->arg
, &su
);
13205 peer
= peer_lookup_by_conf_if (NULL
, argv
[3]->arg
);
13210 json_object
*json_no
= NULL
;
13211 json_object
*json_sub
= NULL
;
13212 json_no
= json_object_new_object();
13213 json_sub
= json_object_new_object();
13214 json_object_string_add(json_no
, "warning", "Malformed address or name");
13215 json_object_string_add(json_sub
, "warningCause", argv
[3]->arg
);
13216 json_object_object_add(json_no
, "detail", json_sub
);
13217 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13218 json_object_free(json_no
);
13221 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[3]->arg
, VTY_NEWLINE
);
13222 return CMD_WARNING
;
13227 peer
= peer_lookup (NULL
, &su
);
13232 json_object
*json_no
= NULL
;
13233 json_no
= json_object_new_object();
13234 json_object_string_add(json_no
, "warning", "No Peer");
13235 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13236 json_object_free(json_no
);
13239 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13240 return CMD_WARNING
;
13244 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13245 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13249 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13250 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13256 json_object
*json_no
= NULL
;
13257 json_no
= json_object_new_object();
13258 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13259 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13260 json_object_free(json_no
);
13263 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13266 return CMD_SUCCESS
;
13273 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13274 ipv6_mbgp_neighbor_received_routes_cmd
,
13275 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13279 "Detailed information on TCP and BGP neighbor connections\n"
13280 "Neighbor to display information about\n"
13281 "Neighbor to display information about\n"
13282 "Neighbor on bgp configured interface\n"
13283 "Display the received routes from neighbor\n"
13284 "JavaScript Object Notation\n")
13287 u_char uj
= use_json(argc
, argv
);
13289 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
13291 return CMD_WARNING
;
13293 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13294 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13298 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
13299 * "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13302 * BGP_INSTANCE_HELP_STR
13303 * "Address family\n"
13304 * "Detailed information on TCP and BGP neighbor connections\n"
13305 * "Neighbor to display information about\n"
13306 * "Neighbor to display information about\n"
13307 * "Neighbor on bgp configured interface\n"
13308 * "Display information received from a BGP neighbor\n"
13309 * "Display the prefixlist filter\n"
13310 * "JavaScript Object NOtation\n"
13313 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13314 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13315 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13318 BGP_INSTANCE_HELP_STR
13319 "Detailed information on TCP and BGP neighbor connections\n"
13320 "Neighbor to display information about\n"
13321 "Neighbor to display information about\n"
13322 "Neighbor on bgp configured interface\n"
13323 "Display information received from a BGP neighbor\n"
13324 "Display the prefixlist filter\n"
13325 "JavaScript Object Notation\n")
13328 union sockunion su
;
13332 u_char uj
= use_json(argc
, argv
);
13334 /* BGP structure lookup. */
13335 bgp
= bgp_lookup_by_name (argv
[3]->arg
);
13340 json_object
*json_no
= NULL
;
13341 json_no
= json_object_new_object();
13342 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13343 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13344 json_object_free(json_no
);
13347 vty_out (vty
, "Can't find BGP instance %s%s", argv
[3]->arg
, VTY_NEWLINE
);
13348 return CMD_WARNING
;
13351 ret
= str2sockunion (argv
[5]->arg
, &su
);
13354 peer
= peer_lookup_by_conf_if (bgp
, argv
[5]->arg
);
13359 json_object
*json_no
= NULL
;
13360 json_object
*json_sub
= NULL
;
13361 json_no
= json_object_new_object();
13362 json_sub
= json_object_new_object();
13363 json_object_string_add(json_no
, "warning", "Malformed address or name");
13364 json_object_string_add(json_sub
, "warningCause", argv
[5]->arg
);
13365 json_object_object_add(json_no
, "detail", json_sub
);
13366 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13367 json_object_free(json_no
);
13370 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[5]->arg
, VTY_NEWLINE
);
13371 return CMD_WARNING
;
13376 peer
= peer_lookup (bgp
, &su
);
13381 json_object
*json_no
= NULL
;
13382 json_no
= json_object_new_object();
13383 json_object_boolean_true_add(json_no
, "noPeer");
13384 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13385 json_object_free(json_no
);
13388 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13389 return CMD_WARNING
;
13394 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13395 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13399 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13400 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13403 return CMD_SUCCESS
;
13405 #endif /* HAVE_IPV6 */
13408 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13409 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13411 if (! peer
|| ! peer
->afc
[afi
][safi
])
13415 json_object
*json_no
= NULL
;
13416 json_no
= json_object_new_object();
13417 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13418 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13419 json_object_free(json_no
);
13422 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13423 return CMD_WARNING
;
13426 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13429 DEFUN (show_ip_bgp_neighbor_routes
,
13430 show_ip_bgp_neighbor_routes_cmd
,
13431 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13435 "Detailed information on TCP and BGP neighbor connections\n"
13436 "Neighbor to display information about\n"
13437 "Neighbor to display information about\n"
13438 "Neighbor on bgp configured interface\n"
13439 "Display routes learned from neighbor\n"
13440 "JavaScript Object Notation\n")
13443 u_char uj
= use_json(argc
, argv
);
13445 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
13447 return CMD_WARNING
;
13449 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13450 bgp_show_type_neighbor
, uj
);
13453 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13454 show_ip_bgp_instance_neighbor_routes_cmd
,
13455 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13459 BGP_INSTANCE_HELP_STR
13460 "Detailed information on TCP and BGP neighbor connections\n"
13461 "Neighbor to display information about\n"
13462 "Neighbor to display information about\n"
13463 "Neighbor on bgp configured interface\n"
13464 "Display routes learned from neighbor\n"
13465 "JavaScript Object Notation\n")
13468 u_char uj
= use_json(argc
, argv
);
13470 peer
= peer_lookup_in_view (vty
, argv
[4]->arg
, argv
[6]->arg
, uj
);
13472 return CMD_WARNING
;
13474 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13475 bgp_show_type_neighbor
, uj
);
13478 DEFUN (show_ip_bgp_neighbor_flap
,
13479 show_ip_bgp_neighbor_flap_cmd
,
13480 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13484 "Detailed information on TCP and BGP neighbor connections\n"
13485 "Neighbor to display information about\n"
13486 "Neighbor to display information about\n"
13487 "Neighbor on bgp configured interface\n"
13488 "Display flap statistics of the routes learned from neighbor\n"
13489 "JavaScript Object Notation\n")
13492 u_char uj
= use_json(argc
, argv
);
13494 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
13496 return CMD_WARNING
;
13498 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13499 bgp_show_type_flap_neighbor
, uj
);
13502 DEFUN (show_ip_bgp_neighbor_damp
,
13503 show_ip_bgp_neighbor_damp_cmd
,
13504 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13508 "Detailed information on TCP and BGP neighbor connections\n"
13509 "Neighbor to display information about\n"
13510 "Neighbor to display information about\n"
13511 "Neighbor on bgp configured interface\n"
13512 "Display the dampened routes received from neighbor\n"
13513 "JavaScript Object Notation\n")
13516 u_char uj
= use_json(argc
, argv
);
13518 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
13520 return CMD_WARNING
;
13522 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13523 bgp_show_type_damp_neighbor
, uj
);
13526 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13527 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13528 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13533 "Address Family modifier\n"
13534 "Address Family modifier\n"
13535 "Detailed information on TCP and BGP neighbor connections\n"
13536 "Neighbor to display information about\n"
13537 "Neighbor to display information about\n"
13538 "Neighbor on bgp configured interface\n"
13539 "Display routes learned from neighbor\n"
13540 "JavaScript Object Notation\n")
13543 u_char uj
= use_json(argc
, argv
);
13545 peer
= peer_lookup_in_view (vty
, NULL
, argv
[6]->arg
, uj
);
13547 return CMD_WARNING
;
13549 if (strncmp (argv
[4]->arg
, "m", 1) == 0)
13550 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
13551 bgp_show_type_neighbor
, uj
);
13553 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13554 bgp_show_type_neighbor
, uj
);
13559 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
13560 * "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13563 * BGP_INSTANCE_HELP_STR
13564 * "Address family\n"
13565 * "Detailed information on TCP and BGP neighbor connections\n"
13566 * "Neighbor to display information about\n"
13567 * "Neighbor to display information about\n"
13568 * "Neighbor on bgp configured interface\n"
13569 * "Display routes learned from neighbor\n"
13570 * "JavaScript Object Notation\n"
13573 DEFUN (show_bgp_instance_neighbor_routes
,
13574 show_bgp_instance_neighbor_routes_cmd
,
13575 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13578 BGP_INSTANCE_HELP_STR
13579 "Detailed information on TCP and BGP neighbor connections\n"
13580 "Neighbor to display information about\n"
13581 "Neighbor to display information about\n"
13582 "Neighbor on bgp configured interface\n"
13583 "Display routes learned from neighbor\n"
13584 "JavaScript Object Notation\n")
13587 u_char uj
= use_json(argc
, argv
);
13589 peer
= peer_lookup_in_view (vty
, argv
[3]->arg
, argv
[5]->arg
, uj
);
13591 return CMD_WARNING
;
13593 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13594 bgp_show_type_neighbor
, uj
);
13599 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
13600 * "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13603 * "Detailed information on TCP and BGP neighbor connections\n"
13604 * "Neighbor to display information about\n"
13605 * "Neighbor to display information about\n"
13606 * "Neighbor on bgp configured interface\n"
13607 * "Display the dampened routes received from neighbor\n"
13608 * "JavaScript Object Notation\n"
13610 * "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13613 * BGP_INSTANCE_HELP_STR
13614 * "Address family\n"
13615 * "Detailed information on TCP and BGP neighbor connections\n"
13616 * "Neighbor to display information about\n"
13617 * "Neighbor to display information about\n"
13618 * "Neighbor on bgp configured interface\n"
13619 * "Display the dampened routes received from neighbor\n"
13620 * "JavaScript Object Notation\n"
13622 * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13625 * "Address family\n"
13626 * "Detailed information on TCP and BGP neighbor connections\n"
13627 * "Neighbor to display information about\n"
13628 * "Neighbor to display information about\n"
13629 * "Neighbor on bgp configured interface\n"
13630 * "Display the dampened routes received from neighbor\n"
13631 * "JavaScript Object Notation\n"
13634 DEFUN (show_bgp_instance_neighbor_damp
,
13635 show_bgp_instance_neighbor_damp_cmd
,
13636 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13639 BGP_INSTANCE_HELP_STR
13640 "Detailed information on TCP and BGP neighbor connections\n"
13641 "Neighbor to display information about\n"
13642 "Neighbor to display information about\n"
13643 "Neighbor on bgp configured interface\n"
13644 "Display the dampened routes received from neighbor\n"
13645 "JavaScript Object Notation\n")
13648 u_char uj
= use_json(argc
, argv
);
13650 if ((argc
== 4 && argv
[7]->arg
&& strcmp(argv
[7]->arg
, "json") == 0)
13651 || (argc
== 3 && argv
[5]->arg
&& strcmp(argv
[5]->arg
, "json") != 0))
13652 peer
= peer_lookup_in_view (vty
, argv
[3]->arg
, argv
[5]->arg
, uj
);
13654 peer
= peer_lookup_in_view (vty
, NULL
, argv
[3]->arg
, uj
);
13657 return CMD_WARNING
;
13659 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13660 bgp_show_type_damp_neighbor
, uj
);
13665 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
13666 * "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13669 * "Detailed information on TCP and BGP neighbor connections\n"
13670 * "Neighbor to display information about\n"
13671 * "Neighbor to display information about\n"
13672 * "Neighbor on bgp configured interface\n"
13673 * "Display flap statistics of the routes learned from neighbor\n"
13674 * "JavaScript Object Notation\n"
13676 * "show bgp " BGP_INSTANCE_CMD " ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13679 * BGP_INSTANCE_HELP_STR
13680 * "Address family\n"
13681 * "Detailed information on TCP and BGP neighbor connections\n"
13682 * "Neighbor to display information about\n"
13683 * "Neighbor to display information about\n"
13684 * "Neighbor on bgp configured interface\n"
13685 * "Display flap statistics of the routes learned from neighbor\n"
13686 * "JavaScript Object Notation\n"
13688 * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13691 * "Address family\n"
13692 * "Detailed information on TCP and BGP neighbor connections\n"
13693 * "Neighbor to display information about\n"
13694 * "Neighbor to display information about\n"
13695 * "Neighbor on bgp configured interface\n"
13696 * "Display flap statistics of the routes learned from neighbor\n"
13697 * "JavaScript Object Notation\n"
13700 DEFUN (show_bgp_instance_neighbor_flap
,
13701 show_bgp_instance_neighbor_flap_cmd
,
13702 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13705 BGP_INSTANCE_HELP_STR
13706 "Detailed information on TCP and BGP neighbor connections\n"
13707 "Neighbor to display information about\n"
13708 "Neighbor to display information about\n"
13709 "Neighbor on bgp configured interface\n"
13710 "Display flap statistics of the routes learned from neighbor\n"
13711 "JavaScript Object Notation\n")
13714 u_char uj
= use_json(argc
, argv
);
13716 if ((argc
== 4 && argv
[7]->arg
&& strcmp(argv
[7]->arg
, "json") == 0)
13717 || (argc
== 3 && argv
[5]->arg
&& strcmp(argv
[5]->arg
, "json") != 0))
13718 peer
= peer_lookup_in_view (vty
, argv
[3]->arg
, argv
[5]->arg
, uj
);
13720 peer
= peer_lookup_in_view (vty
, NULL
, argv
[3]->arg
, uj
);
13723 return CMD_WARNING
;
13725 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13726 bgp_show_type_flap_neighbor
, uj
);
13731 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
13732 * "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13736 * "Detailed information on TCP and BGP neighbor connections\n"
13737 * "Neighbor to display information about\n"
13738 * "Neighbor to display information about\n"
13739 * "Neighbor on bgp configured interface\n"
13740 * "Display routes learned from neighbor\n"
13741 * "JavaScript Object Notation\n"
13743 * "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13746 * "Address family\n"
13747 * "Detailed information on TCP and BGP neighbor connections\n"
13748 * "Neighbor to display information about\n"
13749 * "Neighbor to display information about\n"
13750 * "Neighbor on bgp configured interface\n"
13751 * "Display routes learned from neighbor\n"
13752 * "JavaScript Object Notation\n"
13755 DEFUN (show_bgp_neighbor_routes
,
13756 show_bgp_neighbor_routes_cmd
,
13757 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13760 "Detailed information on TCP and BGP neighbor connections\n"
13761 "Neighbor to display information about\n"
13762 "Neighbor to display information about\n"
13763 "Neighbor on bgp configured interface\n"
13764 "Display routes learned from neighbor\n"
13765 "JavaScript Object Notation\n")
13768 u_char uj
= use_json(argc
, argv
);
13770 peer
= peer_lookup_in_view (vty
, NULL
, argv
[3]->arg
, uj
);
13772 return CMD_WARNING
;
13774 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13775 bgp_show_type_neighbor
, uj
);
13783 DEFUN (ipv6_mbgp_neighbor_routes
,
13784 ipv6_mbgp_neighbor_routes_cmd
,
13785 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13789 "Detailed information on TCP and BGP neighbor connections\n"
13790 "Neighbor to display information about\n"
13791 "Neighbor to display information about\n"
13792 "Neighbor on bgp configured interface\n"
13793 "Display routes learned from neighbor\n"
13794 "JavaScript Object Notation\n")
13797 u_char uj
= use_json(argc
, argv
);
13799 peer
= peer_lookup_in_view (vty
, NULL
, argv
[4]->arg
, uj
);
13801 return CMD_WARNING
;
13803 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13804 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13805 bgp_show_type_neighbor
, uj
);
13812 #endif /* HAVE_IPV6 */
13814 struct bgp_table
*bgp_distance_table
;
13816 struct bgp_distance
13818 /* Distance value for the IP source prefix. */
13821 /* Name of the access-list to be matched. */
13825 static struct bgp_distance
*
13826 bgp_distance_new (void)
13828 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13832 bgp_distance_free (struct bgp_distance
*bdistance
)
13834 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13838 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13839 const char *ip_str
, const char *access_list_str
)
13842 struct prefix_ipv4 p
;
13844 struct bgp_node
*rn
;
13845 struct bgp_distance
*bdistance
;
13847 ret
= str2prefix_ipv4 (ip_str
, &p
);
13850 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13851 return CMD_WARNING
;
13854 distance
= atoi (distance_str
);
13856 /* Get BGP distance node. */
13857 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
13860 bdistance
= rn
->info
;
13861 bgp_unlock_node (rn
);
13865 bdistance
= bgp_distance_new ();
13866 rn
->info
= bdistance
;
13869 /* Set distance value. */
13870 bdistance
->distance
= distance
;
13872 /* Reset access-list configuration. */
13873 if (bdistance
->access_list
)
13875 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13876 bdistance
->access_list
= NULL
;
13878 if (access_list_str
)
13879 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13881 return CMD_SUCCESS
;
13885 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13886 const char *ip_str
, const char *access_list_str
)
13890 struct prefix_ipv4 p
;
13891 struct bgp_node
*rn
;
13892 struct bgp_distance
*bdistance
;
13894 ret
= str2prefix_ipv4 (ip_str
, &p
);
13897 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13898 return CMD_WARNING
;
13901 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
13904 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13905 return CMD_WARNING
;
13908 bdistance
= rn
->info
;
13909 distance
= atoi(distance_str
);
13911 if (bdistance
->distance
!= distance
)
13913 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13914 return CMD_WARNING
;
13917 if (bdistance
->access_list
)
13918 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13919 bgp_distance_free (bdistance
);
13922 bgp_unlock_node (rn
);
13923 bgp_unlock_node (rn
);
13925 return CMD_SUCCESS
;
13928 /* Apply BGP information to distance method. */
13930 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
13932 struct bgp_node
*rn
;
13933 struct prefix_ipv4 q
;
13935 struct bgp_distance
*bdistance
;
13936 struct access_list
*alist
;
13937 struct bgp_static
*bgp_static
;
13942 if (p
->family
!= AF_INET
)
13945 peer
= rinfo
->peer
;
13947 if (peer
->su
.sa
.sa_family
!= AF_INET
)
13950 memset (&q
, 0, sizeof (struct prefix_ipv4
));
13951 q
.family
= AF_INET
;
13952 q
.prefix
= peer
->su
.sin
.sin_addr
;
13953 q
.prefixlen
= IPV4_MAX_BITLEN
;
13955 /* Check source address. */
13956 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
13959 bdistance
= rn
->info
;
13960 bgp_unlock_node (rn
);
13962 if (bdistance
->access_list
)
13964 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
13965 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13966 return bdistance
->distance
;
13969 return bdistance
->distance
;
13972 /* Backdoor check. */
13973 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
13976 bgp_static
= rn
->info
;
13977 bgp_unlock_node (rn
);
13979 if (bgp_static
->backdoor
)
13981 if (bgp
->distance_local
)
13982 return bgp
->distance_local
;
13984 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13988 if (peer
->sort
== BGP_PEER_EBGP
)
13990 if (bgp
->distance_ebgp
)
13991 return bgp
->distance_ebgp
;
13992 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
13996 if (bgp
->distance_ibgp
)
13997 return bgp
->distance_ibgp
;
13998 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
14002 DEFUN (bgp_distance
,
14004 "distance bgp <1-255> <1-255> <1-255>",
14005 "Define an administrative distance\n"
14007 "Distance for routes external to the AS\n"
14008 "Distance for routes internal to the AS\n"
14009 "Distance for local routes\n")
14015 bgp
->distance_ebgp
= atoi (argv
[2]->arg
);
14016 bgp
->distance_ibgp
= atoi (argv
[3]->arg
);
14017 bgp
->distance_local
= atoi (argv
[4]->arg
);
14018 return CMD_SUCCESS
;
14022 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
14023 * "no distance bgp",
14025 * "Define an administrative distance\n"
14029 DEFUN (no_bgp_distance
,
14030 no_bgp_distance_cmd
,
14031 "no distance bgp <1-255> <1-255> <1-255>",
14033 "Define an administrative distance\n"
14035 "Distance for routes external to the AS\n"
14036 "Distance for routes internal to the AS\n"
14037 "Distance for local routes\n")
14043 bgp
->distance_ebgp
= 0;
14044 bgp
->distance_ibgp
= 0;
14045 bgp
->distance_local
= 0;
14046 return CMD_SUCCESS
;
14050 DEFUN (bgp_distance_source
,
14051 bgp_distance_source_cmd
,
14052 "distance <1-255> A.B.C.D/M",
14053 "Define an administrative distance\n"
14054 "Administrative distance\n"
14055 "IP source prefix\n")
14057 bgp_distance_set (vty
, argv
[1]->arg
, argv
[2]->arg
, NULL
);
14058 return CMD_SUCCESS
;
14061 DEFUN (no_bgp_distance_source
,
14062 no_bgp_distance_source_cmd
,
14063 "no distance <1-255> A.B.C.D/M",
14065 "Define an administrative distance\n"
14066 "Administrative distance\n"
14067 "IP source prefix\n")
14069 bgp_distance_unset (vty
, argv
[2]->arg
, argv
[3]->arg
, NULL
);
14070 return CMD_SUCCESS
;
14073 DEFUN (bgp_distance_source_access_list
,
14074 bgp_distance_source_access_list_cmd
,
14075 "distance <1-255> A.B.C.D/M WORD",
14076 "Define an administrative distance\n"
14077 "Administrative distance\n"
14078 "IP source prefix\n"
14079 "Access list name\n")
14081 bgp_distance_set (vty
, argv
[1]->arg
, argv
[2]->arg
, argv
[3]->arg
);
14082 return CMD_SUCCESS
;
14085 DEFUN (no_bgp_distance_source_access_list
,
14086 no_bgp_distance_source_access_list_cmd
,
14087 "no distance <1-255> A.B.C.D/M WORD",
14089 "Define an administrative distance\n"
14090 "Administrative distance\n"
14091 "IP source prefix\n"
14092 "Access list name\n")
14094 bgp_distance_unset (vty
, argv
[2]->arg
, argv
[3]->arg
, argv
[4]->arg
);
14095 return CMD_SUCCESS
;
14099 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
14101 * "BGP Specific commands\n"
14102 * "Enable route-flap dampening\n"
14104 * "bgp dampening <1-45>",
14105 * "BGP Specific commands\n"
14106 * "Enable route-flap dampening\n"
14107 * "Half-life time for the penalty\n"
14110 DEFUN (bgp_damp_set
,
14112 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14113 "BGP Specific commands\n"
14114 "Enable route-flap dampening\n"
14115 "Half-life time for the penalty\n"
14116 "Value to start reusing a route\n"
14117 "Value to start suppressing a route\n"
14118 "Maximum duration to suppress a stable route\n")
14121 int half
= DEFAULT_HALF_LIFE
* 60;
14122 int reuse
= DEFAULT_REUSE
;
14123 int suppress
= DEFAULT_SUPPRESS
;
14124 int max
= 4 * half
;
14128 half
= atoi (argv
[2]->arg
) * 60;
14129 reuse
= atoi (argv
[3]->arg
);
14130 suppress
= atoi (argv
[4]->arg
);
14131 max
= atoi (argv
[5]->arg
) * 60;
14133 else if (argc
== 1)
14135 half
= atoi (argv
[2]->arg
) * 60;
14141 if (suppress
< reuse
)
14143 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
14148 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
14149 half
, reuse
, suppress
, max
);
14155 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
14156 * "no bgp dampening <1-45>",
14158 * "BGP Specific commands\n"
14159 * "Enable route-flap dampening\n"
14160 * "Half-life time for the penalty\n"
14162 * "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14164 * "BGP Specific commands\n"
14165 * "Enable route-flap dampening\n"
14166 * "Half-life time for the penalty\n"
14167 * "Value to start reusing a route\n"
14168 * "Value to start suppressing a route\n"
14169 * "Maximum duration to suppress a stable route\n"
14172 DEFUN (bgp_damp_unset
,
14173 bgp_damp_unset_cmd
,
14174 "no bgp dampening",
14176 "BGP Specific commands\n"
14177 "Enable route-flap dampening\n")
14182 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
14188 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
14189 * "show ip bgp dampening dampened-paths",
14193 * "Display detailed information about dampening\n"
14194 * "Display paths suppressed due to dampening\n"
14197 DEFUN (show_ip_bgp_dampened_paths
,
14198 show_ip_bgp_dampened_paths_cmd
,
14199 "show ip bgp dampened-paths",
14203 "Display paths suppressed due to dampening\n")
14205 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
14211 * CHECK ME - The following ALIASes need to be implemented in this DEFUN
14212 * "show ip bgp dampening flap-statistics",
14216 * "Display detailed information about dampening\n"
14217 * "Display flap statistics of routes\n"
14220 DEFUN (show_ip_bgp_flap_statistics
,
14221 show_ip_bgp_flap_statistics_cmd
,
14222 "show ip bgp flap-statistics",
14226 "Display flap statistics of routes\n")
14228 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
14229 bgp_show_type_flap_statistics
, NULL
, 0);
14233 /* Display specified route of BGP table. */
14235 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
14236 const char *ip_str
, afi_t afi
, safi_t safi
,
14237 struct prefix_rd
*prd
, int prefix_check
)
14240 struct prefix match
;
14241 struct bgp_node
*rn
;
14242 struct bgp_node
*rm
;
14243 struct bgp_info
*ri
;
14244 struct bgp_info
*ri_temp
;
14246 struct bgp_table
*table
;
14248 /* BGP structure lookup. */
14251 bgp
= bgp_lookup_by_name (view_name
);
14254 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
14255 return CMD_WARNING
;
14260 bgp
= bgp_get_default ();
14263 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14264 return CMD_WARNING
;
14268 /* Check IP address argument. */
14269 ret
= str2prefix (ip_str
, &match
);
14272 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14273 return CMD_WARNING
;
14276 match
.family
= afi2family (afi
);
14278 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14280 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14282 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14285 if ((table
= rn
->info
) != NULL
)
14286 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14288 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14293 if (ri
->extra
&& ri
->extra
->damp_info
)
14295 ri_temp
= ri
->next
;
14296 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14304 bgp_unlock_node (rm
);
14310 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14312 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14317 if (ri
->extra
&& ri
->extra
->damp_info
)
14319 ri_temp
= ri
->next
;
14320 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14328 bgp_unlock_node (rn
);
14332 return CMD_SUCCESS
;
14335 DEFUN (clear_ip_bgp_dampening
,
14336 clear_ip_bgp_dampening_cmd
,
14337 "clear ip bgp dampening",
14341 "Clear route flap dampening information\n")
14343 bgp_damp_info_clean ();
14344 return CMD_SUCCESS
;
14347 DEFUN (clear_ip_bgp_dampening_prefix
,
14348 clear_ip_bgp_dampening_prefix_cmd
,
14349 "clear ip bgp dampening A.B.C.D/M",
14353 "Clear route flap dampening information\n"
14354 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14356 return bgp_clear_damp_route (vty
, NULL
, argv
[4]->arg
, AFI_IP
,
14357 SAFI_UNICAST
, NULL
, 1);
14360 DEFUN (clear_ip_bgp_dampening_address
,
14361 clear_ip_bgp_dampening_address_cmd
,
14362 "clear ip bgp dampening A.B.C.D",
14366 "Clear route flap dampening information\n"
14367 "Network to clear damping information\n")
14369 return bgp_clear_damp_route (vty
, NULL
, argv
[4]->arg
, AFI_IP
,
14370 SAFI_UNICAST
, NULL
, 0);
14373 DEFUN (clear_ip_bgp_dampening_address_mask
,
14374 clear_ip_bgp_dampening_address_mask_cmd
,
14375 "clear ip bgp dampening A.B.C.D A.B.C.D",
14379 "Clear route flap dampening information\n"
14380 "Network to clear damping information\n"
14384 char prefix_str
[BUFSIZ
];
14386 ret
= netmask_str2prefix_str (argv
[4]->arg
, argv
[5]->arg
, prefix_str
);
14389 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14390 return CMD_WARNING
;
14393 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14394 SAFI_UNICAST
, NULL
, 0);
14397 /* also used for encap safi */
14399 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14400 afi_t afi
, safi_t safi
, int *write
)
14402 struct bgp_node
*prn
;
14403 struct bgp_node
*rn
;
14404 struct bgp_table
*table
;
14406 struct prefix_rd
*prd
;
14407 struct bgp_static
*bgp_static
;
14409 char buf
[SU_ADDRSTRLEN
];
14410 char rdbuf
[RD_ADDRSTRLEN
];
14412 /* Network configuration. */
14413 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14414 if ((table
= prn
->info
) != NULL
)
14415 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14416 if ((bgp_static
= rn
->info
) != NULL
)
14419 prd
= (struct prefix_rd
*) &prn
->p
;
14421 /* "address-family" display. */
14422 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14424 /* "network" configuration display. */
14425 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14426 label
= decode_label (bgp_static
->tag
);
14428 vty_out (vty
, " network %s/%d rd %s tag %d",
14429 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14432 vty_out (vty
, "%s", VTY_NEWLINE
);
14437 /* Configuration of static route announcement and aggregate
14440 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14441 afi_t afi
, safi_t safi
, int *write
)
14443 struct bgp_node
*rn
;
14445 struct bgp_static
*bgp_static
;
14446 struct bgp_aggregate
*bgp_aggregate
;
14447 char buf
[SU_ADDRSTRLEN
];
14449 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14450 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14452 /* Network configuration. */
14453 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14454 if ((bgp_static
= rn
->info
) != NULL
)
14458 /* "address-family" display. */
14459 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14461 /* "network" configuration display. */
14462 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14464 u_int32_t destination
;
14465 struct in_addr netmask
;
14467 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14468 masklen2ip (p
->prefixlen
, &netmask
);
14469 vty_out (vty
, " network %s",
14470 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14472 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14473 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14474 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14475 || p
->u
.prefix4
.s_addr
== 0)
14477 /* Natural mask is not display. */
14480 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14484 vty_out (vty
, " network %s/%d",
14485 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14489 if (bgp_static
->rmap
.name
)
14490 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14493 if (bgp_static
->backdoor
)
14494 vty_out (vty
, " backdoor");
14497 vty_out (vty
, "%s", VTY_NEWLINE
);
14500 /* Aggregate-address configuration. */
14501 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14502 if ((bgp_aggregate
= rn
->info
) != NULL
)
14506 /* "address-family" display. */
14507 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14509 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14511 struct in_addr netmask
;
14513 masklen2ip (p
->prefixlen
, &netmask
);
14514 vty_out (vty
, " aggregate-address %s %s",
14515 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14516 inet_ntoa (netmask
));
14520 vty_out (vty
, " aggregate-address %s/%d",
14521 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14525 if (bgp_aggregate
->as_set
)
14526 vty_out (vty
, " as-set");
14528 if (bgp_aggregate
->summary_only
)
14529 vty_out (vty
, " summary-only");
14531 vty_out (vty
, "%s", VTY_NEWLINE
);
14538 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
14540 struct bgp_node
*rn
;
14541 struct bgp_distance
*bdistance
;
14543 /* Distance configuration. */
14544 if (bgp
->distance_ebgp
14545 && bgp
->distance_ibgp
14546 && bgp
->distance_local
14547 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
14548 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
14549 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
14550 vty_out (vty
, " distance bgp %d %d %d%s",
14551 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
14554 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
14555 if ((bdistance
= rn
->info
) != NULL
)
14557 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
14558 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
14559 bdistance
->access_list
? bdistance
->access_list
: "",
14566 /* Allocate routing table structure and install commands. */
14568 bgp_route_init (void)
14570 /* Init BGP distance table. */
14571 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
14573 /* IPv4 BGP commands. */
14574 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14575 install_element (BGP_NODE
, &bgp_network_cmd
);
14576 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14577 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14578 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14579 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14580 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14581 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14582 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14583 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14584 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14585 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14586 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14587 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14589 install_element (BGP_NODE
, &aggregate_address_cmd
);
14590 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14591 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14592 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14593 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14594 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14595 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14596 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14597 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14598 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14600 /* IPv4 unicast configuration. */
14601 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14602 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14603 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14604 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14605 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14606 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14607 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14608 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14609 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14610 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14611 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14613 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14614 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14615 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14616 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14617 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14618 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14619 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14620 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14621 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14622 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14624 /* IPv4 multicast configuration. */
14625 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14626 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14627 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14628 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14629 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14630 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14631 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14632 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14633 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14634 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14635 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14636 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14637 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14638 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14639 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14640 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14641 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14642 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14643 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14644 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14645 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14647 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14648 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14649 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14650 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14651 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14652 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14653 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14654 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14655 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14656 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14657 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14658 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14659 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14660 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14661 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14662 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14663 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14664 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14665 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14666 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14668 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14669 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14670 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14671 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14672 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14673 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14674 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14675 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14676 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14677 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14678 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14679 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14680 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14681 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14682 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14683 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14684 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14685 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14686 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14687 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14688 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14689 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14690 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14691 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14692 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14693 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14694 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14695 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14696 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14697 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14698 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14699 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14700 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14701 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14702 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14703 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14704 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14705 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14706 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14707 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14708 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14709 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14710 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
14711 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14712 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
14713 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
14714 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14715 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14716 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14717 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14718 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14719 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14720 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14721 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14722 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14723 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14724 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14726 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
14727 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
14728 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14729 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14730 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14731 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14732 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14733 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14734 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
14735 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14736 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14737 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14738 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14739 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14740 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14741 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14742 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14743 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14744 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
14745 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14746 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14747 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14748 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
14749 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14751 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
14752 install_element (ENABLE_NODE
, &show_ip_bgp_instance_cmd
);
14753 install_element (ENABLE_NODE
, &show_ip_bgp_instance_all_cmd
);
14754 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
14755 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
14756 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_cmd
);
14757 install_element (ENABLE_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14758 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14759 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14760 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14761 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14762 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14763 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
14764 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14765 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14766 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14767 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14768 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14769 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14770 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14772 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
14773 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14774 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
14775 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14776 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14777 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
14778 install_element (ENABLE_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14779 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14780 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
14781 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14782 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14783 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
14784 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14785 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
14786 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14787 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
14788 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14789 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14790 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14791 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
14792 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14793 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
14794 install_element (ENABLE_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14795 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14796 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14797 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14798 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14799 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14800 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14801 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14802 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14803 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14804 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14805 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14806 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14807 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14808 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14809 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14810 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14811 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14812 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14813 install_element (ENABLE_NODE
, &show_ip_bgp_dampening_params_cmd
);
14814 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14815 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
14816 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
14817 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
14818 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14819 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
14820 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14821 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14822 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14823 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14824 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14825 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14826 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14827 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14828 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14830 install_element (VIEW_NODE
, &show_bgp_ipv4_prefix_cmd
);
14831 install_element (ENABLE_NODE
, &show_bgp_ipv4_prefix_cmd
);
14832 install_element (VIEW_NODE
, &show_bgp_ipv4_vpn_rd_route_cmd
);
14833 install_element (ENABLE_NODE
, &show_bgp_ipv4_vpn_rd_route_cmd
);
14834 install_element (VIEW_NODE
, &show_bgp_ipv4_vpn_route_cmd
);
14835 install_element (ENABLE_NODE
, &show_bgp_ipv4_vpn_route_cmd
);
14837 install_element (VIEW_NODE
, &show_bgp_ipv6_vpn_rd_route_cmd
);
14838 install_element (ENABLE_NODE
, &show_bgp_ipv6_vpn_rd_route_cmd
);
14839 install_element (VIEW_NODE
, &show_bgp_ipv6_vpn_route_cmd
);
14840 install_element (ENABLE_NODE
, &show_bgp_ipv6_vpn_route_cmd
);
14842 /* BGP dampening clear commands */
14843 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14844 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14845 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14846 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14849 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14850 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14851 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14852 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
14854 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14855 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14857 /* New config IPv6 BGP commands. */
14858 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14859 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14860 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14861 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14862 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14864 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14865 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14866 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14867 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14869 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14870 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14872 /* Old config IPv6 BGP commands. */
14875 install_element (VIEW_NODE
, &show_bgp_cmd
);
14876 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14877 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14878 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14879 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14880 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14881 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14882 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14883 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14884 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14885 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14886 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14887 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14888 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14889 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14890 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14891 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14892 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14893 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14894 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14895 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14896 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14897 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14898 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14899 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14900 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14901 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14902 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14903 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14904 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14905 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14906 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14907 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14908 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14909 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14910 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14911 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14912 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14913 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14914 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14915 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14916 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14917 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14920 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
14922 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
14923 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
14924 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14925 install_element (RESTRICTED_NODE
, &show_bgp_route_pathtype_cmd
);
14926 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14927 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
14928 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
14929 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14930 install_element (RESTRICTED_NODE
, &show_bgp_prefix_pathtype_cmd
);
14931 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14932 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
14933 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
14934 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_cmd
);
14935 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14936 install_element (RESTRICTED_NODE
, &show_bgp_instance_prefix_cmd
);
14937 install_element (RESTRICTED_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14939 install_element (ENABLE_NODE
, &show_bgp_cmd
);
14940 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
14941 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
14942 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
14943 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14944 install_element (ENABLE_NODE
, &show_bgp_route_pathtype_cmd
);
14945 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14946 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
14947 install_element (ENABLE_NODE
, &show_bgp_prefix_pathtype_cmd
);
14948 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14949 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
14950 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14951 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
14952 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
14953 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
14954 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
14955 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
14956 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
14957 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
14958 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
14959 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
14960 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
14961 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14962 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14963 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
14964 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14965 install_element (ENABLE_NODE
, &show_bgp_instance_cmd
);
14966 install_element (ENABLE_NODE
, &show_bgp_instance_all_cmd
);
14967 install_element (ENABLE_NODE
, &show_bgp_instance_route_cmd
);
14968 install_element (ENABLE_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14969 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_cmd
);
14970 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14971 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_list_cmd
);
14972 install_element (ENABLE_NODE
, &show_bgp_instance_filter_list_cmd
);
14973 install_element (ENABLE_NODE
, &show_bgp_instance_route_map_cmd
);
14974 install_element (ENABLE_NODE
, &show_bgp_instance_community_list_cmd
);
14975 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14976 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14977 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14978 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14979 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14980 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14981 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14984 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
14985 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
14986 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
14987 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
14990 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
14991 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
14992 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
14993 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
14994 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14995 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14996 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
14997 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
14998 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14999 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
15000 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15001 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15002 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
15003 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
15004 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15005 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15006 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15007 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15008 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15009 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
15010 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15011 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15012 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15013 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15016 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
15017 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
15018 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
15019 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
15020 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
15021 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
15022 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
15023 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
15024 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
15025 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
15026 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15027 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15028 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
15029 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
15030 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15031 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15032 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15033 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15034 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15035 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
15036 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15037 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15038 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15039 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15042 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15043 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15046 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15047 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15050 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15051 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15052 #endif /* HAVE_IPV6 */
15054 install_element (BGP_NODE
, &bgp_distance_cmd
);
15055 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
15056 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
15057 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
15058 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
15059 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
15061 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15062 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15063 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15064 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15066 /* IPv4 Multicast Mode */
15067 install_element (BGP_IPV4M_NODE
, &bgp_damp_set_cmd
);
15068 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset_cmd
);
15072 bgp_route_finish (void)
15074 bgp_table_unlock (bgp_distance_table
);
15075 bgp_distance_table
= NULL
;