1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
34 #include "sockunion.h"
37 #include "workqueue.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_table.h"
43 #include "bgpd/bgp_route.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_debug.h"
46 #include "bgpd/bgp_aspath.h"
47 #include "bgpd/bgp_regex.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_ecommunity.h"
50 #include "bgpd/bgp_clist.h"
51 #include "bgpd/bgp_packet.h"
52 #include "bgpd/bgp_filter.h"
53 #include "bgpd/bgp_fsm.h"
54 #include "bgpd/bgp_mplsvpn.h"
55 #include "bgpd/bgp_nexthop.h"
56 #include "bgpd/bgp_damp.h"
57 #include "bgpd/bgp_advertise.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_nht.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_vty.h"
66 #include "rfapi_backend.h"
67 #include "vnc_import_bgp.h"
68 #include "vnc_export_bgp.h"
71 /* Extern from bgp_dump.c */
72 extern const char *bgp_origin_str
[];
73 extern const char *bgp_origin_long_str
[];
76 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
77 struct prefix_rd
*prd
)
80 struct bgp_node
*prn
= NULL
;
86 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
88 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
90 if (prn
->info
== NULL
)
91 prn
->info
= bgp_table_init (afi
, safi
);
93 bgp_unlock_node (prn
);
97 rn
= bgp_node_get (table
, p
);
99 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
105 /* Allocate bgp_info_extra */
106 static struct bgp_info_extra
*
107 bgp_info_extra_new (void)
109 struct bgp_info_extra
*new;
110 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
115 bgp_info_extra_free (struct bgp_info_extra
**extra
)
119 if ((*extra
)->damp_info
)
120 bgp_damp_info_free ((*extra
)->damp_info
, 0);
122 (*extra
)->damp_info
= NULL
;
124 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
130 /* Get bgp_info extra information for the given bgp_info, lazy allocated
133 struct bgp_info_extra
*
134 bgp_info_extra_get (struct bgp_info
*ri
)
137 ri
->extra
= bgp_info_extra_new();
141 /* Allocate new bgp info structure. */
145 return XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
148 /* Free bgp route information. */
150 bgp_info_free (struct bgp_info
*binfo
)
153 bgp_attr_unintern (&binfo
->attr
);
155 bgp_unlink_nexthop(binfo
);
156 bgp_info_extra_free (&binfo
->extra
);
157 bgp_info_mpath_free (&binfo
->mpath
);
159 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
161 XFREE (MTYPE_BGP_ROUTE
, binfo
);
165 bgp_info_lock (struct bgp_info
*binfo
)
172 bgp_info_unlock (struct bgp_info
*binfo
)
174 assert (binfo
&& binfo
->lock
> 0);
177 if (binfo
->lock
== 0)
180 zlog_debug ("%s: unlocked and freeing", __func__
);
181 zlog_backtrace (LOG_DEBUG
);
183 bgp_info_free (binfo
);
188 if (binfo
->lock
== 1)
190 zlog_debug ("%s: unlocked to 1", __func__
);
191 zlog_backtrace (LOG_DEBUG
);
199 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
201 struct bgp_info
*top
;
213 peer_lock (ri
->peer
); /* bgp_info peer reference */
216 /* Do the actual removal of info from RIB, for use by bgp_process
217 completion callback *only* */
219 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
222 ri
->next
->prev
= ri
->prev
;
224 ri
->prev
->next
= ri
->next
;
228 bgp_info_mpath_dequeue (ri
);
229 bgp_info_unlock (ri
);
230 bgp_unlock_node (rn
);
234 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
236 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
237 /* set of previous already took care of pcount */
238 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
241 /* undo the effects of a previous call to bgp_info_delete; typically
242 called when a route is deleted and then quickly re-added before the
243 deletion has been processed */
245 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
247 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
248 /* unset of previous already took care of pcount */
249 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
252 /* Adjust pcount as required */
254 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
256 struct bgp_table
*table
;
258 assert (rn
&& bgp_node_table (rn
));
259 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
261 table
= bgp_node_table (rn
);
263 if (ri
->peer
== ri
->peer
->bgp
->peer_self
)
266 if (!BGP_INFO_COUNTABLE (ri
)
267 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
270 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
272 /* slight hack, but more robust against errors. */
273 if (ri
->peer
->pcount
[table
->afi
][table
->safi
])
274 ri
->peer
->pcount
[table
->afi
][table
->safi
]--;
277 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
278 __func__
, ri
->peer
->host
);
279 zlog_backtrace (LOG_WARNING
);
280 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
283 else if (BGP_INFO_COUNTABLE (ri
)
284 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
286 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
287 ri
->peer
->pcount
[table
->afi
][table
->safi
]++;
292 /* Set/unset bgp_info flags, adjusting any other state as needed.
293 * This is here primarily to keep prefix-count in check.
296 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
298 SET_FLAG (ri
->flags
, flag
);
300 /* early bath if we know it's not a flag that changes countability state */
301 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
304 bgp_pcount_adjust (rn
, ri
);
308 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
310 UNSET_FLAG (ri
->flags
, flag
);
312 /* early bath if we know it's not a flag that changes countability state */
313 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
316 bgp_pcount_adjust (rn
, ri
);
319 /* Get MED value. If MED value is missing and "bgp bestpath
320 missing-as-worst" is specified, treat it as the worst value. */
322 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
324 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
328 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
336 bgp_info_path_with_addpath_rx_str (struct bgp_info
*ri
, char *buf
)
338 if (ri
->addpath_rx_id
)
339 sprintf(buf
, "path %s (addpath rxid %d)", ri
->peer
->host
, ri
->addpath_rx_id
);
341 sprintf(buf
, "path %s", ri
->peer
->host
);
344 /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */
346 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
347 int *paths_eq
, struct bgp_maxpaths_cfg
*mpath_cfg
, int debug
,
350 struct attr
*newattr
, *existattr
;
351 struct attr_extra
*newattre
, *existattre
;
352 bgp_peer_sort_t new_sort
;
353 bgp_peer_sort_t exist_sort
;
355 u_int32_t exist_pref
;
358 u_int32_t new_weight
;
359 u_int32_t exist_weight
;
360 uint32_t newm
, existm
;
361 struct in_addr new_id
;
362 struct in_addr exist_id
;
365 int internal_as_route
;
368 char new_buf
[PATH_ADDPATH_STR_BUFFER
];
369 char exist_buf
[PATH_ADDPATH_STR_BUFFER
];
377 zlog_debug("%s: new is NULL", pfx_buf
);
382 bgp_info_path_with_addpath_rx_str (new, new_buf
);
387 zlog_debug("%s: %s is the initial bestpath", pfx_buf
, new_buf
);
393 bgp_info_path_with_addpath_rx_str (exist
, exist_buf
);
394 zlog_debug("%s: Comparing %s flags 0x%x with %s flags 0x%x",
395 pfx_buf
, new_buf
, new->flags
, exist_buf
, exist
->flags
);
399 existattr
= exist
->attr
;
400 newattre
= newattr
->extra
;
401 existattre
= existattr
->extra
;
403 /* 1. Weight check. */
404 new_weight
= exist_weight
= 0;
407 new_weight
= newattre
->weight
;
409 exist_weight
= existattre
->weight
;
411 if (new_weight
> exist_weight
)
414 zlog_debug("%s: %s wins over %s due to weight %d > %d",
415 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
419 if (new_weight
< exist_weight
)
422 zlog_debug("%s: %s loses to %s due to weight %d < %d",
423 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
427 /* 2. Local preference check. */
428 new_pref
= exist_pref
= bgp
->default_local_pref
;
430 if (newattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
431 new_pref
= newattr
->local_pref
;
432 if (existattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
433 exist_pref
= existattr
->local_pref
;
435 if (new_pref
> exist_pref
)
438 zlog_debug("%s: %s wins over %s due to localpref %d > %d",
439 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
443 if (new_pref
< exist_pref
)
446 zlog_debug("%s: %s loses to %s due to localpref %d < %d",
447 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
451 /* 3. Local route check. We prefer:
453 * - BGP_ROUTE_AGGREGATE
454 * - BGP_ROUTE_REDISTRIBUTE
456 if (! (new->sub_type
== BGP_ROUTE_NORMAL
))
459 zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type",
460 pfx_buf
, new_buf
, exist_buf
);
464 if (! (exist
->sub_type
== BGP_ROUTE_NORMAL
))
467 zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type",
468 pfx_buf
, new_buf
, exist_buf
);
472 /* 4. AS path length check. */
473 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
475 int exist_hops
= aspath_count_hops (existattr
->aspath
);
476 int exist_confeds
= aspath_count_confeds (existattr
->aspath
);
478 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
482 aspath_hops
= aspath_count_hops (newattr
->aspath
);
483 aspath_hops
+= aspath_count_confeds (newattr
->aspath
);
485 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
488 zlog_debug("%s: %s wins over %s due to aspath (with confeds) hopcount %d < %d",
489 pfx_buf
, new_buf
, exist_buf
,
490 aspath_hops
, (exist_hops
+ exist_confeds
));
494 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
497 zlog_debug("%s: %s loses to %s due to aspath (with confeds) hopcount %d > %d",
498 pfx_buf
, new_buf
, exist_buf
,
499 aspath_hops
, (exist_hops
+ exist_confeds
));
505 int newhops
= aspath_count_hops (newattr
->aspath
);
507 if (newhops
< exist_hops
)
510 zlog_debug("%s: %s wins over %s due to aspath hopcount %d < %d",
511 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
515 if (newhops
> exist_hops
)
518 zlog_debug("%s: %s loses to %s due to aspath hopcount %d > %d",
519 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
525 /* 5. Origin check. */
526 if (newattr
->origin
< existattr
->origin
)
529 zlog_debug("%s: %s wins over %s due to ORIGIN %s < %s",
530 pfx_buf
, new_buf
, exist_buf
,
531 bgp_origin_long_str
[newattr
->origin
],
532 bgp_origin_long_str
[existattr
->origin
]);
536 if (newattr
->origin
> existattr
->origin
)
539 zlog_debug("%s: %s loses to %s due to ORIGIN %s > %s",
540 pfx_buf
, new_buf
, exist_buf
,
541 bgp_origin_long_str
[newattr
->origin
],
542 bgp_origin_long_str
[existattr
->origin
]);
547 internal_as_route
= (aspath_count_hops (newattr
->aspath
) == 0
548 && aspath_count_hops (existattr
->aspath
) == 0);
549 confed_as_route
= (aspath_count_confeds (newattr
->aspath
) > 0
550 && aspath_count_confeds (existattr
->aspath
) > 0
551 && aspath_count_hops (newattr
->aspath
) == 0
552 && aspath_count_hops (existattr
->aspath
) == 0);
554 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
555 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
557 || aspath_cmp_left (newattr
->aspath
, existattr
->aspath
)
558 || aspath_cmp_left_confed (newattr
->aspath
, existattr
->aspath
)
559 || internal_as_route
)
561 new_med
= bgp_med_value (new->attr
, bgp
);
562 exist_med
= bgp_med_value (exist
->attr
, bgp
);
564 if (new_med
< exist_med
)
567 zlog_debug("%s: %s wins over %s due to MED %d < %d",
568 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
572 if (new_med
> exist_med
)
575 zlog_debug("%s: %s loses to %s due to MED %d > %d",
576 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
581 /* 7. Peer type check. */
582 new_sort
= new->peer
->sort
;
583 exist_sort
= exist
->peer
->sort
;
585 if (new_sort
== BGP_PEER_EBGP
586 && (exist_sort
== BGP_PEER_IBGP
|| exist_sort
== BGP_PEER_CONFED
))
589 zlog_debug("%s: %s wins over %s due to eBGP peer > iBGP peer",
590 pfx_buf
, new_buf
, exist_buf
);
594 if (exist_sort
== BGP_PEER_EBGP
595 && (new_sort
== BGP_PEER_IBGP
|| new_sort
== BGP_PEER_CONFED
))
598 zlog_debug("%s: %s loses to %s due to iBGP peer < eBGP peer",
599 pfx_buf
, new_buf
, exist_buf
);
603 /* 8. IGP metric check. */
607 newm
= new->extra
->igpmetric
;
609 existm
= exist
->extra
->igpmetric
;
614 zlog_debug("%s: %s wins over %s due to IGP metric %d < %d",
615 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
622 zlog_debug("%s: %s loses to %s due to IGP metric %d > %d",
623 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
627 /* 9. Same IGP metric. Compare the cluster list length as
628 representative of IGP hops metric. Rewrite the metric value
629 pair (newm, existm) with the cluster list length. Prefer the
630 path with smaller cluster list length. */
633 if (peer_sort (new->peer
) == BGP_PEER_IBGP
634 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
635 && CHECK_FLAG (mpath_cfg
->ibgp_flags
,
636 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
638 newm
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
639 existm
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
644 zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
645 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
652 zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
653 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
659 /* 10. confed-external vs. confed-internal */
660 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
662 if (new_sort
== BGP_PEER_CONFED
&& exist_sort
== BGP_PEER_IBGP
)
665 zlog_debug("%s: %s wins over %s due to confed-external peer > confed-internal peer",
666 pfx_buf
, new_buf
, exist_buf
);
670 if (exist_sort
== BGP_PEER_CONFED
&& new_sort
== BGP_PEER_IBGP
)
673 zlog_debug("%s: %s loses to %s due to confed-internal peer < confed-external peer",
674 pfx_buf
, new_buf
, exist_buf
);
679 /* 11. Maximum path check. */
682 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
))
686 * For the two paths, all comparison steps till IGP metric
687 * have succeeded - including AS_PATH hop count. Since 'bgp
688 * bestpath as-path multipath-relax' knob is on, we don't need
689 * an exact match of AS_PATH. Thus, mark the paths are equal.
690 * That will trigger both these paths to get into the multipath
696 zlog_debug("%s: %s and %s are equal via multipath-relax",
697 pfx_buf
, new_buf
, exist_buf
);
699 else if (new->peer
->sort
== BGP_PEER_IBGP
)
701 if (aspath_cmp (new->attr
->aspath
, exist
->attr
->aspath
))
706 zlog_debug("%s: %s and %s are equal via matching aspaths",
707 pfx_buf
, new_buf
, exist_buf
);
710 else if (new->peer
->as
== exist
->peer
->as
)
715 zlog_debug("%s: %s and %s are equal via same remote-as",
716 pfx_buf
, new_buf
, exist_buf
);
722 * TODO: If unequal cost ibgp multipath is enabled we can
723 * mark the paths as equal here instead of returning
728 zlog_debug("%s: %s wins over %s after IGP metric comparison",
729 pfx_buf
, new_buf
, exist_buf
);
731 zlog_debug("%s: %s loses to %s after IGP metric comparison",
732 pfx_buf
, new_buf
, exist_buf
);
737 /* 12. If both paths are external, prefer the path that was received
738 first (the oldest one). This step minimizes route-flap, since a
739 newer path won't displace an older one, even if it was the
740 preferred route based on the additional decision criteria below. */
741 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
742 && new_sort
== BGP_PEER_EBGP
743 && exist_sort
== BGP_PEER_EBGP
)
745 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
748 zlog_debug("%s: %s wins over %s due to oldest external",
749 pfx_buf
, new_buf
, exist_buf
);
753 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
756 zlog_debug("%s: %s loses to %s due to oldest external",
757 pfx_buf
, new_buf
, exist_buf
);
762 /* 13. Router-ID comparision. */
763 /* If one of the paths is "stale", the corresponding peer router-id will
764 * be 0 and would always win over the other path. If originator id is
765 * used for the comparision, it will decide which path is better.
767 if (newattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
768 new_id
.s_addr
= newattre
->originator_id
.s_addr
;
770 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
771 if (existattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
772 exist_id
.s_addr
= existattre
->originator_id
.s_addr
;
774 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
776 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
779 zlog_debug("%s: %s wins over %s due to Router-ID comparison",
780 pfx_buf
, new_buf
, exist_buf
);
784 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
787 zlog_debug("%s: %s loses to %s due to Router-ID comparison",
788 pfx_buf
, new_buf
, exist_buf
);
792 /* 14. Cluster length comparision. */
793 new_cluster
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
794 exist_cluster
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
796 if (new_cluster
< exist_cluster
)
799 zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
800 pfx_buf
, new_buf
, exist_buf
, new_cluster
, exist_cluster
);
804 if (new_cluster
> exist_cluster
)
807 zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
808 pfx_buf
, new_buf
, exist_buf
, new_cluster
, exist_cluster
);
812 /* 15. Neighbor address comparision. */
813 /* Do this only if neither path is "stale" as stale paths do not have
814 * valid peer information (as the connection may or may not be up).
816 if (CHECK_FLAG (exist
->flags
, BGP_INFO_STALE
))
819 zlog_debug("%s: %s wins over %s due to latter path being STALE",
820 pfx_buf
, new_buf
, exist_buf
);
824 if (CHECK_FLAG (new->flags
, BGP_INFO_STALE
))
827 zlog_debug("%s: %s loses to %s due to former path being STALE",
828 pfx_buf
, new_buf
, exist_buf
);
832 /* locally configured routes to advertise do not have su_remote */
833 if (new->peer
->su_remote
== NULL
)
835 if (exist
->peer
->su_remote
== NULL
)
838 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
843 zlog_debug("%s: %s loses to %s due to Neighor IP comparison",
844 pfx_buf
, new_buf
, exist_buf
);
851 zlog_debug("%s: %s wins over %s due to Neighor IP comparison",
852 pfx_buf
, new_buf
, exist_buf
);
857 zlog_debug("%s: %s wins over %s due to nothing left to compare",
858 pfx_buf
, new_buf
, exist_buf
);
863 /* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
864 * is preferred, or 0 if they are the same (usually will only occur if
865 * multipath is enabled
866 * This version is compatible with */
868 bgp_info_cmp_compatible (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
869 afi_t afi
, safi_t safi
)
872 struct bgp_maxpaths_cfg mpath_cfg
;
874 ret
= bgp_info_cmp (bgp
, new, exist
, &paths_eq
, &mpath_cfg
, 0, __func__
);
888 static enum filter_type
889 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
890 afi_t afi
, safi_t safi
)
892 struct bgp_filter
*filter
;
894 filter
= &peer
->filter
[afi
][safi
];
896 #define FILTER_EXIST_WARN(F,f,filter) \
897 if (BGP_DEBUG (update, UPDATE_IN) \
898 && !(F ## _IN (filter))) \
899 zlog_warn ("%s: Could not find configured input %s-list %s!", \
900 peer->host, #f, F ## _IN_NAME(filter));
902 if (DISTRIBUTE_IN_NAME (filter
)) {
903 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
905 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
909 if (PREFIX_LIST_IN_NAME (filter
)) {
910 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
912 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
916 if (FILTER_LIST_IN_NAME (filter
)) {
917 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
919 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
923 return FILTER_PERMIT
;
924 #undef FILTER_EXIST_WARN
927 static enum filter_type
928 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
929 afi_t afi
, safi_t safi
)
931 struct bgp_filter
*filter
;
933 filter
= &peer
->filter
[afi
][safi
];
935 #define FILTER_EXIST_WARN(F,f,filter) \
936 if (BGP_DEBUG (update, UPDATE_OUT) \
937 && !(F ## _OUT (filter))) \
938 zlog_warn ("%s: Could not find configured output %s-list %s!", \
939 peer->host, #f, F ## _OUT_NAME(filter));
941 if (DISTRIBUTE_OUT_NAME (filter
)) {
942 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
944 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
948 if (PREFIX_LIST_OUT_NAME (filter
)) {
949 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
951 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
955 if (FILTER_LIST_OUT_NAME (filter
)) {
956 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
958 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
962 return FILTER_PERMIT
;
963 #undef FILTER_EXIST_WARN
966 /* If community attribute includes no_export then return 1. */
968 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
972 /* NO_ADVERTISE check. */
973 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
976 /* NO_EXPORT check. */
977 if (peer
->sort
== BGP_PEER_EBGP
&&
978 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
981 /* NO_EXPORT_SUBCONFED check. */
982 if (peer
->sort
== BGP_PEER_EBGP
983 || peer
->sort
== BGP_PEER_CONFED
)
984 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
990 /* Route reflection loop check. */
992 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
994 struct in_addr cluster_id
;
996 if (attr
->extra
&& attr
->extra
->cluster
)
998 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
999 cluster_id
= peer
->bgp
->cluster_id
;
1001 cluster_id
= peer
->bgp
->router_id
;
1003 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
1010 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1011 afi_t afi
, safi_t safi
, const char *rmap_name
)
1013 struct bgp_filter
*filter
;
1014 struct bgp_info info
;
1015 route_map_result_t ret
;
1016 struct route_map
*rmap
= NULL
;
1018 filter
= &peer
->filter
[afi
][safi
];
1020 /* Apply default weight value. */
1022 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
1026 rmap
= route_map_lookup_by_name(rmap_name
);
1033 if (ROUTE_MAP_IN_NAME(filter
))
1035 rmap
= ROUTE_MAP_IN (filter
);
1042 /* Route map apply. */
1045 /* Duplicate current value to new strucutre for modification. */
1049 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
1051 /* Apply BGP route map to the attribute. */
1052 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1054 peer
->rmap_type
= 0;
1056 if (ret
== RMAP_DENYMATCH
)
1058 /* Free newly generated AS path and community by route-map. */
1059 bgp_attr_flush (attr
);
1067 bgp_output_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1068 afi_t afi
, safi_t safi
, const char *rmap_name
)
1070 struct bgp_filter
*filter
;
1071 struct bgp_info info
;
1072 route_map_result_t ret
;
1073 struct route_map
*rmap
= NULL
;
1075 filter
= &peer
->filter
[afi
][safi
];
1077 /* Apply default weight value. */
1079 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
1083 rmap
= route_map_lookup_by_name(rmap_name
);
1090 if (ROUTE_MAP_OUT_NAME(filter
))
1092 rmap
= ROUTE_MAP_OUT (filter
);
1099 /* Route map apply. */
1102 /* Duplicate current value to new strucutre for modification. */
1106 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1108 /* Apply BGP route map to the attribute. */
1109 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1111 peer
->rmap_type
= 0;
1113 if (ret
== RMAP_DENYMATCH
)
1114 /* caller has multiple error paths with bgp_attr_flush() */
1120 /* If this is an EBGP peer with remove-private-AS */
1122 bgp_peer_remove_private_as(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1123 struct peer
*peer
, struct attr
*attr
)
1125 if (peer
->sort
== BGP_PEER_EBGP
&&
1126 (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1127 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
) ||
1128 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
) ||
1129 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)))
1131 // Take action on the entire aspath
1132 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1133 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
1135 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
1136 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1138 // The entire aspath consists of private ASNs so create an empty aspath
1139 else if (aspath_private_as_check (attr
->aspath
))
1140 attr
->aspath
= aspath_empty_get ();
1142 // There are some public and some private ASNs, remove the private ASNs
1144 attr
->aspath
= aspath_remove_private_asns (attr
->aspath
);
1147 // 'all' was not specified so the entire aspath must be private ASNs
1148 // for us to do anything
1149 else if (aspath_private_as_check (attr
->aspath
))
1151 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
1152 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1154 attr
->aspath
= aspath_empty_get ();
1159 /* If this is an EBGP peer with as-override */
1161 bgp_peer_as_override(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1162 struct peer
*peer
, struct attr
*attr
)
1164 if (peer
->sort
== BGP_PEER_EBGP
&&
1165 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
))
1167 if (aspath_single_asn_check (attr
->aspath
, peer
->as
))
1168 attr
->aspath
= aspath_replace_specific_asn (attr
->aspath
, peer
->as
, bgp
->as
);
1173 subgroup_announce_reset_nhop (u_char family
, struct attr
*attr
)
1175 if (family
== AF_INET
)
1176 attr
->nexthop
.s_addr
= 0;
1178 if (family
== AF_INET6
)
1179 memset (&attr
->extra
->mp_nexthop_global
, 0, IPV6_MAX_BYTELEN
);
1184 subgroup_announce_check (struct bgp_info
*ri
, struct update_subgroup
*subgrp
,
1185 struct prefix
*p
, struct attr
*attr
)
1187 struct bgp_filter
*filter
;
1190 struct peer
*onlypeer
;
1192 struct attr
*riattr
;
1193 struct peer_af
*paf
;
1194 char buf
[SU_ADDRSTRLEN
];
1200 int samepeer_safe
= 0; /* for synthetic mplsvpns routes */
1202 if (DISABLE_BGP_ANNOUNCE
)
1205 afi
= SUBGRP_AFI(subgrp
);
1206 safi
= SUBGRP_SAFI(subgrp
);
1207 peer
= SUBGRP_PEER(subgrp
);
1209 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_LONESOUL
))
1210 onlypeer
= SUBGRP_PFIRST(subgrp
)->peer
;
1213 filter
= &peer
->filter
[afi
][safi
];
1214 bgp
= SUBGRP_INST(subgrp
);
1215 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
1218 if (((afi
== AFI_IP
) || (afi
== AFI_IP6
)) && (safi
== SAFI_MPLS_VPN
) &&
1219 ((ri
->type
== ZEBRA_ROUTE_BGP_DIRECT
) ||
1220 (ri
->type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
))) {
1223 * direct and direct_ext type routes originate internally even
1224 * though they can have peer pointers that reference other systems
1227 prefix2str(p
, buf
, BUFSIZ
);
1228 zlog_debug("%s: pfx %s bgp_direct->vpn route peer safe", __func__
, buf
);
1233 /* With addpath we may be asked to TX all kinds of paths so make sure
1235 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
) ||
1236 CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
) ||
1237 CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
1242 /* If this is not the bestpath then check to see if there is an enabled addpath
1243 * feature that requires us to advertise it */
1244 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1246 if (! bgp_addpath_tx_path(peer
, afi
, safi
, ri
))
1252 /* Aggregate-address suppress check. */
1253 if (ri
->extra
&& ri
->extra
->suppress
)
1254 if (! UNSUPPRESS_MAP_NAME (filter
))
1259 /* Do not send back route to sender. */
1260 if (onlypeer
&& from
== onlypeer
)
1265 /* Do not send the default route in the BGP table if the neighbor is
1266 * configured for default-originate */
1267 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
1269 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1272 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1274 #endif /* HAVE_IPV6 */
1277 /* Transparency check. */
1278 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
1279 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
1284 /* If community is not disabled check the no-export and local. */
1285 if (! transparent
&& bgp_community_filter (peer
, riattr
))
1287 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1288 zlog_debug ("subgrpannouncecheck: community filter check fail");
1292 /* If the attribute has originator-id and it is same as remote
1295 riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
) &&
1296 (IPV4_ADDR_SAME (&onlypeer
->remote_id
, &riattr
->extra
->originator_id
)))
1298 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1299 zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as "
1302 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1307 /* ORF prefix-list filter check */
1308 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1309 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1310 || CHECK_FLAG (peer
->af_cap
[afi
][safi
],
1311 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1312 if (peer
->orf_plist
[afi
][safi
])
1314 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1316 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1317 zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF",
1319 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1325 /* Output filter check. */
1326 if (bgp_output_filter (peer
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
1328 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1329 zlog_debug ("%s [Update:SEND] %s/%d is filtered",
1331 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1336 #ifdef BGP_SEND_ASPATH_CHECK
1337 /* AS path loop check. */
1338 if (onlypeer
&& aspath_loop_check (riattr
->aspath
, onlypeer
->as
))
1340 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1341 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u "
1342 "that is part of AS path.",
1343 onlypeer
->host
, onlypeer
->as
);
1346 #endif /* BGP_SEND_ASPATH_CHECK */
1348 /* If we're a CONFED we need to loop check the CONFED ID too */
1349 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
1351 if (aspath_loop_check(riattr
->aspath
, bgp
->confed_id
))
1353 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1354 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u"
1362 /* Route-Reflect check. */
1363 if (from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1368 /* IBGP reflection check. */
1369 if (reflect
&& !samepeer_safe
)
1371 /* A route from a Client peer. */
1372 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
1374 /* Reflect to all the Non-Client peers and also to the
1375 Client peers other than the originator. Originator check
1376 is already done. So there is noting to do. */
1377 /* no bgp client-to-client reflection check. */
1378 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
1379 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1380 PEER_FLAG_REFLECTOR_CLIENT
))
1385 /* A route from a Non-client peer. Reflect to all other
1387 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1388 PEER_FLAG_REFLECTOR_CLIENT
))
1393 /* For modify attribute, copy it to temporary structure. */
1394 bgp_attr_dup (attr
, riattr
);
1396 /* If local-preference is not set. */
1397 if ((peer
->sort
== BGP_PEER_IBGP
1398 || peer
->sort
== BGP_PEER_CONFED
)
1399 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
1401 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1402 attr
->local_pref
= bgp
->default_local_pref
;
1405 /* If originator-id is not set and the route is to be reflected,
1406 set the originator id */
1407 if (reflect
&& (!(attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))))
1409 attr
->extra
= bgp_attr_extra_get(attr
);
1410 IPV4_ADDR_COPY(&(attr
->extra
->originator_id
), &(from
->remote_id
));
1411 SET_FLAG(attr
->flag
, BGP_ATTR_ORIGINATOR_ID
);
1414 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
1415 if (peer
->sort
== BGP_PEER_EBGP
1416 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
1418 if (from
!= bgp
->peer_self
&& ! transparent
1419 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
1420 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
1423 /* Since the nexthop attribute can vary per peer, it is not explicitly set
1424 * in announce check, only certain flags and length (or number of nexthops
1425 * -- for IPv6/MP_REACH) are set here in order to guide the update formation
1426 * code in setting the nexthop(s) on a per peer basis in reformat_peer().
1427 * Typically, the source nexthop in the attribute is preserved but in the
1428 * scenarios where we know it will always be overwritten, we reset the
1429 * nexthop to "0" in an attempt to achieve better Update packing. An
1430 * example of this is when a prefix from each of 2 IBGP peers needs to be
1431 * announced to an EBGP peer (and they have the same attributes barring
1435 SET_FLAG(attr
->rmap_change_flags
, BATTR_REFLECTED
);
1438 #define NEXTHOP_IS_V6 (\
1439 (safi != SAFI_ENCAP && \
1440 (p->family == AF_INET6 || peer_cap_enhe(peer))) || \
1441 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
1443 /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
1444 * the peer (group) is configured to receive link-local nexthop unchanged
1445 * and it is available in the prefix OR we're not reflecting the route and
1446 * the peer (group) to whom we're going to announce is on a shared network
1447 * and this is either a self-originated route or the peer is EBGP.
1451 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
1452 if ((CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1453 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) &&
1454 IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
)) ||
1455 (!reflect
&& peer
->shared_network
&&
1456 (from
== bgp
->peer_self
|| peer
->sort
== BGP_PEER_EBGP
)))
1458 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
1461 /* Clear off link-local nexthop in source, whenever it is not needed to
1462 * ensure more prefixes share the same attribute for announcement.
1464 if (!(CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1465 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)))
1466 memset (&attr
->extra
->mp_nexthop_local
, 0, IPV6_MAX_BYTELEN
);
1468 #endif /* HAVE_IPV6 */
1470 bgp_peer_remove_private_as(bgp
, afi
, safi
, peer
, attr
);
1471 bgp_peer_as_override(bgp
, afi
, safi
, peer
, attr
);
1473 /* Route map & unsuppress-map apply. */
1474 if (ROUTE_MAP_OUT_NAME (filter
)
1475 || (ri
->extra
&& ri
->extra
->suppress
) )
1477 struct bgp_info info
;
1478 struct attr dummy_attr
;
1479 struct attr_extra dummy_extra
;
1481 dummy_attr
.extra
= &dummy_extra
;
1485 /* don't confuse inbound and outbound setting */
1486 RESET_FLAG(attr
->rmap_change_flags
);
1489 * The route reflector is not allowed to modify the attributes
1490 * of the reflected IBGP routes unless explicitly allowed.
1492 if ((from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1493 && !bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
))
1495 bgp_attr_dup (&dummy_attr
, attr
);
1496 info
.attr
= &dummy_attr
;
1499 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1501 if (ri
->extra
&& ri
->extra
->suppress
)
1502 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1504 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1506 peer
->rmap_type
= 0;
1508 if (ret
== RMAP_DENYMATCH
)
1510 bgp_attr_flush (attr
);
1515 /* After route-map has been applied, we check to see if the nexthop to
1516 * be carried in the attribute (that is used for the announcement) can
1517 * be cleared off or not. We do this in all cases where we would be
1518 * setting the nexthop to "ourselves". For IPv6, we only need to consider
1519 * the global nexthop here; the link-local nexthop would have been cleared
1520 * already, and if not, it is required by the update formation code.
1521 * Also see earlier comments in this function.
1524 * If route-map has performed some operation on the nexthop or the peer
1525 * configuration says to pass it unchanged, we cannot reset the nexthop
1526 * here, so only attempt to do it if these aren't true. Note that the
1527 * route-map handler itself might have cleared the nexthop, if for example,
1528 * it is configured as 'peer-address'.
1530 if (!bgp_rmap_nhop_changed(attr
->rmap_change_flags
,
1531 riattr
->rmap_change_flags
) &&
1533 !CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
))
1535 /* We can reset the nexthop, if setting (or forcing) it to 'self' */
1536 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
) ||
1537 CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_FORCE_NEXTHOP_SELF
))
1540 CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1541 PEER_FLAG_FORCE_NEXTHOP_SELF
))
1542 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ?
1543 AF_INET6
: p
->family
), attr
);
1545 else if (peer
->sort
== BGP_PEER_EBGP
)
1547 /* Can also reset the nexthop if announcing to EBGP, but only if
1548 * no peer in the subgroup is on a shared subnet.
1549 * Note: 3rd party nexthop currently implemented for IPv4 only.
1551 SUBGRP_FOREACH_PEER (subgrp
, paf
)
1553 if (bgp_multiaccess_check_v4 (riattr
->nexthop
, paf
->peer
))
1557 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ? AF_INET6
: p
->family
), attr
);
1559 /* If IPv6/MP and nexthop does not have any override and happens to
1560 * be a link-local address, reset it so that we don't pass along the
1561 * source's link-local IPv6 address to recipients who may not be on
1562 * the same interface.
1564 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1566 if (IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_global
))
1567 subgroup_announce_reset_nhop (AF_INET6
, attr
);
1574 struct bgp_info_pair
1576 struct bgp_info
*old
;
1577 struct bgp_info
*new;
1581 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
,
1582 struct bgp_maxpaths_cfg
*mpath_cfg
,
1583 struct bgp_info_pair
*result
)
1585 struct bgp_info
*new_select
;
1586 struct bgp_info
*old_select
;
1587 struct bgp_info
*ri
;
1588 struct bgp_info
*ri1
;
1589 struct bgp_info
*ri2
;
1590 struct bgp_info
*nextri
= NULL
;
1591 int paths_eq
, do_mpath
, debug
;
1592 struct list mp_list
;
1593 char pfx_buf
[PREFIX2STR_BUFFER
];
1594 char path_buf
[PATH_ADDPATH_STR_BUFFER
];
1596 bgp_mp_list_init (&mp_list
);
1597 do_mpath
= (mpath_cfg
->maxpaths_ebgp
> 1 || mpath_cfg
->maxpaths_ibgp
> 1);
1599 debug
= bgp_debug_bestpath(&rn
->p
);
1602 prefix2str (&rn
->p
, pfx_buf
, sizeof (pfx_buf
));
1604 /* bgp deterministic-med */
1606 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1609 /* Clear BGP_INFO_DMED_SELECTED for all paths */
1610 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1611 bgp_info_unset_flag (rn
, ri1
, BGP_INFO_DMED_SELECTED
);
1613 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1615 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1617 if (BGP_INFO_HOLDDOWN (ri1
))
1619 if (ri1
->peer
&& ri1
->peer
!= bgp
->peer_self
)
1620 if (ri1
->peer
->status
!= Established
)
1626 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1628 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1630 if (BGP_INFO_HOLDDOWN (ri2
))
1633 ri2
->peer
!= bgp
->peer_self
&&
1634 !CHECK_FLAG (ri2
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1635 if (ri2
->peer
->status
!= Established
)
1638 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1639 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1642 if (bgp_info_cmp (bgp
, ri2
, new_select
, &paths_eq
,
1643 mpath_cfg
, debug
, pfx_buf
))
1645 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1649 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1653 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1654 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1658 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1659 zlog_debug("%s: %s is the bestpath from AS %d",
1660 pfx_buf
, path_buf
, aspath_get_firstas(new_select
->attr
->aspath
));
1665 /* Check old selected route and new selected route. */
1668 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1670 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1673 if (BGP_INFO_HOLDDOWN (ri
))
1675 /* reap REMOVED routes, if needs be
1676 * selected route must stay for a while longer though
1678 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1679 && (ri
!= old_select
))
1680 bgp_info_reap (rn
, 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_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1692 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1694 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1698 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1700 if (bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
))
1706 /* Now that we know which path is the bestpath see if any of the other paths
1707 * qualify as multipaths
1712 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1714 sprintf (path_buf
, "NONE");
1715 zlog_debug("%s: After path selection, newbest is %s oldbest was %s",
1717 old_select
? old_select
->peer
->host
: "NONE");
1720 if (do_mpath
&& new_select
)
1722 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1726 bgp_info_path_with_addpath_rx_str (ri
, path_buf
);
1728 if (ri
== new_select
)
1731 zlog_debug("%s: %s is the bestpath, add to the multipath list",
1733 bgp_mp_list_add (&mp_list
, ri
);
1737 if (BGP_INFO_HOLDDOWN (ri
))
1741 ri
->peer
!= bgp
->peer_self
&&
1742 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1743 if (ri
->peer
->status
!= Established
)
1746 if (!bgp_info_nexthop_cmp (ri
, new_select
))
1749 zlog_debug("%s: %s has the same nexthop as the bestpath, skip it",
1754 bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
);
1759 zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list",
1761 bgp_mp_list_add (&mp_list
, ri
);
1766 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1767 bgp_info_mpath_aggregate_update (new_select
, old_select
);
1768 bgp_mp_list_clear (&mp_list
);
1770 result
->old
= old_select
;
1771 result
->new = new_select
;
1777 * A new route/change in bestpath of an existing route. Evaluate the path
1778 * for advertisement to the subgroup.
1781 subgroup_process_announce_selected (struct update_subgroup
*subgrp
,
1782 struct bgp_info
*selected
,
1783 struct bgp_node
*rn
,
1784 u_int32_t addpath_tx_id
)
1787 struct peer
*onlypeer
;
1789 struct attr_extra extra
;
1794 afi
= SUBGRP_AFI(subgrp
);
1795 safi
= SUBGRP_SAFI(subgrp
);
1796 onlypeer
= ((SUBGRP_PCOUNT(subgrp
) == 1) ?
1797 (SUBGRP_PFIRST(subgrp
))->peer
: NULL
);
1799 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1800 if (onlypeer
&& CHECK_FLAG (onlypeer
->af_sflags
[afi
][safi
],
1801 PEER_STATUS_ORF_WAIT_REFRESH
))
1804 /* It's initialized in bgp_announce_check() */
1805 attr
.extra
= &extra
;
1807 /* Announcement to the subgroup. If the route is filtered withdraw it. */
1810 if (subgroup_announce_check(selected
, subgrp
, p
, &attr
))
1811 bgp_adj_out_set_subgroup(rn
, subgrp
, &attr
, selected
);
1813 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, selected
->addpath_tx_id
);
1816 /* If selected is NULL we must withdraw the path using addpath_tx_id */
1819 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, addpath_tx_id
);
1826 * Clear IGP changed flag and attribute changed flag for a route (all paths).
1827 * This is called at the end of route processing.
1830 bgp_zebra_clear_route_change_flags (struct bgp_node
*rn
)
1832 struct bgp_info
*ri
;
1834 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1836 if (BGP_INFO_HOLDDOWN (ri
))
1838 UNSET_FLAG (ri
->flags
, BGP_INFO_IGP_CHANGED
);
1839 UNSET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
1844 * Has the route changed from the RIB's perspective? This is invoked only
1845 * if the route selection returns the same best route as earlier - to
1846 * determine if we need to update zebra or not.
1849 bgp_zebra_has_route_changed (struct bgp_node
*rn
, struct bgp_info
*selected
)
1851 struct bgp_info
*mpinfo
;
1853 /* If this is multipath, check all selected paths for any nexthop change or
1854 * attribute change. Some attribute changes (e.g., community) aren't of
1855 * relevance to the RIB, but we'll update zebra to ensure we handle the
1856 * case of BGP nexthop change. This is the behavior when the best path has
1857 * an attribute change anyway.
1859 if (CHECK_FLAG (selected
->flags
, BGP_INFO_IGP_CHANGED
) ||
1860 CHECK_FLAG (selected
->flags
, BGP_INFO_MULTIPATH_CHG
))
1863 /* If this is multipath, check all selected paths for any nexthop change */
1864 for (mpinfo
= bgp_info_mpath_first (selected
); mpinfo
;
1865 mpinfo
= bgp_info_mpath_next (mpinfo
))
1867 if (CHECK_FLAG (mpinfo
->flags
, BGP_INFO_IGP_CHANGED
)
1868 || CHECK_FLAG (mpinfo
->flags
, BGP_INFO_ATTR_CHANGED
))
1872 /* Nothing has changed from the RIB's perspective. */
1876 struct bgp_process_queue
1879 struct bgp_node
*rn
;
1884 static wq_item_status
1885 bgp_process_main (struct work_queue
*wq
, void *data
)
1887 struct bgp_process_queue
*pq
= data
;
1888 struct bgp
*bgp
= pq
->bgp
;
1889 struct bgp_node
*rn
= pq
->rn
;
1890 afi_t afi
= pq
->afi
;
1891 safi_t safi
= pq
->safi
;
1892 struct prefix
*p
= &rn
->p
;
1893 struct bgp_info
*new_select
;
1894 struct bgp_info
*old_select
;
1895 struct bgp_info_pair old_and_new
;
1897 /* Is it end of initial update? (after startup) */
1900 quagga_timestamp(3, bgp
->update_delay_zebra_resume_time
,
1901 sizeof(bgp
->update_delay_zebra_resume_time
));
1903 bgp
->main_zebra_update_hold
= 0;
1904 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1905 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1907 bgp_zebra_announce_table(bgp
, afi
, safi
);
1909 bgp
->main_peers_update_hold
= 0;
1911 bgp_start_routeadv(bgp
);
1915 /* Best path selection. */
1916 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1917 old_select
= old_and_new
.old
;
1918 new_select
= old_and_new
.new;
1920 /* Nothing to do. */
1921 if (old_select
&& old_select
== new_select
&&
1922 !CHECK_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
) &&
1923 !CHECK_FLAG(old_select
->flags
, BGP_INFO_ATTR_CHANGED
) &&
1924 !bgp
->addpath_tx_used
[afi
][safi
])
1926 if (bgp_zebra_has_route_changed (rn
, old_select
))
1929 vnc_import_bgp_add_route(bgp
, p
, old_select
);
1930 vnc_import_bgp_exterior_add_route(bgp
, p
, old_select
);
1932 bgp_zebra_announce (p
, old_select
, bgp
, afi
, safi
);
1934 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1935 bgp_zebra_clear_route_change_flags (rn
);
1936 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1940 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1941 UNSET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
1943 /* bestpath has changed; bump version */
1944 if (old_select
|| new_select
)
1946 bgp_bump_version(rn
);
1948 if (!bgp
->t_rmap_def_originate_eval
)
1951 THREAD_TIMER_ON(bm
->master
, bgp
->t_rmap_def_originate_eval
,
1952 update_group_refresh_default_originate_route_map
,
1953 bgp
, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER
);
1958 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1961 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1962 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1963 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1967 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
1968 if (old_select
!= new_select
) {
1970 vnc_import_bgp_exterior_del_route(bgp
, p
, old_select
);
1971 vnc_import_bgp_del_route(bgp
, p
, old_select
);
1974 vnc_import_bgp_exterior_add_route(bgp
, p
, new_select
);
1975 vnc_import_bgp_add_route(bgp
, p
, new_select
);
1981 group_announce_route(bgp
, afi
, safi
, rn
, new_select
);
1984 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) &&
1985 (bgp
->inst_type
!= BGP_INSTANCE_TYPE_VIEW
) &&
1986 !bgp_option_check (BGP_OPT_NO_FIB
))
1989 && new_select
->type
== ZEBRA_ROUTE_BGP
1990 && (new_select
->sub_type
== BGP_ROUTE_NORMAL
||
1991 new_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1992 bgp_zebra_announce (p
, new_select
, bgp
, afi
, safi
);
1995 /* Withdraw the route from the kernel. */
1997 && old_select
->type
== ZEBRA_ROUTE_BGP
1998 && (old_select
->sub_type
== BGP_ROUTE_NORMAL
||
1999 old_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
2000 bgp_zebra_withdraw (p
, old_select
, safi
);
2004 /* Clear any route change flags. */
2005 bgp_zebra_clear_route_change_flags (rn
);
2007 /* Reap old select bgp_info, if it has been removed */
2008 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
2009 bgp_info_reap (rn
, old_select
);
2011 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2016 bgp_processq_del (struct work_queue
*wq
, void *data
)
2018 struct bgp_process_queue
*pq
= data
;
2019 struct bgp_table
*table
;
2021 bgp_unlock (pq
->bgp
);
2024 table
= bgp_node_table (pq
->rn
);
2025 bgp_unlock_node (pq
->rn
);
2026 bgp_table_unlock (table
);
2028 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
2032 bgp_process_queue_init (void)
2034 if (!bm
->process_main_queue
)
2036 bm
->process_main_queue
2037 = work_queue_new (bm
->master
, "process_main_queue");
2039 if ( !bm
->process_main_queue
)
2041 zlog_err ("%s: Failed to allocate work queue", __func__
);
2046 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
2047 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
2048 bm
->process_main_queue
->spec
.max_retries
= 0;
2049 bm
->process_main_queue
->spec
.hold
= 50;
2050 /* Use a higher yield value of 50ms for main queue processing */
2051 bm
->process_main_queue
->spec
.yield
= 50 * 1000L;
2055 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
2057 struct bgp_process_queue
*pqnode
;
2059 /* already scheduled for processing? */
2060 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
2063 if (bm
->process_main_queue
== NULL
)
2064 bgp_process_queue_init ();
2066 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2067 sizeof (struct bgp_process_queue
));
2071 /* all unlocked in bgp_processq_del */
2072 bgp_table_lock (bgp_node_table (rn
));
2073 pqnode
->rn
= bgp_lock_node (rn
);
2077 pqnode
->safi
= safi
;
2078 work_queue_add (bm
->process_main_queue
, pqnode
);
2079 SET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2084 bgp_add_eoiu_mark (struct bgp
*bgp
)
2086 struct bgp_process_queue
*pqnode
;
2088 if (bm
->process_main_queue
== NULL
)
2089 bgp_process_queue_init ();
2091 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2092 sizeof (struct bgp_process_queue
));
2099 work_queue_add (bm
->process_main_queue
, pqnode
);
2103 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
2107 peer
= THREAD_ARG (thread
);
2108 peer
->t_pmax_restart
= NULL
;
2110 if (bgp_debug_neighbor_events(peer
))
2111 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
2114 peer_clear (peer
, NULL
);
2120 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
2121 safi_t safi
, int always
)
2123 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
2126 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
2128 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
2132 zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
2133 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
2134 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
2135 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2137 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
2143 if (safi
== SAFI_MPLS_VPN
)
2144 safi
= SAFI_MPLS_LABELED_VPN
;
2146 ndata
[0] = (afi
>> 8);
2149 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
2150 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
2151 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
2152 ndata
[6] = (peer
->pmax
[afi
][safi
]);
2154 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
2155 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
2156 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
2159 /* Dynamic peers will just close their connection. */
2160 if (peer_dynamic_neighbor (peer
))
2163 /* restart timer start */
2164 if (peer
->pmax_restart
[afi
][safi
])
2166 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
2168 if (bgp_debug_neighbor_events(peer
))
2169 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
2170 peer
->host
, peer
->v_pmax_restart
);
2172 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
2173 peer
->v_pmax_restart
);
2179 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2181 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
2183 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
2187 zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
2188 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
2189 peer
->pmax
[afi
][safi
]);
2190 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2193 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2197 /* Unconditionally remove the route from the RIB, without taking
2198 * damping into consideration (eg, because the session went down)
2201 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2202 afi_t afi
, safi_t safi
)
2204 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2206 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2207 bgp_info_delete (rn
, ri
); /* keep historical info */
2209 bgp_process (peer
->bgp
, rn
, afi
, safi
);
2213 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2214 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
)
2216 int status
= BGP_DAMP_NONE
;
2218 /* apply dampening, if result is suppressed, we'll be retaining
2219 * the bgp_info in the RIB for historical reference.
2221 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2222 && peer
->sort
== BGP_PEER_EBGP
)
2223 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
2224 == BGP_DAMP_SUPPRESSED
)
2226 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2231 if (safi
== SAFI_MPLS_VPN
) {
2232 struct bgp_node
*prn
= NULL
;
2233 struct bgp_table
*table
= NULL
;
2235 prn
= bgp_node_get(peer
->bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2237 table
= (struct bgp_table
*)(prn
->info
);
2239 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2246 bgp_unlock_node(prn
);
2248 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2249 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2251 vnc_import_bgp_del_route(peer
->bgp
, &rn
->p
, ri
);
2252 vnc_import_bgp_exterior_del_route(peer
->bgp
, &rn
->p
, ri
);
2256 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2259 static struct bgp_info
*
2260 info_make (int type
, int sub_type
, u_short instance
, struct peer
*peer
, struct attr
*attr
,
2261 struct bgp_node
*rn
)
2263 struct bgp_info
*new;
2265 /* Make new BGP info. */
2266 new = XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
2268 new->instance
= instance
;
2269 new->sub_type
= sub_type
;
2272 new->uptime
= bgp_clock ();
2274 new->addpath_tx_id
= ++peer
->bgp
->addpath_tx_id
;
2279 bgp_info_addpath_rx_str(u_int32_t addpath_id
, char *buf
)
2282 sprintf(buf
, " with addpath ID %d", addpath_id
);
2286 /* Check if received nexthop is valid or not. */
2288 bgp_update_martian_nexthop (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct attr
*attr
)
2290 struct attr_extra
*attre
= attr
->extra
;
2293 /* Only validated for unicast and multicast currently. */
2294 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2297 /* If NEXT_HOP is present, validate it. */
2298 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2300 if (attr
->nexthop
.s_addr
== 0 ||
2301 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2302 bgp_nexthop_self (bgp
, attr
))
2306 /* If MP_NEXTHOP is present, validate it. */
2307 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2308 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2309 * it is not an IPv6 link-local address.
2311 if (attre
&& attre
->mp_nexthop_len
)
2313 switch (attre
->mp_nexthop_len
)
2315 case BGP_ATTR_NHLEN_IPV4
:
2316 case BGP_ATTR_NHLEN_VPNV4
:
2317 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2318 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2322 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2323 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2324 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2325 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2326 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2328 #endif /* HAVE_IPV6 */
2340 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2341 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2342 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2346 int aspath_loop_count
= 0;
2347 struct bgp_node
*rn
;
2349 struct attr new_attr
;
2350 struct attr_extra new_extra
;
2351 struct attr
*attr_new
;
2352 struct bgp_info
*ri
;
2353 struct bgp_info
*new;
2355 char buf
[SU_ADDRSTRLEN
];
2359 int vnc_implicit_withdraw
= 0;
2363 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2365 /* When peer's soft reconfiguration enabled. Record input packet in
2367 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2368 && peer
!= bgp
->peer_self
)
2369 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2371 /* Check previously received route. */
2372 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2373 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2374 ri
->addpath_rx_id
== addpath_id
)
2377 /* AS path local-as loop check. */
2378 if (peer
->change_local_as
)
2380 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2381 aspath_loop_count
= 1;
2383 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2385 reason
= "as-path contains our own AS;";
2390 /* AS path loop check. */
2391 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2392 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2393 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2394 > peer
->allowas_in
[afi
][safi
]))
2396 reason
= "as-path contains our own AS;";
2400 /* Route reflector originator ID check. */
2401 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2402 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2404 reason
= "originator is us;";
2408 /* Route reflector cluster ID check. */
2409 if (bgp_cluster_filter (peer
, attr
))
2411 reason
= "reflected from the same cluster;";
2415 /* Apply incoming filter. */
2416 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2422 new_attr
.extra
= &new_extra
;
2423 bgp_attr_dup (&new_attr
, attr
);
2425 /* Apply incoming route-map.
2426 * NB: new_attr may now contain newly allocated values from route-map "set"
2427 * commands, so we need bgp_attr_flush in the error paths, until we intern
2428 * the attr (which takes over the memory references) */
2429 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2431 reason
= "route-map;";
2432 bgp_attr_flush (&new_attr
);
2436 /* next hop check. */
2437 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2439 reason
= "martian or self next-hop;";
2440 bgp_attr_flush (&new_attr
);
2444 attr_new
= bgp_attr_intern (&new_attr
);
2446 /* If the update is implicit withdraw. */
2449 ri
->uptime
= bgp_clock ();
2451 /* Same attribute comes in. */
2452 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2453 && attrhash_cmp (ri
->attr
, attr_new
))
2455 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2456 && peer
->sort
== BGP_PEER_EBGP
2457 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2459 if (bgp_debug_update(peer
, p
, NULL
, 1))
2461 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2462 zlog_debug ("%s rcvd %s/%d%s",
2464 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2465 p
->prefixlen
, buf2
);
2468 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2470 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2471 bgp_process (bgp
, rn
, afi
, safi
);
2474 else /* Duplicate - odd */
2476 if (bgp_debug_update(peer
, p
, NULL
, 1))
2478 if (!peer
->rcvd_attr_printed
)
2480 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2481 peer
->rcvd_attr_printed
= 1;
2484 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2485 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2487 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2488 p
->prefixlen
, buf2
);
2491 /* graceful restart STALE flag unset. */
2492 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2494 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2495 bgp_process (bgp
, rn
, afi
, safi
);
2499 bgp_unlock_node (rn
);
2500 bgp_attr_unintern (&attr_new
);
2505 /* Withdraw/Announce before we fully processed the withdraw */
2506 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2508 if (bgp_debug_update(peer
, p
, NULL
, 1))
2510 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2511 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2513 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2514 p
->prefixlen
, buf2
);
2516 bgp_info_restore (rn
, ri
);
2519 /* Received Logging. */
2520 if (bgp_debug_update(peer
, p
, NULL
, 1))
2522 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2523 zlog_debug ("%s rcvd %s/%d%s",
2525 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2526 p
->prefixlen
, buf2
);
2529 /* graceful restart STALE flag unset. */
2530 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2531 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2533 /* The attribute is changed. */
2534 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2536 /* implicit withdraw, decrement aggregate and pcount here.
2537 * only if update is accepted, they'll increment below.
2539 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2541 /* Update bgp route dampening information. */
2542 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2543 && peer
->sort
== BGP_PEER_EBGP
)
2545 /* This is implicit withdraw so we should update dampening
2547 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2548 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2551 if (safi
== SAFI_MPLS_VPN
) {
2552 struct bgp_node
*prn
= NULL
;
2553 struct bgp_table
*table
= NULL
;
2555 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2557 table
= (struct bgp_table
*)(prn
->info
);
2559 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2566 bgp_unlock_node(prn
);
2568 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2569 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2571 * Implicit withdraw case.
2573 ++vnc_implicit_withdraw
;
2574 vnc_import_bgp_del_route(bgp
, p
, ri
);
2575 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
2580 /* Update to new attribute. */
2581 bgp_attr_unintern (&ri
->attr
);
2582 ri
->attr
= attr_new
;
2584 /* Update MPLS tag. */
2585 if (safi
== SAFI_MPLS_VPN
)
2586 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2589 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
2591 if (vnc_implicit_withdraw
)
2594 * Add back the route with its new attributes (e.g., nexthop).
2595 * The route is still selected, until the route selection
2596 * queued by bgp_process actually runs. We have to make this
2597 * update to the VNC side immediately to avoid racing against
2598 * configuration changes (e.g., route-map changes) which
2599 * trigger re-importation of the entire RIB.
2601 vnc_import_bgp_add_route(bgp
, p
, ri
);
2602 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
2607 /* Update bgp route dampening information. */
2608 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2609 && peer
->sort
== BGP_PEER_EBGP
)
2611 /* Now we do normal update dampening. */
2612 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2613 if (ret
== BGP_DAMP_SUPPRESSED
)
2615 bgp_unlock_node (rn
);
2620 /* Nexthop reachability check. */
2621 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2623 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2624 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2625 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2630 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2631 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2634 if (BGP_DEBUG(nht
, NHT
))
2636 char buf1
[INET6_ADDRSTRLEN
];
2637 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2638 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2640 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2644 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2647 if (safi
== SAFI_MPLS_VPN
)
2649 struct bgp_node
*prn
= NULL
;
2650 struct bgp_table
*table
= NULL
;
2652 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2655 table
= (struct bgp_table
*)(prn
->info
);
2657 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2664 bgp_unlock_node(prn
);
2668 /* Process change. */
2669 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2671 bgp_process (bgp
, rn
, afi
, safi
);
2672 bgp_unlock_node (rn
);
2675 } // End of implicit withdraw
2677 /* Received Logging. */
2678 if (bgp_debug_update(peer
, p
, NULL
, 1))
2680 if (!peer
->rcvd_attr_printed
)
2682 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2683 peer
->rcvd_attr_printed
= 1;
2686 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2687 zlog_debug ("%s rcvd %s/%d%s",
2689 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2690 p
->prefixlen
, buf2
);
2693 /* Make new BGP info. */
2694 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2696 /* Update MPLS tag. */
2697 if (safi
== SAFI_MPLS_VPN
)
2698 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2700 /* Nexthop reachability check. */
2701 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2703 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2704 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2705 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2710 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2711 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2714 if (BGP_DEBUG(nht
, NHT
))
2716 char buf1
[INET6_ADDRSTRLEN
];
2717 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2718 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2720 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2724 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2727 new->addpath_rx_id
= addpath_id
;
2729 /* Increment prefix */
2730 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2732 /* Register new BGP information. */
2733 bgp_info_add (rn
, new);
2735 /* route_node_get lock */
2736 bgp_unlock_node (rn
);
2739 if (safi
== SAFI_MPLS_VPN
)
2741 struct bgp_node
*prn
= NULL
;
2742 struct bgp_table
*table
= NULL
;
2744 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2747 table
= (struct bgp_table
*)(prn
->info
);
2749 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2756 bgp_unlock_node(prn
);
2760 /* If maximum prefix count is configured and current prefix
2762 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2765 /* Process change. */
2766 bgp_process (bgp
, rn
, afi
, safi
);
2770 /* This BGP update is filtered. Log the reason then update BGP
2773 if (bgp_debug_update(peer
, p
, NULL
, 1))
2775 if (!peer
->rcvd_attr_printed
)
2777 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2778 peer
->rcvd_attr_printed
= 1;
2781 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2782 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2784 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2785 p
->prefixlen
, buf2
, reason
);
2789 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2791 bgp_unlock_node (rn
);
2797 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2798 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2799 struct prefix_rd
*prd
, u_char
*tag
)
2802 char buf
[SU_ADDRSTRLEN
];
2804 struct bgp_node
*rn
;
2805 struct bgp_info
*ri
;
2810 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2812 /* If peer is soft reconfiguration enabled. Record input packet for
2813 * further calculation.
2815 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2816 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2817 * the iteration over all RS clients.
2818 * Since we need to remove the entry from adj_in anyway, do that first and
2819 * if there was no entry, we don't need to do anything more.
2821 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2822 && peer
!= bgp
->peer_self
)
2823 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2825 if (bgp_debug_update (peer
, p
, NULL
, 1))
2826 zlog_debug ("%s withdrawing route %s/%d "
2827 "not in adj-in", peer
->host
,
2828 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2830 bgp_unlock_node (rn
);
2834 /* Lookup withdrawn route. */
2835 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2836 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2837 ri
->addpath_rx_id
== addpath_id
)
2841 if (bgp_debug_update(peer
, p
, NULL
, 1))
2843 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2844 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2846 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2847 p
->prefixlen
, buf2
);
2850 /* Withdraw specified route from routing table. */
2851 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2852 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
, prd
);
2853 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2854 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2855 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2858 /* Unlock bgp_node_get() lock. */
2859 bgp_unlock_node (rn
);
2865 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2867 struct update_subgroup
*subgrp
;
2868 subgrp
= peer_subgroup(peer
, afi
, safi
);
2869 subgroup_default_originate(subgrp
, withdraw
);
2874 * bgp_stop_announce_route_timer
2877 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2879 if (!paf
->t_announce_route
)
2882 THREAD_TIMER_OFF (paf
->t_announce_route
);
2886 * bgp_announce_route_timer_expired
2888 * Callback that is invoked when the route announcement timer for a
2892 bgp_announce_route_timer_expired (struct thread
*t
)
2894 struct peer_af
*paf
;
2897 paf
= THREAD_ARG (t
);
2900 assert (paf
->t_announce_route
);
2901 paf
->t_announce_route
= NULL
;
2903 if (peer
->status
!= Established
)
2906 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2909 peer_af_announce_route (paf
, 1);
2914 * bgp_announce_route
2916 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2919 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2921 struct peer_af
*paf
;
2922 struct update_subgroup
*subgrp
;
2924 paf
= peer_af_find (peer
, afi
, safi
);
2927 subgrp
= PAF_SUBGRP(paf
);
2930 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2931 * or a refresh has already been triggered.
2933 if (!subgrp
|| paf
->t_announce_route
)
2937 * Start a timer to stagger/delay the announce. This serves
2938 * two purposes - announcement can potentially be combined for
2939 * multiple peers and the announcement doesn't happen in the
2942 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2943 bgp_announce_route_timer_expired
, paf
,
2944 (subgrp
->peer_count
== 1) ?
2945 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2946 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2950 * Announce routes from all AF tables to a peer.
2952 * This should ONLY be called when there is a need to refresh the
2953 * routes to the peer based on a policy change for this peer alone
2954 * or a route refresh request received from the peer.
2955 * The operation will result in splitting the peer from its existing
2956 * subgroups and putting it in new subgroups.
2959 bgp_announce_route_all (struct peer
*peer
)
2964 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2965 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2966 bgp_announce_route (peer
, afi
, safi
);
2970 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2971 struct bgp_table
*table
, struct prefix_rd
*prd
)
2974 struct bgp_node
*rn
;
2975 struct bgp_adj_in
*ain
;
2978 table
= peer
->bgp
->rib
[afi
][safi
];
2980 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2981 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2983 if (ain
->peer
== peer
)
2985 struct bgp_info
*ri
= rn
->info
;
2986 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
2988 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
2989 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2994 bgp_unlock_node (rn
);
3002 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3004 struct bgp_node
*rn
;
3005 struct bgp_table
*table
;
3007 if (peer
->status
!= Established
)
3010 if ((safi
!= SAFI_MPLS_VPN
) && (safi
!= SAFI_ENCAP
))
3011 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
3013 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3014 rn
= bgp_route_next (rn
))
3015 if ((table
= rn
->info
) != NULL
)
3017 struct prefix_rd prd
;
3018 prd
.family
= AF_UNSPEC
;
3020 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
3022 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
3027 struct bgp_clear_node_queue
3029 struct bgp_node
*rn
;
3032 static wq_item_status
3033 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
3035 struct bgp_clear_node_queue
*cnq
= data
;
3036 struct bgp_node
*rn
= cnq
->rn
;
3037 struct peer
*peer
= wq
->spec
.data
;
3038 struct bgp_info
*ri
;
3039 afi_t afi
= bgp_node_table (rn
)->afi
;
3040 safi_t safi
= bgp_node_table (rn
)->safi
;
3042 assert (rn
&& peer
);
3044 /* It is possible that we have multiple paths for a prefix from a peer
3045 * if that peer is using AddPath.
3047 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3048 if (ri
->peer
== peer
)
3050 /* graceful restart STALE flag set. */
3051 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
3052 && peer
->nsf
[afi
][safi
]
3053 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
3054 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
3055 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
3057 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3063 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
3065 struct bgp_clear_node_queue
*cnq
= data
;
3066 struct bgp_node
*rn
= cnq
->rn
;
3067 struct bgp_table
*table
= bgp_node_table (rn
);
3069 bgp_unlock_node (rn
);
3070 bgp_table_unlock (table
);
3071 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
3075 bgp_clear_node_complete (struct work_queue
*wq
)
3077 struct peer
*peer
= wq
->spec
.data
;
3079 /* Tickle FSM to start moving again */
3080 BGP_EVENT_ADD (peer
, Clearing_Completed
);
3082 peer_unlock (peer
); /* bgp_clear_route */
3086 bgp_clear_node_queue_init (struct peer
*peer
)
3088 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
3090 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
3091 #undef CLEAR_QUEUE_NAME_LEN
3093 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
3095 zlog_err ("%s: Failed to allocate work queue", __func__
);
3098 peer
->clear_node_queue
->spec
.hold
= 10;
3099 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
3100 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
3101 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
3102 peer
->clear_node_queue
->spec
.max_retries
= 0;
3104 /* we only 'lock' this peer reference when the queue is actually active */
3105 peer
->clear_node_queue
->spec
.data
= peer
;
3109 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3110 struct bgp_table
*table
)
3112 struct bgp_node
*rn
;
3116 table
= peer
->bgp
->rib
[afi
][safi
];
3118 /* If still no table => afi/safi isn't configured at all or smth. */
3122 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3124 struct bgp_info
*ri
;
3125 struct bgp_adj_in
*ain
;
3126 struct bgp_adj_in
*ain_next
;
3128 /* XXX:TODO: This is suboptimal, every non-empty route_node is
3129 * queued for every clearing peer, regardless of whether it is
3130 * relevant to the peer at hand.
3132 * Overview: There are 3 different indices which need to be
3133 * scrubbed, potentially, when a peer is removed:
3135 * 1 peer's routes visible via the RIB (ie accepted routes)
3136 * 2 peer's routes visible by the (optional) peer's adj-in index
3137 * 3 other routes visible by the peer's adj-out index
3139 * 3 there is no hurry in scrubbing, once the struct peer is
3140 * removed from bgp->peer, we could just GC such deleted peer's
3141 * adj-outs at our leisure.
3143 * 1 and 2 must be 'scrubbed' in some way, at least made
3144 * invisible via RIB index before peer session is allowed to be
3145 * brought back up. So one needs to know when such a 'search' is
3150 * - there'd be a single global queue or a single RIB walker
3151 * - rather than tracking which route_nodes still need to be
3152 * examined on a peer basis, we'd track which peers still
3155 * Given that our per-peer prefix-counts now should be reliable,
3156 * this may actually be achievable. It doesn't seem to be a huge
3157 * problem at this time,
3159 * It is possible that we have multiple paths for a prefix from a peer
3160 * if that peer is using AddPath.
3165 ain_next
= ain
->next
;
3167 if (ain
->peer
== peer
)
3169 bgp_adj_in_remove (rn
, ain
);
3170 bgp_unlock_node (rn
);
3176 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3177 if (ri
->peer
== peer
)
3179 struct bgp_clear_node_queue
*cnq
;
3181 /* both unlocked in bgp_clear_node_queue_del */
3182 bgp_table_lock (bgp_node_table (rn
));
3184 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
3185 sizeof (struct bgp_clear_node_queue
));
3187 work_queue_add (peer
->clear_node_queue
, cnq
);
3195 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3197 struct bgp_node
*rn
;
3198 struct bgp_table
*table
;
3200 if (peer
->clear_node_queue
== NULL
)
3201 bgp_clear_node_queue_init (peer
);
3203 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3204 * Idle until it receives a Clearing_Completed event. This protects
3205 * against peers which flap faster than we can we clear, which could
3208 * a) race with routes from the new session being installed before
3209 * clear_route_node visits the node (to delete the route of that
3211 * b) resource exhaustion, clear_route_node likely leads to an entry
3212 * on the process_main queue. Fast-flapping could cause that queue
3216 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3217 * the unlock will happen upon work-queue completion; other wise, the
3218 * unlock happens at the end of this function.
3220 if (!peer
->clear_node_queue
->thread
)
3223 if (safi
!= SAFI_MPLS_VPN
&& safi
!= SAFI_ENCAP
)
3224 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
3226 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3227 rn
= bgp_route_next (rn
))
3228 if ((table
= rn
->info
) != NULL
)
3229 bgp_clear_route_table (peer
, afi
, safi
, table
);
3231 /* unlock if no nodes got added to the clear-node-queue. */
3232 if (!peer
->clear_node_queue
->thread
)
3238 bgp_clear_route_all (struct peer
*peer
)
3243 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3244 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3245 bgp_clear_route (peer
, afi
, safi
);
3248 rfapiProcessPeerDown(peer
);
3253 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3255 struct bgp_table
*table
;
3256 struct bgp_node
*rn
;
3257 struct bgp_adj_in
*ain
;
3258 struct bgp_adj_in
*ain_next
;
3260 table
= peer
->bgp
->rib
[afi
][safi
];
3262 /* It is possible that we have multiple paths for a prefix from a peer
3263 * if that peer is using AddPath.
3265 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3271 ain_next
= ain
->next
;
3273 if (ain
->peer
== peer
)
3275 bgp_adj_in_remove (rn
, ain
);
3276 bgp_unlock_node (rn
);
3285 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3287 struct bgp_node
*rn
;
3288 struct bgp_info
*ri
;
3289 struct bgp_table
*table
;
3291 table
= peer
->bgp
->rib
[afi
][safi
];
3293 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3295 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3296 if (ri
->peer
== peer
)
3298 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3299 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3306 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3308 struct bgp_node
*rn
;
3309 struct bgp_info
*ri
;
3310 struct bgp_info
*next
;
3312 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3313 for (ri
= rn
->info
; ri
; ri
= next
)
3316 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3317 && ri
->type
== ZEBRA_ROUTE_BGP
3318 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3319 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3322 if (table
->owner
&& table
->owner
->bgp
)
3323 vnc_import_bgp_del_route(table
->owner
->bgp
, &rn
->p
, ri
);
3325 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3330 /* Delete all kernel routes. */
3332 bgp_cleanup_routes (void)
3335 struct listnode
*node
, *nnode
;
3338 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
3340 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3342 struct bgp_node
*rn
;
3344 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3347 * VPN and ENCAP tables are two-level (RD is top level)
3349 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3350 rn
= bgp_route_next (rn
))
3354 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3355 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3357 bgp_unlock_node(rn
);
3361 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_ENCAP
]); rn
;
3362 rn
= bgp_route_next (rn
))
3366 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_ENCAP
);
3367 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3369 bgp_unlock_node(rn
);
3380 bgp_zclient_reset ();
3381 access_list_reset ();
3382 prefix_list_reset ();
3386 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3388 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3389 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3392 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3395 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3404 int addpath_encoded
;
3405 u_int32_t addpath_id
;
3407 /* Check peer status. */
3408 if (peer
->status
!= Established
)
3412 lim
= pnt
+ packet
->length
;
3414 safi
= packet
->safi
;
3416 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3418 for (; pnt
< lim
; pnt
+= psize
)
3420 /* Clear prefix structure. */
3421 memset (&p
, 0, sizeof (struct prefix
));
3423 if (addpath_encoded
)
3426 /* When packet overflow occurs return immediately. */
3427 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3430 addpath_id
= ntohl(*((uint32_t*) pnt
));
3431 pnt
+= BGP_ADDPATH_ID_LEN
;
3434 /* Fetch prefix length. */
3435 p
.prefixlen
= *pnt
++;
3436 p
.family
= afi2family (afi
);
3438 /* Already checked in nlri_sanity_check(). We do double check
3440 if ((afi
== AFI_IP
&& p
.prefixlen
> 32)
3441 || (afi
== AFI_IP6
&& p
.prefixlen
> 128))
3444 /* Packet size overflow check. */
3445 psize
= PSIZE (p
.prefixlen
);
3447 /* When packet overflow occur return immediately. */
3448 if (pnt
+ psize
> lim
)
3451 /* Fetch prefix from NLRI packet. */
3452 memcpy (&p
.u
.prefix
, pnt
, psize
);
3454 /* Check address. */
3455 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3457 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3460 * From draft-ietf-idr-bgp4-22, Section 6.3:
3461 * If a BGP router receives an UPDATE message with a
3462 * semantically incorrect NLRI field, in which a prefix is
3463 * semantically incorrect (eg. an unexpected multicast IP
3464 * address), it should ignore the prefix.
3466 zlog_err ("IPv4 unicast NLRI is multicast address %s",
3467 inet_ntoa (p
.u
.prefix4
));
3474 /* Check address. */
3475 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3477 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3481 zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
3482 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3487 #endif /* HAVE_IPV6 */
3489 /* Normal process. */
3491 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3492 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3494 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3495 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3497 /* Address family configuration mismatch or maximum-prefix count
3503 /* Packet length consistency check. */
3510 /* NLRI encode syntax check routine. */
3512 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, safi_t safi
, u_char
*pnt
,
3513 bgp_size_t length
, int *numpfx
)
3518 int addpath_encoded
;
3522 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3524 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3525 syntactic validity. If the field is syntactically incorrect,
3526 then the Error Subcode is set to Invalid Network Field. */
3532 /* If the NLRI is encoded using addpath then the first 4 bytes are
3533 * the addpath ID. */
3534 if (addpath_encoded
)
3536 if (pnt
+ BGP_ADDPATH_ID_LEN
> end
)
3538 zlog_err ("%s [Error] Update packet error"
3539 " (prefix data addpath overflow)",
3541 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3542 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3545 pnt
+= BGP_ADDPATH_ID_LEN
;
3550 /* Prefix length check. */
3552 if (safi
== SAFI_ENCAP
) {
3553 if (prefixlen
> 128)
3556 if ((afi
== AFI_IP
&& prefixlen
> 32) ||
3557 (afi
== AFI_IP6
&& prefixlen
> 128)) {
3564 zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
3565 peer
->host
, prefixlen
);
3566 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3567 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3571 /* Packet size overflow check. */
3572 psize
= PSIZE (prefixlen
);
3574 if (pnt
+ psize
> end
)
3576 zlog_err ("%s [Error] Update packet error"
3577 " (prefix data overflow prefix size is %d)",
3579 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3580 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3588 /* Packet length consistency check. */
3591 zlog_err ("%s [Error] Update packet error"
3592 " (prefix length mismatch with total length)",
3594 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3595 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3601 static struct bgp_static
*
3602 bgp_static_new (void)
3604 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3608 bgp_static_free (struct bgp_static
*bgp_static
)
3610 if (bgp_static
->rmap
.name
)
3611 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3612 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3616 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3617 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3619 struct bgp_node
*rn
;
3620 struct bgp_info
*ri
;
3621 struct bgp_info
*new;
3622 struct bgp_info info
;
3624 struct attr
*attr_new
;
3627 int vnc_implicit_withdraw
= 0;
3630 assert (bgp_static
);
3634 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3636 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3638 attr
.nexthop
= bgp_static
->igpnexthop
;
3639 attr
.med
= bgp_static
->igpmetric
;
3640 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3642 if (bgp_static
->atomic
)
3643 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3645 /* Apply route-map. */
3646 if (bgp_static
->rmap
.name
)
3648 struct attr attr_tmp
= attr
;
3649 info
.peer
= bgp
->peer_self
;
3650 info
.attr
= &attr_tmp
;
3652 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3654 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3656 bgp
->peer_self
->rmap_type
= 0;
3658 if (ret
== RMAP_DENYMATCH
)
3660 /* Free uninterned attribute. */
3661 bgp_attr_flush (&attr_tmp
);
3663 /* Unintern original. */
3664 aspath_unintern (&attr
.aspath
);
3665 bgp_attr_extra_free (&attr
);
3666 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3669 attr_new
= bgp_attr_intern (&attr_tmp
);
3672 attr_new
= bgp_attr_intern (&attr
);
3674 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3675 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3676 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3681 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3682 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3683 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3685 bgp_unlock_node (rn
);
3686 bgp_attr_unintern (&attr_new
);
3687 aspath_unintern (&attr
.aspath
);
3688 bgp_attr_extra_free (&attr
);
3693 /* The attribute is changed. */
3694 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3696 /* Rewrite BGP route information. */
3697 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3698 bgp_info_restore(rn
, ri
);
3700 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3702 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3704 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
3707 * Implicit withdraw case.
3708 * We have to do this before ri is changed
3710 ++vnc_implicit_withdraw
;
3711 vnc_import_bgp_del_route(bgp
, p
, ri
);
3712 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
3716 bgp_attr_unintern (&ri
->attr
);
3717 ri
->attr
= attr_new
;
3718 ri
->uptime
= bgp_clock ();
3720 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3722 if (vnc_implicit_withdraw
)
3724 vnc_import_bgp_add_route(bgp
, p
, ri
);
3725 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
3730 /* Nexthop reachability check. */
3731 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3733 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3734 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3737 if (BGP_DEBUG(nht
, NHT
))
3739 char buf1
[INET6_ADDRSTRLEN
];
3740 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3742 zlog_debug("%s(%s): Route not in table, not advertising",
3743 __FUNCTION__
, buf1
);
3745 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3750 /* Delete the NHT structure if any, if we're toggling between
3751 * enabling/disabling import check. We deregister the route
3752 * from NHT to avoid overloading NHT and the process interaction
3754 bgp_unlink_nexthop(ri
);
3755 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3757 /* Process change. */
3758 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3759 bgp_process (bgp
, rn
, afi
, safi
);
3760 bgp_unlock_node (rn
);
3761 aspath_unintern (&attr
.aspath
);
3762 bgp_attr_extra_free (&attr
);
3767 /* Make new BGP info. */
3768 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3770 /* Nexthop reachability check. */
3771 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3773 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3774 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3777 if (BGP_DEBUG(nht
, NHT
))
3779 char buf1
[INET6_ADDRSTRLEN
];
3780 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3782 zlog_debug("%s(%s): Route not in table, not advertising",
3783 __FUNCTION__
, buf1
);
3785 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3790 /* Delete the NHT structure if any, if we're toggling between
3791 * enabling/disabling import check. We deregister the route
3792 * from NHT to avoid overloading NHT and the process interaction
3794 bgp_unlink_nexthop(new);
3796 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3799 /* Aggregate address increment. */
3800 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3802 /* Register new BGP information. */
3803 bgp_info_add (rn
, new);
3805 /* route_node_get lock */
3806 bgp_unlock_node (rn
);
3808 /* Process change. */
3809 bgp_process (bgp
, rn
, afi
, safi
);
3811 /* Unintern original. */
3812 aspath_unintern (&attr
.aspath
);
3813 bgp_attr_extra_free (&attr
);
3817 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3818 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3820 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3824 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3827 struct bgp_node
*rn
;
3828 struct bgp_info
*ri
;
3830 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3832 /* Check selected route and self inserted route. */
3833 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3834 if (ri
->peer
== bgp
->peer_self
3835 && ri
->type
== ZEBRA_ROUTE_BGP
3836 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3839 /* Withdraw static BGP route from routing table. */
3842 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3843 bgp_unlink_nexthop(ri
);
3844 bgp_info_delete (rn
, ri
);
3845 bgp_process (bgp
, rn
, afi
, safi
);
3848 /* Unlock bgp_node_lookup. */
3849 bgp_unlock_node (rn
);
3853 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3856 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3857 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3859 struct bgp_node
*rn
;
3860 struct bgp_info
*ri
;
3862 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3864 /* Check selected route and self inserted route. */
3865 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3866 if (ri
->peer
== bgp
->peer_self
3867 && ri
->type
== ZEBRA_ROUTE_BGP
3868 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3871 /* Withdraw static BGP route from routing table. */
3875 rfapiProcessWithdraw(
3884 1); /* Kill, since it is an administrative change */
3886 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3887 bgp_info_delete (rn
, ri
);
3888 bgp_process (bgp
, rn
, afi
, safi
);
3891 /* Unlock bgp_node_lookup. */
3892 bgp_unlock_node (rn
);
3896 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3897 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3899 struct bgp_node
*rn
;
3900 struct bgp_info
*new;
3901 struct attr
*attr_new
;
3902 struct attr attr
= { 0 };
3903 struct bgp_info
*ri
;
3905 u_int32_t label
= 0;
3908 assert (bgp_static
);
3910 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3912 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3914 attr
.nexthop
= bgp_static
->igpnexthop
;
3915 attr
.med
= bgp_static
->igpmetric
;
3916 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3918 /* Apply route-map. */
3919 if (bgp_static
->rmap
.name
)
3921 struct attr attr_tmp
= attr
;
3922 struct bgp_info info
;
3925 info
.peer
= bgp
->peer_self
;
3926 info
.attr
= &attr_tmp
;
3928 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3930 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3932 bgp
->peer_self
->rmap_type
= 0;
3934 if (ret
== RMAP_DENYMATCH
)
3936 /* Free uninterned attribute. */
3937 bgp_attr_flush (&attr_tmp
);
3939 /* Unintern original. */
3940 aspath_unintern (&attr
.aspath
);
3941 bgp_attr_extra_free (&attr
);
3942 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3947 attr_new
= bgp_attr_intern (&attr_tmp
);
3951 attr_new
= bgp_attr_intern (&attr
);
3954 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3955 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3956 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3961 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3962 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3964 bgp_unlock_node (rn
);
3965 bgp_attr_unintern (&attr_new
);
3966 aspath_unintern (&attr
.aspath
);
3967 bgp_attr_extra_free (&attr
);
3972 /* The attribute is changed. */
3973 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3975 /* Rewrite BGP route information. */
3976 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3977 bgp_info_restore(rn
, ri
);
3979 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3980 bgp_attr_unintern (&ri
->attr
);
3981 ri
->attr
= attr_new
;
3982 ri
->uptime
= bgp_clock ();
3985 label
= decode_label (ri
->extra
->tag
);
3988 /* Process change. */
3989 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3990 bgp_process (bgp
, rn
, afi
, safi
);
3992 rfapiProcessUpdate(ri
->peer
, NULL
, p
, &bgp_static
->prd
,
3993 ri
->attr
, afi
, safi
,
3994 ri
->type
, ri
->sub_type
, &label
);
3996 bgp_unlock_node (rn
);
3997 aspath_unintern (&attr
.aspath
);
3998 bgp_attr_extra_free (&attr
);
4004 /* Make new BGP info. */
4005 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
4007 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4008 new->extra
= bgp_info_extra_new();
4009 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
4011 label
= decode_label (bgp_static
->tag
);
4014 /* Aggregate address increment. */
4015 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
4017 /* Register new BGP information. */
4018 bgp_info_add (rn
, new);
4020 /* route_node_get lock */
4021 bgp_unlock_node (rn
);
4023 /* Process change. */
4024 bgp_process (bgp
, rn
, afi
, safi
);
4027 rfapiProcessUpdate(new->peer
, NULL
, p
, &bgp_static
->prd
,
4028 new->attr
, afi
, safi
,
4029 new->type
, new->sub_type
, &label
);
4032 /* Unintern original. */
4033 aspath_unintern (&attr
.aspath
);
4034 bgp_attr_extra_free (&attr
);
4037 /* Configure static BGP network. When user don't run zebra, static
4038 route should be installed as valid. */
4040 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4041 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
4045 struct bgp_static
*bgp_static
;
4046 struct bgp_node
*rn
;
4047 u_char need_update
= 0;
4049 /* Convert IP prefix string to struct prefix. */
4050 ret
= str2prefix (ip_str
, &p
);
4053 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4057 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4059 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4063 #endif /* HAVE_IPV6 */
4067 /* Set BGP static route configuration. */
4068 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
4072 /* Configuration change. */
4073 bgp_static
= rn
->info
;
4075 /* Check previous routes are installed into BGP. */
4076 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
4079 bgp_static
->backdoor
= backdoor
;
4083 if (bgp_static
->rmap
.name
)
4084 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4085 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4086 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4090 if (bgp_static
->rmap
.name
)
4091 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4092 bgp_static
->rmap
.name
= NULL
;
4093 bgp_static
->rmap
.map
= NULL
;
4094 bgp_static
->valid
= 0;
4096 bgp_unlock_node (rn
);
4100 /* New configuration. */
4101 bgp_static
= bgp_static_new ();
4102 bgp_static
->backdoor
= backdoor
;
4103 bgp_static
->valid
= 0;
4104 bgp_static
->igpmetric
= 0;
4105 bgp_static
->igpnexthop
.s_addr
= 0;
4109 if (bgp_static
->rmap
.name
)
4110 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4111 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4112 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4114 rn
->info
= bgp_static
;
4117 bgp_static
->valid
= 1;
4119 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4121 if (! bgp_static
->backdoor
)
4122 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
4127 /* Configure static BGP network. */
4129 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4130 afi_t afi
, safi_t safi
)
4134 struct bgp_static
*bgp_static
;
4135 struct bgp_node
*rn
;
4137 /* Convert IP prefix string to struct prefix. */
4138 ret
= str2prefix (ip_str
, &p
);
4141 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4145 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4147 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4151 #endif /* HAVE_IPV6 */
4155 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
4158 vty_out (vty
, "%% Can't find specified static route configuration.%s",
4163 bgp_static
= rn
->info
;
4165 /* Update BGP RIB. */
4166 if (! bgp_static
->backdoor
)
4167 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4169 /* Clear configuration. */
4170 bgp_static_free (bgp_static
);
4172 bgp_unlock_node (rn
);
4173 bgp_unlock_node (rn
);
4179 bgp_static_add (struct bgp
*bgp
)
4183 struct bgp_node
*rn
;
4184 struct bgp_node
*rm
;
4185 struct bgp_table
*table
;
4186 struct bgp_static
*bgp_static
;
4188 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4189 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4190 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4191 if (rn
->info
!= NULL
)
4193 if (safi
== SAFI_MPLS_VPN
)
4197 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4199 bgp_static
= rn
->info
;
4200 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
4205 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
4210 /* Called from bgp_delete(). Delete all static routes from the BGP
4213 bgp_static_delete (struct bgp
*bgp
)
4217 struct bgp_node
*rn
;
4218 struct bgp_node
*rm
;
4219 struct bgp_table
*table
;
4220 struct bgp_static
*bgp_static
;
4222 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4223 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4224 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4225 if (rn
->info
!= NULL
)
4227 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4231 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4233 bgp_static
= rn
->info
;
4234 bgp_static_withdraw_safi (bgp
, &rm
->p
,
4236 (struct prefix_rd
*)&rn
->p
,
4238 bgp_static_free (bgp_static
);
4240 bgp_unlock_node (rn
);
4245 bgp_static
= rn
->info
;
4246 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
4247 bgp_static_free (bgp_static
);
4249 bgp_unlock_node (rn
);
4255 bgp_static_redo_import_check (struct bgp
*bgp
)
4259 struct bgp_node
*rn
;
4260 struct bgp_static
*bgp_static
;
4262 /* Use this flag to force reprocessing of the route */
4263 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4264 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4265 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4266 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4267 if (rn
->info
!= NULL
)
4269 bgp_static
= rn
->info
;
4270 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
4272 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4276 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
4278 struct bgp_table
*table
;
4279 struct bgp_node
*rn
;
4280 struct bgp_info
*ri
;
4282 table
= bgp
->rib
[afi
][safi
];
4283 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
4285 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4287 if (ri
->peer
== bgp
->peer_self
&&
4288 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
4289 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
4290 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
4291 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
4293 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4294 bgp_unlink_nexthop(ri
);
4295 bgp_info_delete (rn
, ri
);
4296 bgp_process (bgp
, rn
, afi
, safi
);
4303 * Purge all networks and redistributed routes from routing table.
4304 * Invoked upon the instance going down.
4307 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4312 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4313 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4314 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4319 * Currently this is used to set static routes for VPN and ENCAP.
4320 * I think it can probably be factored with bgp_static_set.
4323 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4324 const char *rd_str
, const char *tag_str
,
4325 const char *rmap_str
)
4329 struct prefix_rd prd
;
4331 struct bgp_node
*prn
;
4332 struct bgp_node
*rn
;
4333 struct bgp_table
*table
;
4334 struct bgp_static
*bgp_static
;
4339 ret
= str2prefix (ip_str
, &p
);
4342 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4347 ret
= str2prefix_rd (rd_str
, &prd
);
4350 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4354 ret
= str2tag (tag_str
, tag
);
4357 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4361 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4362 (struct prefix
*)&prd
);
4363 if (prn
->info
== NULL
)
4364 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4366 bgp_unlock_node (prn
);
4369 rn
= bgp_node_get (table
, &p
);
4373 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4374 bgp_unlock_node (rn
);
4378 /* New configuration. */
4379 bgp_static
= bgp_static_new ();
4380 bgp_static
->backdoor
= 0;
4381 bgp_static
->valid
= 0;
4382 bgp_static
->igpmetric
= 0;
4383 bgp_static
->igpnexthop
.s_addr
= 0;
4384 memcpy(bgp_static
->tag
, tag
, 3);
4385 bgp_static
->prd
= prd
;
4389 if (bgp_static
->rmap
.name
)
4390 free (bgp_static
->rmap
.name
);
4391 bgp_static
->rmap
.name
= strdup (rmap_str
);
4392 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4394 rn
->info
= bgp_static
;
4396 bgp_static
->valid
= 1;
4397 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4403 /* Configure static BGP network. */
4405 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4406 const char *rd_str
, const char *tag_str
)
4411 struct prefix_rd prd
;
4412 struct bgp_node
*prn
;
4413 struct bgp_node
*rn
;
4414 struct bgp_table
*table
;
4415 struct bgp_static
*bgp_static
;
4420 /* Convert IP prefix string to struct prefix. */
4421 ret
= str2prefix (ip_str
, &p
);
4424 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4429 ret
= str2prefix_rd (rd_str
, &prd
);
4432 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4436 ret
= str2tag (tag_str
, tag
);
4439 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4443 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4444 (struct prefix
*)&prd
);
4445 if (prn
->info
== NULL
)
4446 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4448 bgp_unlock_node (prn
);
4451 rn
= bgp_node_lookup (table
, &p
);
4455 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4457 bgp_static
= rn
->info
;
4458 bgp_static_free (bgp_static
);
4460 bgp_unlock_node (rn
);
4461 bgp_unlock_node (rn
);
4464 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4470 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4471 const char *rmap_name
)
4473 struct bgp_rmap
*rmap
;
4475 rmap
= &bgp
->table_map
[afi
][safi
];
4479 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4480 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4481 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4486 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4491 bgp_zebra_announce_table(bgp
, afi
, safi
);
4497 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4498 const char *rmap_name
)
4500 struct bgp_rmap
*rmap
;
4502 rmap
= &bgp
->table_map
[afi
][safi
];
4504 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4508 bgp_zebra_announce_table(bgp
, afi
, safi
);
4514 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4515 safi_t safi
, int *write
)
4517 if (bgp
->table_map
[afi
][safi
].name
)
4519 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4520 vty_out (vty
, " table-map %s%s",
4521 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4528 DEFUN (bgp_table_map
,
4531 "BGP table to RIB route download filter\n"
4532 "Name of the route map\n")
4534 return bgp_table_map_set (vty
, vty
->index
,
4535 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4537 DEFUN (no_bgp_table_map
,
4538 no_bgp_table_map_cmd
,
4539 "no table-map WORD",
4540 "BGP table to RIB route download filter\n"
4541 "Name of the route map\n")
4543 return bgp_table_map_unset (vty
, vty
->index
,
4544 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4549 "network A.B.C.D/M",
4550 "Specify a network to announce via BGP\n"
4551 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4553 return bgp_static_set (vty
, vty
->index
, argv
[0],
4554 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4557 DEFUN (bgp_network_route_map
,
4558 bgp_network_route_map_cmd
,
4559 "network A.B.C.D/M route-map WORD",
4560 "Specify a network to announce via BGP\n"
4561 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4562 "Route-map to modify the attributes\n"
4563 "Name of the route map\n")
4565 return bgp_static_set (vty
, vty
->index
, argv
[0],
4566 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4569 DEFUN (bgp_network_backdoor
,
4570 bgp_network_backdoor_cmd
,
4571 "network A.B.C.D/M backdoor",
4572 "Specify a network to announce via BGP\n"
4573 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4574 "Specify a BGP backdoor route\n")
4576 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4580 DEFUN (bgp_network_mask
,
4581 bgp_network_mask_cmd
,
4582 "network A.B.C.D mask A.B.C.D",
4583 "Specify a network to announce via BGP\n"
4589 char prefix_str
[BUFSIZ
];
4591 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4594 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4598 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4599 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4602 DEFUN (bgp_network_mask_route_map
,
4603 bgp_network_mask_route_map_cmd
,
4604 "network A.B.C.D mask A.B.C.D route-map WORD",
4605 "Specify a network to announce via BGP\n"
4609 "Route-map to modify the attributes\n"
4610 "Name of the route map\n")
4613 char prefix_str
[BUFSIZ
];
4615 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4618 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4622 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4623 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4626 DEFUN (bgp_network_mask_backdoor
,
4627 bgp_network_mask_backdoor_cmd
,
4628 "network A.B.C.D mask A.B.C.D backdoor",
4629 "Specify a network to announce via BGP\n"
4633 "Specify a BGP backdoor route\n")
4636 char prefix_str
[BUFSIZ
];
4638 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4641 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4645 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4649 DEFUN (bgp_network_mask_natural
,
4650 bgp_network_mask_natural_cmd
,
4652 "Specify a network to announce via BGP\n"
4656 char prefix_str
[BUFSIZ
];
4658 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4661 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4665 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4666 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4669 DEFUN (bgp_network_mask_natural_route_map
,
4670 bgp_network_mask_natural_route_map_cmd
,
4671 "network A.B.C.D route-map WORD",
4672 "Specify a network to announce via BGP\n"
4674 "Route-map to modify the attributes\n"
4675 "Name of the route map\n")
4678 char prefix_str
[BUFSIZ
];
4680 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4683 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4687 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4688 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4691 DEFUN (bgp_network_mask_natural_backdoor
,
4692 bgp_network_mask_natural_backdoor_cmd
,
4693 "network A.B.C.D backdoor",
4694 "Specify a network to announce via BGP\n"
4696 "Specify a BGP backdoor route\n")
4699 char prefix_str
[BUFSIZ
];
4701 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4704 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4708 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4712 DEFUN (no_bgp_network
,
4714 "no network A.B.C.D/M",
4716 "Specify a network to announce via BGP\n"
4717 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4719 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4720 bgp_node_safi (vty
));
4723 ALIAS (no_bgp_network
,
4724 no_bgp_network_route_map_cmd
,
4725 "no network A.B.C.D/M route-map WORD",
4727 "Specify a network to announce via BGP\n"
4728 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4729 "Route-map to modify the attributes\n"
4730 "Name of the route map\n")
4732 ALIAS (no_bgp_network
,
4733 no_bgp_network_backdoor_cmd
,
4734 "no network A.B.C.D/M backdoor",
4736 "Specify a network to announce via BGP\n"
4737 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4738 "Specify a BGP backdoor route\n")
4740 DEFUN (no_bgp_network_mask
,
4741 no_bgp_network_mask_cmd
,
4742 "no network A.B.C.D mask A.B.C.D",
4744 "Specify a network to announce via BGP\n"
4750 char prefix_str
[BUFSIZ
];
4752 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4755 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4759 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4760 bgp_node_safi (vty
));
4763 ALIAS (no_bgp_network_mask
,
4764 no_bgp_network_mask_route_map_cmd
,
4765 "no network A.B.C.D mask A.B.C.D route-map WORD",
4767 "Specify a network to announce via BGP\n"
4771 "Route-map to modify the attributes\n"
4772 "Name of the route map\n")
4774 ALIAS (no_bgp_network_mask
,
4775 no_bgp_network_mask_backdoor_cmd
,
4776 "no network A.B.C.D mask A.B.C.D backdoor",
4778 "Specify a network to announce via BGP\n"
4782 "Specify a BGP backdoor route\n")
4784 DEFUN (no_bgp_network_mask_natural
,
4785 no_bgp_network_mask_natural_cmd
,
4786 "no network A.B.C.D",
4788 "Specify a network to announce via BGP\n"
4792 char prefix_str
[BUFSIZ
];
4794 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4797 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4801 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4802 bgp_node_safi (vty
));
4805 ALIAS (no_bgp_network_mask_natural
,
4806 no_bgp_network_mask_natural_route_map_cmd
,
4807 "no network A.B.C.D route-map WORD",
4809 "Specify a network to announce via BGP\n"
4811 "Route-map to modify the attributes\n"
4812 "Name of the route map\n")
4814 ALIAS (no_bgp_network_mask_natural
,
4815 no_bgp_network_mask_natural_backdoor_cmd
,
4816 "no network A.B.C.D backdoor",
4818 "Specify a network to announce via BGP\n"
4820 "Specify a BGP backdoor route\n")
4823 DEFUN (ipv6_bgp_network
,
4824 ipv6_bgp_network_cmd
,
4825 "network X:X::X:X/M",
4826 "Specify a network to announce via BGP\n"
4827 "IPv6 prefix <network>/<length>\n")
4829 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4833 DEFUN (ipv6_bgp_network_route_map
,
4834 ipv6_bgp_network_route_map_cmd
,
4835 "network X:X::X:X/M route-map WORD",
4836 "Specify a network to announce via BGP\n"
4837 "IPv6 prefix <network>/<length>\n"
4838 "Route-map to modify the attributes\n"
4839 "Name of the route map\n")
4841 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4842 bgp_node_safi (vty
), argv
[1], 0);
4845 DEFUN (no_ipv6_bgp_network
,
4846 no_ipv6_bgp_network_cmd
,
4847 "no network X:X::X:X/M",
4849 "Specify a network to announce via BGP\n"
4850 "IPv6 prefix <network>/<length>\n")
4852 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4855 ALIAS (no_ipv6_bgp_network
,
4856 no_ipv6_bgp_network_route_map_cmd
,
4857 "no network X:X::X:X/M route-map WORD",
4859 "Specify a network to announce via BGP\n"
4860 "IPv6 prefix <network>/<length>\n"
4861 "Route-map to modify the attributes\n"
4862 "Name of the route map\n")
4864 ALIAS (ipv6_bgp_network
,
4865 old_ipv6_bgp_network_cmd
,
4866 "ipv6 bgp network X:X::X:X/M",
4869 "Specify a network to announce via BGP\n"
4870 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4872 ALIAS (no_ipv6_bgp_network
,
4873 old_no_ipv6_bgp_network_cmd
,
4874 "no ipv6 bgp network X:X::X:X/M",
4878 "Specify a network to announce via BGP\n"
4879 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4880 #endif /* HAVE_IPV6 */
4882 /* Aggreagete address:
4884 advertise-map Set condition to advertise attribute
4885 as-set Generate AS set path information
4886 attribute-map Set attributes of aggregate
4887 route-map Set parameters of aggregate
4888 summary-only Filter more specific routes from updates
4889 suppress-map Conditionally filter more specific routes from updates
4892 struct bgp_aggregate
4894 /* Summary-only flag. */
4895 u_char summary_only
;
4897 /* AS set generation. */
4900 /* Route-map for aggregated route. */
4901 struct route_map
*map
;
4903 /* Suppress-count. */
4904 unsigned long count
;
4906 /* SAFI configuration. */
4910 static struct bgp_aggregate
*
4911 bgp_aggregate_new (void)
4913 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4917 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4919 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4922 /* Update an aggregate as routes are added/removed from the BGP table */
4924 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4925 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4926 struct bgp_aggregate
*aggregate
)
4928 struct bgp_table
*table
;
4929 struct bgp_node
*top
;
4930 struct bgp_node
*rn
;
4932 struct aspath
*aspath
= NULL
;
4933 struct aspath
*asmerge
= NULL
;
4934 struct community
*community
= NULL
;
4935 struct community
*commerge
= NULL
;
4936 #if defined(AGGREGATE_NEXTHOP_CHECK)
4937 struct in_addr nexthop
;
4940 struct bgp_info
*ri
;
4941 struct bgp_info
*new;
4943 unsigned long match
= 0;
4944 u_char atomic_aggregate
= 0;
4946 /* Record adding route's nexthop and med. */
4949 #if defined(AGGREGATE_NEXTHOP_CHECK)
4950 nexthop
= rinew
->attr
->nexthop
;
4951 med
= rinew
->attr
->med
;
4955 /* ORIGIN attribute: If at least one route among routes that are
4956 aggregated has ORIGIN with the value INCOMPLETE, then the
4957 aggregated route must have the ORIGIN attribute with the value
4958 INCOMPLETE. Otherwise, if at least one route among routes that
4959 are aggregated has ORIGIN with the value EGP, then the aggregated
4960 route must have the origin attribute with the value EGP. In all
4961 other case the value of the ORIGIN attribute of the aggregated
4962 route is INTERNAL. */
4963 origin
= BGP_ORIGIN_IGP
;
4965 table
= bgp
->rib
[afi
][safi
];
4967 top
= bgp_node_get (table
, p
);
4968 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4969 if (rn
->p
.prefixlen
> p
->prefixlen
)
4973 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4975 if (BGP_INFO_HOLDDOWN (ri
))
4978 if (del
&& ri
== del
)
4981 if (! rinew
&& first
)
4983 #if defined(AGGREGATE_NEXTHOP_CHECK)
4984 nexthop
= ri
->attr
->nexthop
;
4985 med
= ri
->attr
->med
;
4990 #ifdef AGGREGATE_NEXTHOP_CHECK
4991 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4992 || ri
->attr
->med
!= med
)
4995 aspath_free (aspath
);
4997 community_free (community
);
4998 bgp_unlock_node (rn
);
4999 bgp_unlock_node (top
);
5002 #endif /* AGGREGATE_NEXTHOP_CHECK */
5004 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5005 atomic_aggregate
= 1;
5007 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5009 if (aggregate
->summary_only
)
5011 (bgp_info_extra_get (ri
))->suppress
++;
5012 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5018 if (origin
< ri
->attr
->origin
)
5019 origin
= ri
->attr
->origin
;
5021 if (aggregate
->as_set
)
5025 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5026 aspath_free (aspath
);
5030 aspath
= aspath_dup (ri
->attr
->aspath
);
5032 if (ri
->attr
->community
)
5036 commerge
= community_merge (community
,
5037 ri
->attr
->community
);
5038 community
= community_uniq_sort (commerge
);
5039 community_free (commerge
);
5042 community
= community_dup (ri
->attr
->community
);
5048 bgp_process (bgp
, rn
, afi
, safi
);
5050 bgp_unlock_node (top
);
5056 if (aggregate
->summary_only
)
5057 (bgp_info_extra_get (rinew
))->suppress
++;
5059 if (origin
< rinew
->attr
->origin
)
5060 origin
= rinew
->attr
->origin
;
5062 if (aggregate
->as_set
)
5066 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
5067 aspath_free (aspath
);
5071 aspath
= aspath_dup (rinew
->attr
->aspath
);
5073 if (rinew
->attr
->community
)
5077 commerge
= community_merge (community
,
5078 rinew
->attr
->community
);
5079 community
= community_uniq_sort (commerge
);
5080 community_free (commerge
);
5083 community
= community_dup (rinew
->attr
->community
);
5088 if (aggregate
->count
> 0)
5090 rn
= bgp_node_get (table
, p
);
5091 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5092 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5094 atomic_aggregate
), rn
);
5095 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5097 bgp_info_add (rn
, new);
5098 bgp_unlock_node (rn
);
5099 bgp_process (bgp
, rn
, afi
, safi
);
5104 aspath_free (aspath
);
5106 community_free (community
);
5110 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
5111 struct bgp_aggregate
*);
5114 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
5115 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
5117 struct bgp_node
*child
;
5118 struct bgp_node
*rn
;
5119 struct bgp_aggregate
*aggregate
;
5120 struct bgp_table
*table
;
5122 /* MPLS-VPN aggregation is not yet supported. */
5123 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5126 table
= bgp
->aggregate
[afi
][safi
];
5128 /* No aggregates configured. */
5129 if (bgp_table_top_nolock (table
) == NULL
)
5132 if (p
->prefixlen
== 0)
5135 if (BGP_INFO_HOLDDOWN (ri
))
5138 child
= bgp_node_get (table
, p
);
5140 /* Aggregate address configuration check. */
5141 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5142 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5144 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5145 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
5147 bgp_unlock_node (child
);
5151 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
5152 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
5154 struct bgp_node
*child
;
5155 struct bgp_node
*rn
;
5156 struct bgp_aggregate
*aggregate
;
5157 struct bgp_table
*table
;
5159 /* MPLS-VPN aggregation is not yet supported. */
5160 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5163 table
= bgp
->aggregate
[afi
][safi
];
5165 /* No aggregates configured. */
5166 if (bgp_table_top_nolock (table
) == NULL
)
5169 if (p
->prefixlen
== 0)
5172 child
= bgp_node_get (table
, p
);
5174 /* Aggregate address configuration check. */
5175 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5176 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5178 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5179 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
5181 bgp_unlock_node (child
);
5184 /* Called via bgp_aggregate_set when the user configures aggregate-address */
5186 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
5187 struct bgp_aggregate
*aggregate
)
5189 struct bgp_table
*table
;
5190 struct bgp_node
*top
;
5191 struct bgp_node
*rn
;
5192 struct bgp_info
*new;
5193 struct bgp_info
*ri
;
5194 unsigned long match
;
5195 u_char origin
= BGP_ORIGIN_IGP
;
5196 struct aspath
*aspath
= NULL
;
5197 struct aspath
*asmerge
= NULL
;
5198 struct community
*community
= NULL
;
5199 struct community
*commerge
= NULL
;
5200 u_char atomic_aggregate
= 0;
5202 table
= bgp
->rib
[afi
][safi
];
5205 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5207 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5210 /* If routes exists below this node, generate aggregate routes. */
5211 top
= bgp_node_get (table
, p
);
5212 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5213 if (rn
->p
.prefixlen
> p
->prefixlen
)
5217 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5219 if (BGP_INFO_HOLDDOWN (ri
))
5222 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5223 atomic_aggregate
= 1;
5225 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5227 /* summary-only aggregate route suppress aggregated
5228 route announcement. */
5229 if (aggregate
->summary_only
)
5231 (bgp_info_extra_get (ri
))->suppress
++;
5232 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5236 /* If at least one route among routes that are aggregated has
5237 * ORIGIN with the value INCOMPLETE, then the aggregated route
5238 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5239 * Otherwise, if at least one route among routes that are
5240 * aggregated has ORIGIN with the value EGP, then the aggregated
5241 * route MUST have the ORIGIN attribute with the value EGP.
5243 if (origin
< ri
->attr
->origin
)
5244 origin
= ri
->attr
->origin
;
5246 /* as-set aggregate route generate origin, as path,
5247 community aggregation. */
5248 if (aggregate
->as_set
)
5252 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5253 aspath_free (aspath
);
5257 aspath
= aspath_dup (ri
->attr
->aspath
);
5259 if (ri
->attr
->community
)
5263 commerge
= community_merge (community
,
5264 ri
->attr
->community
);
5265 community
= community_uniq_sort (commerge
);
5266 community_free (commerge
);
5269 community
= community_dup (ri
->attr
->community
);
5276 /* If this node is suppressed, process the change. */
5278 bgp_process (bgp
, rn
, afi
, safi
);
5280 bgp_unlock_node (top
);
5282 /* Add aggregate route to BGP table. */
5283 if (aggregate
->count
)
5285 rn
= bgp_node_get (table
, p
);
5286 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5287 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5289 atomic_aggregate
), rn
);
5290 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5292 bgp_info_add (rn
, new);
5293 bgp_unlock_node (rn
);
5295 /* Process change. */
5296 bgp_process (bgp
, rn
, afi
, safi
);
5301 aspath_free (aspath
);
5303 community_free (community
);
5308 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5309 safi_t safi
, struct bgp_aggregate
*aggregate
)
5311 struct bgp_table
*table
;
5312 struct bgp_node
*top
;
5313 struct bgp_node
*rn
;
5314 struct bgp_info
*ri
;
5315 unsigned long match
;
5317 table
= bgp
->rib
[afi
][safi
];
5319 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5321 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5324 /* If routes exists below this node, generate aggregate routes. */
5325 top
= bgp_node_get (table
, p
);
5326 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5327 if (rn
->p
.prefixlen
> p
->prefixlen
)
5331 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5333 if (BGP_INFO_HOLDDOWN (ri
))
5336 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5338 if (aggregate
->summary_only
&& ri
->extra
)
5340 ri
->extra
->suppress
--;
5342 if (ri
->extra
->suppress
== 0)
5344 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5352 /* If this node was suppressed, process the change. */
5354 bgp_process (bgp
, rn
, afi
, safi
);
5356 bgp_unlock_node (top
);
5358 /* Delete aggregate route from BGP table. */
5359 rn
= bgp_node_get (table
, p
);
5361 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5362 if (ri
->peer
== bgp
->peer_self
5363 && ri
->type
== ZEBRA_ROUTE_BGP
5364 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5367 /* Withdraw static BGP route from routing table. */
5370 bgp_info_delete (rn
, ri
);
5371 bgp_process (bgp
, rn
, afi
, safi
);
5374 /* Unlock bgp_node_lookup. */
5375 bgp_unlock_node (rn
);
5378 /* Aggregate route attribute. */
5379 #define AGGREGATE_SUMMARY_ONLY 1
5380 #define AGGREGATE_AS_SET 1
5383 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5384 afi_t afi
, safi_t safi
)
5388 struct bgp_node
*rn
;
5390 struct bgp_aggregate
*aggregate
;
5392 /* Convert string to prefix structure. */
5393 ret
= str2prefix (prefix_str
, &p
);
5396 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5401 /* Get BGP structure. */
5404 /* Old configuration check. */
5405 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5408 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5413 aggregate
= rn
->info
;
5414 if (aggregate
->safi
& SAFI_UNICAST
)
5415 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5416 if (aggregate
->safi
& SAFI_MULTICAST
)
5417 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5419 /* Unlock aggregate address configuration. */
5421 bgp_aggregate_free (aggregate
);
5422 bgp_unlock_node (rn
);
5423 bgp_unlock_node (rn
);
5429 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5430 afi_t afi
, safi_t safi
,
5431 u_char summary_only
, u_char as_set
)
5435 struct bgp_node
*rn
;
5437 struct bgp_aggregate
*aggregate
;
5439 /* Convert string to prefix structure. */
5440 ret
= str2prefix (prefix_str
, &p
);
5443 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5448 /* Get BGP structure. */
5451 /* Old configuration check. */
5452 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5456 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5457 /* try to remove the old entry */
5458 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5461 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5462 bgp_unlock_node (rn
);
5467 /* Make aggregate address structure. */
5468 aggregate
= bgp_aggregate_new ();
5469 aggregate
->summary_only
= summary_only
;
5470 aggregate
->as_set
= as_set
;
5471 aggregate
->safi
= safi
;
5472 rn
->info
= aggregate
;
5474 /* Aggregate address insert into BGP routing table. */
5475 if (safi
& SAFI_UNICAST
)
5476 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5477 if (safi
& SAFI_MULTICAST
)
5478 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5483 DEFUN (aggregate_address
,
5484 aggregate_address_cmd
,
5485 "aggregate-address A.B.C.D/M",
5486 "Configure BGP aggregate entries\n"
5487 "Aggregate prefix\n")
5489 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5492 DEFUN (aggregate_address_mask
,
5493 aggregate_address_mask_cmd
,
5494 "aggregate-address A.B.C.D A.B.C.D",
5495 "Configure BGP aggregate entries\n"
5496 "Aggregate address\n"
5500 char prefix_str
[BUFSIZ
];
5502 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5506 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5510 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5514 DEFUN (aggregate_address_summary_only
,
5515 aggregate_address_summary_only_cmd
,
5516 "aggregate-address A.B.C.D/M summary-only",
5517 "Configure BGP aggregate entries\n"
5518 "Aggregate prefix\n"
5519 "Filter more specific routes from updates\n")
5521 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5522 AGGREGATE_SUMMARY_ONLY
, 0);
5525 DEFUN (aggregate_address_mask_summary_only
,
5526 aggregate_address_mask_summary_only_cmd
,
5527 "aggregate-address A.B.C.D A.B.C.D summary-only",
5528 "Configure BGP aggregate entries\n"
5529 "Aggregate address\n"
5531 "Filter more specific routes from updates\n")
5534 char prefix_str
[BUFSIZ
];
5536 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5540 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5544 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5545 AGGREGATE_SUMMARY_ONLY
, 0);
5548 DEFUN (aggregate_address_as_set
,
5549 aggregate_address_as_set_cmd
,
5550 "aggregate-address A.B.C.D/M as-set",
5551 "Configure BGP aggregate entries\n"
5552 "Aggregate prefix\n"
5553 "Generate AS set path information\n")
5555 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5556 0, AGGREGATE_AS_SET
);
5559 DEFUN (aggregate_address_mask_as_set
,
5560 aggregate_address_mask_as_set_cmd
,
5561 "aggregate-address A.B.C.D A.B.C.D as-set",
5562 "Configure BGP aggregate entries\n"
5563 "Aggregate address\n"
5565 "Generate AS set path information\n")
5568 char prefix_str
[BUFSIZ
];
5570 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5574 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5578 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5579 0, AGGREGATE_AS_SET
);
5583 DEFUN (aggregate_address_as_set_summary
,
5584 aggregate_address_as_set_summary_cmd
,
5585 "aggregate-address A.B.C.D/M as-set summary-only",
5586 "Configure BGP aggregate entries\n"
5587 "Aggregate prefix\n"
5588 "Generate AS set path information\n"
5589 "Filter more specific routes from updates\n")
5591 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5592 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5595 ALIAS (aggregate_address_as_set_summary
,
5596 aggregate_address_summary_as_set_cmd
,
5597 "aggregate-address A.B.C.D/M summary-only as-set",
5598 "Configure BGP aggregate entries\n"
5599 "Aggregate prefix\n"
5600 "Filter more specific routes from updates\n"
5601 "Generate AS set path information\n")
5603 DEFUN (aggregate_address_mask_as_set_summary
,
5604 aggregate_address_mask_as_set_summary_cmd
,
5605 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5606 "Configure BGP aggregate entries\n"
5607 "Aggregate address\n"
5609 "Generate AS set path information\n"
5610 "Filter more specific routes from updates\n")
5613 char prefix_str
[BUFSIZ
];
5615 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5619 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5623 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5624 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5627 ALIAS (aggregate_address_mask_as_set_summary
,
5628 aggregate_address_mask_summary_as_set_cmd
,
5629 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5630 "Configure BGP aggregate entries\n"
5631 "Aggregate address\n"
5633 "Filter more specific routes from updates\n"
5634 "Generate AS set path information\n")
5636 DEFUN (no_aggregate_address
,
5637 no_aggregate_address_cmd
,
5638 "no aggregate-address A.B.C.D/M",
5640 "Configure BGP aggregate entries\n"
5641 "Aggregate prefix\n")
5643 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5646 ALIAS (no_aggregate_address
,
5647 no_aggregate_address_summary_only_cmd
,
5648 "no aggregate-address A.B.C.D/M summary-only",
5650 "Configure BGP aggregate entries\n"
5651 "Aggregate prefix\n"
5652 "Filter more specific routes from updates\n")
5654 ALIAS (no_aggregate_address
,
5655 no_aggregate_address_as_set_cmd
,
5656 "no aggregate-address A.B.C.D/M as-set",
5658 "Configure BGP aggregate entries\n"
5659 "Aggregate prefix\n"
5660 "Generate AS set path information\n")
5662 ALIAS (no_aggregate_address
,
5663 no_aggregate_address_as_set_summary_cmd
,
5664 "no aggregate-address A.B.C.D/M as-set summary-only",
5666 "Configure BGP aggregate entries\n"
5667 "Aggregate prefix\n"
5668 "Generate AS set path information\n"
5669 "Filter more specific routes from updates\n")
5671 ALIAS (no_aggregate_address
,
5672 no_aggregate_address_summary_as_set_cmd
,
5673 "no aggregate-address A.B.C.D/M summary-only as-set",
5675 "Configure BGP aggregate entries\n"
5676 "Aggregate prefix\n"
5677 "Filter more specific routes from updates\n"
5678 "Generate AS set path information\n")
5680 DEFUN (no_aggregate_address_mask
,
5681 no_aggregate_address_mask_cmd
,
5682 "no aggregate-address A.B.C.D A.B.C.D",
5684 "Configure BGP aggregate entries\n"
5685 "Aggregate address\n"
5689 char prefix_str
[BUFSIZ
];
5691 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5695 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5699 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5702 ALIAS (no_aggregate_address_mask
,
5703 no_aggregate_address_mask_summary_only_cmd
,
5704 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5706 "Configure BGP aggregate entries\n"
5707 "Aggregate address\n"
5709 "Filter more specific routes from updates\n")
5711 ALIAS (no_aggregate_address_mask
,
5712 no_aggregate_address_mask_as_set_cmd
,
5713 "no aggregate-address A.B.C.D A.B.C.D as-set",
5715 "Configure BGP aggregate entries\n"
5716 "Aggregate address\n"
5718 "Generate AS set path information\n")
5720 ALIAS (no_aggregate_address_mask
,
5721 no_aggregate_address_mask_as_set_summary_cmd
,
5722 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5724 "Configure BGP aggregate entries\n"
5725 "Aggregate address\n"
5727 "Generate AS set path information\n"
5728 "Filter more specific routes from updates\n")
5730 ALIAS (no_aggregate_address_mask
,
5731 no_aggregate_address_mask_summary_as_set_cmd
,
5732 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5734 "Configure BGP aggregate entries\n"
5735 "Aggregate address\n"
5737 "Filter more specific routes from updates\n"
5738 "Generate AS set path information\n")
5741 DEFUN (ipv6_aggregate_address
,
5742 ipv6_aggregate_address_cmd
,
5743 "aggregate-address X:X::X:X/M",
5744 "Configure BGP aggregate entries\n"
5745 "Aggregate prefix\n")
5747 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5750 DEFUN (ipv6_aggregate_address_summary_only
,
5751 ipv6_aggregate_address_summary_only_cmd
,
5752 "aggregate-address X:X::X:X/M summary-only",
5753 "Configure BGP aggregate entries\n"
5754 "Aggregate prefix\n"
5755 "Filter more specific routes from updates\n")
5757 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5758 AGGREGATE_SUMMARY_ONLY
, 0);
5761 DEFUN (no_ipv6_aggregate_address
,
5762 no_ipv6_aggregate_address_cmd
,
5763 "no aggregate-address X:X::X:X/M",
5765 "Configure BGP aggregate entries\n"
5766 "Aggregate prefix\n")
5768 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5771 DEFUN (no_ipv6_aggregate_address_summary_only
,
5772 no_ipv6_aggregate_address_summary_only_cmd
,
5773 "no aggregate-address X:X::X:X/M summary-only",
5775 "Configure BGP aggregate entries\n"
5776 "Aggregate prefix\n"
5777 "Filter more specific routes from updates\n")
5779 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5782 ALIAS (ipv6_aggregate_address
,
5783 old_ipv6_aggregate_address_cmd
,
5784 "ipv6 bgp aggregate-address X:X::X:X/M",
5787 "Configure BGP aggregate entries\n"
5788 "Aggregate prefix\n")
5790 ALIAS (ipv6_aggregate_address_summary_only
,
5791 old_ipv6_aggregate_address_summary_only_cmd
,
5792 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5795 "Configure BGP aggregate entries\n"
5796 "Aggregate prefix\n"
5797 "Filter more specific routes from updates\n")
5799 ALIAS (no_ipv6_aggregate_address
,
5800 old_no_ipv6_aggregate_address_cmd
,
5801 "no ipv6 bgp aggregate-address X:X::X:X/M",
5805 "Configure BGP aggregate entries\n"
5806 "Aggregate prefix\n")
5808 ALIAS (no_ipv6_aggregate_address_summary_only
,
5809 old_no_ipv6_aggregate_address_summary_only_cmd
,
5810 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5814 "Configure BGP aggregate entries\n"
5815 "Aggregate prefix\n"
5816 "Filter more specific routes from updates\n")
5817 #endif /* HAVE_IPV6 */
5819 /* Redistribute route treatment. */
5821 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5822 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5823 u_int32_t metric
, u_char type
, u_short instance
, u_short tag
)
5825 struct bgp_info
*new;
5826 struct bgp_info
*bi
;
5827 struct bgp_info info
;
5828 struct bgp_node
*bn
;
5830 struct attr
*new_attr
;
5833 struct bgp_redist
*red
;
5835 /* Make default attribute. */
5836 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5838 attr
.nexthop
= *nexthop
;
5839 attr
.nh_ifindex
= ifindex
;
5844 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5845 extra
->mp_nexthop_global
= *nexthop6
;
5846 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5851 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5852 attr
.extra
->tag
= tag
;
5854 afi
= family2afi (p
->family
);
5856 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5859 struct attr attr_new
;
5860 struct attr_extra extra_new
;
5862 /* Copy attribute for modification. */
5863 attr_new
.extra
= &extra_new
;
5864 bgp_attr_dup (&attr_new
, &attr
);
5866 if (red
->redist_metric_flag
)
5867 attr_new
.med
= red
->redist_metric
;
5869 /* Apply route-map. */
5872 info
.peer
= bgp
->peer_self
;
5873 info
.attr
= &attr_new
;
5875 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5877 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5879 bgp
->peer_self
->rmap_type
= 0;
5881 if (ret
== RMAP_DENYMATCH
)
5883 /* Free uninterned attribute. */
5884 bgp_attr_flush (&attr_new
);
5886 /* Unintern original. */
5887 aspath_unintern (&attr
.aspath
);
5888 bgp_attr_extra_free (&attr
);
5889 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5894 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5895 afi
, SAFI_UNICAST
, p
, NULL
);
5897 new_attr
= bgp_attr_intern (&attr_new
);
5899 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5900 if (bi
->peer
== bgp
->peer_self
5901 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5906 /* Ensure the (source route) type is updated. */
5908 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5909 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5911 bgp_attr_unintern (&new_attr
);
5912 aspath_unintern (&attr
.aspath
);
5913 bgp_attr_extra_free (&attr
);
5914 bgp_unlock_node (bn
);
5919 /* The attribute is changed. */
5920 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5922 /* Rewrite BGP route information. */
5923 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5924 bgp_info_restore(bn
, bi
);
5926 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5927 bgp_attr_unintern (&bi
->attr
);
5928 bi
->attr
= new_attr
;
5929 bi
->uptime
= bgp_clock ();
5931 /* Process change. */
5932 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5933 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5934 bgp_unlock_node (bn
);
5935 aspath_unintern (&attr
.aspath
);
5936 bgp_attr_extra_free (&attr
);
5941 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5943 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5945 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5946 bgp_info_add (bn
, new);
5947 bgp_unlock_node (bn
);
5948 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5951 /* Unintern original. */
5952 aspath_unintern (&attr
.aspath
);
5953 bgp_attr_extra_free (&attr
);
5957 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5960 struct bgp_node
*rn
;
5961 struct bgp_info
*ri
;
5962 struct bgp_redist
*red
;
5964 afi
= family2afi (p
->family
);
5966 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5969 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5971 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5972 if (ri
->peer
== bgp
->peer_self
5973 && ri
->type
== type
)
5978 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5979 bgp_info_delete (rn
, ri
);
5980 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5982 bgp_unlock_node (rn
);
5986 /* Withdraw specified route type's route. */
5988 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5990 struct bgp_node
*rn
;
5991 struct bgp_info
*ri
;
5992 struct bgp_table
*table
;
5994 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5996 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5998 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5999 if (ri
->peer
== bgp
->peer_self
6001 && ri
->instance
== instance
)
6006 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
6007 bgp_info_delete (rn
, ri
);
6008 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
6013 /* Static function to display route. */
6015 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
6018 u_int32_t destination
;
6021 if (p
->family
== AF_INET
)
6023 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
6024 destination
= ntohl (p
->u
.prefix4
.s_addr
);
6026 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
6027 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
6028 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
6029 || p
->u
.prefix4
.s_addr
== 0)
6031 /* When mask is natural, mask is not displayed. */
6034 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
6037 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
6042 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
6044 vty_out (vty
, "%*s", len
, " ");
6047 enum bgp_display_type
6052 /* Print the short form route status for a bgp_info */
6054 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
6055 json_object
*json_path
)
6060 /* Route status display. */
6061 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6062 json_object_boolean_true_add(json_path
, "removed");
6064 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6065 json_object_boolean_true_add(json_path
, "stale");
6067 if (binfo
->extra
&& binfo
->extra
->suppress
)
6068 json_object_boolean_true_add(json_path
, "suppressed");
6070 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6071 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6072 json_object_boolean_true_add(json_path
, "valid");
6075 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6076 json_object_boolean_true_add(json_path
, "history");
6078 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6079 json_object_boolean_true_add(json_path
, "damped");
6081 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6082 json_object_boolean_true_add(json_path
, "bestpath");
6084 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6085 json_object_boolean_true_add(json_path
, "multipath");
6087 /* Internal route. */
6088 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6089 json_object_string_add(json_path
, "pathFrom", "internal");
6091 json_object_string_add(json_path
, "pathFrom", "external");
6096 /* Route status display. */
6097 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6099 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6101 else if (binfo
->extra
&& binfo
->extra
->suppress
)
6103 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6104 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6110 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6112 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6114 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6116 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6121 /* Internal route. */
6122 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6128 /* called from terminal list command */
6130 route_vty_out (struct vty
*vty
, struct prefix
*p
,
6131 struct bgp_info
*binfo
, int display
, safi_t safi
,
6132 json_object
*json_paths
)
6135 json_object
*json_path
= NULL
;
6136 json_object
*json_nexthops
= NULL
;
6137 json_object
*json_nexthop_global
= NULL
;
6138 json_object
*json_nexthop_ll
= NULL
;
6141 json_path
= json_object_new_object();
6143 /* short status lead text */
6144 route_vty_short_status_out (vty
, binfo
, json_path
);
6148 /* print prefix and mask */
6150 route_vty_out_route (p
, vty
);
6152 vty_out (vty
, "%*s", 17, " ");
6155 /* Print attribute */
6160 * For ENCAP routes, nexthop address family is not
6161 * neccessarily the same as the prefix address family.
6162 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
6164 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
6169 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
6174 vty_out (vty
, "%s", inet_ntop(af
,
6175 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
6179 vty_out (vty
, "%s", inet_ntop(af
,
6180 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
6192 else if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6196 json_nexthop_global
= json_object_new_object();
6198 if (safi
== SAFI_MPLS_VPN
)
6199 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6201 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6203 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6204 json_object_boolean_true_add(json_nexthop_global
, "used");
6208 if (safi
== SAFI_MPLS_VPN
)
6209 vty_out (vty
, "%-16s",
6210 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6212 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6217 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6224 json_nexthop_global
= json_object_new_object();
6225 json_object_string_add(json_nexthop_global
, "ip",
6226 inet_ntop (AF_INET6
,
6227 &attr
->extra
->mp_nexthop_global
,
6229 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6230 json_object_string_add(json_nexthop_global
, "scope", "global");
6232 /* We display both LL & GL if both have been received */
6233 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
6235 json_nexthop_ll
= json_object_new_object();
6236 json_object_string_add(json_nexthop_ll
, "ip",
6237 inet_ntop (AF_INET6
,
6238 &attr
->extra
->mp_nexthop_local
,
6240 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6241 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6243 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
6244 &attr
->extra
->mp_nexthop_local
) != 0) &&
6245 !attr
->extra
->mp_nexthop_prefer_global
)
6246 json_object_boolean_true_add(json_nexthop_ll
, "used");
6248 json_object_boolean_true_add(json_nexthop_global
, "used");
6251 json_object_boolean_true_add(json_nexthop_global
, "used");
6255 /* Display LL if LL/Global both in table unless prefer-global is set */
6256 if (((attr
->extra
->mp_nexthop_len
== 32) &&
6257 !attr
->extra
->mp_nexthop_prefer_global
) ||
6258 (binfo
->peer
->conf_if
))
6260 if (binfo
->peer
->conf_if
)
6262 len
= vty_out (vty
, "%s",
6263 binfo
->peer
->conf_if
);
6264 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6267 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6269 vty_out (vty
, "%*s", len
, " ");
6273 len
= vty_out (vty
, "%s",
6274 inet_ntop (AF_INET6
,
6275 &attr
->extra
->mp_nexthop_local
,
6280 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6282 vty_out (vty
, "%*s", len
, " ");
6287 len
= vty_out (vty
, "%s",
6288 inet_ntop (AF_INET6
,
6289 &attr
->extra
->mp_nexthop_global
,
6294 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6296 vty_out (vty
, "%*s", len
, " ");
6302 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6304 json_object_int_add(json_path
, "med", attr
->med
);
6306 vty_out (vty
, "%10u ", attr
->med
);
6312 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6314 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6316 vty_out (vty
, "%7u ", attr
->local_pref
);
6324 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6326 json_object_int_add(json_path
, "weight", 0);
6329 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6333 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6340 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6342 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6347 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6349 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6354 json_object_string_add(json_path
, "alert", "No attributes");
6356 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6361 if (json_nexthop_global
|| json_nexthop_ll
)
6363 json_nexthops
= json_object_new_array();
6365 if (json_nexthop_global
)
6366 json_object_array_add(json_nexthops
, json_nexthop_global
);
6368 if (json_nexthop_ll
)
6369 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6371 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6374 json_object_array_add(json_paths
, json_path
);
6378 vty_out (vty
, "%s", VTY_NEWLINE
);
6380 /* prints an additional line, indented, with VNC info, if present */
6381 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
) || (safi
== SAFI_UNICAST
))
6382 rfapi_vty_out_vncinfo(vty
, p
, binfo
, safi
);
6387 /* called from terminal list command */
6389 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6390 u_char use_json
, json_object
*json_ar
)
6392 json_object
*json_status
= NULL
;
6393 json_object
*json_net
= NULL
;
6395 /* Route status display. */
6398 json_status
= json_object_new_object();
6399 json_net
= json_object_new_object();
6408 /* print prefix and mask */
6410 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6412 route_vty_out_route (p
, vty
);
6414 /* Print attribute */
6419 if (p
->family
== AF_INET
&&
6420 (safi
== SAFI_MPLS_VPN
||
6421 safi
== SAFI_ENCAP
||
6422 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6424 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6425 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6427 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6430 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6434 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6437 #endif /* HAVE_IPV6 */
6439 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6440 json_object_int_add(json_net
, "metric", attr
->med
);
6442 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6443 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6446 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6448 json_object_int_add(json_net
, "weight", 0);
6452 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6455 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6459 if (p
->family
== AF_INET
&&
6460 (safi
== SAFI_MPLS_VPN
||
6461 safi
== SAFI_ENCAP
||
6462 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6464 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6465 vty_out (vty
, "%-16s",
6466 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6468 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6471 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6476 assert (attr
->extra
);
6478 len
= vty_out (vty
, "%s",
6479 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6483 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6485 vty_out (vty
, "%*s", len
, " ");
6487 #endif /* HAVE_IPV6 */
6488 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6489 vty_out (vty
, "%10u ", attr
->med
);
6493 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6494 vty_out (vty
, "%7u ", attr
->local_pref
);
6498 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6502 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6505 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6510 json_object_boolean_true_add(json_status
, "*");
6511 json_object_boolean_true_add(json_status
, ">");
6512 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6513 char buf_cut
[BUFSIZ
];
6514 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6517 vty_out (vty
, "%s", VTY_NEWLINE
);
6521 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6522 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6524 json_object
*json_out
= NULL
;
6526 u_int32_t label
= 0;
6532 json_out
= json_object_new_object();
6534 /* short status lead text */
6535 route_vty_short_status_out (vty
, binfo
, json_out
);
6537 /* print prefix and mask */
6541 route_vty_out_route (p
, vty
);
6543 vty_out (vty
, "%*s", 17, " ");
6546 /* Print attribute */
6550 if (p
->family
== AF_INET
6551 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6553 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6556 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6558 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6563 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6565 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6569 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6571 assert (attr
->extra
);
6575 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6578 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6579 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6582 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6585 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6589 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6591 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6593 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6594 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6597 vty_out (vty
, "%s(%s)",
6598 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6600 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6605 #endif /* HAVE_IPV6 */
6608 label
= decode_label (binfo
->extra
->tag
);
6613 json_object_int_add(json_out
, "notag", label
);
6614 json_object_array_add(json
, json_out
);
6618 vty_out (vty
, "notag/%d", label
);
6619 vty_out (vty
, "%s", VTY_NEWLINE
);
6623 /* dampening route */
6625 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6626 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6630 char timebuf
[BGP_UPTIME_LEN
];
6632 /* short status lead text */
6633 route_vty_short_status_out (vty
, binfo
, json
);
6635 /* print prefix and mask */
6639 route_vty_out_route (p
, vty
);
6641 vty_out (vty
, "%*s", 17, " ");
6644 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6649 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6654 json_object_int_add(json
, "peerHost", len
);
6656 vty_out (vty
, "%*s", len
, " ");
6660 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6662 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6664 /* Print attribute */
6672 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6674 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6679 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6681 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6684 vty_out (vty
, "%s", VTY_NEWLINE
);
6689 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6690 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6693 struct bgp_damp_info
*bdi
;
6694 char timebuf
[BGP_UPTIME_LEN
];
6700 bdi
= binfo
->extra
->damp_info
;
6702 /* short status lead text */
6703 route_vty_short_status_out (vty
, binfo
, json
);
6705 /* print prefix and mask */
6709 route_vty_out_route (p
, vty
);
6711 vty_out (vty
, "%*s", 17, " ");
6714 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6719 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6724 json_object_int_add(json
, "peerHost", len
);
6726 vty_out (vty
, "%*s", len
, " ");
6729 len
= vty_out (vty
, "%d", bdi
->flap
);
6739 json_object_int_add(json
, "bdiFlap", len
);
6741 vty_out (vty
, "%*s", len
, " ");
6745 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6747 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6748 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6750 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6751 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6754 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6756 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6761 vty_out (vty
, "%*s ", 8, " ");
6764 /* Print attribute */
6772 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6774 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6779 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6781 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6784 vty_out (vty
, "%s", VTY_NEWLINE
);
6788 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6789 const char *header
, json_object
*json_adv_to
)
6791 char buf1
[INET6_ADDRSTRLEN
];
6792 json_object
*json_peer
= NULL
;
6796 /* 'advertised-to' is a dictionary of peers we have advertised this
6797 * prefix too. The key is the peer's IP or swpX, the value is the
6798 * hostname if we know it and "" if not.
6800 json_peer
= json_object_new_object();
6803 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6806 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6808 json_object_object_add(json_adv_to
,
6809 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6816 vty_out (vty
, "%s", header
);
6820 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6823 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6825 vty_out (vty
, " %s(%s)", peer
->hostname
,
6826 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6831 vty_out (vty
, " %s", peer
->conf_if
);
6833 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6839 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6840 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6841 json_object
*json_paths
)
6843 char buf
[INET6_ADDRSTRLEN
];
6846 int sockunion_vty_out (struct vty
*, union sockunion
*);
6847 #ifdef HAVE_CLOCK_MONOTONIC
6850 json_object
*json_bestpath
= NULL
;
6851 json_object
*json_cluster_list
= NULL
;
6852 json_object
*json_cluster_list_list
= NULL
;
6853 json_object
*json_ext_community
= NULL
;
6854 json_object
*json_last_update
= NULL
;
6855 json_object
*json_nexthop_global
= NULL
;
6856 json_object
*json_nexthop_ll
= NULL
;
6857 json_object
*json_nexthops
= NULL
;
6858 json_object
*json_path
= NULL
;
6859 json_object
*json_peer
= NULL
;
6860 json_object
*json_string
= NULL
;
6861 json_object
*json_adv_to
= NULL
;
6863 struct listnode
*node
, *nnode
;
6865 int addpath_capable
;
6871 json_path
= json_object_new_object();
6872 json_peer
= json_object_new_object();
6873 json_nexthop_global
= json_object_new_object();
6880 /* Line1 display AS-path, Aggregator */
6885 json_object_lock(attr
->aspath
->json
);
6886 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6890 if (attr
->aspath
->segments
)
6891 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6893 vty_out (vty
, " Local");
6897 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6900 json_object_boolean_true_add(json_path
, "removed");
6902 vty_out (vty
, ", (removed)");
6905 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6908 json_object_boolean_true_add(json_path
, "stale");
6910 vty_out (vty
, ", (stale)");
6913 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6917 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6918 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6922 vty_out (vty
, ", (aggregated by %u %s)",
6923 attr
->extra
->aggregator_as
,
6924 inet_ntoa (attr
->extra
->aggregator_addr
));
6928 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6931 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6933 vty_out (vty
, ", (Received from a RR-client)");
6936 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6939 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6941 vty_out (vty
, ", (Received from a RS-client)");
6944 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6947 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6949 vty_out (vty
, ", (history entry)");
6951 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6954 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6956 vty_out (vty
, ", (suppressed due to dampening)");
6960 vty_out (vty
, "%s", VTY_NEWLINE
);
6962 /* Line2 display Next-hop, Neighbor, Router-id */
6963 /* Display the nexthop */
6964 if (p
->family
== AF_INET
&&
6965 (safi
== SAFI_MPLS_VPN
||
6966 safi
== SAFI_ENCAP
||
6967 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6969 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6972 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6974 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6979 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6981 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6985 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6989 assert (attr
->extra
);
6992 json_object_string_add(json_nexthop_global
, "ip",
6993 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6994 buf
, INET6_ADDRSTRLEN
));
6995 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6996 json_object_string_add(json_nexthop_global
, "scope", "global");
7000 vty_out (vty
, " %s",
7001 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
7002 buf
, INET6_ADDRSTRLEN
));
7006 /* Display the IGP cost or 'inaccessible' */
7007 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7010 json_object_boolean_false_add(json_nexthop_global
, "accessible");
7012 vty_out (vty
, " (inaccessible)");
7016 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
7019 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
7021 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
7024 /* IGP cost is 0, display this only for json */
7028 json_object_int_add(json_nexthop_global
, "metric", 0);
7032 json_object_boolean_true_add(json_nexthop_global
, "accessible");
7035 /* Display peer "from" output */
7036 /* This path was originated locally */
7037 if (binfo
->peer
== bgp
->peer_self
)
7040 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
7043 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
7045 vty_out (vty
, " from 0.0.0.0 ");
7050 json_object_string_add(json_peer
, "peerId", "::");
7052 vty_out (vty
, " from :: ");
7056 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
7058 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
7061 /* We RXed this path from one of our peers */
7067 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7068 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7070 if (binfo
->peer
->hostname
)
7071 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
7073 if (binfo
->peer
->domainname
)
7074 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
7076 if (binfo
->peer
->conf_if
)
7077 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
7081 if (binfo
->peer
->conf_if
)
7083 if (binfo
->peer
->hostname
&&
7084 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7085 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7086 binfo
->peer
->conf_if
);
7088 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
7092 if (binfo
->peer
->hostname
&&
7093 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7094 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7097 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7100 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7101 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
7103 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7108 vty_out (vty
, "%s", VTY_NEWLINE
);
7110 /* display the link-local nexthop */
7111 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
7115 json_nexthop_ll
= json_object_new_object();
7116 json_object_string_add(json_nexthop_ll
, "ip",
7117 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7118 buf
, INET6_ADDRSTRLEN
));
7119 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
7120 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
7122 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
7124 if (!attr
->extra
->mp_nexthop_prefer_global
)
7125 json_object_boolean_true_add(json_nexthop_ll
, "used");
7127 json_object_boolean_true_add(json_nexthop_global
, "used");
7131 vty_out (vty
, " (%s) %s%s",
7132 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7133 buf
, INET6_ADDRSTRLEN
),
7134 attr
->extra
->mp_nexthop_prefer_global
?
7135 "(prefer-global)" : "(used)",
7139 /* If we do not have a link-local nexthop then we must flag the global as "used" */
7143 json_object_boolean_true_add(json_nexthop_global
, "used");
7146 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
7148 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
7150 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
7152 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
7155 json_object_int_add(json_path
, "med", attr
->med
);
7157 vty_out (vty
, ", metric %u", attr
->med
);
7160 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
7163 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
7165 vty_out (vty
, ", localpref %u", attr
->local_pref
);
7170 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
7172 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
7175 if (attr
->extra
&& attr
->extra
->weight
!= 0)
7178 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
7180 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
7183 if (attr
->extra
&& attr
->extra
->tag
!= 0)
7186 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
7188 vty_out (vty
, ", tag %d", attr
->extra
->tag
);
7191 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7194 json_object_boolean_false_add(json_path
, "valid");
7196 vty_out (vty
, ", invalid");
7198 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
7201 json_object_boolean_true_add(json_path
, "valid");
7203 vty_out (vty
, ", valid");
7206 if (binfo
->peer
!= bgp
->peer_self
)
7208 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
7210 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7213 json_object_string_add(json_peer
, "type", "confed-internal");
7215 vty_out (vty
, ", confed-internal");
7220 json_object_string_add(json_peer
, "type", "internal");
7222 vty_out (vty
, ", internal");
7227 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
7230 json_object_string_add(json_peer
, "type", "confed-external");
7232 vty_out (vty
, ", confed-external");
7237 json_object_string_add(json_peer
, "type", "external");
7239 vty_out (vty
, ", external");
7243 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
7247 json_object_boolean_true_add(json_path
, "aggregated");
7248 json_object_boolean_true_add(json_path
, "local");
7252 vty_out (vty
, ", aggregated, local");
7255 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
7258 json_object_boolean_true_add(json_path
, "sourced");
7260 vty_out (vty
, ", sourced");
7266 json_object_boolean_true_add(json_path
, "sourced");
7267 json_object_boolean_true_add(json_path
, "local");
7271 vty_out (vty
, ", sourced, local");
7275 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7278 json_object_boolean_true_add(json_path
, "atomicAggregate");
7280 vty_out (vty
, ", atomic-aggregate");
7283 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7284 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7285 bgp_info_mpath_count (binfo
)))
7288 json_object_boolean_true_add(json_path
, "multipath");
7290 vty_out (vty
, ", multipath");
7293 // Mark the bestpath(s)
7294 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7296 first_as
= aspath_get_firstas(attr
->aspath
);
7301 json_bestpath
= json_object_new_object();
7302 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7307 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7309 vty_out (vty
, ", bestpath-from-AS Local");
7313 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7318 json_bestpath
= json_object_new_object();
7319 json_object_boolean_true_add(json_bestpath
, "overall");
7322 vty_out (vty
, ", best");
7326 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7329 vty_out (vty
, "%s", VTY_NEWLINE
);
7331 /* Line 4 display Community */
7332 if (attr
->community
)
7336 json_object_lock(attr
->community
->json
);
7337 json_object_object_add(json_path
, "community", attr
->community
->json
);
7341 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7346 /* Line 5 display Extended-community */
7347 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7351 json_ext_community
= json_object_new_object();
7352 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7353 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7357 vty_out (vty
, " Extended Community: %s%s",
7358 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7362 /* Line 6 display Originator, Cluster-id */
7363 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7364 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7366 assert (attr
->extra
);
7367 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7370 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7372 vty_out (vty
, " Originator: %s",
7373 inet_ntoa (attr
->extra
->originator_id
));
7376 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7382 json_cluster_list
= json_object_new_object();
7383 json_cluster_list_list
= json_object_new_array();
7385 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7387 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7388 json_object_array_add(json_cluster_list_list
, json_string
);
7391 /* struct cluster_list does not have "str" variable like
7392 * aspath and community do. Add this someday if someone
7394 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7396 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7397 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7401 vty_out (vty
, ", Cluster list: ");
7403 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7405 vty_out (vty
, "%s ",
7406 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7412 vty_out (vty
, "%s", VTY_NEWLINE
);
7415 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7416 bgp_damp_info_vty (vty
, binfo
, json_path
);
7418 /* Line 7 display Addpath IDs */
7419 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7423 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7424 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7428 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7429 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7434 /* If we used addpath to TX a non-bestpath we need to display
7435 * "Advertised to" on a path-by-path basis */
7436 if (bgp
->addpath_tx_used
[afi
][safi
])
7440 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7442 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7443 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7445 if ((addpath_capable
&& has_adj
) ||
7446 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7448 if (json_path
&& !json_adv_to
)
7449 json_adv_to
= json_object_new_object();
7451 route_vty_out_advertised_to(vty
, peer
, &first
,
7461 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7468 vty_out (vty
, "%s", VTY_NEWLINE
);
7473 /* Line 8 display Uptime */
7474 #ifdef HAVE_CLOCK_MONOTONIC
7475 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7478 json_last_update
= json_object_new_object();
7479 json_object_int_add(json_last_update
, "epoch", tbuf
);
7480 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7481 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7484 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7488 json_last_update
= json_object_new_object();
7489 json_object_int_add(json_last_update
, "epoch", tbuf
);
7490 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7491 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7494 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7495 #endif /* HAVE_CLOCK_MONOTONIC */
7498 /* We've constructed the json object for this path, add it to the json
7503 if (json_nexthop_global
|| json_nexthop_ll
)
7505 json_nexthops
= json_object_new_array();
7507 if (json_nexthop_global
)
7508 json_object_array_add(json_nexthops
, json_nexthop_global
);
7510 if (json_nexthop_ll
)
7511 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7513 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7516 json_object_object_add(json_path
, "peer", json_peer
);
7517 json_object_array_add(json_paths
, json_path
);
7520 vty_out (vty
, "%s", VTY_NEWLINE
);
7523 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7524 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7525 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7529 bgp_show_type_normal
,
7530 bgp_show_type_regexp
,
7531 bgp_show_type_prefix_list
,
7532 bgp_show_type_filter_list
,
7533 bgp_show_type_route_map
,
7534 bgp_show_type_neighbor
,
7535 bgp_show_type_cidr_only
,
7536 bgp_show_type_prefix_longer
,
7537 bgp_show_type_community_all
,
7538 bgp_show_type_community
,
7539 bgp_show_type_community_exact
,
7540 bgp_show_type_community_list
,
7541 bgp_show_type_community_list_exact
,
7542 bgp_show_type_flap_statistics
,
7543 bgp_show_type_flap_address
,
7544 bgp_show_type_flap_prefix
,
7545 bgp_show_type_flap_cidr_only
,
7546 bgp_show_type_flap_regexp
,
7547 bgp_show_type_flap_filter_list
,
7548 bgp_show_type_flap_prefix_list
,
7549 bgp_show_type_flap_prefix_longer
,
7550 bgp_show_type_flap_route_map
,
7551 bgp_show_type_flap_neighbor
,
7552 bgp_show_type_dampend_paths
,
7553 bgp_show_type_damp_neighbor
7557 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7558 const char *prefix_list_str
, afi_t afi
,
7559 safi_t safi
, enum bgp_show_type type
);
7561 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7562 const char *filter
, afi_t afi
,
7563 safi_t safi
, enum bgp_show_type type
);
7565 bgp_show_route_map (struct vty
*vty
, const char *name
,
7566 const char *rmap_str
, afi_t afi
,
7567 safi_t safi
, enum bgp_show_type type
);
7569 bgp_show_community_list (struct vty
*vty
, const char *name
,
7570 const char *com
, int exact
,
7571 afi_t afi
, safi_t safi
);
7573 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7574 const char *prefix
, afi_t afi
,
7575 safi_t safi
, enum bgp_show_type type
);
7578 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
,
7579 struct in_addr
*router_id
, enum bgp_show_type type
,
7580 void *output_arg
, u_char use_json
, json_object
*json
)
7582 struct bgp_info
*ri
;
7583 struct bgp_node
*rn
;
7586 unsigned long output_count
;
7587 unsigned long total_count
;
7591 json_object
*json_paths
= NULL
;
7592 json_object
*json_routes
= NULL
;
7597 json
= json_object_new_object();
7599 json_object_int_add(json
, "tableVersion", table
->version
);
7600 json_object_string_add(json
, "routerId", inet_ntoa (*router_id
));
7601 json_routes
= json_object_new_object();
7604 /* This is first entry point, so reset total line. */
7608 /* Start processing of routes. */
7609 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7610 if (rn
->info
!= NULL
)
7615 json_paths
= json_object_new_array();
7619 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7622 if (type
== bgp_show_type_flap_statistics
7623 || type
== bgp_show_type_flap_address
7624 || type
== bgp_show_type_flap_prefix
7625 || type
== bgp_show_type_flap_cidr_only
7626 || type
== bgp_show_type_flap_regexp
7627 || type
== bgp_show_type_flap_filter_list
7628 || type
== bgp_show_type_flap_prefix_list
7629 || type
== bgp_show_type_flap_prefix_longer
7630 || type
== bgp_show_type_flap_route_map
7631 || type
== bgp_show_type_flap_neighbor
7632 || type
== bgp_show_type_dampend_paths
7633 || type
== bgp_show_type_damp_neighbor
)
7635 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7638 if (type
== bgp_show_type_regexp
7639 || type
== bgp_show_type_flap_regexp
)
7641 regex_t
*regex
= output_arg
;
7643 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7646 if (type
== bgp_show_type_prefix_list
7647 || type
== bgp_show_type_flap_prefix_list
)
7649 struct prefix_list
*plist
= output_arg
;
7651 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7654 if (type
== bgp_show_type_filter_list
7655 || type
== bgp_show_type_flap_filter_list
)
7657 struct as_list
*as_list
= output_arg
;
7659 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7662 if (type
== bgp_show_type_route_map
7663 || type
== bgp_show_type_flap_route_map
)
7665 struct route_map
*rmap
= output_arg
;
7666 struct bgp_info binfo
;
7667 struct attr dummy_attr
;
7668 struct attr_extra dummy_extra
;
7671 dummy_attr
.extra
= &dummy_extra
;
7672 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7674 binfo
.peer
= ri
->peer
;
7675 binfo
.attr
= &dummy_attr
;
7677 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7678 if (ret
== RMAP_DENYMATCH
)
7681 if (type
== bgp_show_type_neighbor
7682 || type
== bgp_show_type_flap_neighbor
7683 || type
== bgp_show_type_damp_neighbor
)
7685 union sockunion
*su
= output_arg
;
7687 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7690 if (type
== bgp_show_type_cidr_only
7691 || type
== bgp_show_type_flap_cidr_only
)
7693 u_int32_t destination
;
7695 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7696 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7698 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7700 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7703 if (type
== bgp_show_type_prefix_longer
7704 || type
== bgp_show_type_flap_prefix_longer
)
7706 struct prefix
*p
= output_arg
;
7708 if (! prefix_match (p
, &rn
->p
))
7711 if (type
== bgp_show_type_community_all
)
7713 if (! ri
->attr
->community
)
7716 if (type
== bgp_show_type_community
)
7718 struct community
*com
= output_arg
;
7720 if (! ri
->attr
->community
||
7721 ! community_match (ri
->attr
->community
, com
))
7724 if (type
== bgp_show_type_community_exact
)
7726 struct community
*com
= output_arg
;
7728 if (! ri
->attr
->community
||
7729 ! community_cmp (ri
->attr
->community
, com
))
7732 if (type
== bgp_show_type_community_list
)
7734 struct community_list
*list
= output_arg
;
7736 if (! community_list_match (ri
->attr
->community
, list
))
7739 if (type
== bgp_show_type_community_list_exact
)
7741 struct community_list
*list
= output_arg
;
7743 if (! community_list_exact_match (ri
->attr
->community
, list
))
7746 if (type
== bgp_show_type_flap_address
7747 || type
== bgp_show_type_flap_prefix
)
7749 struct prefix
*p
= output_arg
;
7751 if (! prefix_match (&rn
->p
, p
))
7754 if (type
== bgp_show_type_flap_prefix
)
7755 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7758 if (type
== bgp_show_type_dampend_paths
7759 || type
== bgp_show_type_damp_neighbor
)
7761 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7762 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7766 if (!use_json
&& header
)
7768 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (*router_id
), VTY_NEWLINE
);
7769 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7770 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7771 if (type
== bgp_show_type_dampend_paths
7772 || type
== bgp_show_type_damp_neighbor
)
7773 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7774 else if (type
== bgp_show_type_flap_statistics
7775 || type
== bgp_show_type_flap_address
7776 || type
== bgp_show_type_flap_prefix
7777 || type
== bgp_show_type_flap_cidr_only
7778 || type
== bgp_show_type_flap_regexp
7779 || type
== bgp_show_type_flap_filter_list
7780 || type
== bgp_show_type_flap_prefix_list
7781 || type
== bgp_show_type_flap_prefix_longer
7782 || type
== bgp_show_type_flap_route_map
7783 || type
== bgp_show_type_flap_neighbor
)
7784 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7786 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7790 if (type
== bgp_show_type_dampend_paths
7791 || type
== bgp_show_type_damp_neighbor
)
7792 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7793 else if (type
== bgp_show_type_flap_statistics
7794 || type
== bgp_show_type_flap_address
7795 || type
== bgp_show_type_flap_prefix
7796 || type
== bgp_show_type_flap_cidr_only
7797 || type
== bgp_show_type_flap_regexp
7798 || type
== bgp_show_type_flap_filter_list
7799 || type
== bgp_show_type_flap_prefix_list
7800 || type
== bgp_show_type_flap_prefix_longer
7801 || type
== bgp_show_type_flap_route_map
7802 || type
== bgp_show_type_flap_neighbor
)
7803 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7805 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7815 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7816 json_object_object_add(json_routes
, buf2
, json_paths
);
7823 /* This can produce a LOT of text so do not use
7824 * JSON_C_TO_STRING_PRETTY here
7826 json_object_object_add(json
, "routes", json_routes
);
7827 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7828 json_object_free(json
);
7832 /* No route is displayed */
7833 if (output_count
== 0)
7835 if (type
== bgp_show_type_normal
)
7836 vty_out (vty
, "No BGP prefixes displayed, %ld exist%s", total_count
, VTY_NEWLINE
);
7839 vty_out (vty
, "%sDisplayed %ld out of %ld total prefixes%s",
7840 VTY_NEWLINE
, output_count
, total_count
, VTY_NEWLINE
);
7847 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7848 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7850 struct bgp_table
*table
;
7854 bgp
= bgp_get_default ();
7860 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7864 table
= bgp
->rib
[afi
][safi
];
7866 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
,
7871 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7874 struct listnode
*node
, *nnode
;
7876 struct bgp_table
*table
;
7877 json_object
*json
= NULL
;
7881 vty_out (vty
, "{%s", VTY_NEWLINE
);
7883 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7887 if (!(json
= json_object_new_object()))
7889 zlog_err("Unable to allocate memory for JSON object");
7891 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
7895 json_object_int_add(json
, "vrfId",
7896 (bgp
->vrf_id
== VRF_UNKNOWN
)
7897 ? -1 : bgp
->vrf_id
);
7898 json_object_string_add(json
, "vrfName",
7899 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7900 ? "Default" : bgp
->name
);
7902 vty_out (vty
, ",%s", VTY_NEWLINE
);
7906 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7907 ? "Default" : bgp
->name
);
7911 vty_out (vty
, "%sInstance %s:%s",
7913 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7914 ? "Default" : bgp
->name
,
7917 table
= bgp
->rib
[afi
][safi
];
7918 bgp_show_table (vty
, table
, &bgp
->router_id
,
7919 bgp_show_type_normal
, NULL
, use_json
, json
);
7924 vty_out (vty
, "}%s", VTY_NEWLINE
);
7927 /* Header of detailed BGP route information */
7929 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7930 struct bgp_node
*rn
,
7931 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7934 struct bgp_info
*ri
;
7937 struct listnode
*node
, *nnode
;
7938 char buf1
[INET6_ADDRSTRLEN
];
7939 char buf2
[INET6_ADDRSTRLEN
];
7944 int no_advertise
= 0;
7947 json_object
*json_adv_to
= NULL
;
7953 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7954 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7958 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7959 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7960 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7961 safi
== SAFI_MPLS_VPN
? ":" : "",
7962 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7963 p
->prefixlen
, VTY_NEWLINE
);
7966 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7969 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7972 if (ri
->extra
&& ri
->extra
->suppress
)
7974 if (ri
->attr
->community
!= NULL
)
7976 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7978 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7980 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7988 vty_out (vty
, "Paths: (%d available", count
);
7991 vty_out (vty
, ", best #%d", best
);
7992 if (safi
== SAFI_UNICAST
)
7993 vty_out (vty
, ", table %s",
7994 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7995 ? "Default-IP-Routing-Table" : bgp
->name
);
7998 vty_out (vty
, ", no best path");
8001 vty_out (vty
, ", not advertised to any peer");
8003 vty_out (vty
, ", not advertised to EBGP peer");
8005 vty_out (vty
, ", not advertised outside local AS");
8008 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
8009 vty_out (vty
, ")%s", VTY_NEWLINE
);
8012 /* If we are not using addpath then we can display Advertised to and that will
8013 * show what peers we advertised the bestpath to. If we are using addpath
8014 * though then we must display Advertised to on a path-by-path basis. */
8015 if (!bgp
->addpath_tx_used
[afi
][safi
])
8017 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
8019 if (bgp_adj_out_lookup (peer
, rn
, 0))
8021 if (json
&& !json_adv_to
)
8022 json_adv_to
= json_object_new_object();
8024 route_vty_out_advertised_to(vty
, peer
, &first
,
8025 " Advertised to non peer-group peers:\n ",
8034 json_object_object_add(json
, "advertisedTo", json_adv_to
);
8040 vty_out (vty
, " Not advertised to any peer");
8041 vty_out (vty
, "%s", VTY_NEWLINE
);
8046 /* Display specified route of BGP table. */
8048 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
8049 struct bgp_table
*rib
, const char *ip_str
,
8050 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8051 int prefix_check
, enum bgp_path_type pathtype
,
8057 struct prefix match
;
8058 struct bgp_node
*rn
;
8059 struct bgp_node
*rm
;
8060 struct bgp_info
*ri
;
8061 struct bgp_table
*table
;
8062 json_object
*json
= NULL
;
8063 json_object
*json_paths
= NULL
;
8065 /* Check IP address argument. */
8066 ret
= str2prefix (ip_str
, &match
);
8069 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
8073 match
.family
= afi2family (afi
);
8077 json
= json_object_new_object();
8078 json_paths
= json_object_new_array();
8081 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
8083 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
8085 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
8088 if ((table
= rn
->info
) != NULL
)
8092 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
8094 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
8096 bgp_unlock_node (rm
);
8100 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
8104 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
8105 AFI_IP
, safi
, json
);
8110 if (pathtype
== BGP_PATH_ALL
||
8111 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8112 (pathtype
== BGP_PATH_MULTIPATH
&&
8113 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8114 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
8117 bgp_unlock_node (rm
);
8126 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
8128 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
8130 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8134 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
8139 if (pathtype
== BGP_PATH_ALL
||
8140 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8141 (pathtype
== BGP_PATH_MULTIPATH
&&
8142 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8143 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
8147 bgp_unlock_node (rn
);
8154 json_object_object_add(json
, "paths", json_paths
);
8156 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
8157 json_object_free(json
);
8163 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
8171 /* Display specified route of Main RIB */
8173 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
8174 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8175 int prefix_check
, enum bgp_path_type pathtype
,
8180 /* BGP structure lookup. */
8183 bgp
= bgp_lookup_by_name (view_name
);
8186 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
8192 bgp
= bgp_get_default ();
8195 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8200 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
8201 afi
, safi
, prd
, prefix_check
, pathtype
,
8205 /* BGP route print out function. */
8208 "show ip bgp {json}",
8212 "JavaScript Object Notation\n")
8214 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8217 DEFUN (show_ip_bgp_ipv4
,
8218 show_ip_bgp_ipv4_cmd
,
8219 "show ip bgp ipv4 (unicast|multicast) {json}",
8224 "Address Family modifier\n"
8225 "Address Family modifier\n"
8226 "JavaScript Object Notation\n")
8228 u_char uj
= use_json(argc
, argv
);
8230 if (strncmp (argv
[0], "m", 1) == 0)
8231 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
8234 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8237 ALIAS (show_ip_bgp_ipv4
,
8238 show_bgp_ipv4_safi_cmd
,
8239 "show bgp ipv4 (unicast|multicast) {json}",
8243 "Address Family modifier\n"
8244 "Address Family modifier\n"
8245 "JavaScript Object Notation\n")
8247 DEFUN (show_ip_bgp_route
,
8248 show_ip_bgp_route_cmd
,
8249 "show ip bgp A.B.C.D {json}",
8253 "Network in the BGP routing table to display\n"
8254 "JavaScript Object Notation\n")
8256 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8259 DEFUN (show_ip_bgp_route_pathtype
,
8260 show_ip_bgp_route_pathtype_cmd
,
8261 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
8265 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8266 "Display only the bestpath\n"
8267 "Display only multipaths\n"
8268 "JavaScript Object Notation\n")
8270 u_char uj
= use_json(argc
, argv
);
8272 if (strncmp (argv
[1], "b", 1) == 0)
8273 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8275 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8278 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
8279 show_bgp_ipv4_safi_route_pathtype_cmd
,
8280 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
8284 "Address Family modifier\n"
8285 "Address Family modifier\n"
8286 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8287 "Display only the bestpath\n"
8288 "Display only multipaths\n"
8289 "JavaScript Object Notation\n")
8291 u_char uj
= use_json(argc
, argv
);
8293 if (strncmp (argv
[0], "m", 1) == 0)
8294 if (strncmp (argv
[2], "b", 1) == 0)
8295 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8297 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8299 if (strncmp (argv
[2], "b", 1) == 0)
8300 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8302 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8305 DEFUN (show_bgp_ipv4_prefix
,
8306 show_bgp_ipv4_prefix_cmd
,
8307 "show bgp ipv4 A.B.C.D/M {json}",
8311 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8314 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8317 DEFUN (show_bgp_ipv6_route
,
8318 show_bgp_ipv6_route_cmd
,
8319 "show bgp ipv6 X:X::X:X {json}",
8323 "Network in the BGP routing table to display\n"
8326 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8329 DEFUN (show_bgp_ipv6_prefix
,
8330 show_bgp_ipv6_prefix_cmd
,
8331 "show bgp ipv6 X:X::X:X/M {json}",
8335 "IPv6 prefix <network>/<length>\n"
8338 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
,argv
));
8341 DEFUN (show_ip_bgp_ipv4_route
,
8342 show_ip_bgp_ipv4_route_cmd
,
8343 "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
8348 "Address Family modifier\n"
8349 "Address Family modifier\n"
8350 "Network in the BGP routing table to display\n"
8351 "JavaScript Object Notation\n")
8353 u_char uj
= use_json(argc
, argv
);
8355 if (strncmp (argv
[0], "m", 1) == 0)
8356 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8358 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8361 ALIAS (show_ip_bgp_ipv4_route
,
8362 show_bgp_ipv4_safi_route_cmd
,
8363 "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
8367 "Address Family modifier\n"
8368 "Address Family modifier\n"
8369 "Network in the BGP routing table to display\n"
8370 "JavaScript Object Notation\n")
8372 DEFUN (show_ip_bgp_vpnv4_all_route
,
8373 show_ip_bgp_vpnv4_all_route_cmd
,
8374 "show ip bgp vpnv4 all A.B.C.D {json}",
8378 "Display VPNv4 NLRI specific information\n"
8379 "Display information about all VPNv4 NLRIs\n"
8380 "Network in the BGP routing table to display\n"
8381 "JavaScript Object Notation\n")
8383 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8386 DEFUN (show_bgp_ipv4_vpn_route
,
8387 show_bgp_ipv4_vpn_route_cmd
,
8388 "show bgp ipv4 vpn A.B.C.D {json}",
8392 "Display VPN NLRI specific information\n"
8393 "Network in the BGP routing table to display\n"
8396 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8399 DEFUN (show_bgp_ipv6_vpn_route
,
8400 show_bgp_ipv6_vpn_route_cmd
,
8401 "show bgp ipv6 vpn X:X::X:X {json}",
8405 "Display VPN NLRI specific information\n"
8406 "Network in the BGP routing table to display\n"
8409 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8412 DEFUN (show_bgp_ipv4_vpn_rd_route
,
8413 show_bgp_ipv4_vpn_rd_route_cmd
,
8414 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8418 "Display VPN NLRI specific information\n"
8419 "Display information for a route distinguisher\n"
8420 "VPN Route Distinguisher\n"
8421 "Network in the BGP routing table to display\n"
8425 struct prefix_rd prd
;
8427 ret
= str2prefix_rd (argv
[0], &prd
);
8430 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8433 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8436 DEFUN (show_bgp_ipv6_vpn_rd_route
,
8437 show_bgp_ipv6_vpn_rd_route_cmd
,
8438 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
8442 "Display VPN NLRI specific information\n"
8443 "Display information for a route distinguisher\n"
8444 "VPN Route Distinguisher\n"
8445 "Network in the BGP routing table to display\n"
8449 struct prefix_rd prd
;
8451 ret
= str2prefix_rd (argv
[0], &prd
);
8454 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8457 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8460 DEFUN (show_ip_bgp_vpnv4_rd_route
,
8461 show_ip_bgp_vpnv4_rd_route_cmd
,
8462 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8466 "Display VPNv4 NLRI specific information\n"
8467 "Display information for a route distinguisher\n"
8468 "VPN Route Distinguisher\n"
8469 "Network in the BGP routing table to display\n"
8470 "JavaScript Object Notation\n")
8473 struct prefix_rd prd
;
8474 u_char uj
= use_json(argc
, argv
);
8476 ret
= str2prefix_rd (argv
[0], &prd
);
8479 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8482 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, uj
);
8485 DEFUN (show_ip_bgp_prefix
,
8486 show_ip_bgp_prefix_cmd
,
8487 "show ip bgp A.B.C.D/M {json}",
8491 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8492 "JavaScript Object Notation\n")
8494 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8497 DEFUN (show_ip_bgp_prefix_pathtype
,
8498 show_ip_bgp_prefix_pathtype_cmd
,
8499 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8503 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8504 "Display only the bestpath\n"
8505 "Display only multipaths\n"
8506 "JavaScript Object Notation\n")
8508 u_char uj
= use_json(argc
, argv
);
8509 if (strncmp (argv
[1], "b", 1) == 0)
8510 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8512 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8515 DEFUN (show_ip_bgp_ipv4_prefix
,
8516 show_ip_bgp_ipv4_prefix_cmd
,
8517 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8522 "Address Family modifier\n"
8523 "Address Family modifier\n"
8524 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8525 "JavaScript Object Notation\n")
8527 u_char uj
= use_json(argc
, argv
);
8529 if (strncmp (argv
[0], "m", 1) == 0)
8530 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8532 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8535 ALIAS (show_ip_bgp_ipv4_prefix
,
8536 show_bgp_ipv4_safi_prefix_cmd
,
8537 "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8541 "Address Family modifier\n"
8542 "Address Family modifier\n"
8543 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8544 "JavaScript Object Notation\n")
8546 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8547 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8548 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8553 "Address Family modifier\n"
8554 "Address Family modifier\n"
8555 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8556 "Display only the bestpath\n"
8557 "Display only multipaths\n"
8558 "JavaScript Object Notation\n")
8560 u_char uj
= use_json(argc
, argv
);
8562 if (strncmp (argv
[0], "m", 1) == 0)
8563 if (strncmp (argv
[2], "b", 1) == 0)
8564 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8566 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8568 if (strncmp (argv
[2], "b", 1) == 0)
8569 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8571 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8574 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8575 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8576 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8580 "Address Family modifier\n"
8581 "Address Family modifier\n"
8582 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8583 "Display only the bestpath\n"
8584 "Display only multipaths\n"
8585 "JavaScript Object Notation\n")
8587 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
8588 show_ip_bgp_vpnv4_all_prefix_cmd
,
8589 "show ip bgp vpnv4 all A.B.C.D/M {json}",
8593 "Display VPNv4 NLRI specific information\n"
8594 "Display information about all VPNv4 NLRIs\n"
8595 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8596 "JavaScript Object Notation\n")
8598 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8601 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
8602 show_ip_bgp_vpnv4_rd_prefix_cmd
,
8603 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8607 "Display VPNv4 NLRI specific information\n"
8608 "Display information for a route distinguisher\n"
8609 "VPN Route Distinguisher\n"
8610 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8611 "JavaScript Object Notation\n")
8614 struct prefix_rd prd
;
8616 ret
= str2prefix_rd (argv
[0], &prd
);
8619 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8622 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8625 DEFUN (show_ip_bgp_view
,
8626 show_ip_bgp_instance_cmd
,
8627 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8631 BGP_INSTANCE_HELP_STR
8632 "JavaScript Object Notation\n")
8636 /* BGP structure lookup. */
8637 bgp
= bgp_lookup_by_name (argv
[1]);
8640 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8644 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8647 DEFUN (show_ip_bgp_instance_all
,
8648 show_ip_bgp_instance_all_cmd
,
8649 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8653 BGP_INSTANCE_ALL_HELP_STR
8654 "JavaScript Object Notation\n")
8656 u_char uj
= use_json(argc
, argv
);
8658 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8662 DEFUN (show_ip_bgp_instance_route
,
8663 show_ip_bgp_instance_route_cmd
,
8664 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8668 BGP_INSTANCE_HELP_STR
8669 "Network in the BGP routing table to display\n"
8670 "JavaScript Object Notation\n")
8672 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8675 DEFUN (show_ip_bgp_instance_route_pathtype
,
8676 show_ip_bgp_instance_route_pathtype_cmd
,
8677 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8681 BGP_INSTANCE_HELP_STR
8682 "Network in the BGP routing table to display\n"
8683 "Display only the bestpath\n"
8684 "Display only multipaths\n"
8685 "JavaScript Object Notation\n")
8687 u_char uj
= use_json(argc
, argv
);
8689 if (strncmp (argv
[3], "b", 1) == 0)
8690 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8692 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8695 DEFUN (show_ip_bgp_instance_prefix
,
8696 show_ip_bgp_instance_prefix_cmd
,
8697 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8701 BGP_INSTANCE_HELP_STR
8702 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8703 "JavaScript Object Notation\n")
8705 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8708 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8709 show_ip_bgp_instance_prefix_pathtype_cmd
,
8710 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8714 BGP_INSTANCE_HELP_STR
8715 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8716 "Display only the bestpath\n"
8717 "Display only multipaths\n"
8718 "JavaScript Object Notation\n")
8720 u_char uj
= use_json(argc
, argv
);
8721 if (strncmp (argv
[3], "b", 1) == 0)
8722 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8724 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8733 "JavaScript Object Notation\n")
8735 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8736 NULL
, use_json(argc
, argv
));
8741 "show bgp ipv6 {json}",
8745 "JavaScript Object Notation\n")
8747 DEFUN (show_bgp_ipv6_safi
,
8748 show_bgp_ipv6_safi_cmd
,
8749 "show bgp ipv6 (unicast|multicast) {json}",
8753 "Address Family modifier\n"
8754 "Address Family modifier\n"
8755 "JavaScript Object Notation\n")
8757 u_char uj
= use_json(argc
, argv
);
8758 if (strncmp (argv
[0], "m", 1) == 0)
8759 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8762 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8766 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8768 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8769 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8770 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8774 DEFUN (show_ipv6_bgp
,
8776 "show ipv6 bgp {json}",
8780 "JavaScript Object Notation\n")
8782 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8783 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8784 NULL
, use_json(argc
, argv
));
8787 DEFUN (show_bgp_route
,
8789 "show bgp X:X::X:X {json}",
8792 "Network in the BGP routing table to display\n"
8793 "JavaScript Object Notation\n")
8795 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8798 DEFUN (show_bgp_ipv6_safi_route
,
8799 show_bgp_ipv6_safi_route_cmd
,
8800 "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
8804 "Address Family modifier\n"
8805 "Address Family modifier\n"
8806 "Network in the BGP routing table to display\n"
8807 "JavaScript Object Notation\n")
8809 u_char uj
= use_json(argc
, argv
);
8810 if (strncmp (argv
[0], "m", 1) == 0)
8811 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8813 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8816 DEFUN (show_bgp_route_pathtype
,
8817 show_bgp_route_pathtype_cmd
,
8818 "show bgp X:X::X:X (bestpath|multipath) {json}",
8821 "Network in the BGP routing table to display\n"
8822 "Display only the bestpath\n"
8823 "Display only multipaths\n"
8824 "JavaScript Object Notation\n")
8826 u_char uj
= use_json(argc
, argv
);
8827 if (strncmp (argv
[1], "b", 1) == 0)
8828 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8830 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8833 ALIAS (show_bgp_route_pathtype
,
8834 show_bgp_ipv6_route_pathtype_cmd
,
8835 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8839 "Network in the BGP routing table to display\n"
8840 "Display only the bestpath\n"
8841 "Display only multipaths\n"
8842 "JavaScript Object Notation\n")
8844 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8845 show_bgp_ipv6_safi_route_pathtype_cmd
,
8846 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
8850 "Address Family modifier\n"
8851 "Address Family modifier\n"
8852 "Network in the BGP routing table to display\n"
8853 "Display only the bestpath\n"
8854 "Display only multipaths\n"
8855 "JavaScript Object Notation\n")
8857 u_char uj
= use_json(argc
, argv
);
8858 if (strncmp (argv
[0], "m", 1) == 0)
8859 if (strncmp (argv
[2], "b", 1) == 0)
8860 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8862 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8864 if (strncmp (argv
[2], "b", 1) == 0)
8865 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8867 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8871 DEFUN (show_ipv6_bgp_route
,
8872 show_ipv6_bgp_route_cmd
,
8873 "show ipv6 bgp X:X::X:X {json}",
8877 "Network in the BGP routing table to display\n"
8878 "JavaScript Object Notation\n")
8880 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8881 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8884 DEFUN (show_bgp_prefix
,
8885 show_bgp_prefix_cmd
,
8886 "show bgp X:X::X:X/M {json}",
8889 "IPv6 prefix <network>/<length>\n"
8890 "JavaScript Object Notation\n")
8892 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8895 DEFUN (show_bgp_ipv6_safi_prefix
,
8896 show_bgp_ipv6_safi_prefix_cmd
,
8897 "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
8901 "Address Family modifier\n"
8902 "Address Family modifier\n"
8903 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8904 "JavaScript Object Notation\n")
8906 u_char uj
= use_json(argc
, argv
);
8907 if (strncmp (argv
[0], "m", 1) == 0)
8908 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8910 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8913 DEFUN (show_bgp_prefix_pathtype
,
8914 show_bgp_prefix_pathtype_cmd
,
8915 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8918 "IPv6 prefix <network>/<length>\n"
8919 "Display only the bestpath\n"
8920 "Display only multipaths\n"
8921 "JavaScript Object Notation\n")
8923 u_char uj
= use_json(argc
, argv
);
8924 if (strncmp (argv
[1], "b", 1) == 0)
8925 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8927 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8930 ALIAS (show_bgp_prefix_pathtype
,
8931 show_bgp_ipv6_prefix_pathtype_cmd
,
8932 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8936 "IPv6 prefix <network>/<length>\n"
8937 "Display only the bestpath\n"
8938 "Display only multipaths\n"
8939 "JavaScript Object Notation\n")
8941 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8942 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8943 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
8947 "Address Family modifier\n"
8948 "Address Family modifier\n"
8949 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8950 "Display only the bestpath\n"
8951 "Display only multipaths\n"
8952 "JavaScript Object Notation\n")
8954 u_char uj
= use_json(argc
, argv
);
8955 if (strncmp (argv
[0], "m", 1) == 0)
8956 if (strncmp (argv
[2], "b", 1) == 0)
8957 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8959 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8961 if (strncmp (argv
[2], "b", 1) == 0)
8962 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8964 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8968 DEFUN (show_ipv6_bgp_prefix
,
8969 show_ipv6_bgp_prefix_cmd
,
8970 "show ipv6 bgp X:X::X:X/M {json}",
8974 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8975 "JavaScript Object Notation\n")
8977 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8978 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8981 DEFUN (show_bgp_view
,
8982 show_bgp_instance_cmd
,
8983 "show bgp " BGP_INSTANCE_CMD
" {json}",
8986 BGP_INSTANCE_HELP_STR
8987 "JavaScript Object Notation\n")
8991 /* BGP structure lookup. */
8992 bgp
= bgp_lookup_by_name (argv
[1]);
8995 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8999 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
9002 DEFUN (show_bgp_instance_all
,
9003 show_bgp_instance_all_cmd
,
9004 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
9007 BGP_INSTANCE_ALL_HELP_STR
9008 "JavaScript Object Notation\n")
9010 u_char uj
= use_json(argc
, argv
);
9012 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
9016 ALIAS (show_bgp_view
,
9017 show_bgp_instance_ipv6_cmd
,
9018 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
9021 BGP_INSTANCE_HELP_STR
9023 "JavaScript Object Notation\n")
9025 DEFUN (show_bgp_instance_route
,
9026 show_bgp_instance_route_cmd
,
9027 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
9030 BGP_INSTANCE_HELP_STR
9031 "Network in the BGP routing table to display\n"
9032 "JavaScript Object Notation\n")
9034 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9037 ALIAS (show_bgp_instance_route
,
9038 show_bgp_instance_ipv6_route_cmd
,
9039 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
9042 BGP_INSTANCE_HELP_STR
9044 "Network in the BGP routing table to display\n"
9045 "JavaScript Object Notation\n")
9047 DEFUN (show_bgp_instance_route_pathtype
,
9048 show_bgp_instance_route_pathtype_cmd
,
9049 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
9052 BGP_INSTANCE_HELP_STR
9053 "Network in the BGP routing table to display\n"
9054 "Display only the bestpath\n"
9055 "Display only multipaths\n"
9056 "JavaScript Object Notation\n")
9058 u_char uj
= use_json(argc
, argv
);
9059 if (strncmp (argv
[3], "b", 1) == 0)
9060 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
9062 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
9065 ALIAS (show_bgp_instance_route_pathtype
,
9066 show_bgp_instance_ipv6_route_pathtype_cmd
,
9067 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
9070 BGP_INSTANCE_HELP_STR
9072 "Network in the BGP routing table to display\n"
9073 "Display only the bestpath\n"
9074 "Display only multipaths\n"
9075 "JavaScript Object Notation\n")
9077 DEFUN (show_bgp_instance_prefix
,
9078 show_bgp_instance_prefix_cmd
,
9079 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
9082 BGP_INSTANCE_HELP_STR
9083 "IPv6 prefix <network>/<length>\n"
9084 "JavaScript Object Notation\n")
9086 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9089 ALIAS (show_bgp_instance_prefix
,
9090 show_bgp_instance_ipv6_prefix_cmd
,
9091 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
9094 BGP_INSTANCE_HELP_STR
9096 "IPv6 prefix <network>/<length>\n"
9097 "JavaScript Object Notation\n")
9099 DEFUN (show_bgp_instance_prefix_pathtype
,
9100 show_bgp_instance_prefix_pathtype_cmd
,
9101 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
9104 BGP_INSTANCE_HELP_STR
9105 "IPv6 prefix <network>/<length>\n"
9106 "Display only the bestpath\n"
9107 "Display only multipaths\n"
9108 "JavaScript Object Notation\n")
9110 u_char uj
= use_json(argc
, argv
);
9111 if (strncmp (argv
[3], "b", 1) == 0)
9112 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
9114 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
9117 ALIAS (show_bgp_instance_prefix_pathtype
,
9118 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
9119 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
9122 BGP_INSTANCE_HELP_STR
9124 "IPv6 prefix <network>/<length>\n"
9125 "Display only the bestpath\n"
9126 "Display only multipaths\n"
9127 "JavaScript Object Notation\n")
9129 DEFUN (show_bgp_instance_prefix_list
,
9130 show_bgp_instance_prefix_list_cmd
,
9131 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9134 BGP_INSTANCE_HELP_STR
9135 "Display routes conforming to the prefix-list\n"
9136 "IPv6 prefix-list name\n")
9138 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9139 bgp_show_type_prefix_list
);
9142 ALIAS (show_bgp_instance_prefix_list
,
9143 show_bgp_instance_ipv6_prefix_list_cmd
,
9144 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
9147 BGP_INSTANCE_HELP_STR
9149 "Display routes conforming to the prefix-list\n"
9150 "IPv6 prefix-list name\n")
9152 DEFUN (show_bgp_instance_filter_list
,
9153 show_bgp_instance_filter_list_cmd
,
9154 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9157 BGP_INSTANCE_HELP_STR
9158 "Display routes conforming to the filter-list\n"
9159 "Regular expression access list name\n")
9161 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9162 bgp_show_type_filter_list
);
9165 ALIAS (show_bgp_instance_filter_list
,
9166 show_bgp_instance_ipv6_filter_list_cmd
,
9167 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
9170 BGP_INSTANCE_HELP_STR
9172 "Display routes conforming to the filter-list\n"
9173 "Regular expression access list name\n")
9175 DEFUN (show_bgp_instance_route_map
,
9176 show_bgp_instance_route_map_cmd
,
9177 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
9180 BGP_INSTANCE_HELP_STR
9181 "Display routes matching the route-map\n"
9182 "A route-map to match on\n")
9184 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9185 bgp_show_type_route_map
);
9188 ALIAS (show_bgp_instance_route_map
,
9189 show_bgp_instance_ipv6_route_map_cmd
,
9190 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
9193 BGP_INSTANCE_HELP_STR
9195 "Display routes matching the route-map\n"
9196 "A route-map to match on\n")
9198 DEFUN (show_bgp_instance_community_list
,
9199 show_bgp_instance_community_list_cmd
,
9200 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
9203 BGP_INSTANCE_HELP_STR
9204 "Display routes matching the community-list\n"
9205 "community-list number\n"
9206 "community-list name\n")
9208 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
9211 ALIAS (show_bgp_instance_community_list
,
9212 show_bgp_instance_ipv6_community_list_cmd
,
9213 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
9216 BGP_INSTANCE_HELP_STR
9218 "Display routes matching the community-list\n"
9219 "community-list number\n"
9220 "community-list name\n")
9222 DEFUN (show_bgp_instance_prefix_longer
,
9223 show_bgp_instance_prefix_longer_cmd
,
9224 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
9227 BGP_INSTANCE_HELP_STR
9228 "IPv6 prefix <network>/<length>\n"
9229 "Display route and more specific routes\n")
9231 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9232 bgp_show_type_prefix_longer
);
9235 ALIAS (show_bgp_instance_prefix_longer
,
9236 show_bgp_instance_ipv6_prefix_longer_cmd
,
9237 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
9240 BGP_INSTANCE_HELP_STR
9242 "IPv6 prefix <network>/<length>\n"
9243 "Display route and more specific routes\n")
9246 DEFUN (show_ipv6_mbgp
,
9248 "show ipv6 mbgp {json}",
9252 "JavaScript Object Notation\n")
9254 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9255 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
9256 NULL
, use_json(argc
, argv
));
9260 DEFUN (show_ipv6_mbgp_route
,
9261 show_ipv6_mbgp_route_cmd
,
9262 "show ipv6 mbgp X:X::X:X {json}",
9266 "Network in the MBGP routing table to display\n"
9267 "JavaScript Object Notation\n")
9269 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9270 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9274 DEFUN (show_ipv6_mbgp_prefix
,
9275 show_ipv6_mbgp_prefix_cmd
,
9276 "show ipv6 mbgp X:X::X:X/M {json}",
9280 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9281 "JavaScript Object Notation\n")
9283 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9284 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9290 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
9291 safi_t safi
, enum bgp_show_type type
)
9301 b
= buffer_new (1024);
9302 for (i
= 0; i
< argc
; i
++)
9305 buffer_putc (b
, ' ');
9308 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9313 buffer_putstr (b
, argv
[i
]);
9315 buffer_putc (b
, '\0');
9317 regstr
= buffer_getstr (b
);
9320 regex
= bgp_regcomp (regstr
);
9321 XFREE(MTYPE_TMP
, regstr
);
9324 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
9329 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
9330 bgp_regex_free (regex
);
9334 DEFUN (show_ip_bgp_regexp
,
9335 show_ip_bgp_regexp_cmd
,
9336 "show ip bgp regexp .LINE",
9340 "Display routes matching the AS path regular expression\n"
9341 "A regular-expression to match the BGP AS paths\n")
9343 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9344 bgp_show_type_regexp
);
9347 DEFUN (show_ip_bgp_flap_regexp
,
9348 show_ip_bgp_flap_regexp_cmd
,
9349 "show ip bgp flap-statistics regexp .LINE",
9353 "Display flap statistics of routes\n"
9354 "Display routes matching the AS path regular expression\n"
9355 "A regular-expression to match the BGP AS paths\n")
9357 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9358 bgp_show_type_flap_regexp
);
9361 ALIAS (show_ip_bgp_flap_regexp
,
9362 show_ip_bgp_damp_flap_regexp_cmd
,
9363 "show ip bgp dampening flap-statistics regexp .LINE",
9367 "Display detailed information about dampening\n"
9368 "Display flap statistics of routes\n"
9369 "Display routes matching the AS path regular expression\n"
9370 "A regular-expression to match the BGP AS paths\n")
9372 DEFUN (show_ip_bgp_ipv4_regexp
,
9373 show_ip_bgp_ipv4_regexp_cmd
,
9374 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
9379 "Address Family modifier\n"
9380 "Address Family modifier\n"
9381 "Display routes matching the AS path regular expression\n"
9382 "A regular-expression to match the BGP AS paths\n")
9384 if (strncmp (argv
[0], "m", 1) == 0)
9385 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
9386 bgp_show_type_regexp
);
9388 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9389 bgp_show_type_regexp
);
9393 DEFUN (show_bgp_regexp
,
9394 show_bgp_regexp_cmd
,
9395 "show bgp regexp .LINE",
9398 "Display routes matching the AS path regular expression\n"
9399 "A regular-expression to match the BGP AS paths\n")
9401 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9402 bgp_show_type_regexp
);
9405 ALIAS (show_bgp_regexp
,
9406 show_bgp_ipv6_regexp_cmd
,
9407 "show bgp ipv6 regexp .LINE",
9411 "Display routes matching the AS path regular expression\n"
9412 "A regular-expression to match the BGP AS paths\n")
9415 DEFUN (show_ipv6_bgp_regexp
,
9416 show_ipv6_bgp_regexp_cmd
,
9417 "show ipv6 bgp regexp .LINE",
9421 "Display routes matching the AS path regular expression\n"
9422 "A regular-expression to match the BGP AS paths\n")
9424 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9425 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9426 bgp_show_type_regexp
);
9430 DEFUN (show_ipv6_mbgp_regexp
,
9431 show_ipv6_mbgp_regexp_cmd
,
9432 "show ipv6 mbgp regexp .LINE",
9436 "Display routes matching the AS path regular expression\n"
9437 "A regular-expression to match the MBGP AS paths\n")
9439 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9440 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9441 bgp_show_type_regexp
);
9443 #endif /* HAVE_IPV6 */
9446 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9447 const char *prefix_list_str
, afi_t afi
,
9448 safi_t safi
, enum bgp_show_type type
)
9450 struct prefix_list
*plist
;
9451 struct bgp
*bgp
= NULL
;
9453 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9455 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9459 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9462 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9463 prefix_list_str
, VTY_NEWLINE
);
9467 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9470 DEFUN (show_ip_bgp_prefix_list
,
9471 show_ip_bgp_prefix_list_cmd
,
9472 "show ip bgp prefix-list WORD",
9476 "Display routes conforming to the prefix-list\n"
9477 "IP prefix-list name\n")
9479 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9480 bgp_show_type_prefix_list
);
9483 DEFUN (show_ip_bgp_instance_prefix_list
,
9484 show_ip_bgp_instance_prefix_list_cmd
,
9485 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9489 BGP_INSTANCE_HELP_STR
9490 "Display routes conforming to the prefix-list\n"
9491 "IP prefix-list name\n")
9493 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9494 bgp_show_type_prefix_list
);
9497 DEFUN (show_ip_bgp_flap_prefix_list
,
9498 show_ip_bgp_flap_prefix_list_cmd
,
9499 "show ip bgp flap-statistics prefix-list WORD",
9503 "Display flap statistics of routes\n"
9504 "Display routes conforming to the prefix-list\n"
9505 "IP prefix-list name\n")
9507 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9508 bgp_show_type_flap_prefix_list
);
9511 ALIAS (show_ip_bgp_flap_prefix_list
,
9512 show_ip_bgp_damp_flap_prefix_list_cmd
,
9513 "show ip bgp dampening flap-statistics prefix-list WORD",
9517 "Display detailed information about dampening\n"
9518 "Display flap statistics of routes\n"
9519 "Display routes conforming to the prefix-list\n"
9520 "IP prefix-list name\n")
9522 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9523 show_ip_bgp_ipv4_prefix_list_cmd
,
9524 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
9529 "Address Family modifier\n"
9530 "Address Family modifier\n"
9531 "Display routes conforming to the prefix-list\n"
9532 "IP prefix-list name\n")
9534 if (strncmp (argv
[0], "m", 1) == 0)
9535 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9536 bgp_show_type_prefix_list
);
9538 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9539 bgp_show_type_prefix_list
);
9543 DEFUN (show_bgp_prefix_list
,
9544 show_bgp_prefix_list_cmd
,
9545 "show bgp prefix-list WORD",
9548 "Display routes conforming to the prefix-list\n"
9549 "IPv6 prefix-list name\n")
9551 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9552 bgp_show_type_prefix_list
);
9555 ALIAS (show_bgp_prefix_list
,
9556 show_bgp_ipv6_prefix_list_cmd
,
9557 "show bgp ipv6 prefix-list WORD",
9561 "Display routes conforming to the prefix-list\n"
9562 "IPv6 prefix-list name\n")
9565 DEFUN (show_ipv6_bgp_prefix_list
,
9566 show_ipv6_bgp_prefix_list_cmd
,
9567 "show ipv6 bgp prefix-list WORD",
9571 "Display routes matching the prefix-list\n"
9572 "IPv6 prefix-list name\n")
9574 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9575 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9576 bgp_show_type_prefix_list
);
9580 DEFUN (show_ipv6_mbgp_prefix_list
,
9581 show_ipv6_mbgp_prefix_list_cmd
,
9582 "show ipv6 mbgp prefix-list WORD",
9586 "Display routes matching the prefix-list\n"
9587 "IPv6 prefix-list name\n")
9589 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9590 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9591 bgp_show_type_prefix_list
);
9593 #endif /* HAVE_IPV6 */
9596 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9597 const char *filter
, afi_t afi
,
9598 safi_t safi
, enum bgp_show_type type
)
9600 struct as_list
*as_list
;
9601 struct bgp
*bgp
= NULL
;
9603 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9605 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9609 as_list
= as_list_lookup (filter
);
9610 if (as_list
== NULL
)
9612 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9616 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9619 DEFUN (show_ip_bgp_filter_list
,
9620 show_ip_bgp_filter_list_cmd
,
9621 "show ip bgp filter-list WORD",
9625 "Display routes conforming to the filter-list\n"
9626 "Regular expression access list name\n")
9628 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9629 bgp_show_type_filter_list
);
9632 DEFUN (show_ip_bgp_instance_filter_list
,
9633 show_ip_bgp_instance_filter_list_cmd
,
9634 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9638 BGP_INSTANCE_HELP_STR
9639 "Display routes conforming to the filter-list\n"
9640 "Regular expression access list name\n")
9642 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9643 bgp_show_type_filter_list
);
9646 DEFUN (show_ip_bgp_flap_filter_list
,
9647 show_ip_bgp_flap_filter_list_cmd
,
9648 "show ip bgp flap-statistics filter-list WORD",
9652 "Display flap statistics of routes\n"
9653 "Display routes conforming to the filter-list\n"
9654 "Regular expression access list name\n")
9656 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9657 bgp_show_type_flap_filter_list
);
9660 ALIAS (show_ip_bgp_flap_filter_list
,
9661 show_ip_bgp_damp_flap_filter_list_cmd
,
9662 "show ip bgp dampening flap-statistics filter-list WORD",
9666 "Display detailed information about dampening\n"
9667 "Display flap statistics of routes\n"
9668 "Display routes conforming to the filter-list\n"
9669 "Regular expression access list name\n")
9671 DEFUN (show_ip_bgp_ipv4_filter_list
,
9672 show_ip_bgp_ipv4_filter_list_cmd
,
9673 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9678 "Address Family modifier\n"
9679 "Address Family modifier\n"
9680 "Display routes conforming to the filter-list\n"
9681 "Regular expression access list name\n")
9683 if (strncmp (argv
[0], "m", 1) == 0)
9684 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9685 bgp_show_type_filter_list
);
9687 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9688 bgp_show_type_filter_list
);
9692 DEFUN (show_bgp_filter_list
,
9693 show_bgp_filter_list_cmd
,
9694 "show bgp filter-list WORD",
9697 "Display routes conforming to the filter-list\n"
9698 "Regular expression access list name\n")
9700 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9701 bgp_show_type_filter_list
);
9704 ALIAS (show_bgp_filter_list
,
9705 show_bgp_ipv6_filter_list_cmd
,
9706 "show bgp ipv6 filter-list WORD",
9710 "Display routes conforming to the filter-list\n"
9711 "Regular expression access list name\n")
9714 DEFUN (show_ipv6_bgp_filter_list
,
9715 show_ipv6_bgp_filter_list_cmd
,
9716 "show ipv6 bgp filter-list WORD",
9720 "Display routes conforming to the filter-list\n"
9721 "Regular expression access list name\n")
9723 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9724 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9725 bgp_show_type_filter_list
);
9729 DEFUN (show_ipv6_mbgp_filter_list
,
9730 show_ipv6_mbgp_filter_list_cmd
,
9731 "show ipv6 mbgp filter-list WORD",
9735 "Display routes conforming to the filter-list\n"
9736 "Regular expression access list name\n")
9738 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9739 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9740 bgp_show_type_filter_list
);
9742 #endif /* HAVE_IPV6 */
9744 DEFUN (show_ip_bgp_dampening_info
,
9745 show_ip_bgp_dampening_params_cmd
,
9746 "show ip bgp dampening parameters",
9750 "Display detailed information about dampening\n"
9751 "Display detail of configured dampening parameters\n")
9753 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9757 DEFUN (show_ip_bgp_ipv4_dampening_parameters
,
9758 show_ip_bgp_ipv4_dampening_parameters_cmd
,
9759 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
9764 "Address Family modifier\n"
9765 "Address Family modifier\n"
9766 "Display detailed information about dampening\n"
9767 "Display detail of configured dampening parameters\n")
9769 if (strncmp(argv
[0], "m", 1) == 0)
9770 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_MULTICAST
);
9772 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9776 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats
,
9777 show_ip_bgp_ipv4_dampening_flap_stats_cmd
,
9778 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
9783 "Address Family modifier\n"
9784 "Address Family modifier\n"
9785 "Display detailed information about dampening\n"
9786 "Display flap statistics of routes\n")
9788 if (strncmp(argv
[0], "m", 1) == 0)
9789 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9790 bgp_show_type_flap_statistics
, NULL
, 0);
9792 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9793 bgp_show_type_flap_statistics
, NULL
, 0);
9796 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths
,
9797 show_ip_bgp_ipv4_dampening_dampd_paths_cmd
,
9798 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
9803 "Address Family modifier\n"
9804 "Address Family modifier\n"
9805 "Display detailed information about dampening\n"
9806 "Display paths suppressed due to dampening\n")
9808 if (strncmp(argv
[0], "m", 1) == 0)
9809 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9810 bgp_show_type_dampend_paths
, NULL
, 0);
9812 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9813 bgp_show_type_dampend_paths
, NULL
, 0);
9817 bgp_show_route_map (struct vty
*vty
, const char *name
,
9818 const char *rmap_str
, afi_t afi
,
9819 safi_t safi
, enum bgp_show_type type
)
9821 struct route_map
*rmap
;
9822 struct bgp
*bgp
= NULL
;
9824 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9826 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9830 rmap
= route_map_lookup_by_name (rmap_str
);
9833 vty_out (vty
, "%% %s is not a valid route-map name%s",
9834 rmap_str
, VTY_NEWLINE
);
9838 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9841 DEFUN (show_ip_bgp_route_map
,
9842 show_ip_bgp_route_map_cmd
,
9843 "show ip bgp route-map WORD",
9847 "Display routes matching the route-map\n"
9848 "A route-map to match on\n")
9850 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9851 bgp_show_type_route_map
);
9854 DEFUN (show_ip_bgp_instance_route_map
,
9855 show_ip_bgp_instance_route_map_cmd
,
9856 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9860 BGP_INSTANCE_HELP_STR
9861 "Display routes matching the route-map\n"
9862 "A route-map to match on\n")
9864 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9865 bgp_show_type_route_map
);
9868 DEFUN (show_ip_bgp_flap_route_map
,
9869 show_ip_bgp_flap_route_map_cmd
,
9870 "show ip bgp flap-statistics route-map WORD",
9874 "Display flap statistics of routes\n"
9875 "Display routes matching the route-map\n"
9876 "A route-map to match on\n")
9878 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9879 bgp_show_type_flap_route_map
);
9882 ALIAS (show_ip_bgp_flap_route_map
,
9883 show_ip_bgp_damp_flap_route_map_cmd
,
9884 "show ip bgp dampening flap-statistics route-map WORD",
9888 "Display detailed information about dampening\n"
9889 "Display flap statistics of routes\n"
9890 "Display routes matching the route-map\n"
9891 "A route-map to match on\n")
9893 DEFUN (show_ip_bgp_ipv4_route_map
,
9894 show_ip_bgp_ipv4_route_map_cmd
,
9895 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9900 "Address Family modifier\n"
9901 "Address Family modifier\n"
9902 "Display routes matching the route-map\n"
9903 "A route-map to match on\n")
9905 if (strncmp (argv
[0], "m", 1) == 0)
9906 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9907 bgp_show_type_route_map
);
9909 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9910 bgp_show_type_route_map
);
9913 DEFUN (show_bgp_route_map
,
9914 show_bgp_route_map_cmd
,
9915 "show bgp route-map WORD",
9918 "Display routes matching the route-map\n"
9919 "A route-map to match on\n")
9921 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9922 bgp_show_type_route_map
);
9925 ALIAS (show_bgp_route_map
,
9926 show_bgp_ipv6_route_map_cmd
,
9927 "show bgp ipv6 route-map WORD",
9931 "Display routes matching the route-map\n"
9932 "A route-map to match on\n")
9934 DEFUN (show_ip_bgp_cidr_only
,
9935 show_ip_bgp_cidr_only_cmd
,
9936 "show ip bgp cidr-only",
9940 "Display only routes with non-natural netmasks\n")
9942 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9943 bgp_show_type_cidr_only
, NULL
, 0);
9946 DEFUN (show_ip_bgp_flap_cidr_only
,
9947 show_ip_bgp_flap_cidr_only_cmd
,
9948 "show ip bgp flap-statistics cidr-only",
9952 "Display flap statistics of routes\n"
9953 "Display only routes with non-natural netmasks\n")
9955 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9956 bgp_show_type_flap_cidr_only
, NULL
, 0);
9959 ALIAS (show_ip_bgp_flap_cidr_only
,
9960 show_ip_bgp_damp_flap_cidr_only_cmd
,
9961 "show ip bgp dampening flap-statistics cidr-only",
9965 "Display detailed information about dampening\n"
9966 "Display flap statistics of routes\n"
9967 "Display only routes with non-natural netmasks\n")
9969 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9970 show_ip_bgp_ipv4_cidr_only_cmd
,
9971 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9976 "Address Family modifier\n"
9977 "Address Family modifier\n"
9978 "Display only routes with non-natural netmasks\n")
9980 if (strncmp (argv
[0], "m", 1) == 0)
9981 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9982 bgp_show_type_cidr_only
, NULL
, 0);
9984 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9985 bgp_show_type_cidr_only
, NULL
, 0);
9988 DEFUN (show_ip_bgp_community_all
,
9989 show_ip_bgp_community_all_cmd
,
9990 "show ip bgp community",
9994 "Display routes matching the communities\n")
9996 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9997 bgp_show_type_community_all
, NULL
, 0);
10000 DEFUN (show_ip_bgp_ipv4_community_all
,
10001 show_ip_bgp_ipv4_community_all_cmd
,
10002 "show ip bgp ipv4 (unicast|multicast) community",
10007 "Address Family modifier\n"
10008 "Address Family modifier\n"
10009 "Display routes matching the communities\n")
10011 if (strncmp (argv
[0], "m", 1) == 0)
10012 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
10013 bgp_show_type_community_all
, NULL
, 0);
10015 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10016 bgp_show_type_community_all
, NULL
, 0);
10020 DEFUN (show_bgp_community_all
,
10021 show_bgp_community_all_cmd
,
10022 "show bgp community",
10025 "Display routes matching the communities\n")
10027 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10028 bgp_show_type_community_all
, NULL
, 0);
10031 ALIAS (show_bgp_community_all
,
10032 show_bgp_ipv6_community_all_cmd
,
10033 "show bgp ipv6 community",
10037 "Display routes matching the communities\n")
10040 DEFUN (show_ipv6_bgp_community_all
,
10041 show_ipv6_bgp_community_all_cmd
,
10042 "show ipv6 bgp community",
10046 "Display routes matching the communities\n")
10048 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10049 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10050 bgp_show_type_community_all
, NULL
, 0);
10054 DEFUN (show_ipv6_mbgp_community_all
,
10055 show_ipv6_mbgp_community_all_cmd
,
10056 "show ipv6 mbgp community",
10060 "Display routes matching the communities\n")
10062 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10063 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
10064 bgp_show_type_community_all
, NULL
, 0);
10066 #endif /* HAVE_IPV6 */
10069 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
10070 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
10072 struct community
*com
;
10079 /* BGP structure lookup */
10082 bgp
= bgp_lookup_by_name (view_name
);
10085 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
10086 return CMD_WARNING
;
10091 bgp
= bgp_get_default ();
10094 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10095 return CMD_WARNING
;
10099 b
= buffer_new (1024);
10100 for (i
= 0; i
< argc
; i
++)
10103 buffer_putc (b
, ' ');
10106 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
10111 buffer_putstr (b
, argv
[i
]);
10113 buffer_putc (b
, '\0');
10115 str
= buffer_getstr (b
);
10118 com
= community_str2com (str
);
10119 XFREE (MTYPE_TMP
, str
);
10122 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
10123 return CMD_WARNING
;
10126 return bgp_show (vty
, bgp
, afi
, safi
,
10127 (exact
? bgp_show_type_community_exact
:
10128 bgp_show_type_community
), com
, 0);
10131 DEFUN (show_ip_bgp_community
,
10132 show_ip_bgp_community_cmd
,
10133 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
10137 "Display routes matching the communities\n"
10139 "Do not send outside local AS (well-known community)\n"
10140 "Do not advertise to any peer (well-known community)\n"
10141 "Do not export to next AS (well-known community)\n")
10143 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
10146 ALIAS (show_ip_bgp_community
,
10147 show_ip_bgp_community2_cmd
,
10148 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10152 "Display routes matching the communities\n"
10154 "Do not send outside local AS (well-known community)\n"
10155 "Do not advertise to any peer (well-known community)\n"
10156 "Do not export to next AS (well-known community)\n"
10158 "Do not send outside local AS (well-known community)\n"
10159 "Do not advertise to any peer (well-known community)\n"
10160 "Do not export to next AS (well-known community)\n")
10162 ALIAS (show_ip_bgp_community
,
10163 show_ip_bgp_community3_cmd
,
10164 "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)",
10168 "Display routes matching the communities\n"
10170 "Do not send outside local AS (well-known community)\n"
10171 "Do not advertise to any peer (well-known community)\n"
10172 "Do not export to next AS (well-known community)\n"
10174 "Do not send outside local AS (well-known community)\n"
10175 "Do not advertise to any peer (well-known community)\n"
10176 "Do not export to next AS (well-known community)\n"
10178 "Do not send outside local AS (well-known community)\n"
10179 "Do not advertise to any peer (well-known community)\n"
10180 "Do not export to next AS (well-known community)\n")
10182 ALIAS (show_ip_bgp_community
,
10183 show_ip_bgp_community4_cmd
,
10184 "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)",
10188 "Display routes matching the communities\n"
10190 "Do not send outside local AS (well-known community)\n"
10191 "Do not advertise to any peer (well-known community)\n"
10192 "Do not export to next AS (well-known community)\n"
10194 "Do not send outside local AS (well-known community)\n"
10195 "Do not advertise to any peer (well-known community)\n"
10196 "Do not export to next AS (well-known community)\n"
10198 "Do not send outside local AS (well-known community)\n"
10199 "Do not advertise to any peer (well-known community)\n"
10200 "Do not export to next AS (well-known community)\n"
10202 "Do not send outside local AS (well-known community)\n"
10203 "Do not advertise to any peer (well-known community)\n"
10204 "Do not export to next AS (well-known community)\n")
10206 DEFUN (show_ip_bgp_ipv4_community
,
10207 show_ip_bgp_ipv4_community_cmd
,
10208 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10213 "Address Family modifier\n"
10214 "Address Family modifier\n"
10215 "Display routes matching the communities\n"
10217 "Do not send outside local AS (well-known community)\n"
10218 "Do not advertise to any peer (well-known community)\n"
10219 "Do not export to next AS (well-known community)\n")
10221 if (strncmp (argv
[0], "m", 1) == 0)
10222 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
10224 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
10227 ALIAS (show_ip_bgp_ipv4_community
,
10228 show_ip_bgp_ipv4_community2_cmd
,
10229 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10234 "Address Family modifier\n"
10235 "Address Family modifier\n"
10236 "Display routes matching the communities\n"
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"
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")
10246 ALIAS (show_ip_bgp_ipv4_community
,
10247 show_ip_bgp_ipv4_community3_cmd
,
10248 "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)",
10253 "Address Family modifier\n"
10254 "Address Family modifier\n"
10255 "Display routes matching the communities\n"
10257 "Do not send outside local AS (well-known community)\n"
10258 "Do not advertise to any peer (well-known community)\n"
10259 "Do not export to next AS (well-known community)\n"
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"
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")
10269 ALIAS (show_ip_bgp_ipv4_community
,
10270 show_ip_bgp_ipv4_community4_cmd
,
10271 "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)",
10276 "Address Family modifier\n"
10277 "Address Family modifier\n"
10278 "Display routes matching the communities\n"
10280 "Do not send outside local AS (well-known community)\n"
10281 "Do not advertise to any peer (well-known community)\n"
10282 "Do not export to next AS (well-known community)\n"
10284 "Do not send outside local AS (well-known community)\n"
10285 "Do not advertise to any peer (well-known community)\n"
10286 "Do not export to next AS (well-known community)\n"
10288 "Do not send outside local AS (well-known community)\n"
10289 "Do not advertise to any peer (well-known community)\n"
10290 "Do not export to next AS (well-known community)\n"
10292 "Do not send outside local AS (well-known community)\n"
10293 "Do not advertise to any peer (well-known community)\n"
10294 "Do not export to next AS (well-known community)\n")
10296 DEFUN (show_bgp_instance_afi_safi_community_all
,
10297 show_bgp_instance_afi_safi_community_all_cmd
,
10298 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
10301 BGP_INSTANCE_HELP_STR
10304 "Address Family modifier\n"
10305 "Address Family modifier\n"
10306 "Display routes matching the communities\n")
10312 /* BGP structure lookup. */
10313 bgp
= bgp_lookup_by_name (argv
[1]);
10316 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
10317 return CMD_WARNING
;
10320 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10321 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10322 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
10325 DEFUN (show_bgp_instance_afi_safi_community
,
10326 show_bgp_instance_afi_safi_community_cmd
,
10327 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10330 BGP_INSTANCE_HELP_STR
10333 "Address family modifier\n"
10334 "Address family modifier\n"
10335 "Display routes matching the communities\n"
10337 "Do not send outside local AS (well-known community)\n"
10338 "Do not advertise to any peer (well-known community)\n"
10339 "Do not export to next AS (well-known community)\n")
10344 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10345 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10346 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
10349 ALIAS (show_bgp_instance_afi_safi_community
,
10350 show_bgp_instance_afi_safi_community2_cmd
,
10351 "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)",
10354 BGP_INSTANCE_HELP_STR
10357 "Address family modifier\n"
10358 "Address family modifier\n"
10359 "Display routes matching the communities\n"
10361 "Do not send outside local AS (well-known community)\n"
10362 "Do not advertise to any peer (well-known community)\n"
10363 "Do not export to next AS (well-known community)\n"
10365 "Do not send outside local AS (well-known community)\n"
10366 "Do not advertise to any peer (well-known community)\n"
10367 "Do not export to next AS (well-known community)\n")
10369 ALIAS (show_bgp_instance_afi_safi_community
,
10370 show_bgp_instance_afi_safi_community3_cmd
,
10371 "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)",
10374 BGP_INSTANCE_HELP_STR
10377 "Address family modifier\n"
10378 "Address family modifier\n"
10379 "Display routes matching the communities\n"
10381 "Do not send outside local AS (well-known community)\n"
10382 "Do not advertise to any peer (well-known community)\n"
10383 "Do not export to next AS (well-known community)\n"
10385 "Do not send outside local AS (well-known community)\n"
10386 "Do not advertise to any peer (well-known community)\n"
10387 "Do not export to next AS (well-known community)\n"
10389 "Do not send outside local AS (well-known community)\n"
10390 "Do not advertise to any peer (well-known community)\n"
10391 "Do not export to next AS (well-known community)\n")
10393 ALIAS (show_bgp_instance_afi_safi_community
,
10394 show_bgp_instance_afi_safi_community4_cmd
,
10395 "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)",
10398 BGP_INSTANCE_HELP_STR
10401 "Address family modifier\n"
10402 "Address family modifier\n"
10403 "Display routes matching the communities\n"
10405 "Do not send outside local AS (well-known community)\n"
10406 "Do not advertise to any peer (well-known community)\n"
10407 "Do not export to next AS (well-known community)\n"
10409 "Do not send outside local AS (well-known community)\n"
10410 "Do not advertise to any peer (well-known community)\n"
10411 "Do not export to next AS (well-known community)\n"
10413 "Do not send outside local AS (well-known community)\n"
10414 "Do not advertise to any peer (well-known community)\n"
10415 "Do not export to next AS (well-known community)\n"
10417 "Do not send outside local AS (well-known community)\n"
10418 "Do not advertise to any peer (well-known community)\n"
10419 "Do not export to next AS (well-known community)\n")
10421 DEFUN (show_ip_bgp_community_exact
,
10422 show_ip_bgp_community_exact_cmd
,
10423 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10427 "Display routes matching the communities\n"
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"
10432 "Exact match of the communities")
10434 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10437 ALIAS (show_ip_bgp_community_exact
,
10438 show_ip_bgp_community2_exact_cmd
,
10439 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10443 "Display routes matching the communities\n"
10445 "Do not send outside local AS (well-known community)\n"
10446 "Do not advertise to any peer (well-known community)\n"
10447 "Do not export to next AS (well-known community)\n"
10449 "Do not send outside local AS (well-known community)\n"
10450 "Do not advertise to any peer (well-known community)\n"
10451 "Do not export to next AS (well-known community)\n"
10452 "Exact match of the communities")
10454 ALIAS (show_ip_bgp_community_exact
,
10455 show_ip_bgp_community3_exact_cmd
,
10456 "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",
10460 "Display routes matching the communities\n"
10462 "Do not send outside local AS (well-known community)\n"
10463 "Do not advertise to any peer (well-known community)\n"
10464 "Do not export to next AS (well-known community)\n"
10466 "Do not send outside local AS (well-known community)\n"
10467 "Do not advertise to any peer (well-known community)\n"
10468 "Do not export to next AS (well-known community)\n"
10470 "Do not send outside local AS (well-known community)\n"
10471 "Do not advertise to any peer (well-known community)\n"
10472 "Do not export to next AS (well-known community)\n"
10473 "Exact match of the communities")
10475 ALIAS (show_ip_bgp_community_exact
,
10476 show_ip_bgp_community4_exact_cmd
,
10477 "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",
10481 "Display routes matching the communities\n"
10483 "Do not send outside local AS (well-known community)\n"
10484 "Do not advertise to any peer (well-known community)\n"
10485 "Do not export to next AS (well-known community)\n"
10487 "Do not send outside local AS (well-known community)\n"
10488 "Do not advertise to any peer (well-known community)\n"
10489 "Do not export to next AS (well-known community)\n"
10491 "Do not send outside local AS (well-known community)\n"
10492 "Do not advertise to any peer (well-known community)\n"
10493 "Do not export to next AS (well-known community)\n"
10495 "Do not send outside local AS (well-known community)\n"
10496 "Do not advertise to any peer (well-known community)\n"
10497 "Do not export to next AS (well-known community)\n"
10498 "Exact match of the communities")
10500 DEFUN (show_ip_bgp_ipv4_community_exact
,
10501 show_ip_bgp_ipv4_community_exact_cmd
,
10502 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10507 "Address Family modifier\n"
10508 "Address Family modifier\n"
10509 "Display routes matching the communities\n"
10511 "Do not send outside local AS (well-known community)\n"
10512 "Do not advertise to any peer (well-known community)\n"
10513 "Do not export to next AS (well-known community)\n"
10514 "Exact match of the communities")
10516 if (strncmp (argv
[0], "m", 1) == 0)
10517 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
10519 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10522 ALIAS (show_ip_bgp_ipv4_community_exact
,
10523 show_ip_bgp_ipv4_community2_exact_cmd
,
10524 "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",
10529 "Address Family modifier\n"
10530 "Address Family modifier\n"
10531 "Display routes matching the communities\n"
10533 "Do not send outside local AS (well-known community)\n"
10534 "Do not advertise to any peer (well-known community)\n"
10535 "Do not export to next AS (well-known community)\n"
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 "Exact match of the communities")
10542 ALIAS (show_ip_bgp_ipv4_community_exact
,
10543 show_ip_bgp_ipv4_community3_exact_cmd
,
10544 "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",
10549 "Address Family modifier\n"
10550 "Address Family modifier\n"
10551 "Display routes matching the communities\n"
10553 "Do not send outside local AS (well-known community)\n"
10554 "Do not advertise to any peer (well-known community)\n"
10555 "Do not export to next AS (well-known community)\n"
10557 "Do not send outside local AS (well-known community)\n"
10558 "Do not advertise to any peer (well-known community)\n"
10559 "Do not export to next AS (well-known community)\n"
10561 "Do not send outside local AS (well-known community)\n"
10562 "Do not advertise to any peer (well-known community)\n"
10563 "Do not export to next AS (well-known community)\n"
10564 "Exact match of the communities")
10566 ALIAS (show_ip_bgp_ipv4_community_exact
,
10567 show_ip_bgp_ipv4_community4_exact_cmd
,
10568 "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",
10573 "Address Family modifier\n"
10574 "Address Family modifier\n"
10575 "Display routes matching the communities\n"
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"
10581 "Do not send outside local AS (well-known community)\n"
10582 "Do not advertise to any peer (well-known community)\n"
10583 "Do not export to next AS (well-known community)\n"
10585 "Do not send outside local AS (well-known community)\n"
10586 "Do not advertise to any peer (well-known community)\n"
10587 "Do not export to next AS (well-known community)\n"
10589 "Do not send outside local AS (well-known community)\n"
10590 "Do not advertise to any peer (well-known community)\n"
10591 "Do not export to next AS (well-known community)\n"
10592 "Exact match of the communities")
10595 DEFUN (show_bgp_community
,
10596 show_bgp_community_cmd
,
10597 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10600 "Display routes matching the communities\n"
10602 "Do not send outside local AS (well-known community)\n"
10603 "Do not advertise to any peer (well-known community)\n"
10604 "Do not export to next AS (well-known community)\n")
10606 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10609 ALIAS (show_bgp_community
,
10610 show_bgp_ipv6_community_cmd
,
10611 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10615 "Display routes matching the communities\n"
10617 "Do not send outside local AS (well-known community)\n"
10618 "Do not advertise to any peer (well-known community)\n"
10619 "Do not export to next AS (well-known community)\n")
10621 ALIAS (show_bgp_community
,
10622 show_bgp_community2_cmd
,
10623 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10626 "Display routes matching the communities\n"
10628 "Do not send outside local AS (well-known community)\n"
10629 "Do not advertise to any peer (well-known community)\n"
10630 "Do not export to next AS (well-known community)\n"
10632 "Do not send outside local AS (well-known community)\n"
10633 "Do not advertise to any peer (well-known community)\n"
10634 "Do not export to next AS (well-known community)\n")
10636 ALIAS (show_bgp_community
,
10637 show_bgp_ipv6_community2_cmd
,
10638 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10642 "Display routes matching the communities\n"
10644 "Do not send outside local AS (well-known community)\n"
10645 "Do not advertise to any peer (well-known community)\n"
10646 "Do not export to next AS (well-known community)\n"
10648 "Do not send outside local AS (well-known community)\n"
10649 "Do not advertise to any peer (well-known community)\n"
10650 "Do not export to next AS (well-known community)\n")
10652 ALIAS (show_bgp_community
,
10653 show_bgp_community3_cmd
,
10654 "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)",
10657 "Display routes matching the communities\n"
10659 "Do not send outside local AS (well-known community)\n"
10660 "Do not advertise to any peer (well-known community)\n"
10661 "Do not export to next AS (well-known community)\n"
10663 "Do not send outside local AS (well-known community)\n"
10664 "Do not advertise to any peer (well-known community)\n"
10665 "Do not export to next AS (well-known community)\n"
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")
10671 ALIAS (show_bgp_community
,
10672 show_bgp_ipv6_community3_cmd
,
10673 "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)",
10677 "Display routes matching the communities\n"
10679 "Do not send outside local AS (well-known community)\n"
10680 "Do not advertise to any peer (well-known community)\n"
10681 "Do not export to next AS (well-known community)\n"
10683 "Do not send outside local AS (well-known community)\n"
10684 "Do not advertise to any peer (well-known community)\n"
10685 "Do not export to next AS (well-known community)\n"
10687 "Do not send outside local AS (well-known community)\n"
10688 "Do not advertise to any peer (well-known community)\n"
10689 "Do not export to next AS (well-known community)\n")
10691 ALIAS (show_bgp_community
,
10692 show_bgp_community4_cmd
,
10693 "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)",
10696 "Display routes matching the communities\n"
10698 "Do not send outside local AS (well-known community)\n"
10699 "Do not advertise to any peer (well-known community)\n"
10700 "Do not export to next AS (well-known community)\n"
10702 "Do not send outside local AS (well-known community)\n"
10703 "Do not advertise to any peer (well-known community)\n"
10704 "Do not export to next AS (well-known community)\n"
10706 "Do not send outside local AS (well-known community)\n"
10707 "Do not advertise to any peer (well-known community)\n"
10708 "Do not export to next AS (well-known community)\n"
10710 "Do not send outside local AS (well-known community)\n"
10711 "Do not advertise to any peer (well-known community)\n"
10712 "Do not export to next AS (well-known community)\n")
10714 ALIAS (show_bgp_community
,
10715 show_bgp_ipv6_community4_cmd
,
10716 "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)",
10720 "Display routes matching the communities\n"
10722 "Do not send outside local AS (well-known community)\n"
10723 "Do not advertise to any peer (well-known community)\n"
10724 "Do not export to next AS (well-known community)\n"
10726 "Do not send outside local AS (well-known community)\n"
10727 "Do not advertise to any peer (well-known community)\n"
10728 "Do not export to next AS (well-known community)\n"
10730 "Do not send outside local AS (well-known community)\n"
10731 "Do not advertise to any peer (well-known community)\n"
10732 "Do not export to next AS (well-known community)\n"
10734 "Do not send outside local AS (well-known community)\n"
10735 "Do not advertise to any peer (well-known community)\n"
10736 "Do not export to next AS (well-known community)\n")
10739 DEFUN (show_ipv6_bgp_community
,
10740 show_ipv6_bgp_community_cmd
,
10741 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10745 "Display routes matching the communities\n"
10747 "Do not send outside local AS (well-known community)\n"
10748 "Do not advertise to any peer (well-known community)\n"
10749 "Do not export to next AS (well-known community)\n")
10751 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10752 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10756 ALIAS (show_ipv6_bgp_community
,
10757 show_ipv6_bgp_community2_cmd
,
10758 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10762 "Display routes matching the communities\n"
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"
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")
10773 ALIAS (show_ipv6_bgp_community
,
10774 show_ipv6_bgp_community3_cmd
,
10775 "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)",
10779 "Display routes matching the communities\n"
10781 "Do not send outside local AS (well-known community)\n"
10782 "Do not advertise to any peer (well-known community)\n"
10783 "Do not export to next AS (well-known community)\n"
10785 "Do not send outside local AS (well-known community)\n"
10786 "Do not advertise to any peer (well-known community)\n"
10787 "Do not export to next AS (well-known community)\n"
10789 "Do not send outside local AS (well-known community)\n"
10790 "Do not advertise to any peer (well-known community)\n"
10791 "Do not export to next AS (well-known community)\n")
10794 ALIAS (show_ipv6_bgp_community
,
10795 show_ipv6_bgp_community4_cmd
,
10796 "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)",
10800 "Display routes matching the communities\n"
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"
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"
10810 "Do not send outside local AS (well-known community)\n"
10811 "Do not advertise to any peer (well-known community)\n"
10812 "Do not export to next AS (well-known community)\n"
10814 "Do not send outside local AS (well-known community)\n"
10815 "Do not advertise to any peer (well-known community)\n"
10816 "Do not export to next AS (well-known community)\n")
10818 DEFUN (show_bgp_community_exact
,
10819 show_bgp_community_exact_cmd
,
10820 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10823 "Display routes matching the communities\n"
10825 "Do not send outside local AS (well-known community)\n"
10826 "Do not advertise to any peer (well-known community)\n"
10827 "Do not export to next AS (well-known community)\n"
10828 "Exact match of the communities")
10830 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10833 ALIAS (show_bgp_community_exact
,
10834 show_bgp_ipv6_community_exact_cmd
,
10835 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10839 "Display routes matching the communities\n"
10841 "Do not send outside local AS (well-known community)\n"
10842 "Do not advertise to any peer (well-known community)\n"
10843 "Do not export to next AS (well-known community)\n"
10844 "Exact match of the communities")
10846 ALIAS (show_bgp_community_exact
,
10847 show_bgp_community2_exact_cmd
,
10848 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10851 "Display routes matching the communities\n"
10853 "Do not send outside local AS (well-known community)\n"
10854 "Do not advertise to any peer (well-known community)\n"
10855 "Do not export to next AS (well-known community)\n"
10857 "Do not send outside local AS (well-known community)\n"
10858 "Do not advertise to any peer (well-known community)\n"
10859 "Do not export to next AS (well-known community)\n"
10860 "Exact match of the communities")
10862 ALIAS (show_bgp_community_exact
,
10863 show_bgp_ipv6_community2_exact_cmd
,
10864 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10868 "Display routes matching the communities\n"
10870 "Do not send outside local AS (well-known community)\n"
10871 "Do not advertise to any peer (well-known community)\n"
10872 "Do not export to next AS (well-known community)\n"
10874 "Do not send outside local AS (well-known community)\n"
10875 "Do not advertise to any peer (well-known community)\n"
10876 "Do not export to next AS (well-known community)\n"
10877 "Exact match of the communities")
10879 ALIAS (show_bgp_community_exact
,
10880 show_bgp_community3_exact_cmd
,
10881 "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",
10884 "Display routes matching the communities\n"
10886 "Do not send outside local AS (well-known community)\n"
10887 "Do not advertise to any peer (well-known community)\n"
10888 "Do not export to next AS (well-known community)\n"
10890 "Do not send outside local AS (well-known community)\n"
10891 "Do not advertise to any peer (well-known community)\n"
10892 "Do not export to next AS (well-known community)\n"
10894 "Do not send outside local AS (well-known community)\n"
10895 "Do not advertise to any peer (well-known community)\n"
10896 "Do not export to next AS (well-known community)\n"
10897 "Exact match of the communities")
10899 ALIAS (show_bgp_community_exact
,
10900 show_bgp_ipv6_community3_exact_cmd
,
10901 "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",
10905 "Display routes matching the communities\n"
10907 "Do not send outside local AS (well-known community)\n"
10908 "Do not advertise to any peer (well-known community)\n"
10909 "Do not export to next AS (well-known community)\n"
10911 "Do not send outside local AS (well-known community)\n"
10912 "Do not advertise to any peer (well-known community)\n"
10913 "Do not export to next AS (well-known community)\n"
10915 "Do not send outside local AS (well-known community)\n"
10916 "Do not advertise to any peer (well-known community)\n"
10917 "Do not export to next AS (well-known community)\n"
10918 "Exact match of the communities")
10920 ALIAS (show_bgp_community_exact
,
10921 show_bgp_community4_exact_cmd
,
10922 "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",
10925 "Display routes matching the communities\n"
10927 "Do not send outside local AS (well-known community)\n"
10928 "Do not advertise to any peer (well-known community)\n"
10929 "Do not export to next AS (well-known community)\n"
10931 "Do not send outside local AS (well-known community)\n"
10932 "Do not advertise to any peer (well-known community)\n"
10933 "Do not export to next AS (well-known community)\n"
10935 "Do not send outside local AS (well-known community)\n"
10936 "Do not advertise to any peer (well-known community)\n"
10937 "Do not export to next AS (well-known community)\n"
10939 "Do not send outside local AS (well-known community)\n"
10940 "Do not advertise to any peer (well-known community)\n"
10941 "Do not export to next AS (well-known community)\n"
10942 "Exact match of the communities")
10944 ALIAS (show_bgp_community_exact
,
10945 show_bgp_ipv6_community4_exact_cmd
,
10946 "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",
10950 "Display routes matching the communities\n"
10952 "Do not send outside local AS (well-known community)\n"
10953 "Do not advertise to any peer (well-known community)\n"
10954 "Do not export to next AS (well-known community)\n"
10956 "Do not send outside local AS (well-known community)\n"
10957 "Do not advertise to any peer (well-known community)\n"
10958 "Do not export to next AS (well-known community)\n"
10960 "Do not send outside local AS (well-known community)\n"
10961 "Do not advertise to any peer (well-known community)\n"
10962 "Do not export to next AS (well-known community)\n"
10964 "Do not send outside local AS (well-known community)\n"
10965 "Do not advertise to any peer (well-known community)\n"
10966 "Do not export to next AS (well-known community)\n"
10967 "Exact match of the communities")
10970 DEFUN (show_ipv6_bgp_community_exact
,
10971 show_ipv6_bgp_community_exact_cmd
,
10972 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10976 "Display routes matching the communities\n"
10978 "Do not send outside local AS (well-known community)\n"
10979 "Do not advertise to any peer (well-known community)\n"
10980 "Do not export to next AS (well-known community)\n"
10981 "Exact match of the communities")
10983 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10984 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10988 ALIAS (show_ipv6_bgp_community_exact
,
10989 show_ipv6_bgp_community2_exact_cmd
,
10990 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10994 "Display routes matching the communities\n"
10996 "Do not send outside local AS (well-known community)\n"
10997 "Do not advertise to any peer (well-known community)\n"
10998 "Do not export to next AS (well-known community)\n"
11000 "Do not send outside local AS (well-known community)\n"
11001 "Do not advertise to any peer (well-known community)\n"
11002 "Do not export to next AS (well-known community)\n"
11003 "Exact match of the communities")
11006 ALIAS (show_ipv6_bgp_community_exact
,
11007 show_ipv6_bgp_community3_exact_cmd
,
11008 "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",
11012 "Display routes matching the communities\n"
11014 "Do not send outside local AS (well-known community)\n"
11015 "Do not advertise to any peer (well-known community)\n"
11016 "Do not export to next AS (well-known community)\n"
11018 "Do not send outside local AS (well-known community)\n"
11019 "Do not advertise to any peer (well-known community)\n"
11020 "Do not export to next AS (well-known community)\n"
11022 "Do not send outside local AS (well-known community)\n"
11023 "Do not advertise to any peer (well-known community)\n"
11024 "Do not export to next AS (well-known community)\n"
11025 "Exact match of the communities")
11028 ALIAS (show_ipv6_bgp_community_exact
,
11029 show_ipv6_bgp_community4_exact_cmd
,
11030 "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",
11034 "Display routes matching the communities\n"
11036 "Do not send outside local AS (well-known community)\n"
11037 "Do not advertise to any peer (well-known community)\n"
11038 "Do not export to next AS (well-known community)\n"
11040 "Do not send outside local AS (well-known community)\n"
11041 "Do not advertise to any peer (well-known community)\n"
11042 "Do not export to next AS (well-known community)\n"
11044 "Do not send outside local AS (well-known community)\n"
11045 "Do not advertise to any peer (well-known community)\n"
11046 "Do not export to next AS (well-known community)\n"
11048 "Do not send outside local AS (well-known community)\n"
11049 "Do not advertise to any peer (well-known community)\n"
11050 "Do not export to next AS (well-known community)\n"
11051 "Exact match of the communities")
11054 DEFUN (show_ipv6_mbgp_community
,
11055 show_ipv6_mbgp_community_cmd
,
11056 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
11060 "Display routes matching the communities\n"
11062 "Do not send outside local AS (well-known community)\n"
11063 "Do not advertise to any peer (well-known community)\n"
11064 "Do not export to next AS (well-known community)\n")
11066 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11067 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
11071 ALIAS (show_ipv6_mbgp_community
,
11072 show_ipv6_mbgp_community2_cmd
,
11073 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
11077 "Display routes matching the communities\n"
11079 "Do not send outside local AS (well-known community)\n"
11080 "Do not advertise to any peer (well-known community)\n"
11081 "Do not export to next AS (well-known community)\n"
11083 "Do not send outside local AS (well-known community)\n"
11084 "Do not advertise to any peer (well-known community)\n"
11085 "Do not export to next AS (well-known community)\n")
11088 ALIAS (show_ipv6_mbgp_community
,
11089 show_ipv6_mbgp_community3_cmd
,
11090 "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)",
11094 "Display routes matching the communities\n"
11096 "Do not send outside local AS (well-known community)\n"
11097 "Do not advertise to any peer (well-known community)\n"
11098 "Do not export to next AS (well-known community)\n"
11100 "Do not send outside local AS (well-known community)\n"
11101 "Do not advertise to any peer (well-known community)\n"
11102 "Do not export to next AS (well-known community)\n"
11104 "Do not send outside local AS (well-known community)\n"
11105 "Do not advertise to any peer (well-known community)\n"
11106 "Do not export to next AS (well-known community)\n")
11109 ALIAS (show_ipv6_mbgp_community
,
11110 show_ipv6_mbgp_community4_cmd
,
11111 "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)",
11115 "Display routes matching the communities\n"
11117 "Do not send outside local AS (well-known community)\n"
11118 "Do not advertise to any peer (well-known community)\n"
11119 "Do not export to next AS (well-known community)\n"
11121 "Do not send outside local AS (well-known community)\n"
11122 "Do not advertise to any peer (well-known community)\n"
11123 "Do not export to next AS (well-known community)\n"
11125 "Do not send outside local AS (well-known community)\n"
11126 "Do not advertise to any peer (well-known community)\n"
11127 "Do not export to next AS (well-known community)\n"
11129 "Do not send outside local AS (well-known community)\n"
11130 "Do not advertise to any peer (well-known community)\n"
11131 "Do not export to next AS (well-known community)\n")
11134 DEFUN (show_ipv6_mbgp_community_exact
,
11135 show_ipv6_mbgp_community_exact_cmd
,
11136 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
11140 "Display routes matching the communities\n"
11142 "Do not send outside local AS (well-known community)\n"
11143 "Do not advertise to any peer (well-known community)\n"
11144 "Do not export to next AS (well-known community)\n"
11145 "Exact match of the communities")
11147 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11148 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
11152 ALIAS (show_ipv6_mbgp_community_exact
,
11153 show_ipv6_mbgp_community2_exact_cmd
,
11154 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11158 "Display routes matching the communities\n"
11160 "Do not send outside local AS (well-known community)\n"
11161 "Do not advertise to any peer (well-known community)\n"
11162 "Do not export to next AS (well-known community)\n"
11164 "Do not send outside local AS (well-known community)\n"
11165 "Do not advertise to any peer (well-known community)\n"
11166 "Do not export to next AS (well-known community)\n"
11167 "Exact match of the communities")
11170 ALIAS (show_ipv6_mbgp_community_exact
,
11171 show_ipv6_mbgp_community3_exact_cmd
,
11172 "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",
11176 "Display routes matching the communities\n"
11178 "Do not send outside local AS (well-known community)\n"
11179 "Do not advertise to any peer (well-known community)\n"
11180 "Do not export to next AS (well-known community)\n"
11182 "Do not send outside local AS (well-known community)\n"
11183 "Do not advertise to any peer (well-known community)\n"
11184 "Do not export to next AS (well-known community)\n"
11186 "Do not send outside local AS (well-known community)\n"
11187 "Do not advertise to any peer (well-known community)\n"
11188 "Do not export to next AS (well-known community)\n"
11189 "Exact match of the communities")
11192 ALIAS (show_ipv6_mbgp_community_exact
,
11193 show_ipv6_mbgp_community4_exact_cmd
,
11194 "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",
11198 "Display routes matching the communities\n"
11200 "Do not send outside local AS (well-known community)\n"
11201 "Do not advertise to any peer (well-known community)\n"
11202 "Do not export to next AS (well-known community)\n"
11204 "Do not send outside local AS (well-known community)\n"
11205 "Do not advertise to any peer (well-known community)\n"
11206 "Do not export to next AS (well-known community)\n"
11208 "Do not send outside local AS (well-known community)\n"
11209 "Do not advertise to any peer (well-known community)\n"
11210 "Do not export to next AS (well-known community)\n"
11212 "Do not send outside local AS (well-known community)\n"
11213 "Do not advertise to any peer (well-known community)\n"
11214 "Do not export to next AS (well-known community)\n"
11215 "Exact match of the communities")
11216 #endif /* HAVE_IPV6 */
11219 bgp_show_community_list (struct vty
*vty
, const char *name
,
11220 const char *com
, int exact
,
11221 afi_t afi
, safi_t safi
)
11223 struct community_list
*list
;
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
;
11232 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
11235 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
11237 return CMD_WARNING
;
11240 return bgp_show (vty
, bgp
, afi
, safi
,
11241 (exact
? bgp_show_type_community_list_exact
:
11242 bgp_show_type_community_list
), list
, 0);
11245 DEFUN (show_ip_bgp_community_list
,
11246 show_ip_bgp_community_list_cmd
,
11247 "show ip bgp community-list (<1-500>|WORD)",
11251 "Display routes matching the community-list\n"
11252 "community-list number\n"
11253 "community-list name\n")
11255 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
11258 DEFUN (show_ip_bgp_instance_community_list
,
11259 show_ip_bgp_instance_community_list_cmd
,
11260 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
11264 BGP_INSTANCE_HELP_STR
11265 "Display routes matching the community-list\n"
11266 "community-list number\n"
11267 "community-list name\n")
11269 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
11272 DEFUN (show_ip_bgp_ipv4_community_list
,
11273 show_ip_bgp_ipv4_community_list_cmd
,
11274 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11279 "Address Family modifier\n"
11280 "Address Family modifier\n"
11281 "Display routes matching the community-list\n"
11282 "community-list number\n"
11283 "community-list name\n")
11285 if (strncmp (argv
[0], "m", 1) == 0)
11286 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
11288 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
11291 DEFUN (show_ip_bgp_community_list_exact
,
11292 show_ip_bgp_community_list_exact_cmd
,
11293 "show ip bgp community-list (<1-500>|WORD) exact-match",
11297 "Display routes matching the community-list\n"
11298 "community-list number\n"
11299 "community-list name\n"
11300 "Exact match of the communities\n")
11302 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
11305 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
11306 show_ip_bgp_ipv4_community_list_exact_cmd
,
11307 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11312 "Address Family modifier\n"
11313 "Address Family modifier\n"
11314 "Display routes matching the community-list\n"
11315 "community-list number\n"
11316 "community-list name\n"
11317 "Exact match of the communities\n")
11319 if (strncmp (argv
[0], "m", 1) == 0)
11320 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
11322 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
11326 DEFUN (show_bgp_community_list
,
11327 show_bgp_community_list_cmd
,
11328 "show bgp community-list (<1-500>|WORD)",
11331 "Display routes matching the community-list\n"
11332 "community-list number\n"
11333 "community-list name\n")
11335 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11338 ALIAS (show_bgp_community_list
,
11339 show_bgp_ipv6_community_list_cmd
,
11340 "show bgp ipv6 community-list (<1-500>|WORD)",
11344 "Display routes matching the community-list\n"
11345 "community-list number\n"
11346 "community-list name\n")
11349 DEFUN (show_ipv6_bgp_community_list
,
11350 show_ipv6_bgp_community_list_cmd
,
11351 "show ipv6 bgp community-list WORD",
11355 "Display routes matching the community-list\n"
11356 "community-list name\n")
11358 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11359 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11363 DEFUN (show_ipv6_mbgp_community_list
,
11364 show_ipv6_mbgp_community_list_cmd
,
11365 "show ipv6 mbgp community-list WORD",
11369 "Display routes matching the community-list\n"
11370 "community-list name\n")
11372 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11373 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
11376 DEFUN (show_bgp_community_list_exact
,
11377 show_bgp_community_list_exact_cmd
,
11378 "show bgp community-list (<1-500>|WORD) exact-match",
11381 "Display routes matching the community-list\n"
11382 "community-list number\n"
11383 "community-list name\n"
11384 "Exact match of the communities\n")
11386 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11389 ALIAS (show_bgp_community_list_exact
,
11390 show_bgp_ipv6_community_list_exact_cmd
,
11391 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11395 "Display routes matching the community-list\n"
11396 "community-list number\n"
11397 "community-list name\n"
11398 "Exact match of the communities\n")
11401 DEFUN (show_ipv6_bgp_community_list_exact
,
11402 show_ipv6_bgp_community_list_exact_cmd
,
11403 "show ipv6 bgp community-list WORD exact-match",
11407 "Display routes matching the community-list\n"
11408 "community-list name\n"
11409 "Exact match of the communities\n")
11411 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11412 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11416 DEFUN (show_ipv6_mbgp_community_list_exact
,
11417 show_ipv6_mbgp_community_list_exact_cmd
,
11418 "show ipv6 mbgp community-list WORD exact-match",
11422 "Display routes matching the community-list\n"
11423 "community-list name\n"
11424 "Exact match of the communities\n")
11426 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11427 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
11429 #endif /* HAVE_IPV6 */
11432 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11433 const char *prefix
, afi_t afi
,
11434 safi_t safi
, enum bgp_show_type type
)
11438 struct bgp
*bgp
= NULL
;
11440 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11442 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11443 return CMD_WARNING
;
11448 ret
= str2prefix (prefix
, p
);
11451 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11452 return CMD_WARNING
;
11455 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11460 DEFUN (show_ip_bgp_prefix_longer
,
11461 show_ip_bgp_prefix_longer_cmd
,
11462 "show ip bgp A.B.C.D/M longer-prefixes",
11466 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11467 "Display route and more specific routes\n")
11469 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11470 bgp_show_type_prefix_longer
);
11473 DEFUN (show_ip_bgp_instance_prefix_longer
,
11474 show_ip_bgp_instance_prefix_longer_cmd
,
11475 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11479 BGP_INSTANCE_HELP_STR
11480 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11481 "Display route and more specific routes\n")
11483 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
11484 bgp_show_type_prefix_longer
);
11487 DEFUN (show_ip_bgp_flap_prefix_longer
,
11488 show_ip_bgp_flap_prefix_longer_cmd
,
11489 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11493 "Display flap statistics of routes\n"
11494 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11495 "Display route and more specific routes\n")
11497 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11498 bgp_show_type_flap_prefix_longer
);
11501 ALIAS (show_ip_bgp_flap_prefix_longer
,
11502 show_ip_bgp_damp_flap_prefix_longer_cmd
,
11503 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11507 "Display detailed information about dampening\n"
11508 "Display flap statistics of routes\n"
11509 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11510 "Display route and more specific routes\n")
11512 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11513 show_ip_bgp_ipv4_prefix_longer_cmd
,
11514 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11519 "Address Family modifier\n"
11520 "Address Family modifier\n"
11521 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11522 "Display route and more specific routes\n")
11524 if (strncmp (argv
[0], "m", 1) == 0)
11525 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
11526 bgp_show_type_prefix_longer
);
11528 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
11529 bgp_show_type_prefix_longer
);
11532 DEFUN (show_ip_bgp_flap_address
,
11533 show_ip_bgp_flap_address_cmd
,
11534 "show ip bgp flap-statistics A.B.C.D",
11538 "Display flap statistics of routes\n"
11539 "Network in the BGP routing table to display\n")
11541 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11542 bgp_show_type_flap_address
);
11545 ALIAS (show_ip_bgp_flap_address
,
11546 show_ip_bgp_damp_flap_address_cmd
,
11547 "show ip bgp dampening flap-statistics A.B.C.D",
11551 "Display detailed information about dampening\n"
11552 "Display flap statistics of routes\n"
11553 "Network in the BGP routing table to display\n")
11555 DEFUN (show_ip_bgp_flap_prefix
,
11556 show_ip_bgp_flap_prefix_cmd
,
11557 "show ip bgp flap-statistics A.B.C.D/M",
11561 "Display flap statistics of routes\n"
11562 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11564 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11565 bgp_show_type_flap_prefix
);
11568 ALIAS (show_ip_bgp_flap_prefix
,
11569 show_ip_bgp_damp_flap_prefix_cmd
,
11570 "show ip bgp dampening flap-statistics A.B.C.D/M",
11574 "Display detailed information about dampening\n"
11575 "Display flap statistics of routes\n"
11576 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11579 DEFUN (show_bgp_prefix_longer
,
11580 show_bgp_prefix_longer_cmd
,
11581 "show bgp X:X::X:X/M longer-prefixes",
11584 "IPv6 prefix <network>/<length>\n"
11585 "Display route and more specific routes\n")
11587 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11588 bgp_show_type_prefix_longer
);
11591 ALIAS (show_bgp_prefix_longer
,
11592 show_bgp_ipv6_prefix_longer_cmd
,
11593 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11597 "IPv6 prefix <network>/<length>\n"
11598 "Display route and more specific routes\n")
11601 DEFUN (show_ipv6_bgp_prefix_longer
,
11602 show_ipv6_bgp_prefix_longer_cmd
,
11603 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11607 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11608 "Display route and more specific routes\n")
11610 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11611 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11612 bgp_show_type_prefix_longer
);
11616 DEFUN (show_ipv6_mbgp_prefix_longer
,
11617 show_ipv6_mbgp_prefix_longer_cmd
,
11618 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11622 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11623 "Display route and more specific routes\n")
11625 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11626 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11627 bgp_show_type_prefix_longer
);
11629 #endif /* HAVE_IPV6 */
11631 static struct peer
*
11632 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11633 const char *ip_str
, u_char use_json
)
11638 union sockunion su
;
11640 /* BGP structure lookup. */
11643 bgp
= bgp_lookup_by_name (view_name
);
11648 json_object
*json_no
= NULL
;
11649 json_no
= json_object_new_object();
11650 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11651 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11652 json_object_free(json_no
);
11655 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11661 bgp
= bgp_get_default ();
11666 json_object
*json_no
= NULL
;
11667 json_no
= json_object_new_object();
11668 json_object_string_add(json_no
, "warning", "No BGP process configured");
11669 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11670 json_object_free(json_no
);
11673 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11678 /* Get peer sockunion. */
11679 ret
= str2sockunion (ip_str
, &su
);
11682 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11685 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11691 json_object
*json_no
= NULL
;
11692 json_no
= json_object_new_object();
11693 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11694 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11695 json_object_free(json_no
);
11698 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11705 /* Peer structure lookup. */
11706 peer
= peer_lookup (bgp
, &su
);
11711 json_object
*json_no
= NULL
;
11712 json_no
= json_object_new_object();
11713 json_object_string_add(json_no
, "warning","No such neighbor");
11714 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11715 json_object_free(json_no
);
11718 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11727 BGP_STATS_MAXBITLEN
= 0,
11729 BGP_STATS_PREFIXES
,
11731 BGP_STATS_UNAGGREGATEABLE
,
11732 BGP_STATS_MAX_AGGREGATEABLE
,
11733 BGP_STATS_AGGREGATES
,
11735 BGP_STATS_ASPATH_COUNT
,
11736 BGP_STATS_ASPATH_MAXHOPS
,
11737 BGP_STATS_ASPATH_TOTHOPS
,
11738 BGP_STATS_ASPATH_MAXSIZE
,
11739 BGP_STATS_ASPATH_TOTSIZE
,
11740 BGP_STATS_ASN_HIGHEST
,
11744 static const char *table_stats_strs
[] =
11746 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11747 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11748 [BGP_STATS_RIB
] = "Total Advertisements",
11749 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11750 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11751 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11752 [BGP_STATS_SPACE
] = "Address space advertised",
11753 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11754 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11755 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11756 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11757 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11758 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11759 [BGP_STATS_MAX
] = NULL
,
11762 struct bgp_table_stats
11764 struct bgp_table
*table
;
11765 unsigned long long counts
[BGP_STATS_MAX
];
11769 #define TALLY_SIGFIG 100000
11770 static unsigned long
11771 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11773 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11774 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11775 unsigned long ret
= newtot
/ count
;
11777 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11785 bgp_table_stats_walker (struct thread
*t
)
11787 struct bgp_node
*rn
;
11788 struct bgp_node
*top
;
11789 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11790 unsigned int space
= 0;
11792 if (!(top
= bgp_table_top (ts
->table
)))
11795 switch (top
->p
.family
)
11798 space
= IPV4_MAX_BITLEN
;
11801 space
= IPV6_MAX_BITLEN
;
11805 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11807 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11809 struct bgp_info
*ri
;
11810 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11811 unsigned int rinum
= 0;
11819 ts
->counts
[BGP_STATS_PREFIXES
]++;
11820 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11823 ts
->counts
[BGP_STATS_AVGPLEN
]
11824 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11825 ts
->counts
[BGP_STATS_AVGPLEN
],
11829 /* check if the prefix is included by any other announcements */
11830 while (prn
&& !prn
->info
)
11831 prn
= bgp_node_parent_nolock (prn
);
11833 if (prn
== NULL
|| prn
== top
)
11835 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11836 /* announced address space */
11838 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11840 else if (prn
->info
)
11841 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11843 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11846 ts
->counts
[BGP_STATS_RIB
]++;
11849 (CHECK_FLAG (ri
->attr
->flag
,
11850 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11851 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11853 /* as-path stats */
11854 if (ri
->attr
&& ri
->attr
->aspath
)
11856 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11857 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11858 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11860 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11862 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11863 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11865 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11866 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11868 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11869 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11871 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11872 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11873 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11875 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11876 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11877 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11880 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11881 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11889 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11891 struct bgp_table_stats ts
;
11894 if (!bgp
->rib
[afi
][safi
])
11896 vty_out (vty
, "%% No RIB exists for the AFI(%d)/SAFI(%d)%s",
11897 afi
, safi
, VTY_NEWLINE
);
11898 return CMD_WARNING
;
11901 memset (&ts
, 0, sizeof (ts
));
11902 ts
.table
= bgp
->rib
[afi
][safi
];
11903 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11905 vty_out (vty
, "BGP %s RIB statistics%s%s",
11906 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11908 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11910 if (!table_stats_strs
[i
])
11916 case BGP_STATS_ASPATH_AVGHOPS
:
11917 case BGP_STATS_ASPATH_AVGSIZE
:
11918 case BGP_STATS_AVGPLEN
:
11919 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11920 vty_out (vty
, "%12.2f",
11921 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11924 case BGP_STATS_ASPATH_TOTHOPS
:
11925 case BGP_STATS_ASPATH_TOTSIZE
:
11926 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11927 vty_out (vty
, "%12.2f",
11929 (float)ts
.counts
[i
] /
11930 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11933 case BGP_STATS_TOTPLEN
:
11934 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11935 vty_out (vty
, "%12.2f",
11937 (float)ts
.counts
[i
] /
11938 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11941 case BGP_STATS_SPACE
:
11942 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11943 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11944 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11946 vty_out (vty
, "%30s: ", "%% announced ");
11947 vty_out (vty
, "%12.2f%s",
11948 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11949 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11951 vty_out (vty
, "%30s: ", "/8 equivalent ");
11952 vty_out (vty
, "%12.2f%s",
11953 (float)ts
.counts
[BGP_STATS_SPACE
] /
11954 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11956 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11958 vty_out (vty
, "%30s: ", "/24 equivalent ");
11959 vty_out (vty
, "%12.2f",
11960 (float)ts
.counts
[BGP_STATS_SPACE
] /
11961 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11964 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11965 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11968 vty_out (vty
, "%s", VTY_NEWLINE
);
11970 return CMD_SUCCESS
;
11974 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11975 const char *afi_str
, const char *safi_str
)
11982 bgp
= bgp_lookup_by_name (name
);
11984 bgp
= bgp_get_default ();
11988 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11989 return CMD_WARNING
;
11991 if (strncmp (afi_str
, "ipv", 3) == 0)
11993 if (strncmp (afi_str
, "ipv4", 4) == 0)
11995 else if (strncmp (afi_str
, "ipv6", 4) == 0)
11999 vty_out (vty
, "%% Invalid address family %s%s",
12000 afi_str
, VTY_NEWLINE
);
12001 return CMD_WARNING
;
12003 if (strncmp (safi_str
, "m", 1) == 0)
12004 safi
= SAFI_MULTICAST
;
12005 else if (strncmp (safi_str
, "u", 1) == 0)
12006 safi
= SAFI_UNICAST
;
12007 else if (strncmp (safi_str
, "e", 1) == 0)
12009 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
12010 safi
= SAFI_MPLS_VPN
;
12013 vty_out (vty
, "%% Invalid subsequent address family %s%s",
12014 safi_str
, VTY_NEWLINE
);
12015 return CMD_WARNING
;
12020 vty_out (vty
, "%% Invalid address family \"%s\"%s",
12021 afi_str
, VTY_NEWLINE
);
12022 return CMD_WARNING
;
12025 return bgp_table_stats (vty
, bgp
, afi
, safi
);
12028 DEFUN (show_bgp_statistics
,
12029 show_bgp_statistics_cmd
,
12030 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
12035 "Address Family modifier\n"
12036 "Address Family modifier\n"
12037 "Address Family modifier\n"
12038 "Address Family modifier\n"
12039 "BGP RIB advertisement statistics\n")
12041 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
12044 DEFUN (show_bgp_statistics_view
,
12045 show_bgp_statistics_view_cmd
,
12046 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics",
12049 BGP_INSTANCE_HELP_STR
12052 "Address Family modifier\n"
12053 "Address Family modifier\n"
12054 "Address Family modifier\n"
12055 "Address Family modifier\n"
12056 "BGP RIB advertisement statistics\n")
12058 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
12071 PCOUNT_PFCNT
, /* the figure we display to users */
12075 static const char *pcount_strs
[] =
12077 [PCOUNT_ADJ_IN
] = "Adj-in",
12078 [PCOUNT_DAMPED
] = "Damped",
12079 [PCOUNT_REMOVED
] = "Removed",
12080 [PCOUNT_HISTORY
] = "History",
12081 [PCOUNT_STALE
] = "Stale",
12082 [PCOUNT_VALID
] = "Valid",
12083 [PCOUNT_ALL
] = "All RIB",
12084 [PCOUNT_COUNTED
] = "PfxCt counted",
12085 [PCOUNT_PFCNT
] = "Useable",
12086 [PCOUNT_MAX
] = NULL
,
12089 struct peer_pcounts
12091 unsigned int count
[PCOUNT_MAX
];
12092 const struct peer
*peer
;
12093 const struct bgp_table
*table
;
12097 bgp_peer_count_walker (struct thread
*t
)
12099 struct bgp_node
*rn
;
12100 struct peer_pcounts
*pc
= THREAD_ARG (t
);
12101 const struct peer
*peer
= pc
->peer
;
12103 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
12105 struct bgp_adj_in
*ain
;
12106 struct bgp_info
*ri
;
12108 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12109 if (ain
->peer
== peer
)
12110 pc
->count
[PCOUNT_ADJ_IN
]++;
12112 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
12114 char buf
[SU_ADDRSTRLEN
];
12116 if (ri
->peer
!= peer
)
12119 pc
->count
[PCOUNT_ALL
]++;
12121 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
12122 pc
->count
[PCOUNT_DAMPED
]++;
12123 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
12124 pc
->count
[PCOUNT_HISTORY
]++;
12125 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
12126 pc
->count
[PCOUNT_REMOVED
]++;
12127 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
12128 pc
->count
[PCOUNT_STALE
]++;
12129 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
12130 pc
->count
[PCOUNT_VALID
]++;
12131 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12132 pc
->count
[PCOUNT_PFCNT
]++;
12134 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
12136 pc
->count
[PCOUNT_COUNTED
]++;
12137 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12138 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
12140 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12141 buf
, SU_ADDRSTRLEN
),
12147 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12148 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
12150 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12151 buf
, SU_ADDRSTRLEN
),
12161 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
12163 struct peer_pcounts pcounts
= { .peer
= peer
};
12165 json_object
*json
= NULL
;
12166 json_object
*json_loop
= NULL
;
12170 json
= json_object_new_object();
12171 json_loop
= json_object_new_object();
12174 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
12175 || !peer
->bgp
->rib
[afi
][safi
])
12179 json_object_string_add(json
, "warning", "No such neighbor or address family");
12180 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12181 json_object_free(json
);
12184 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12186 return CMD_WARNING
;
12189 memset (&pcounts
, 0, sizeof(pcounts
));
12190 pcounts
.peer
= peer
;
12191 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
12193 /* in-place call via thread subsystem so as to record execution time
12194 * * stats for the thread-walk (i.e. ensure this can't be blamed on
12195 * * on just vty_read()).
12197 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
12201 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
12202 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
12203 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
12205 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12206 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
12208 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
12210 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12212 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
12213 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
12215 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12216 json_object_free(json
);
12221 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
12223 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
12224 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
12229 vty_out (vty
, "Prefix counts for %s, %s%s",
12230 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
12233 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
12234 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
12235 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
12237 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12238 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
12240 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12242 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
12243 peer
->host
, VTY_NEWLINE
);
12244 vty_out (vty
, "Please report this bug, with the above command output%s",
12249 return CMD_SUCCESS
;
12252 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
12253 show_ip_bgp_neighbor_prefix_counts_cmd
,
12254 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12258 "Detailed information on TCP and BGP neighbor connections\n"
12259 "Neighbor to display information about\n"
12260 "Neighbor to display information about\n"
12261 "Neighbor on bgp configured interface\n"
12262 "Display detailed prefix count information\n"
12263 "JavaScript Object Notation\n")
12266 u_char uj
= use_json(argc
, argv
);
12268 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12270 return CMD_WARNING
;
12272 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12275 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
12276 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
12277 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12281 BGP_INSTANCE_HELP_STR
12282 "Detailed information on TCP and BGP neighbor connections\n"
12283 "Neighbor to display information about\n"
12284 "Neighbor to display information about\n"
12285 "Neighbor on bgp configured interface\n"
12286 "Display detailed prefix count information\n"
12287 "JavaScript Object Notation\n")
12290 u_char uj
= use_json(argc
, argv
);
12292 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12294 return CMD_WARNING
;
12296 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12299 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
12300 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
12301 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12305 "Detailed information on TCP and BGP neighbor connections\n"
12306 "Neighbor to display information about\n"
12307 "Neighbor to display information about\n"
12308 "Neighbor on bgp configured interface\n"
12309 "Display detailed prefix count information\n"
12310 "JavaScript Object Notation\n")
12313 u_char uj
= use_json(argc
, argv
);
12315 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12317 return CMD_WARNING
;
12319 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12322 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
12323 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
12324 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12327 BGP_INSTANCE_HELP_STR
12329 "Detailed information on TCP and BGP neighbor connections\n"
12330 "Neighbor to display information about\n"
12331 "Neighbor to display information about\n"
12332 "Neighbor on bgp configured interface\n"
12333 "Display detailed prefix count information\n"
12334 "JavaScript Object Notation\n")
12337 u_char uj
= use_json(argc
, argv
);
12339 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12341 return CMD_WARNING
;
12343 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12346 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
12347 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
12348 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12353 "Address Family modifier\n"
12354 "Address Family modifier\n"
12355 "Detailed information on TCP and BGP neighbor connections\n"
12356 "Neighbor to display information about\n"
12357 "Neighbor to display information about\n"
12358 "Neighbor on bgp configured interface\n"
12359 "Display detailed prefix count information\n"
12360 "JavaScript Object Notation\n")
12363 u_char uj
= use_json(argc
, argv
);
12365 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12367 return CMD_WARNING
;
12369 if (strncmp (argv
[0], "m", 1) == 0)
12370 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, uj
);
12372 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12375 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
12376 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
12377 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12382 "Address Family modifier\n"
12383 "Address Family modifier\n"
12384 "Detailed information on TCP and BGP neighbor connections\n"
12385 "Neighbor to display information about\n"
12386 "Neighbor to display information about\n"
12387 "Neighbor on bgp configured interface\n"
12388 "Display detailed prefix count information\n"
12389 "JavaScript Object Notation\n")
12392 u_char uj
= use_json(argc
, argv
);
12394 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12396 return CMD_WARNING
;
12398 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
, uj
);
12402 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12403 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
12405 struct bgp_table
*table
;
12406 struct bgp_adj_in
*ain
;
12407 struct bgp_adj_out
*adj
;
12408 unsigned long output_count
;
12409 unsigned long filtered_count
;
12410 struct bgp_node
*rn
;
12415 struct attr_extra extra
;
12417 struct update_subgroup
*subgrp
;
12418 json_object
*json_scode
= NULL
;
12419 json_object
*json_ocode
= NULL
;
12420 json_object
*json_ar
= NULL
;
12421 struct peer_af
*paf
;
12425 json_scode
= json_object_new_object();
12426 json_ocode
= json_object_new_object();
12427 json_ar
= json_object_new_object();
12429 json_object_string_add(json_scode
, "suppressed", "s");
12430 json_object_string_add(json_scode
, "damped", "d");
12431 json_object_string_add(json_scode
, "history", "h");
12432 json_object_string_add(json_scode
, "valid", "*");
12433 json_object_string_add(json_scode
, "best", ">");
12434 json_object_string_add(json_scode
, "multipath", "=");
12435 json_object_string_add(json_scode
, "internal", "i");
12436 json_object_string_add(json_scode
, "ribFailure", "r");
12437 json_object_string_add(json_scode
, "stale", "S");
12438 json_object_string_add(json_scode
, "removed", "R");
12440 json_object_string_add(json_ocode
, "igp", "i");
12441 json_object_string_add(json_ocode
, "egp", "e");
12442 json_object_string_add(json_ocode
, "incomplete", "?");
12451 json_object_string_add(json
, "alert", "no BGP");
12452 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12453 json_object_free(json
);
12456 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12460 table
= bgp
->rib
[afi
][safi
];
12462 output_count
= filtered_count
= 0;
12463 subgrp
= peer_subgroup(peer
, afi
, safi
);
12465 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12469 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12470 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12471 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12472 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12473 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12477 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12478 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12479 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12481 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12482 VTY_NEWLINE
, VTY_NEWLINE
);
12487 attr
.extra
= &extra
;
12488 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12492 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12494 if (ain
->peer
== peer
)
12500 json_object_int_add(json
, "bgpTableVersion", 0);
12501 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12502 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12503 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12507 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12508 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12509 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12516 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12521 bgp_attr_dup(&attr
, ain
->attr
);
12522 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12524 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12535 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12536 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12537 if (paf
->peer
== peer
)
12543 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12544 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12545 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12546 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12550 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12551 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12552 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12553 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12561 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12567 bgp_attr_dup(&attr
, adj
->attr
);
12568 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12569 if (ret
!= RMAP_DENY
)
12571 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12581 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12583 if (output_count
!= 0)
12586 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12588 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12589 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12593 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12594 json_object_free(json
);
12600 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12601 int in
, const char *rmap_name
, u_char use_json
)
12603 json_object
*json
= NULL
;
12606 json
= json_object_new_object();
12608 if (!peer
|| !peer
->afc
[afi
][safi
])
12612 json_object_string_add(json
, "warning", "No such neighbor or address family");
12613 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12614 json_object_free(json
);
12617 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12619 return CMD_WARNING
;
12622 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12626 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12627 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12628 json_object_free(json
);
12631 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12633 return CMD_WARNING
;
12636 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12638 return CMD_SUCCESS
;
12641 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12642 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12643 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12647 BGP_INSTANCE_HELP_STR
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 "Display the routes advertised to a BGP neighbor\n"
12652 "JavaScript Object Notation\n")
12655 u_char uj
= use_json(argc
, argv
);
12657 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12658 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12660 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12663 return CMD_WARNING
;
12665 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12668 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12669 show_ip_bgp_neighbor_advertised_route_cmd
,
12670 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12674 "Detailed information on TCP and BGP neighbor connections\n"
12675 "Neighbor to display information about\n"
12676 "Neighbor to display information about\n"
12677 "Neighbor on bgp configured interface\n"
12678 "Display the routes advertised to a BGP neighbor\n"
12679 "JavaScript Object Notation\n")
12683 const char *rmap_name
= NULL
;
12684 u_char uj
= use_json(argc
, argv
);
12686 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12689 return CMD_WARNING
;
12691 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12693 rmap_name
= argv
[1];
12695 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12698 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12699 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12700 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12704 "Detailed information on TCP and BGP neighbor connections\n"
12705 "Neighbor to display information about\n"
12706 "Neighbor to display information about\n"
12707 "Neighbor on bgp configured interface\n"
12708 "Display the routes advertised to a BGP neighbor\n"
12709 "JavaScript Object Notation\n")
12711 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12712 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12713 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12717 BGP_INSTANCE_HELP_STR
12718 "Detailed information on TCP and BGP neighbor connections\n"
12719 "Neighbor to display information about\n"
12720 "Neighbor to display information about\n"
12721 "Neighbor on bgp configured interface\n"
12722 "Display the routes advertised to a BGP neighbor\n"
12723 "JavaScript Object Notation\n")
12724 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12725 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12726 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12731 "Address Family modifier\n"
12732 "Address Family modifier\n"
12733 "Detailed information on TCP and BGP neighbor connections\n"
12734 "Neighbor to display information about\n"
12735 "Neighbor to display information about\n"
12736 "Neighbor on bgp configured interface\n"
12737 "Display the routes advertised to a BGP neighbor\n"
12738 "JavaScript Object Notation\n")
12741 const char *rmap_name
= NULL
;
12742 u_char uj
= use_json(argc
, argv
);
12744 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12746 return CMD_WARNING
;
12748 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12749 rmap_name
= argv
[2];
12751 if (strncmp (argv
[0], "m", 1) == 0)
12752 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0, rmap_name
, uj
);
12754 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12757 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12758 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12759 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12764 "Address Family modifier\n"
12765 "Address Family modifier\n"
12766 "Detailed information on TCP and BGP neighbor connections\n"
12767 "Neighbor to display information about\n"
12768 "Neighbor to display information about\n"
12769 "Neighbor on bgp configured interface\n"
12770 "Display the routes advertised to a BGP neighbor\n"
12771 "Route-map to control what is displayed\n"
12772 "JavaScript Object Notation\n")
12775 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12776 show_bgp_instance_neighbor_advertised_route_cmd
,
12777 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12780 BGP_INSTANCE_HELP_STR
12781 "Detailed information on TCP and BGP neighbor connections\n"
12782 "Neighbor to display information about\n"
12783 "Neighbor to display information about\n"
12784 "Neighbor on bgp configured interface\n"
12785 "Display the routes advertised to a BGP neighbor\n"
12786 "JavaScript Object Notation\n")
12789 u_char uj
= use_json(argc
, argv
);
12791 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12792 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12794 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12797 return CMD_WARNING
;
12799 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12802 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12803 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12804 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12807 BGP_INSTANCE_HELP_STR
12809 "Detailed information on TCP and BGP neighbor connections\n"
12810 "Neighbor to display information about\n"
12811 "Neighbor to display information about\n"
12812 "Neighbor on bgp configured interface\n"
12813 "Display the routes advertised to a BGP neighbor\n"
12814 "JavaScript Object Notation\n")
12816 DEFUN (show_bgp_neighbor_advertised_route
,
12817 show_bgp_neighbor_advertised_route_cmd
,
12818 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12821 "Detailed information on TCP and BGP neighbor connections\n"
12822 "Neighbor to display information about\n"
12823 "Neighbor to display information about\n"
12824 "Neighbor on bgp configured interface\n"
12825 "Display the routes advertised to a BGP neighbor\n"
12826 "JavaScript Object Notation\n")
12830 const char *rmap_name
= NULL
;
12831 u_char uj
= use_json(argc
, argv
);
12833 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12836 return CMD_WARNING
;
12838 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12839 rmap_name
= argv
[1];
12841 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12844 ALIAS (show_bgp_neighbor_advertised_route
,
12845 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12846 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
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 routes advertised to a BGP neighbor\n"
12855 "JavaScript Object Notation\n")
12858 ALIAS (show_bgp_neighbor_advertised_route
,
12859 ipv6_bgp_neighbor_advertised_route_cmd
,
12860 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12864 "Detailed information on TCP and BGP neighbor connections\n"
12865 "Neighbor to display information about\n"
12866 "Neighbor to display information about\n"
12867 "Neighbor on bgp configured interface\n"
12868 "Display the routes advertised to a BGP neighbor\n"
12869 "JavaScript Object Notation\n")
12872 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12873 ipv6_mbgp_neighbor_advertised_route_cmd
,
12874 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12878 "Detailed information on TCP and BGP neighbor connections\n"
12879 "Neighbor to display information about\n"
12880 "Neighbor to display information about\n"
12881 "Neighbor on bgp configured interface\n"
12882 "Neighbor on bgp configured interface\n"
12883 "Display the routes advertised to a BGP neighbor\n"
12884 "JavaScript Object Notation\n")
12887 u_char uj
= use_json(argc
, argv
);
12889 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12891 return CMD_WARNING
;
12893 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12894 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12896 #endif /* HAVE_IPV6 */
12898 DEFUN (show_bgp_instance_neighbor_received_routes
,
12899 show_bgp_instance_neighbor_received_routes_cmd
,
12900 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12903 BGP_INSTANCE_HELP_STR
12904 "Detailed information on TCP and BGP neighbor connections\n"
12905 "Neighbor to display information about\n"
12906 "Neighbor to display information about\n"
12907 "Neighbor on bgp configured interface\n"
12908 "Display the received routes from neighbor\n"
12909 "JavaScript Object Notation\n")
12912 u_char uj
= use_json(argc
, argv
);
12914 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12916 return CMD_WARNING
;
12918 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12921 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12922 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12923 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12927 BGP_INSTANCE_HELP_STR
12928 "Detailed information on TCP and BGP neighbor connections\n"
12929 "Neighbor to display information about\n"
12930 "Neighbor to display information about\n"
12931 "Neighbor on bgp configured interface\n"
12932 "Display the received routes from neighbor\n"
12933 "JavaScript Object Notation\n")
12936 u_char uj
= use_json(argc
, argv
);
12938 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12940 return CMD_WARNING
;
12942 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12945 ALIAS (show_bgp_instance_neighbor_received_routes
,
12946 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12947 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12950 BGP_INSTANCE_HELP_STR
12952 "Detailed information on TCP and BGP neighbor connections\n"
12953 "Neighbor to display information about\n"
12954 "Neighbor to display information about\n"
12955 "Neighbor on bgp configured interface\n"
12956 "Display the received routes from neighbor\n"
12957 "JavaScript Object Notation\n")
12959 DEFUN (show_ip_bgp_neighbor_received_routes
,
12960 show_ip_bgp_neighbor_received_routes_cmd
,
12961 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12965 "Detailed information on TCP and BGP neighbor connections\n"
12966 "Neighbor to display information about\n"
12967 "Neighbor to display information about\n"
12968 "Neighbor on bgp configured interface\n"
12969 "Display the received routes from neighbor\n"
12970 "JavaScript Object Notation\n")
12974 const char *rmap_name
= NULL
;
12975 u_char uj
= use_json(argc
, argv
);
12977 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12980 return CMD_WARNING
;
12982 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12983 rmap_name
= argv
[1];
12985 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12988 ALIAS (show_ip_bgp_neighbor_received_routes
,
12989 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12990 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12994 "Detailed information on TCP and BGP neighbor connections\n"
12995 "Neighbor to display information about\n"
12996 "Neighbor to display information about\n"
12997 "Neighbor on bgp configured interface\n"
12998 "Display the received routes from neighbor\n"
12999 "JavaScript Object Notation\n")
13001 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
13002 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
13003 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
13007 BGP_INSTANCE_HELP_STR
13008 "Detailed information on TCP and BGP neighbor connections\n"
13009 "Neighbor to display information about\n"
13010 "Neighbor to display information about\n"
13011 "Neighbor on bgp configured interface\n"
13012 "Display the received routes from neighbor\n"
13013 "JavaScript Object Notation\n")
13015 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
13016 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
13017 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13022 "Address Family modifier\n"
13023 "Address Family modifier\n"
13024 "Detailed information on TCP and BGP neighbor connections\n"
13025 "Neighbor to display information about\n"
13026 "Neighbor to display information about\n"
13027 "Neighbor on bgp configured interface\n"
13028 "Display the received routes from neighbor\n"
13029 "JavaScript Object Notation\n")
13032 const char *rmap_name
= NULL
;
13033 u_char uj
= use_json(argc
, argv
);
13035 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13037 return CMD_WARNING
;
13039 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13040 rmap_name
= argv
[2];
13042 if (strncmp (argv
[0], "m", 1) == 0)
13043 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1, rmap_name
, uj
);
13045 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13048 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
13049 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
13050 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
13055 "Address Family modifier\n"
13056 "Address Family modifier\n"
13057 "Detailed information on TCP and BGP neighbor connections\n"
13058 "Neighbor to display information about\n"
13059 "Neighbor to display information about\n"
13060 "Neighbor on bgp configured interface\n"
13061 "Display the received routes from neighbor\n"
13062 "JavaScript Object Notation\n")
13064 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
13065 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
13066 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
13069 BGP_INSTANCE_HELP_STR
13072 "Address family modifier\n"
13073 "Address family modifier\n"
13074 "Detailed information on TCP and BGP neighbor connections\n"
13075 "Neighbor to display information about\n"
13076 "Neighbor to display information about\n"
13077 "Neighbor on bgp configured interface\n"
13078 "Display the advertised routes to neighbor\n"
13079 "Display the received routes from neighbor\n"
13080 "JavaScript Object Notation\n")
13086 u_char uj
= use_json(argc
, argv
);
13088 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
13091 return CMD_WARNING
;
13093 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
13094 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
13095 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
13097 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
13100 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
13101 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
13102 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13106 "Detailed information on TCP and BGP neighbor connections\n"
13107 "Neighbor to display information about\n"
13108 "Neighbor to display information about\n"
13109 "Neighbor on bgp configured interface\n"
13110 "Display information received from a BGP neighbor\n"
13111 "Display the prefixlist filter\n"
13112 "JavaScript Object Notation\n")
13115 union sockunion su
;
13118 u_char uj
= use_json(argc
, argv
);
13120 ret
= str2sockunion (argv
[0], &su
);
13123 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13128 json_object
*json_no
= NULL
;
13129 json_object
*json_sub
= NULL
;
13130 json_no
= json_object_new_object();
13131 json_sub
= json_object_new_object();
13132 json_object_string_add(json_no
, "warning", "Malformed address or name");
13133 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13134 json_object_object_add(json_no
, "detail", json_sub
);
13135 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13136 json_object_free(json_no
);
13139 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13140 return CMD_WARNING
;
13145 peer
= peer_lookup (NULL
, &su
);
13150 json_object
*json_no
= NULL
;
13151 json_no
= json_object_new_object();
13152 json_object_string_add(json_no
, "warning", "Peer not found");
13153 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13154 json_object_free(json_no
);
13157 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13158 return CMD_WARNING
;
13162 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
13163 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13167 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
13168 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13174 json_object
*json_no
= NULL
;
13175 json_no
= json_object_new_object();
13176 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13177 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13178 json_object_free(json_no
);
13181 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13184 return CMD_SUCCESS
;
13187 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
13188 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
13189 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13194 "Address Family modifier\n"
13195 "Address Family modifier\n"
13196 "Detailed information on TCP and BGP neighbor connections\n"
13197 "Neighbor to display information about\n"
13198 "Neighbor to display information about\n"
13199 "Neighbor on bgp configured interface\n"
13200 "Display information received from a BGP neighbor\n"
13201 "Display the prefixlist filter\n"
13202 "JavaScript Object Notation\n")
13205 union sockunion su
;
13208 u_char uj
= use_json(argc
, argv
);
13210 ret
= str2sockunion (argv
[1], &su
);
13213 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
13218 json_object
*json_no
= NULL
;
13219 json_object
*json_sub
= NULL
;
13220 json_no
= json_object_new_object();
13221 json_sub
= json_object_new_object();
13222 json_object_string_add(json_no
, "warning", "Malformed address or name");
13223 json_object_string_add(json_sub
, "warningCause", argv
[1]);
13224 json_object_object_add(json_no
, "detail", json_sub
);
13225 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13226 json_object_free(json_no
);
13229 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
13230 return CMD_WARNING
;
13235 peer
= peer_lookup (NULL
, &su
);
13240 json_object
*json_no
= NULL
;
13241 json_no
= json_object_new_object();
13242 json_object_string_add(json_no
, "warning", "Peer not found");
13243 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13244 json_object_free(json_no
);
13247 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13248 return CMD_WARNING
;
13252 if (strncmp (argv
[0], "m", 1) == 0)
13254 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
13255 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13259 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
13260 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13266 json_object
*json_no
= NULL
;
13267 json_no
= json_object_new_object();
13268 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13269 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13270 json_object_free(json_no
);
13273 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13278 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
13279 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13283 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
13284 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13290 json_object
*json_no
= NULL
;
13291 json_no
= json_object_new_object();
13292 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13293 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13294 json_object_free(json_no
);
13297 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13301 return CMD_SUCCESS
;
13304 DEFUN (show_bgp_neighbor_received_routes
,
13305 show_bgp_neighbor_received_routes_cmd
,
13306 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13309 "Detailed information on TCP and BGP neighbor connections\n"
13310 "Neighbor to display information about\n"
13311 "Neighbor to display information about\n"
13312 "Neighbor on bgp configured interface\n"
13313 "Display the received routes from neighbor\n"
13314 "JavaScript Object Notation\n")
13317 const char *rmap_name
= NULL
;
13318 u_char uj
= use_json(argc
, argv
);
13320 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13323 return CMD_WARNING
;
13325 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
13326 rmap_name
= argv
[1];
13328 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13331 ALIAS (show_bgp_neighbor_received_routes
,
13332 show_bgp_ipv6_neighbor_received_routes_cmd
,
13333 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13337 "Detailed information on TCP and BGP neighbor connections\n"
13338 "Neighbor to display information about\n"
13339 "Neighbor to display information about\n"
13340 "Neighbor on bgp configured interface\n"
13341 "Display the received routes from neighbor\n"
13342 "JavaScript Object Notation\n")
13344 DEFUN (show_bgp_neighbor_received_prefix_filter
,
13345 show_bgp_neighbor_received_prefix_filter_cmd
,
13346 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13349 "Detailed information on TCP and BGP neighbor connections\n"
13350 "Neighbor to display information about\n"
13351 "Neighbor to display information about\n"
13352 "Neighbor on bgp configured interface\n"
13353 "Display information received from a BGP neighbor\n"
13354 "Display the prefixlist filter\n"
13355 "JavaScript Object Notation\n")
13358 union sockunion su
;
13361 u_char uj
= use_json(argc
, argv
);
13363 ret
= str2sockunion (argv
[0], &su
);
13366 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13371 json_object
*json_no
= NULL
;
13372 json_object
*json_sub
= NULL
;
13373 json_no
= json_object_new_object();
13374 json_sub
= json_object_new_object();
13375 json_object_string_add(json_no
, "warning", "Malformed address or name");
13376 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13377 json_object_object_add(json_no
, "detail", json_sub
);
13378 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13379 json_object_free(json_no
);
13382 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13383 return CMD_WARNING
;
13388 peer
= peer_lookup (NULL
, &su
);
13393 json_object
*json_no
= NULL
;
13394 json_no
= json_object_new_object();
13395 json_object_string_add(json_no
, "warning", "No Peer");
13396 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13397 json_object_free(json_no
);
13400 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13401 return CMD_WARNING
;
13405 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13406 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13410 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13411 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13417 json_object
*json_no
= NULL
;
13418 json_no
= json_object_new_object();
13419 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13420 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13421 json_object_free(json_no
);
13424 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13427 return CMD_SUCCESS
;
13430 ALIAS (show_bgp_neighbor_received_prefix_filter
,
13431 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
13432 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13436 "Detailed information on TCP and BGP neighbor connections\n"
13437 "Neighbor to display information about\n"
13438 "Neighbor to display information about\n"
13439 "Neighbor on bgp configured interface\n"
13440 "Display information received from a BGP neighbor\n"
13441 "Display the prefixlist filter\n"
13442 "JavaScript Object Notation\n")
13445 ALIAS (show_bgp_neighbor_received_routes
,
13446 ipv6_bgp_neighbor_received_routes_cmd
,
13447 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13451 "Detailed information on TCP and BGP neighbor connections\n"
13452 "Neighbor to display information about\n"
13453 "Neighbor to display information about\n"
13454 "Neighbor on bgp configured interface\n"
13455 "Display the received routes from neighbor\n"
13456 "JavaScript Object Notation\n")
13459 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13460 ipv6_mbgp_neighbor_received_routes_cmd
,
13461 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13465 "Detailed information on TCP and BGP neighbor connections\n"
13466 "Neighbor to display information about\n"
13467 "Neighbor to display information about\n"
13468 "Neighbor on bgp configured interface\n"
13469 "Display the received routes from neighbor\n"
13470 "JavaScript Object Notation\n")
13473 u_char uj
= use_json(argc
, argv
);
13475 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13477 return CMD_WARNING
;
13479 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13480 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13483 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13484 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13485 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13488 BGP_INSTANCE_HELP_STR
13489 "Detailed information on TCP and BGP neighbor connections\n"
13490 "Neighbor to display information about\n"
13491 "Neighbor to display information about\n"
13492 "Neighbor on bgp configured interface\n"
13493 "Display information received from a BGP neighbor\n"
13494 "Display the prefixlist filter\n"
13495 "JavaScript Object Notation\n")
13498 union sockunion su
;
13502 u_char uj
= use_json(argc
, argv
);
13504 /* BGP structure lookup. */
13505 bgp
= bgp_lookup_by_name (argv
[1]);
13510 json_object
*json_no
= NULL
;
13511 json_no
= json_object_new_object();
13512 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13513 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13514 json_object_free(json_no
);
13517 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13518 return CMD_WARNING
;
13521 ret
= str2sockunion (argv
[2], &su
);
13524 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13529 json_object
*json_no
= NULL
;
13530 json_object
*json_sub
= NULL
;
13531 json_no
= json_object_new_object();
13532 json_sub
= json_object_new_object();
13533 json_object_string_add(json_no
, "warning", "Malformed address or name");
13534 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13535 json_object_object_add(json_no
, "detail", json_sub
);
13536 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13537 json_object_free(json_no
);
13540 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13541 return CMD_WARNING
;
13546 peer
= peer_lookup (bgp
, &su
);
13551 json_object
*json_no
= NULL
;
13552 json_no
= json_object_new_object();
13553 json_object_boolean_true_add(json_no
, "noPeer");
13554 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13555 json_object_free(json_no
);
13558 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13559 return CMD_WARNING
;
13564 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13565 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13569 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13570 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13573 return CMD_SUCCESS
;
13575 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13576 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13577 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13580 BGP_INSTANCE_HELP_STR
13582 "Detailed information on TCP and BGP neighbor connections\n"
13583 "Neighbor to display information about\n"
13584 "Neighbor to display information about\n"
13585 "Neighbor on bgp configured interface\n"
13586 "Display information received from a BGP neighbor\n"
13587 "Display the prefixlist filter\n"
13588 "JavaScript Object NOtation\n")
13589 #endif /* HAVE_IPV6 */
13592 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13593 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13595 if (! peer
|| ! peer
->afc
[afi
][safi
])
13599 json_object
*json_no
= NULL
;
13600 json_no
= json_object_new_object();
13601 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13602 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13603 json_object_free(json_no
);
13606 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13607 return CMD_WARNING
;
13610 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13613 DEFUN (show_ip_bgp_neighbor_routes
,
13614 show_ip_bgp_neighbor_routes_cmd
,
13615 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13619 "Detailed information on TCP and BGP neighbor connections\n"
13620 "Neighbor to display information about\n"
13621 "Neighbor to display information about\n"
13622 "Neighbor on bgp configured interface\n"
13623 "Display routes learned from neighbor\n"
13624 "JavaScript Object Notation\n")
13627 u_char uj
= use_json(argc
, argv
);
13629 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13631 return CMD_WARNING
;
13633 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13634 bgp_show_type_neighbor
, uj
);
13637 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13638 show_ip_bgp_instance_neighbor_routes_cmd
,
13639 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13643 BGP_INSTANCE_HELP_STR
13644 "Detailed information on TCP and BGP neighbor connections\n"
13645 "Neighbor to display information about\n"
13646 "Neighbor to display information about\n"
13647 "Neighbor on bgp configured interface\n"
13648 "Display routes learned from neighbor\n"
13649 "JavaScript Object Notation\n")
13652 u_char uj
= use_json(argc
, argv
);
13654 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13656 return CMD_WARNING
;
13658 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13659 bgp_show_type_neighbor
, uj
);
13662 DEFUN (show_ip_bgp_neighbor_flap
,
13663 show_ip_bgp_neighbor_flap_cmd
,
13664 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13668 "Detailed information on TCP and BGP neighbor connections\n"
13669 "Neighbor to display information about\n"
13670 "Neighbor to display information about\n"
13671 "Neighbor on bgp configured interface\n"
13672 "Display flap statistics of the routes learned from neighbor\n"
13673 "JavaScript Object Notation\n")
13676 u_char uj
= use_json(argc
, argv
);
13678 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13680 return CMD_WARNING
;
13682 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13683 bgp_show_type_flap_neighbor
, uj
);
13686 DEFUN (show_ip_bgp_neighbor_damp
,
13687 show_ip_bgp_neighbor_damp_cmd
,
13688 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
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 the dampened routes received from neighbor\n"
13697 "JavaScript Object Notation\n")
13700 u_char uj
= use_json(argc
, argv
);
13702 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13704 return CMD_WARNING
;
13706 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13707 bgp_show_type_damp_neighbor
, uj
);
13710 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13711 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13712 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13717 "Address Family modifier\n"
13718 "Address Family modifier\n"
13719 "Detailed information on TCP and BGP neighbor connections\n"
13720 "Neighbor to display information about\n"
13721 "Neighbor to display information about\n"
13722 "Neighbor on bgp configured interface\n"
13723 "Display routes learned from neighbor\n"
13724 "JavaScript Object Notation\n")
13727 u_char uj
= use_json(argc
, argv
);
13729 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13731 return CMD_WARNING
;
13733 if (strncmp (argv
[0], "m", 1) == 0)
13734 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
13735 bgp_show_type_neighbor
, uj
);
13737 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13738 bgp_show_type_neighbor
, uj
);
13742 DEFUN (show_bgp_instance_neighbor_routes
,
13743 show_bgp_instance_neighbor_routes_cmd
,
13744 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13747 BGP_INSTANCE_HELP_STR
13748 "Detailed information on TCP and BGP neighbor connections\n"
13749 "Neighbor to display information about\n"
13750 "Neighbor to display information about\n"
13751 "Neighbor on bgp configured interface\n"
13752 "Display routes learned from neighbor\n"
13753 "JavaScript Object Notation\n")
13756 u_char uj
= use_json(argc
, argv
);
13758 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13760 return CMD_WARNING
;
13762 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13763 bgp_show_type_neighbor
, uj
);
13766 ALIAS (show_bgp_instance_neighbor_routes
,
13767 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13768 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13771 BGP_INSTANCE_HELP_STR
13773 "Detailed information on TCP and BGP neighbor connections\n"
13774 "Neighbor to display information about\n"
13775 "Neighbor to display information about\n"
13776 "Neighbor on bgp configured interface\n"
13777 "Display routes learned from neighbor\n"
13778 "JavaScript Object Notation\n")
13780 DEFUN (show_bgp_instance_neighbor_damp
,
13781 show_bgp_instance_neighbor_damp_cmd
,
13782 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13785 BGP_INSTANCE_HELP_STR
13786 "Detailed information on TCP and BGP neighbor connections\n"
13787 "Neighbor to display information about\n"
13788 "Neighbor to display information about\n"
13789 "Neighbor on bgp configured interface\n"
13790 "Display the dampened routes received from neighbor\n"
13791 "JavaScript Object Notation\n")
13794 u_char uj
= use_json(argc
, argv
);
13796 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13797 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13798 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13800 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13803 return CMD_WARNING
;
13805 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13806 bgp_show_type_damp_neighbor
, uj
);
13809 ALIAS (show_bgp_instance_neighbor_damp
,
13810 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13811 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13814 BGP_INSTANCE_HELP_STR
13816 "Detailed information on TCP and BGP neighbor connections\n"
13817 "Neighbor to display information about\n"
13818 "Neighbor to display information about\n"
13819 "Neighbor on bgp configured interface\n"
13820 "Display the dampened routes received from neighbor\n"
13821 "JavaScript Object Notation\n")
13823 DEFUN (show_bgp_instance_neighbor_flap
,
13824 show_bgp_instance_neighbor_flap_cmd
,
13825 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13828 BGP_INSTANCE_HELP_STR
13829 "Detailed information on TCP and BGP neighbor connections\n"
13830 "Neighbor to display information about\n"
13831 "Neighbor to display information about\n"
13832 "Neighbor on bgp configured interface\n"
13833 "Display flap statistics of the routes learned from neighbor\n"
13834 "JavaScript Object Notation\n")
13837 u_char uj
= use_json(argc
, argv
);
13839 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13840 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13841 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13843 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13846 return CMD_WARNING
;
13848 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13849 bgp_show_type_flap_neighbor
, uj
);
13852 ALIAS (show_bgp_instance_neighbor_flap
,
13853 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13854 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13857 BGP_INSTANCE_HELP_STR
13859 "Detailed information on TCP and BGP neighbor connections\n"
13860 "Neighbor to display information about\n"
13861 "Neighbor to display information about\n"
13862 "Neighbor on bgp configured interface\n"
13863 "Display flap statistics of the routes learned from neighbor\n"
13864 "JavaScript Object Notation\n")
13866 DEFUN (show_bgp_neighbor_routes
,
13867 show_bgp_neighbor_routes_cmd
,
13868 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13871 "Detailed information on TCP and BGP neighbor connections\n"
13872 "Neighbor to display information about\n"
13873 "Neighbor to display information about\n"
13874 "Neighbor on bgp configured interface\n"
13875 "Display routes learned from neighbor\n"
13876 "JavaScript Object Notation\n")
13879 u_char uj
= use_json(argc
, argv
);
13881 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13883 return CMD_WARNING
;
13885 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13886 bgp_show_type_neighbor
, uj
);
13890 ALIAS (show_bgp_neighbor_routes
,
13891 show_bgp_ipv6_neighbor_routes_cmd
,
13892 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13896 "Detailed information on TCP and BGP neighbor connections\n"
13897 "Neighbor to display information about\n"
13898 "Neighbor to display information about\n"
13899 "Neighbor on bgp configured interface\n"
13900 "Display routes learned from neighbor\n"
13901 "JavaScript Object Notation\n")
13904 ALIAS (show_bgp_neighbor_routes
,
13905 ipv6_bgp_neighbor_routes_cmd
,
13906 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13910 "Detailed information on TCP and BGP neighbor connections\n"
13911 "Neighbor to display information about\n"
13912 "Neighbor to display information about\n"
13913 "Neighbor on bgp configured interface\n"
13914 "Display routes learned from neighbor\n"
13915 "JavaScript Object Notation\n")
13918 DEFUN (ipv6_mbgp_neighbor_routes
,
13919 ipv6_mbgp_neighbor_routes_cmd
,
13920 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13924 "Detailed information on TCP and BGP neighbor connections\n"
13925 "Neighbor to display information about\n"
13926 "Neighbor to display information about\n"
13927 "Neighbor on bgp configured interface\n"
13928 "Display routes learned from neighbor\n"
13929 "JavaScript Object Notation\n")
13932 u_char uj
= use_json(argc
, argv
);
13934 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13936 return CMD_WARNING
;
13938 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13939 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13940 bgp_show_type_neighbor
, uj
);
13943 ALIAS (show_bgp_instance_neighbor_flap
,
13944 show_bgp_neighbor_flap_cmd
,
13945 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13948 "Detailed information on TCP and BGP neighbor connections\n"
13949 "Neighbor to display information about\n"
13950 "Neighbor to display information about\n"
13951 "Neighbor on bgp configured interface\n"
13952 "Display flap statistics of the routes learned from neighbor\n"
13953 "JavaScript Object Notation\n")
13955 ALIAS (show_bgp_instance_neighbor_flap
,
13956 show_bgp_ipv6_neighbor_flap_cmd
,
13957 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13961 "Detailed information on TCP and BGP neighbor connections\n"
13962 "Neighbor to display information about\n"
13963 "Neighbor to display information about\n"
13964 "Neighbor on bgp configured interface\n"
13965 "Display flap statistics of the routes learned from neighbor\n"
13966 "JavaScript Object Notation\n")
13968 ALIAS (show_bgp_instance_neighbor_damp
,
13969 show_bgp_neighbor_damp_cmd
,
13970 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13973 "Detailed information on TCP and BGP neighbor connections\n"
13974 "Neighbor to display information about\n"
13975 "Neighbor to display information about\n"
13976 "Neighbor on bgp configured interface\n"
13977 "Display the dampened routes received from neighbor\n"
13978 "JavaScript Object Notation\n")
13980 ALIAS (show_bgp_instance_neighbor_damp
,
13981 show_bgp_ipv6_neighbor_damp_cmd
,
13982 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13986 "Detailed information on TCP and BGP neighbor connections\n"
13987 "Neighbor to display information about\n"
13988 "Neighbor to display information about\n"
13989 "Neighbor on bgp configured interface\n"
13990 "Display the dampened routes received from neighbor\n"
13991 "JavaScript Object Notation\n")
13993 #endif /* HAVE_IPV6 */
13995 struct bgp_table
*bgp_distance_table
;
13997 struct bgp_distance
13999 /* Distance value for the IP source prefix. */
14002 /* Name of the access-list to be matched. */
14006 static struct bgp_distance
*
14007 bgp_distance_new (void)
14009 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
14013 bgp_distance_free (struct bgp_distance
*bdistance
)
14015 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
14019 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
14020 const char *ip_str
, const char *access_list_str
)
14023 struct prefix_ipv4 p
;
14025 struct bgp_node
*rn
;
14026 struct bgp_distance
*bdistance
;
14028 ret
= str2prefix_ipv4 (ip_str
, &p
);
14031 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
14032 return CMD_WARNING
;
14035 distance
= atoi (distance_str
);
14037 /* Get BGP distance node. */
14038 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
14041 bdistance
= rn
->info
;
14042 bgp_unlock_node (rn
);
14046 bdistance
= bgp_distance_new ();
14047 rn
->info
= bdistance
;
14050 /* Set distance value. */
14051 bdistance
->distance
= distance
;
14053 /* Reset access-list configuration. */
14054 if (bdistance
->access_list
)
14056 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
14057 bdistance
->access_list
= NULL
;
14059 if (access_list_str
)
14060 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
14062 return CMD_SUCCESS
;
14066 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
14067 const char *ip_str
, const char *access_list_str
)
14071 struct prefix_ipv4 p
;
14072 struct bgp_node
*rn
;
14073 struct bgp_distance
*bdistance
;
14075 ret
= str2prefix_ipv4 (ip_str
, &p
);
14078 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
14079 return CMD_WARNING
;
14082 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
14085 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
14086 return CMD_WARNING
;
14089 bdistance
= rn
->info
;
14090 distance
= atoi(distance_str
);
14092 if (bdistance
->distance
!= distance
)
14094 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
14095 return CMD_WARNING
;
14098 if (bdistance
->access_list
)
14099 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
14100 bgp_distance_free (bdistance
);
14103 bgp_unlock_node (rn
);
14104 bgp_unlock_node (rn
);
14106 return CMD_SUCCESS
;
14109 /* Apply BGP information to distance method. */
14111 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
14113 struct bgp_node
*rn
;
14114 struct prefix_ipv4 q
;
14116 struct bgp_distance
*bdistance
;
14117 struct access_list
*alist
;
14118 struct bgp_static
*bgp_static
;
14123 if (p
->family
!= AF_INET
)
14126 peer
= rinfo
->peer
;
14128 if (peer
->su
.sa
.sa_family
!= AF_INET
)
14131 memset (&q
, 0, sizeof (struct prefix_ipv4
));
14132 q
.family
= AF_INET
;
14133 q
.prefix
= peer
->su
.sin
.sin_addr
;
14134 q
.prefixlen
= IPV4_MAX_BITLEN
;
14136 /* Check source address. */
14137 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
14140 bdistance
= rn
->info
;
14141 bgp_unlock_node (rn
);
14143 if (bdistance
->access_list
)
14145 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
14146 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
14147 return bdistance
->distance
;
14150 return bdistance
->distance
;
14153 /* Backdoor check. */
14154 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
14157 bgp_static
= rn
->info
;
14158 bgp_unlock_node (rn
);
14160 if (bgp_static
->backdoor
)
14162 if (bgp
->distance_local
)
14163 return bgp
->distance_local
;
14165 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
14169 if (peer
->sort
== BGP_PEER_EBGP
)
14171 if (bgp
->distance_ebgp
)
14172 return bgp
->distance_ebgp
;
14173 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
14177 if (bgp
->distance_ibgp
)
14178 return bgp
->distance_ibgp
;
14179 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
14183 DEFUN (bgp_distance
,
14185 "distance bgp <1-255> <1-255> <1-255>",
14186 "Define an administrative distance\n"
14188 "Distance for routes external to the AS\n"
14189 "Distance for routes internal to the AS\n"
14190 "Distance for local routes\n")
14196 bgp
->distance_ebgp
= atoi (argv
[0]);
14197 bgp
->distance_ibgp
= atoi (argv
[1]);
14198 bgp
->distance_local
= atoi (argv
[2]);
14199 return CMD_SUCCESS
;
14202 DEFUN (no_bgp_distance
,
14203 no_bgp_distance_cmd
,
14204 "no distance bgp <1-255> <1-255> <1-255>",
14206 "Define an administrative distance\n"
14208 "Distance for routes external to the AS\n"
14209 "Distance for routes internal to the AS\n"
14210 "Distance for local routes\n")
14216 bgp
->distance_ebgp
= 0;
14217 bgp
->distance_ibgp
= 0;
14218 bgp
->distance_local
= 0;
14219 return CMD_SUCCESS
;
14222 ALIAS (no_bgp_distance
,
14223 no_bgp_distance2_cmd
,
14226 "Define an administrative distance\n"
14229 DEFUN (bgp_distance_source
,
14230 bgp_distance_source_cmd
,
14231 "distance <1-255> A.B.C.D/M",
14232 "Define an administrative distance\n"
14233 "Administrative distance\n"
14234 "IP source prefix\n")
14236 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14237 return CMD_SUCCESS
;
14240 DEFUN (no_bgp_distance_source
,
14241 no_bgp_distance_source_cmd
,
14242 "no distance <1-255> A.B.C.D/M",
14244 "Define an administrative distance\n"
14245 "Administrative distance\n"
14246 "IP source prefix\n")
14248 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14249 return CMD_SUCCESS
;
14252 DEFUN (bgp_distance_source_access_list
,
14253 bgp_distance_source_access_list_cmd
,
14254 "distance <1-255> A.B.C.D/M WORD",
14255 "Define an administrative distance\n"
14256 "Administrative distance\n"
14257 "IP source prefix\n"
14258 "Access list name\n")
14260 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14261 return CMD_SUCCESS
;
14264 DEFUN (no_bgp_distance_source_access_list
,
14265 no_bgp_distance_source_access_list_cmd
,
14266 "no distance <1-255> A.B.C.D/M WORD",
14268 "Define an administrative distance\n"
14269 "Administrative distance\n"
14270 "IP source prefix\n"
14271 "Access list name\n")
14273 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14274 return CMD_SUCCESS
;
14277 DEFUN (bgp_damp_set
,
14279 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14280 "BGP Specific commands\n"
14281 "Enable route-flap dampening\n"
14282 "Half-life time for the penalty\n"
14283 "Value to start reusing a route\n"
14284 "Value to start suppressing a route\n"
14285 "Maximum duration to suppress a stable route\n")
14288 int half
= DEFAULT_HALF_LIFE
* 60;
14289 int reuse
= DEFAULT_REUSE
;
14290 int suppress
= DEFAULT_SUPPRESS
;
14291 int max
= 4 * half
;
14295 half
= atoi (argv
[0]) * 60;
14296 reuse
= atoi (argv
[1]);
14297 suppress
= atoi (argv
[2]);
14298 max
= atoi (argv
[3]) * 60;
14300 else if (argc
== 1)
14302 half
= atoi (argv
[0]) * 60;
14308 if (suppress
< reuse
)
14310 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
14315 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
14316 half
, reuse
, suppress
, max
);
14319 ALIAS (bgp_damp_set
,
14321 "bgp dampening <1-45>",
14322 "BGP Specific commands\n"
14323 "Enable route-flap dampening\n"
14324 "Half-life time for the penalty\n")
14326 ALIAS (bgp_damp_set
,
14329 "BGP Specific commands\n"
14330 "Enable route-flap dampening\n")
14332 DEFUN (bgp_damp_unset
,
14333 bgp_damp_unset_cmd
,
14334 "no bgp dampening",
14336 "BGP Specific commands\n"
14337 "Enable route-flap dampening\n")
14342 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
14345 ALIAS (bgp_damp_unset
,
14346 bgp_damp_unset2_cmd
,
14347 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14349 "BGP Specific commands\n"
14350 "Enable route-flap dampening\n"
14351 "Half-life time for the penalty\n"
14352 "Value to start reusing a route\n"
14353 "Value to start suppressing a route\n"
14354 "Maximum duration to suppress a stable route\n")
14356 ALIAS (bgp_damp_unset
,
14357 bgp_damp_unset3_cmd
,
14358 "no bgp dampening <1-45>",
14360 "BGP Specific commands\n"
14361 "Enable route-flap dampening\n"
14362 "Half-life time for the penalty\n")
14364 DEFUN (show_ip_bgp_dampened_paths
,
14365 show_ip_bgp_dampened_paths_cmd
,
14366 "show ip bgp dampened-paths",
14370 "Display paths suppressed due to dampening\n")
14372 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
14376 ALIAS (show_ip_bgp_dampened_paths
,
14377 show_ip_bgp_damp_dampened_paths_cmd
,
14378 "show ip bgp dampening dampened-paths",
14382 "Display detailed information about dampening\n"
14383 "Display paths suppressed due to dampening\n")
14385 DEFUN (show_ip_bgp_flap_statistics
,
14386 show_ip_bgp_flap_statistics_cmd
,
14387 "show ip bgp flap-statistics",
14391 "Display flap statistics of routes\n")
14393 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
14394 bgp_show_type_flap_statistics
, NULL
, 0);
14397 ALIAS (show_ip_bgp_flap_statistics
,
14398 show_ip_bgp_damp_flap_statistics_cmd
,
14399 "show ip bgp dampening flap-statistics",
14403 "Display detailed information about dampening\n"
14404 "Display flap statistics of routes\n")
14406 /* Display specified route of BGP table. */
14408 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
14409 const char *ip_str
, afi_t afi
, safi_t safi
,
14410 struct prefix_rd
*prd
, int prefix_check
)
14413 struct prefix match
;
14414 struct bgp_node
*rn
;
14415 struct bgp_node
*rm
;
14416 struct bgp_info
*ri
;
14417 struct bgp_info
*ri_temp
;
14419 struct bgp_table
*table
;
14421 /* BGP structure lookup. */
14424 bgp
= bgp_lookup_by_name (view_name
);
14427 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
14428 return CMD_WARNING
;
14433 bgp
= bgp_get_default ();
14436 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14437 return CMD_WARNING
;
14441 /* Check IP address argument. */
14442 ret
= str2prefix (ip_str
, &match
);
14445 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14446 return CMD_WARNING
;
14449 match
.family
= afi2family (afi
);
14451 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14453 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14455 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14458 if ((table
= rn
->info
) != NULL
)
14459 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14461 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14466 if (ri
->extra
&& ri
->extra
->damp_info
)
14468 ri_temp
= ri
->next
;
14469 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14477 bgp_unlock_node (rm
);
14483 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14485 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14490 if (ri
->extra
&& ri
->extra
->damp_info
)
14492 ri_temp
= ri
->next
;
14493 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14501 bgp_unlock_node (rn
);
14505 return CMD_SUCCESS
;
14508 DEFUN (clear_ip_bgp_dampening
,
14509 clear_ip_bgp_dampening_cmd
,
14510 "clear ip bgp dampening",
14514 "Clear route flap dampening information\n")
14516 bgp_damp_info_clean ();
14517 return CMD_SUCCESS
;
14520 DEFUN (clear_ip_bgp_dampening_prefix
,
14521 clear_ip_bgp_dampening_prefix_cmd
,
14522 "clear ip bgp dampening A.B.C.D/M",
14526 "Clear route flap dampening information\n"
14527 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14529 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14530 SAFI_UNICAST
, NULL
, 1);
14533 DEFUN (clear_ip_bgp_dampening_address
,
14534 clear_ip_bgp_dampening_address_cmd
,
14535 "clear ip bgp dampening A.B.C.D",
14539 "Clear route flap dampening information\n"
14540 "Network to clear damping information\n")
14542 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14543 SAFI_UNICAST
, NULL
, 0);
14546 DEFUN (clear_ip_bgp_dampening_address_mask
,
14547 clear_ip_bgp_dampening_address_mask_cmd
,
14548 "clear ip bgp dampening A.B.C.D A.B.C.D",
14552 "Clear route flap dampening information\n"
14553 "Network to clear damping information\n"
14557 char prefix_str
[BUFSIZ
];
14559 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14562 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14563 return CMD_WARNING
;
14566 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14567 SAFI_UNICAST
, NULL
, 0);
14570 /* also used for encap safi */
14572 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14573 afi_t afi
, safi_t safi
, int *write
)
14575 struct bgp_node
*prn
;
14576 struct bgp_node
*rn
;
14577 struct bgp_table
*table
;
14579 struct prefix_rd
*prd
;
14580 struct bgp_static
*bgp_static
;
14582 char buf
[SU_ADDRSTRLEN
];
14583 char rdbuf
[RD_ADDRSTRLEN
];
14585 /* Network configuration. */
14586 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14587 if ((table
= prn
->info
) != NULL
)
14588 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14589 if ((bgp_static
= rn
->info
) != NULL
)
14592 prd
= (struct prefix_rd
*) &prn
->p
;
14594 /* "address-family" display. */
14595 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14597 /* "network" configuration display. */
14598 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14599 label
= decode_label (bgp_static
->tag
);
14601 vty_out (vty
, " network %s/%d rd %s tag %d",
14602 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14605 vty_out (vty
, "%s", VTY_NEWLINE
);
14610 /* Configuration of static route announcement and aggregate
14613 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14614 afi_t afi
, safi_t safi
, int *write
)
14616 struct bgp_node
*rn
;
14618 struct bgp_static
*bgp_static
;
14619 struct bgp_aggregate
*bgp_aggregate
;
14620 char buf
[SU_ADDRSTRLEN
];
14622 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14623 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14625 /* Network configuration. */
14626 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14627 if ((bgp_static
= rn
->info
) != NULL
)
14631 /* "address-family" display. */
14632 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14634 /* "network" configuration display. */
14635 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14637 u_int32_t destination
;
14638 struct in_addr netmask
;
14640 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14641 masklen2ip (p
->prefixlen
, &netmask
);
14642 vty_out (vty
, " network %s",
14643 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14645 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14646 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14647 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14648 || p
->u
.prefix4
.s_addr
== 0)
14650 /* Natural mask is not display. */
14653 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14657 vty_out (vty
, " network %s/%d",
14658 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14662 if (bgp_static
->rmap
.name
)
14663 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14666 if (bgp_static
->backdoor
)
14667 vty_out (vty
, " backdoor");
14670 vty_out (vty
, "%s", VTY_NEWLINE
);
14673 /* Aggregate-address configuration. */
14674 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14675 if ((bgp_aggregate
= rn
->info
) != NULL
)
14679 /* "address-family" display. */
14680 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14682 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14684 struct in_addr netmask
;
14686 masklen2ip (p
->prefixlen
, &netmask
);
14687 vty_out (vty
, " aggregate-address %s %s",
14688 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14689 inet_ntoa (netmask
));
14693 vty_out (vty
, " aggregate-address %s/%d",
14694 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14698 if (bgp_aggregate
->as_set
)
14699 vty_out (vty
, " as-set");
14701 if (bgp_aggregate
->summary_only
)
14702 vty_out (vty
, " summary-only");
14704 vty_out (vty
, "%s", VTY_NEWLINE
);
14711 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
14713 struct bgp_node
*rn
;
14714 struct bgp_distance
*bdistance
;
14716 /* Distance configuration. */
14717 if (bgp
->distance_ebgp
14718 && bgp
->distance_ibgp
14719 && bgp
->distance_local
14720 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
14721 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
14722 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
14723 vty_out (vty
, " distance bgp %d %d %d%s",
14724 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
14727 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
14728 if ((bdistance
= rn
->info
) != NULL
)
14730 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
14731 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
14732 bdistance
->access_list
? bdistance
->access_list
: "",
14739 /* Allocate routing table structure and install commands. */
14741 bgp_route_init (void)
14743 /* Init BGP distance table. */
14744 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
14746 /* IPv4 BGP commands. */
14747 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14748 install_element (BGP_NODE
, &bgp_network_cmd
);
14749 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14750 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14751 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14752 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14753 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14754 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14755 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14756 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14757 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14758 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14759 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14760 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14761 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14762 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14763 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14764 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14765 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14766 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14768 install_element (BGP_NODE
, &aggregate_address_cmd
);
14769 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14770 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14771 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14772 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14773 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14774 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14775 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14776 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14777 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14778 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14779 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14780 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14781 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14782 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14783 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14784 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14785 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14786 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14787 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14789 /* IPv4 unicast configuration. */
14790 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14791 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14792 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14793 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14794 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14795 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14796 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14797 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14798 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14799 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14800 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14801 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14802 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14803 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14805 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14806 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14807 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14808 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14809 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14810 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14811 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14812 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14813 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14814 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14815 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14816 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14817 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14818 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14819 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14820 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14821 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14822 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14823 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14824 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14826 /* IPv4 multicast configuration. */
14827 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14828 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14829 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14830 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14831 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14832 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14833 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14834 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14835 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14836 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14837 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14838 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14839 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14840 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14841 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14842 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14843 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14844 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14845 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14846 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14847 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14848 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14849 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14850 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14851 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14852 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14853 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14854 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14855 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14856 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14857 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14858 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14859 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14860 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14862 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14863 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14864 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14865 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14866 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14867 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14868 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14869 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14870 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14871 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14872 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14873 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14874 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14875 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14876 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14877 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14878 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14879 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14880 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14881 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14882 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14883 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14884 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14885 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14887 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14888 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14889 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14890 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14891 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14892 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14893 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14894 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14895 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14896 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14897 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14898 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14899 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14900 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14901 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14902 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14903 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14904 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14905 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14906 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14907 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14908 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14909 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14910 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14911 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14912 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14913 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14914 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14915 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14916 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14917 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14918 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14919 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14920 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14921 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14922 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14923 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14924 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14925 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14926 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14927 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14928 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14929 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14930 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14931 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14932 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14933 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14934 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14935 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14936 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14937 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14938 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14939 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14940 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14941 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14942 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14943 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14944 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14945 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14946 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14947 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14948 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14949 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14950 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
14951 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14952 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
14953 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
14954 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14955 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14956 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14957 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14958 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14959 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14960 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14961 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14962 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14963 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14964 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14965 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14966 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14967 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14968 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14969 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14970 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14971 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14972 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14974 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
14975 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
14976 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14977 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14978 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14979 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14980 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14981 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14982 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14983 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
14984 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14985 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14986 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14987 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14988 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14989 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14990 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14991 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14992 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14993 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14994 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14995 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
14996 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
14997 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
14998 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
14999 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
15000 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
15001 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
15002 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
15003 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
15004 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
15005 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
15006 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
15007 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
15008 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
15009 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
15010 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
15011 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
15012 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
15013 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
15014 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
15015 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
15017 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
15018 install_element (ENABLE_NODE
, &show_ip_bgp_instance_cmd
);
15019 install_element (ENABLE_NODE
, &show_ip_bgp_instance_all_cmd
);
15020 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
15021 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
15022 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
15023 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_cmd
);
15024 install_element (ENABLE_NODE
, &show_ip_bgp_route_pathtype_cmd
);
15025 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
15026 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
15027 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
15028 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
15029 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
15030 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
15031 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
15032 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_cmd
);
15033 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
15034 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
15035 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
15036 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
15037 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
15038 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
15039 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
15040 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
15042 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
15043 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
15044 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
15045 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
15046 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
15047 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
15048 install_element (ENABLE_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
15049 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
15050 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
15051 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_map_cmd
);
15052 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
15053 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
15054 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
15055 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
15056 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
15057 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
15058 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
15059 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
15060 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
15061 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
15062 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
15063 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
15064 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
15065 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
15066 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
15067 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
15068 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
15069 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
15070 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
15071 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
15072 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
15073 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
15074 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
15075 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
15076 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
15077 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
15078 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
15079 install_element (ENABLE_NODE
, &show_ip_bgp_instance_community_list_cmd
);
15080 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
15081 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
15082 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
15083 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
15084 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
15085 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
15086 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
15087 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
15088 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
15089 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
15090 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
15091 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
15092 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
15093 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
15094 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
15095 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
15096 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
15097 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
15098 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
15099 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
15100 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
15101 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
15102 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
15103 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
15104 install_element (ENABLE_NODE
, &show_ip_bgp_dampening_params_cmd
);
15105 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
15106 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
15107 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
15108 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
15109 install_element (ENABLE_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
15110 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
15111 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
15112 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
15113 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
15114 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
15115 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
15116 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
15117 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
15118 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_regexp_cmd
);
15119 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
15120 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
15121 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
15122 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
15123 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
15124 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
15125 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
15126 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
15127 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
15128 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
15129 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
15131 install_element (VIEW_NODE
, &show_bgp_ipv4_prefix_cmd
);
15132 install_element (ENABLE_NODE
, &show_bgp_ipv4_prefix_cmd
);
15133 install_element (VIEW_NODE
, &show_bgp_ipv4_vpn_rd_route_cmd
);
15134 install_element (ENABLE_NODE
, &show_bgp_ipv4_vpn_rd_route_cmd
);
15135 install_element (VIEW_NODE
, &show_bgp_ipv4_vpn_route_cmd
);
15136 install_element (ENABLE_NODE
, &show_bgp_ipv4_vpn_route_cmd
);
15138 install_element (VIEW_NODE
, &show_bgp_ipv6_vpn_rd_route_cmd
);
15139 install_element (ENABLE_NODE
, &show_bgp_ipv6_vpn_rd_route_cmd
);
15140 install_element (VIEW_NODE
, &show_bgp_ipv6_vpn_route_cmd
);
15141 install_element (ENABLE_NODE
, &show_bgp_ipv6_vpn_route_cmd
);
15143 /* BGP dampening clear commands */
15144 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
15145 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
15146 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
15147 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
15150 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
15151 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
15152 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
15153 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
15155 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
15156 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
15158 /* New config IPv6 BGP commands. */
15159 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
15160 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
15161 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
15162 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
15163 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
15164 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
15166 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
15167 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
15168 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
15169 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
15171 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
15172 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
15174 /* Old config IPv6 BGP commands. */
15175 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
15176 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
15178 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
15179 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
15180 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
15181 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
15183 install_element (VIEW_NODE
, &show_bgp_cmd
);
15184 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
15185 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
15186 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
15187 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
15188 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
15189 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
15190 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
15191 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
15192 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
15193 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
15194 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
15195 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
15196 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
15197 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
15198 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
15199 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
15200 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
15201 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
15202 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
15203 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
15204 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
15205 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
15206 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
15207 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
15208 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
15209 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
15210 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
15211 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
15212 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
15213 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
15214 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
15215 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
15216 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
15217 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
15218 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
15219 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
15220 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
15221 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
15222 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
15223 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
15224 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
15225 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
15226 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
15227 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
15228 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
15229 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
15230 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
15231 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
15232 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
15233 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
15234 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
15235 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
15236 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
15237 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
15238 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
15239 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
15240 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
15241 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
15242 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
15243 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
15244 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
15245 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
15246 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
15247 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
15248 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
15249 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
15250 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
15251 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
15252 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
15253 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
15254 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
15255 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
15256 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
15257 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
15258 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
15259 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
15260 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
15261 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
15262 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
15263 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
15264 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
15265 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
15266 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
15267 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
15268 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
15269 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
15270 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
15271 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
15272 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
15273 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
15274 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
15277 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
15279 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
15280 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
15281 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
15282 install_element (RESTRICTED_NODE
, &show_bgp_route_pathtype_cmd
);
15283 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
15284 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
15285 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
15286 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
15287 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
15288 install_element (RESTRICTED_NODE
, &show_bgp_prefix_pathtype_cmd
);
15289 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
15290 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
15291 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
15292 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
15293 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
15294 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
15295 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
15296 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
15297 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
15298 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
15299 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
15300 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
15301 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
15302 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
15303 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
15304 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
15305 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
15306 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
15307 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_cmd
);
15308 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_cmd
);
15309 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_pathtype_cmd
);
15310 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
15311 install_element (RESTRICTED_NODE
, &show_bgp_instance_prefix_cmd
);
15312 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
15313 install_element (RESTRICTED_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
15314 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
15316 install_element (ENABLE_NODE
, &show_bgp_cmd
);
15317 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
15318 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
15319 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
15320 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
15321 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
15322 install_element (ENABLE_NODE
, &show_bgp_route_pathtype_cmd
);
15323 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
15324 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
15325 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
15326 install_element (ENABLE_NODE
, &show_bgp_prefix_pathtype_cmd
);
15327 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
15328 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
15329 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
15330 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
15331 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
15332 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
15333 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
15334 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
15335 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
15336 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
15337 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
15338 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
15339 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
15340 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
15341 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
15342 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
15343 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
15344 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
15345 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
15346 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
15347 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
15348 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
15349 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
15350 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
15351 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
15352 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
15353 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
15354 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
15355 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
15356 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
15357 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
15358 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
15359 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
15360 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
15361 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
15362 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
15363 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
15364 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
15365 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
15366 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
15367 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
15368 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
15369 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
15370 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
15371 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
15372 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
15373 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
15374 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
15375 install_element (ENABLE_NODE
, &show_bgp_instance_cmd
);
15376 install_element (ENABLE_NODE
, &show_bgp_instance_all_cmd
);
15377 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_cmd
);
15378 install_element (ENABLE_NODE
, &show_bgp_instance_route_cmd
);
15379 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_cmd
);
15380 install_element (ENABLE_NODE
, &show_bgp_instance_route_pathtype_cmd
);
15381 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
15382 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_cmd
);
15383 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
15384 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
15385 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
15386 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_list_cmd
);
15387 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
15388 install_element (ENABLE_NODE
, &show_bgp_instance_filter_list_cmd
);
15389 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
15390 install_element (ENABLE_NODE
, &show_bgp_instance_route_map_cmd
);
15391 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
15392 install_element (ENABLE_NODE
, &show_bgp_instance_community_list_cmd
);
15393 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
15394 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_longer_cmd
);
15395 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
15396 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
15397 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
15398 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
15399 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
15400 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
15401 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
15402 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
15403 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
15404 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
15405 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
15406 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
15407 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
15410 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
15411 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
15412 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
15413 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
15416 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
15417 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
15418 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
15419 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
15420 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
15421 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
15422 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
15423 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
15424 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
15425 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
15426 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
15427 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
15428 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
15429 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
15430 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
15431 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
15432 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15433 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15434 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
15435 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
15436 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15437 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15438 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15439 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15440 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15441 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
15442 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
15443 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
15444 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
15445 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15446 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
15447 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
15448 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
15449 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15450 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15451 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15454 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
15455 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
15456 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
15457 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
15458 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
15459 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
15460 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
15461 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
15462 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
15463 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
15464 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
15465 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
15466 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
15467 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
15468 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
15469 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
15470 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15471 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15472 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
15473 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
15474 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15475 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15476 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15477 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15478 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15479 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
15480 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
15481 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
15482 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
15483 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15484 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
15485 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
15486 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
15487 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15488 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15489 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15492 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
15493 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
15494 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15495 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15498 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
15499 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
15500 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15501 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15504 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
15505 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
15506 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15507 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15508 #endif /* HAVE_IPV6 */
15510 install_element (BGP_NODE
, &bgp_distance_cmd
);
15511 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
15512 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
15513 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
15514 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
15515 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
15516 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
15518 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15519 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15520 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15521 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15522 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15523 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15524 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15525 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15526 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15527 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15528 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15529 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15531 /* IPv4 Multicast Mode */
15532 install_element (BGP_IPV4M_NODE
, &bgp_damp_set_cmd
);
15533 install_element (BGP_IPV4M_NODE
, &bgp_damp_set2_cmd
);
15534 install_element (BGP_IPV4M_NODE
, &bgp_damp_set3_cmd
);
15535 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset_cmd
);
15536 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset2_cmd
);
15540 bgp_route_finish (void)
15542 bgp_table_unlock (bgp_distance_table
);
15543 bgp_distance_table
= NULL
;