1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
34 #include "sockunion.h"
37 #include "workqueue.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_table.h"
43 #include "bgpd/bgp_route.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_debug.h"
46 #include "bgpd/bgp_aspath.h"
47 #include "bgpd/bgp_regex.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_ecommunity.h"
50 #include "bgpd/bgp_clist.h"
51 #include "bgpd/bgp_packet.h"
52 #include "bgpd/bgp_filter.h"
53 #include "bgpd/bgp_fsm.h"
54 #include "bgpd/bgp_mplsvpn.h"
55 #include "bgpd/bgp_nexthop.h"
56 #include "bgpd/bgp_damp.h"
57 #include "bgpd/bgp_advertise.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_nht.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_vty.h"
65 /* Extern from bgp_dump.c */
66 extern const char *bgp_origin_str
[];
67 extern const char *bgp_origin_long_str
[];
70 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
71 struct prefix_rd
*prd
)
74 struct bgp_node
*prn
= NULL
;
80 if (safi
== SAFI_MPLS_VPN
)
82 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
84 if (prn
->info
== NULL
)
85 prn
->info
= bgp_table_init (afi
, safi
);
87 bgp_unlock_node (prn
);
91 rn
= bgp_node_get (table
, p
);
93 if (safi
== SAFI_MPLS_VPN
)
99 /* Allocate bgp_info_extra */
100 static struct bgp_info_extra
*
101 bgp_info_extra_new (void)
103 struct bgp_info_extra
*new;
104 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
109 bgp_info_extra_free (struct bgp_info_extra
**extra
)
113 if ((*extra
)->damp_info
)
114 bgp_damp_info_free ((*extra
)->damp_info
, 0);
116 (*extra
)->damp_info
= NULL
;
118 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
124 /* Get bgp_info extra information for the given bgp_info, lazy allocated
127 struct bgp_info_extra
*
128 bgp_info_extra_get (struct bgp_info
*ri
)
131 ri
->extra
= bgp_info_extra_new();
135 /* Free bgp route information. */
137 bgp_info_free (struct bgp_info
*binfo
)
140 bgp_attr_unintern (&binfo
->attr
);
142 bgp_unlink_nexthop(binfo
);
143 bgp_info_extra_free (&binfo
->extra
);
144 bgp_info_mpath_free (&binfo
->mpath
);
146 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
148 XFREE (MTYPE_BGP_ROUTE
, binfo
);
152 bgp_info_lock (struct bgp_info
*binfo
)
159 bgp_info_unlock (struct bgp_info
*binfo
)
161 assert (binfo
&& binfo
->lock
> 0);
164 if (binfo
->lock
== 0)
167 zlog_debug ("%s: unlocked and freeing", __func__
);
168 zlog_backtrace (LOG_DEBUG
);
170 bgp_info_free (binfo
);
175 if (binfo
->lock
== 1)
177 zlog_debug ("%s: unlocked to 1", __func__
);
178 zlog_backtrace (LOG_DEBUG
);
186 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
188 struct bgp_info
*top
;
200 peer_lock (ri
->peer
); /* bgp_info peer reference */
203 /* Do the actual removal of info from RIB, for use by bgp_process
204 completion callback *only* */
206 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
209 ri
->next
->prev
= ri
->prev
;
211 ri
->prev
->next
= ri
->next
;
215 bgp_info_mpath_dequeue (ri
);
216 bgp_info_unlock (ri
);
217 bgp_unlock_node (rn
);
221 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
223 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
224 /* set of previous already took care of pcount */
225 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
228 /* undo the effects of a previous call to bgp_info_delete; typically
229 called when a route is deleted and then quickly re-added before the
230 deletion has been processed */
232 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
234 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
235 /* unset of previous already took care of pcount */
236 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
239 /* Adjust pcount as required */
241 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
243 struct bgp_table
*table
;
245 assert (rn
&& bgp_node_table (rn
));
246 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
248 table
= bgp_node_table (rn
);
250 if (ri
->peer
== ri
->peer
->bgp
->peer_self
)
253 if (!BGP_INFO_COUNTABLE (ri
)
254 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
257 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
259 /* slight hack, but more robust against errors. */
260 if (ri
->peer
->pcount
[table
->afi
][table
->safi
])
261 ri
->peer
->pcount
[table
->afi
][table
->safi
]--;
264 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
265 __func__
, ri
->peer
->host
);
266 zlog_backtrace (LOG_WARNING
);
267 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
270 else if (BGP_INFO_COUNTABLE (ri
)
271 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
273 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
274 ri
->peer
->pcount
[table
->afi
][table
->safi
]++;
279 /* Set/unset bgp_info flags, adjusting any other state as needed.
280 * This is here primarily to keep prefix-count in check.
283 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
285 SET_FLAG (ri
->flags
, flag
);
287 /* early bath if we know it's not a flag that changes countability state */
288 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
291 bgp_pcount_adjust (rn
, ri
);
295 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
297 UNSET_FLAG (ri
->flags
, flag
);
299 /* early bath if we know it's not a flag that changes countability state */
300 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
303 bgp_pcount_adjust (rn
, ri
);
306 /* Get MED value. If MED value is missing and "bgp bestpath
307 missing-as-worst" is specified, treat it as the worst value. */
309 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
311 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
315 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
323 bgp_info_path_with_addpath_rx_str (struct bgp_info
*ri
, char *buf
)
325 if (ri
->addpath_rx_id
)
326 sprintf(buf
, "path %s (addpath rxid %d)", ri
->peer
->host
, ri
->addpath_rx_id
);
328 sprintf(buf
, "path %s", ri
->peer
->host
);
331 /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */
333 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
334 int *paths_eq
, struct bgp_maxpaths_cfg
*mpath_cfg
, int debug
,
337 struct attr
*newattr
, *existattr
;
338 struct attr_extra
*newattre
, *existattre
;
339 bgp_peer_sort_t new_sort
;
340 bgp_peer_sort_t exist_sort
;
342 u_int32_t exist_pref
;
345 u_int32_t new_weight
;
346 u_int32_t exist_weight
;
347 uint32_t newm
, existm
;
348 struct in_addr new_id
;
349 struct in_addr exist_id
;
352 int internal_as_route
;
355 char new_buf
[PATH_ADDPATH_STR_BUFFER
];
356 char exist_buf
[PATH_ADDPATH_STR_BUFFER
];
364 zlog_debug("%s: new is NULL", pfx_buf
);
369 bgp_info_path_with_addpath_rx_str (new, new_buf
);
374 zlog_debug("%s: %s is the initial bestpath", pfx_buf
, new_buf
);
379 bgp_info_path_with_addpath_rx_str (exist
, exist_buf
);
382 existattr
= exist
->attr
;
383 newattre
= newattr
->extra
;
384 existattre
= existattr
->extra
;
386 /* 1. Weight check. */
387 new_weight
= exist_weight
= 0;
390 new_weight
= newattre
->weight
;
392 exist_weight
= existattre
->weight
;
394 if (new_weight
> exist_weight
)
397 zlog_debug("%s: %s wins over %s due to weight %d > %d",
398 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
402 if (new_weight
< exist_weight
)
405 zlog_debug("%s: %s loses to %s due to weight %d < %d",
406 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
410 /* 2. Local preference check. */
411 new_pref
= exist_pref
= bgp
->default_local_pref
;
413 if (newattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
414 new_pref
= newattr
->local_pref
;
415 if (existattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
416 exist_pref
= existattr
->local_pref
;
418 if (new_pref
> exist_pref
)
421 zlog_debug("%s: %s wins over %s due to localpref %d > %d",
422 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
426 if (new_pref
< exist_pref
)
429 zlog_debug("%s: %s loses to %s due to localpref %d < %d",
430 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
434 /* 3. Local route check. We prefer:
436 * - BGP_ROUTE_AGGREGATE
437 * - BGP_ROUTE_REDISTRIBUTE
439 if (! (new->sub_type
== BGP_ROUTE_NORMAL
))
442 zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type",
443 pfx_buf
, new_buf
, exist_buf
);
447 if (! (exist
->sub_type
== BGP_ROUTE_NORMAL
))
450 zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type",
451 pfx_buf
, new_buf
, exist_buf
);
455 /* 4. AS path length check. */
456 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
458 int exist_hops
= aspath_count_hops (existattr
->aspath
);
459 int exist_confeds
= aspath_count_confeds (existattr
->aspath
);
461 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
465 aspath_hops
= aspath_count_hops (newattr
->aspath
);
466 aspath_hops
+= aspath_count_confeds (newattr
->aspath
);
468 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
471 zlog_debug("%s: %s wins over %s due to aspath (with confeds) hopcount %d < %d",
472 pfx_buf
, new_buf
, exist_buf
,
473 aspath_hops
, (exist_hops
+ exist_confeds
));
477 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
480 zlog_debug("%s: %s loses to %s due to aspath (with confeds) hopcount %d > %d",
481 pfx_buf
, new_buf
, exist_buf
,
482 aspath_hops
, (exist_hops
+ exist_confeds
));
488 int newhops
= aspath_count_hops (newattr
->aspath
);
490 if (newhops
< exist_hops
)
493 zlog_debug("%s: %s wins over %s due to aspath hopcount %d < %d",
494 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
498 if (newhops
> exist_hops
)
501 zlog_debug("%s: %s loses to %s due to aspath hopcount %d > %d",
502 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
508 /* 5. Origin check. */
509 if (newattr
->origin
< existattr
->origin
)
512 zlog_debug("%s: %s wins over %s due to ORIGIN %s < %s",
513 pfx_buf
, new_buf
, exist_buf
,
514 bgp_origin_long_str
[newattr
->origin
],
515 bgp_origin_long_str
[existattr
->origin
]);
519 if (newattr
->origin
> existattr
->origin
)
522 zlog_debug("%s: %s loses to %s due to ORIGIN %s > %s",
523 pfx_buf
, new_buf
, exist_buf
,
524 bgp_origin_long_str
[newattr
->origin
],
525 bgp_origin_long_str
[existattr
->origin
]);
530 internal_as_route
= (aspath_count_hops (newattr
->aspath
) == 0
531 && aspath_count_hops (existattr
->aspath
) == 0);
532 confed_as_route
= (aspath_count_confeds (newattr
->aspath
) > 0
533 && aspath_count_confeds (existattr
->aspath
) > 0
534 && aspath_count_hops (newattr
->aspath
) == 0
535 && aspath_count_hops (existattr
->aspath
) == 0);
537 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
538 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
540 || aspath_cmp_left (newattr
->aspath
, existattr
->aspath
)
541 || aspath_cmp_left_confed (newattr
->aspath
, existattr
->aspath
)
542 || internal_as_route
)
544 new_med
= bgp_med_value (new->attr
, bgp
);
545 exist_med
= bgp_med_value (exist
->attr
, bgp
);
547 if (new_med
< exist_med
)
550 zlog_debug("%s: %s wins over %s due to MED %d < %d",
551 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
555 if (new_med
> exist_med
)
558 zlog_debug("%s: %s loses to %s due to MED %d > %d",
559 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
564 /* 7. Peer type check. */
565 new_sort
= new->peer
->sort
;
566 exist_sort
= exist
->peer
->sort
;
568 if (new_sort
== BGP_PEER_EBGP
569 && (exist_sort
== BGP_PEER_IBGP
|| exist_sort
== BGP_PEER_CONFED
))
572 zlog_debug("%s: %s wins over %s due to eBGP peer > iBGP peer",
573 pfx_buf
, new_buf
, exist_buf
);
577 if (exist_sort
== BGP_PEER_EBGP
578 && (new_sort
== BGP_PEER_IBGP
|| new_sort
== BGP_PEER_CONFED
))
581 zlog_debug("%s: %s loses to %s due to iBGP peer < eBGP peer",
582 pfx_buf
, new_buf
, exist_buf
);
586 /* 8. IGP metric check. */
590 newm
= new->extra
->igpmetric
;
592 existm
= exist
->extra
->igpmetric
;
597 zlog_debug("%s: %s wins over %s due to IGP metric %d < %d",
598 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
605 zlog_debug("%s: %s loses to %s due to IGP metric %d > %d",
606 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
610 /* 9. Same IGP metric. Compare the cluster list length as
611 representative of IGP hops metric. Rewrite the metric value
612 pair (newm, existm) with the cluster list length. Prefer the
613 path with smaller cluster list length. */
616 if (peer_sort (new->peer
) == BGP_PEER_IBGP
617 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
618 && CHECK_FLAG (mpath_cfg
->ibgp_flags
,
619 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
621 newm
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
622 existm
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
627 zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
628 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
635 zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
636 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
642 /* 10. confed-external vs. confed-internal */
643 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
645 if (new_sort
== BGP_PEER_CONFED
&& exist_sort
== BGP_PEER_IBGP
)
648 zlog_debug("%s: %s wins over %s due to confed-external peer > confed-internal peer",
649 pfx_buf
, new_buf
, exist_buf
);
653 if (exist_sort
== BGP_PEER_CONFED
&& new_sort
== BGP_PEER_IBGP
)
656 zlog_debug("%s: %s loses to %s due to confed-internal peer < confed-external peer",
657 pfx_buf
, new_buf
, exist_buf
);
662 /* 11. Maximum path check. */
665 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
))
669 * For the two paths, all comparison steps till IGP metric
670 * have succeeded - including AS_PATH hop count. Since 'bgp
671 * bestpath as-path multipath-relax' knob is on, we don't need
672 * an exact match of AS_PATH. Thus, mark the paths are equal.
673 * That will trigger both these paths to get into the multipath
679 zlog_debug("%s: %s and %s are equal via multipath-relax",
680 pfx_buf
, new_buf
, exist_buf
);
682 else if (new->peer
->sort
== BGP_PEER_IBGP
)
684 if (aspath_cmp (new->attr
->aspath
, exist
->attr
->aspath
))
689 zlog_debug("%s: %s and %s are equal via matching aspaths",
690 pfx_buf
, new_buf
, exist_buf
);
693 else if (new->peer
->as
== exist
->peer
->as
)
698 zlog_debug("%s: %s and %s are equal via same remote-as",
699 pfx_buf
, new_buf
, exist_buf
);
705 * TODO: If unequal cost ibgp multipath is enabled we can
706 * mark the paths as equal here instead of returning
711 /* 12. If both paths are external, prefer the path that was received
712 first (the oldest one). This step minimizes route-flap, since a
713 newer path won't displace an older one, even if it was the
714 preferred route based on the additional decision criteria below. */
715 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
716 && new_sort
== BGP_PEER_EBGP
717 && exist_sort
== BGP_PEER_EBGP
)
719 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
722 zlog_debug("%s: %s wins over %s due to oldest external",
723 pfx_buf
, new_buf
, exist_buf
);
727 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
730 zlog_debug("%s: %s loses to %s due to oldest external",
731 pfx_buf
, new_buf
, exist_buf
);
736 /* 13. Router-ID comparision. */
737 /* If one of the paths is "stale", the corresponding peer router-id will
738 * be 0 and would always win over the other path. If originator id is
739 * used for the comparision, it will decide which path is better.
741 if (newattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
742 new_id
.s_addr
= newattre
->originator_id
.s_addr
;
744 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
745 if (existattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
746 exist_id
.s_addr
= existattre
->originator_id
.s_addr
;
748 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
750 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
753 zlog_debug("%s: %s wins over %s due to Router-ID comparison",
754 pfx_buf
, new_buf
, exist_buf
);
758 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
761 zlog_debug("%s: %s loses to %s due to Router-ID comparison",
762 pfx_buf
, new_buf
, exist_buf
);
766 /* 14. Cluster length comparision. */
767 new_cluster
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
768 exist_cluster
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
770 if (new_cluster
< exist_cluster
)
773 zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
774 pfx_buf
, new_buf
, exist_buf
, new_cluster
, exist_cluster
);
778 if (new_cluster
> exist_cluster
)
781 zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
782 pfx_buf
, new_buf
, exist_buf
, new_cluster
, exist_cluster
);
786 /* 15. Neighbor address comparision. */
787 /* Do this only if neither path is "stale" as stale paths do not have
788 * valid peer information (as the connection may or may not be up).
790 if (CHECK_FLAG (exist
->flags
, BGP_INFO_STALE
))
793 zlog_debug("%s: %s wins over %s due to latter path being STALE",
794 pfx_buf
, new_buf
, exist_buf
);
798 if (CHECK_FLAG (new->flags
, BGP_INFO_STALE
))
801 zlog_debug("%s: %s loses to %s due to former path being STALE",
802 pfx_buf
, new_buf
, exist_buf
);
806 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
811 zlog_debug("%s: %s loses to %s due to Neighor IP comparison",
812 pfx_buf
, new_buf
, exist_buf
);
819 zlog_debug("%s: %s wins over %s due to Neighor IP comparison",
820 pfx_buf
, new_buf
, exist_buf
);
825 zlog_debug("%s: %s wins over %s due to nothing left to compare",
826 pfx_buf
, new_buf
, exist_buf
);
831 static enum filter_type
832 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
833 afi_t afi
, safi_t safi
)
835 struct bgp_filter
*filter
;
837 filter
= &peer
->filter
[afi
][safi
];
839 #define FILTER_EXIST_WARN(F,f,filter) \
840 if (BGP_DEBUG (update, UPDATE_IN) \
841 && !(F ## _IN (filter))) \
842 zlog_warn ("%s: Could not find configured input %s-list %s!", \
843 peer->host, #f, F ## _IN_NAME(filter));
845 if (DISTRIBUTE_IN_NAME (filter
)) {
846 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
848 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
852 if (PREFIX_LIST_IN_NAME (filter
)) {
853 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
855 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
859 if (FILTER_LIST_IN_NAME (filter
)) {
860 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
862 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
866 return FILTER_PERMIT
;
867 #undef FILTER_EXIST_WARN
870 static enum filter_type
871 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
872 afi_t afi
, safi_t safi
)
874 struct bgp_filter
*filter
;
876 filter
= &peer
->filter
[afi
][safi
];
878 #define FILTER_EXIST_WARN(F,f,filter) \
879 if (BGP_DEBUG (update, UPDATE_OUT) \
880 && !(F ## _OUT (filter))) \
881 zlog_warn ("%s: Could not find configured output %s-list %s!", \
882 peer->host, #f, F ## _OUT_NAME(filter));
884 if (DISTRIBUTE_OUT_NAME (filter
)) {
885 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
887 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
891 if (PREFIX_LIST_OUT_NAME (filter
)) {
892 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
894 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
898 if (FILTER_LIST_OUT_NAME (filter
)) {
899 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
901 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
905 return FILTER_PERMIT
;
906 #undef FILTER_EXIST_WARN
909 /* If community attribute includes no_export then return 1. */
911 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
915 /* NO_ADVERTISE check. */
916 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
919 /* NO_EXPORT check. */
920 if (peer
->sort
== BGP_PEER_EBGP
&&
921 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
924 /* NO_EXPORT_SUBCONFED check. */
925 if (peer
->sort
== BGP_PEER_EBGP
926 || peer
->sort
== BGP_PEER_CONFED
)
927 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
933 /* Route reflection loop check. */
935 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
937 struct in_addr cluster_id
;
939 if (attr
->extra
&& attr
->extra
->cluster
)
941 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
942 cluster_id
= peer
->bgp
->cluster_id
;
944 cluster_id
= peer
->bgp
->router_id
;
946 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
953 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
954 afi_t afi
, safi_t safi
, const char *rmap_name
)
956 struct bgp_filter
*filter
;
957 struct bgp_info info
;
958 route_map_result_t ret
;
959 struct route_map
*rmap
= NULL
;
961 filter
= &peer
->filter
[afi
][safi
];
963 /* Apply default weight value. */
965 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
969 rmap
= route_map_lookup_by_name(rmap_name
);
976 if (ROUTE_MAP_IN_NAME(filter
))
978 rmap
= ROUTE_MAP_IN (filter
);
985 /* Route map apply. */
988 /* Duplicate current value to new strucutre for modification. */
992 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
994 /* Apply BGP route map to the attribute. */
995 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
999 if (ret
== RMAP_DENYMATCH
)
1001 /* Free newly generated AS path and community by route-map. */
1002 bgp_attr_flush (attr
);
1010 bgp_output_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_OUT_NAME(filter
))
1035 rmap
= ROUTE_MAP_OUT (filter
);
1042 /* Route map apply. */
1045 /* Duplicate current value to new strucutre for modification. */
1049 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
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
)
1057 /* caller has multiple error paths with bgp_attr_flush() */
1063 /* If this is an EBGP peer with remove-private-AS */
1065 bgp_peer_remove_private_as(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1066 struct peer
*peer
, struct attr
*attr
)
1068 if (peer
->sort
== BGP_PEER_EBGP
&&
1069 (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1070 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
) ||
1071 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
) ||
1072 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)))
1074 // Take action on the entire aspath
1075 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1076 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
1078 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
1079 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1081 // The entire aspath consists of private ASNs so create an empty aspath
1082 else if (aspath_private_as_check (attr
->aspath
))
1083 attr
->aspath
= aspath_empty_get ();
1085 // There are some public and some private ASNs, remove the private ASNs
1087 attr
->aspath
= aspath_remove_private_asns (attr
->aspath
);
1090 // 'all' was not specified so the entire aspath must be private ASNs
1091 // for us to do anything
1092 else if (aspath_private_as_check (attr
->aspath
))
1094 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
1095 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1097 attr
->aspath
= aspath_empty_get ();
1102 /* If this is an EBGP peer with as-override */
1104 bgp_peer_as_override(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1105 struct peer
*peer
, struct attr
*attr
)
1107 if (peer
->sort
== BGP_PEER_EBGP
&&
1108 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
))
1110 if (aspath_single_asn_check (attr
->aspath
, peer
->as
))
1111 attr
->aspath
= aspath_replace_specific_asn (attr
->aspath
, peer
->as
, bgp
->as
);
1116 subgroup_announce_reset_nhop (u_char family
, struct attr
*attr
)
1118 if (family
== AF_INET
)
1119 attr
->nexthop
.s_addr
= 0;
1121 if (family
== AF_INET6
)
1122 memset (&attr
->extra
->mp_nexthop_global
, 0, IPV6_MAX_BYTELEN
);
1127 subgroup_announce_check (struct bgp_info
*ri
, struct update_subgroup
*subgrp
,
1128 struct prefix
*p
, struct attr
*attr
)
1130 struct bgp_filter
*filter
;
1133 struct peer
*onlypeer
;
1135 struct attr
*riattr
;
1136 struct peer_af
*paf
;
1137 char buf
[SU_ADDRSTRLEN
];
1144 if (DISABLE_BGP_ANNOUNCE
)
1147 afi
= SUBGRP_AFI(subgrp
);
1148 safi
= SUBGRP_SAFI(subgrp
);
1149 peer
= SUBGRP_PEER(subgrp
);
1151 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_LONESOUL
))
1152 onlypeer
= SUBGRP_PFIRST(subgrp
)->peer
;
1155 filter
= &peer
->filter
[afi
][safi
];
1156 bgp
= SUBGRP_INST(subgrp
);
1157 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
1159 /* With addpath we may be asked to TX all kinds of paths so make sure
1161 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
) ||
1162 CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
) ||
1163 CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
1168 /* If this is not the bestpath then check to see if there is an enabled addpath
1169 * feature that requires us to advertise it */
1170 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1172 if (! bgp_addpath_tx_path(peer
, afi
, safi
, ri
))
1178 /* Aggregate-address suppress check. */
1179 if (ri
->extra
&& ri
->extra
->suppress
)
1180 if (! UNSUPPRESS_MAP_NAME (filter
))
1185 /* Do not send back route to sender. */
1186 if (onlypeer
&& from
== onlypeer
)
1191 /* Do not send the default route in the BGP table if the neighbor is
1192 * configured for default-originate */
1193 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
1195 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1198 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1200 #endif /* HAVE_IPV6 */
1203 /* Transparency check. */
1204 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
1205 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
1210 /* If community is not disabled check the no-export and local. */
1211 if (! transparent
&& bgp_community_filter (peer
, riattr
))
1213 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1214 zlog_debug ("subgrpannouncecheck: community filter check fail");
1218 /* If the attribute has originator-id and it is same as remote
1221 riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
) &&
1222 (IPV4_ADDR_SAME (&onlypeer
->remote_id
, &riattr
->extra
->originator_id
)))
1224 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1225 zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as "
1228 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1233 /* ORF prefix-list filter check */
1234 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1235 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1236 || CHECK_FLAG (peer
->af_cap
[afi
][safi
],
1237 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1238 if (peer
->orf_plist
[afi
][safi
])
1240 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1242 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1243 zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF",
1245 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1251 /* Output filter check. */
1252 if (bgp_output_filter (peer
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
1254 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1255 zlog_debug ("%s [Update:SEND] %s/%d is filtered",
1257 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1262 #ifdef BGP_SEND_ASPATH_CHECK
1263 /* AS path loop check. */
1264 if (onlypeer
&& aspath_loop_check (riattr
->aspath
, onlypeer
->as
))
1266 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1267 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u "
1268 "that is part of AS path.",
1269 onlypeer
->host
, onlypeer
->as
);
1272 #endif /* BGP_SEND_ASPATH_CHECK */
1274 /* If we're a CONFED we need to loop check the CONFED ID too */
1275 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
1277 if (aspath_loop_check(riattr
->aspath
, bgp
->confed_id
))
1279 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1280 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u"
1288 /* Route-Reflect check. */
1289 if (from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1294 /* IBGP reflection check. */
1297 /* A route from a Client peer. */
1298 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
1300 /* Reflect to all the Non-Client peers and also to the
1301 Client peers other than the originator. Originator check
1302 is already done. So there is noting to do. */
1303 /* no bgp client-to-client reflection check. */
1304 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
1305 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1306 PEER_FLAG_REFLECTOR_CLIENT
))
1311 /* A route from a Non-client peer. Reflect to all other
1313 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1314 PEER_FLAG_REFLECTOR_CLIENT
))
1319 /* For modify attribute, copy it to temporary structure. */
1320 bgp_attr_dup (attr
, riattr
);
1322 /* If local-preference is not set. */
1323 if ((peer
->sort
== BGP_PEER_IBGP
1324 || peer
->sort
== BGP_PEER_CONFED
)
1325 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
1327 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1328 attr
->local_pref
= bgp
->default_local_pref
;
1331 /* If originator-id is not set and the route is to be reflected,
1332 set the originator id */
1333 if (reflect
&& (!(attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))))
1335 attr
->extra
= bgp_attr_extra_get(attr
);
1336 IPV4_ADDR_COPY(&(attr
->extra
->originator_id
), &(from
->remote_id
));
1337 SET_FLAG(attr
->flag
, BGP_ATTR_ORIGINATOR_ID
);
1340 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
1341 if (peer
->sort
== BGP_PEER_EBGP
1342 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
1344 if (from
!= bgp
->peer_self
&& ! transparent
1345 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
1346 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
1349 /* Since the nexthop attribute can vary per peer, it is not explicitly set
1350 * in announce check, only certain flags and length (or number of nexthops
1351 * -- for IPv6/MP_REACH) are set here in order to guide the update formation
1352 * code in setting the nexthop(s) on a per peer basis in reformat_peer().
1353 * Typically, the source nexthop in the attribute is preserved but in the
1354 * scenarios where we know it will always be overwritten, we reset the
1355 * nexthop to "0" in an attempt to achieve better Update packing. An
1356 * example of this is when a prefix from each of 2 IBGP peers needs to be
1357 * announced to an EBGP peer (and they have the same attributes barring
1361 SET_FLAG(attr
->rmap_change_flags
, BATTR_REFLECTED
);
1364 /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
1365 * the peer (group) is configured to receive link-local nexthop unchanged
1366 * and it is available in the prefix OR we're not reflecting the route and
1367 * the peer (group) to whom we're going to announce is on a shared network
1368 * and this is either a self-originated route or the peer is EBGP.
1370 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1372 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
1373 if ((CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1374 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) &&
1375 IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
)) ||
1376 (!reflect
&& peer
->shared_network
&&
1377 (from
== bgp
->peer_self
|| peer
->sort
== BGP_PEER_EBGP
)))
1379 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
1382 /* Clear off link-local nexthop in source, whenever it is not needed to
1383 * ensure more prefixes share the same attribute for announcement.
1385 if (!(CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1386 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)))
1387 memset (&attr
->extra
->mp_nexthop_local
, 0, IPV6_MAX_BYTELEN
);
1389 #endif /* HAVE_IPV6 */
1391 bgp_peer_remove_private_as(bgp
, afi
, safi
, peer
, attr
);
1392 bgp_peer_as_override(bgp
, afi
, safi
, peer
, attr
);
1394 /* Route map & unsuppress-map apply. */
1395 if (ROUTE_MAP_OUT_NAME (filter
)
1396 || (ri
->extra
&& ri
->extra
->suppress
) )
1398 struct bgp_info info
;
1399 struct attr dummy_attr
;
1400 struct attr_extra dummy_extra
;
1402 dummy_attr
.extra
= &dummy_extra
;
1406 /* don't confuse inbound and outbound setting */
1407 RESET_FLAG(attr
->rmap_change_flags
);
1410 * The route reflector is not allowed to modify the attributes
1411 * of the reflected IBGP routes unless explicitly allowed.
1413 if ((from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1414 && !bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
))
1416 bgp_attr_dup (&dummy_attr
, attr
);
1417 info
.attr
= &dummy_attr
;
1420 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1422 if (ri
->extra
&& ri
->extra
->suppress
)
1423 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1425 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1427 peer
->rmap_type
= 0;
1429 if (ret
== RMAP_DENYMATCH
)
1431 bgp_attr_flush (attr
);
1436 /* After route-map has been applied, we check to see if the nexthop to
1437 * be carried in the attribute (that is used for the announcement) can
1438 * be cleared off or not. We do this in all cases where we would be
1439 * setting the nexthop to "ourselves". For IPv6, we only need to consider
1440 * the global nexthop here; the link-local nexthop would have been cleared
1441 * already, and if not, it is required by the update formation code.
1442 * Also see earlier comments in this function.
1445 * If route-map has performed some operation on the nexthop or the peer
1446 * configuration says to pass it unchanged, we cannot reset the nexthop
1447 * here, so only attempt to do it if these aren't true. Note that the
1448 * route-map handler itself might have cleared the nexthop, if for example,
1449 * it is configured as 'peer-address'.
1451 if (!bgp_rmap_nhop_changed(attr
->rmap_change_flags
,
1452 riattr
->rmap_change_flags
) &&
1454 !CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
))
1456 /* We can reset the nexthop, if setting (or forcing) it to 'self' */
1457 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
) ||
1458 CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_FORCE_NEXTHOP_SELF
))
1461 CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1462 PEER_FLAG_FORCE_NEXTHOP_SELF
))
1463 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ?
1464 AF_INET6
: p
->family
), attr
);
1466 else if (peer
->sort
== BGP_PEER_EBGP
)
1468 /* Can also reset the nexthop if announcing to EBGP, but only if
1469 * no peer in the subgroup is on a shared subnet.
1470 * Note: 3rd party nexthop currently implemented for IPv4 only.
1472 SUBGRP_FOREACH_PEER (subgrp
, paf
)
1474 if (bgp_multiaccess_check_v4 (riattr
->nexthop
, paf
->peer
))
1478 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ? AF_INET6
: p
->family
), attr
);
1480 /* If IPv6/MP and nexthop does not have any override and happens to
1481 * be a link-local address, reset it so that we don't pass along the
1482 * source's link-local IPv6 address to recipients who may not be on
1483 * the same interface.
1485 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1487 if (IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_global
))
1488 subgroup_announce_reset_nhop (AF_INET6
, attr
);
1495 struct bgp_info_pair
1497 struct bgp_info
*old
;
1498 struct bgp_info
*new;
1502 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
,
1503 struct bgp_maxpaths_cfg
*mpath_cfg
,
1504 struct bgp_info_pair
*result
)
1506 struct bgp_info
*new_select
;
1507 struct bgp_info
*old_select
;
1508 struct bgp_info
*ri
;
1509 struct bgp_info
*ri1
;
1510 struct bgp_info
*ri2
;
1511 struct bgp_info
*nextri
= NULL
;
1512 int paths_eq
, do_mpath
, debug
;
1513 struct list mp_list
;
1514 char pfx_buf
[PREFIX2STR_BUFFER
];
1515 char path_buf
[PATH_ADDPATH_STR_BUFFER
];
1517 bgp_mp_list_init (&mp_list
);
1518 do_mpath
= (mpath_cfg
->maxpaths_ebgp
> 1 || mpath_cfg
->maxpaths_ibgp
> 1);
1520 debug
= bgp_debug_bestpath(&rn
->p
);
1523 prefix2str (&rn
->p
, pfx_buf
, sizeof (pfx_buf
));
1525 /* bgp deterministic-med */
1527 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1530 /* Clear BGP_INFO_DMED_SELECTED for all paths */
1531 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1532 bgp_info_unset_flag (rn
, ri1
, BGP_INFO_DMED_SELECTED
);
1534 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1536 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1538 if (BGP_INFO_HOLDDOWN (ri1
))
1540 if (ri1
->peer
&& ri1
->peer
!= bgp
->peer_self
)
1541 if (ri1
->peer
->status
!= Established
)
1545 old_select
= CHECK_FLAG (ri1
->flags
, BGP_INFO_SELECTED
) ? ri1
: NULL
;
1548 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1550 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1552 if (BGP_INFO_HOLDDOWN (ri2
))
1555 ri2
->peer
!= bgp
->peer_self
&&
1556 !CHECK_FLAG (ri2
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1557 if (ri2
->peer
->status
!= Established
)
1560 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1561 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1564 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_SELECTED
))
1566 if (bgp_info_cmp (bgp
, ri2
, new_select
, &paths_eq
,
1567 mpath_cfg
, debug
, pfx_buf
))
1569 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1573 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1577 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1578 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1582 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1583 zlog_debug("%s: %s is the bestpath from AS %d",
1584 pfx_buf
, path_buf
, aspath_get_firstas(new_select
->attr
->aspath
));
1589 /* Check old selected route and new selected route. */
1592 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1594 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1597 if (BGP_INFO_HOLDDOWN (ri
))
1599 /* reap REMOVED routes, if needs be
1600 * selected route must stay for a while longer though
1602 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1603 && (ri
!= old_select
))
1604 bgp_info_reap (rn
, ri
);
1610 ri
->peer
!= bgp
->peer_self
&&
1611 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1612 if (ri
->peer
->status
!= Established
)
1615 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1616 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1618 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1622 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1624 if (bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
))
1630 /* Now that we know which path is the bestpath see if any of the other paths
1631 * qualify as multipaths
1633 if (do_mpath
&& new_select
)
1637 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1638 zlog_debug("%s: %s is the bestpath, now find multipaths", pfx_buf
, path_buf
);
1641 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1645 bgp_info_path_with_addpath_rx_str (ri
, path_buf
);
1647 if (ri
== new_select
)
1650 zlog_debug("%s: %s is the bestpath, add to the multipath list",
1652 bgp_mp_list_add (&mp_list
, ri
);
1656 if (BGP_INFO_HOLDDOWN (ri
))
1660 ri
->peer
!= bgp
->peer_self
&&
1661 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1662 if (ri
->peer
->status
!= Established
)
1665 if (!bgp_info_nexthop_cmp (ri
, new_select
))
1668 zlog_debug("%s: %s has the same nexthop as the bestpath, skip it",
1673 bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
);
1678 zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list",
1680 bgp_mp_list_add (&mp_list
, ri
);
1685 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1686 bgp_info_mpath_aggregate_update (new_select
, old_select
);
1687 bgp_mp_list_clear (&mp_list
);
1689 result
->old
= old_select
;
1690 result
->new = new_select
;
1696 * A new route/change in bestpath of an existing route. Evaluate the path
1697 * for advertisement to the subgroup.
1700 subgroup_process_announce_selected (struct update_subgroup
*subgrp
,
1701 struct bgp_info
*selected
,
1702 struct bgp_node
*rn
,
1703 u_int32_t addpath_tx_id
)
1706 struct peer
*onlypeer
;
1708 struct attr_extra extra
;
1713 afi
= SUBGRP_AFI(subgrp
);
1714 safi
= SUBGRP_SAFI(subgrp
);
1715 onlypeer
= ((SUBGRP_PCOUNT(subgrp
) == 1) ?
1716 (SUBGRP_PFIRST(subgrp
))->peer
: NULL
);
1718 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1719 if (onlypeer
&& CHECK_FLAG (onlypeer
->af_sflags
[afi
][safi
],
1720 PEER_STATUS_ORF_WAIT_REFRESH
))
1723 /* It's initialized in bgp_announce_check() */
1724 attr
.extra
= &extra
;
1726 /* Announcement to the subgroup. If the route is filtered withdraw it. */
1729 if (subgroup_announce_check(selected
, subgrp
, p
, &attr
))
1730 bgp_adj_out_set_subgroup(rn
, subgrp
, &attr
, selected
);
1732 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, selected
->addpath_tx_id
);
1735 /* If selected is NULL we must withdraw the path using addpath_tx_id */
1738 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, addpath_tx_id
);
1744 struct bgp_process_queue
1747 struct bgp_node
*rn
;
1752 static wq_item_status
1753 bgp_process_main (struct work_queue
*wq
, void *data
)
1755 struct bgp_process_queue
*pq
= data
;
1756 struct bgp
*bgp
= pq
->bgp
;
1757 struct bgp_node
*rn
= pq
->rn
;
1758 afi_t afi
= pq
->afi
;
1759 safi_t safi
= pq
->safi
;
1760 struct prefix
*p
= &rn
->p
;
1761 struct bgp_info
*new_select
;
1762 struct bgp_info
*old_select
;
1763 struct bgp_info_pair old_and_new
;
1765 /* Is it end of initial update? (after startup) */
1768 quagga_timestamp(3, bgp
->update_delay_zebra_resume_time
,
1769 sizeof(bgp
->update_delay_zebra_resume_time
));
1771 bgp
->main_zebra_update_hold
= 0;
1772 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1773 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1775 bgp_zebra_announce_table(bgp
, afi
, safi
);
1777 bgp
->main_peers_update_hold
= 0;
1779 bgp_start_routeadv(bgp
);
1783 /* Best path selection. */
1784 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1785 old_select
= old_and_new
.old
;
1786 new_select
= old_and_new
.new;
1788 /* Nothing to do. */
1789 if (old_select
&& old_select
== new_select
&&
1790 !CHECK_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
) &&
1791 !CHECK_FLAG(old_select
->flags
, BGP_INFO_ATTR_CHANGED
) &&
1792 !bgp
->addpath_tx_used
[afi
][safi
])
1794 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
) ||
1795 CHECK_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
))
1796 bgp_zebra_announce (p
, old_select
, bgp
, afi
, safi
);
1798 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1799 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1803 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1804 UNSET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
1806 /* bestpath has changed; bump version */
1807 if (old_select
|| new_select
)
1809 bgp_bump_version(rn
);
1811 if (!bgp
->t_rmap_def_originate_eval
)
1814 THREAD_TIMER_ON(bm
->master
, bgp
->t_rmap_def_originate_eval
,
1815 update_group_refresh_default_originate_route_map
,
1816 bgp
, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER
);
1821 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1824 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1825 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1826 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1829 group_announce_route(bgp
, afi
, safi
, rn
, new_select
);
1832 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) &&
1833 (bgp
->inst_type
!= BGP_INSTANCE_TYPE_VIEW
) &&
1834 !bgp_option_check (BGP_OPT_NO_FIB
))
1837 && new_select
->type
== ZEBRA_ROUTE_BGP
1838 && (new_select
->sub_type
== BGP_ROUTE_NORMAL
||
1839 new_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1840 bgp_zebra_announce (p
, new_select
, bgp
, afi
, safi
);
1843 /* Withdraw the route from the kernel. */
1845 && old_select
->type
== ZEBRA_ROUTE_BGP
1846 && (old_select
->sub_type
== BGP_ROUTE_NORMAL
||
1847 old_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1848 bgp_zebra_withdraw (p
, old_select
, safi
);
1852 /* Reap old select bgp_info, if it has been removed */
1853 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1854 bgp_info_reap (rn
, old_select
);
1856 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1861 bgp_processq_del (struct work_queue
*wq
, void *data
)
1863 struct bgp_process_queue
*pq
= data
;
1864 struct bgp_table
*table
;
1866 bgp_unlock (pq
->bgp
);
1869 table
= bgp_node_table (pq
->rn
);
1870 bgp_unlock_node (pq
->rn
);
1871 bgp_table_unlock (table
);
1873 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1877 bgp_process_queue_init (void)
1879 if (!bm
->process_main_queue
)
1881 bm
->process_main_queue
1882 = work_queue_new (bm
->master
, "process_main_queue");
1884 if ( !bm
->process_main_queue
)
1886 zlog_err ("%s: Failed to allocate work queue", __func__
);
1891 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1892 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1893 bm
->process_main_queue
->spec
.max_retries
= 0;
1894 bm
->process_main_queue
->spec
.hold
= 50;
1895 /* Use a higher yield value of 50ms for main queue processing */
1896 bm
->process_main_queue
->spec
.yield
= 50 * 1000L;
1900 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1902 struct bgp_process_queue
*pqnode
;
1904 /* already scheduled for processing? */
1905 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1908 if (bm
->process_main_queue
== NULL
)
1909 bgp_process_queue_init ();
1911 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1912 sizeof (struct bgp_process_queue
));
1916 /* all unlocked in bgp_processq_del */
1917 bgp_table_lock (bgp_node_table (rn
));
1918 pqnode
->rn
= bgp_lock_node (rn
);
1922 pqnode
->safi
= safi
;
1923 work_queue_add (bm
->process_main_queue
, pqnode
);
1924 SET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1929 bgp_add_eoiu_mark (struct bgp
*bgp
)
1931 struct bgp_process_queue
*pqnode
;
1933 if (bm
->process_main_queue
== NULL
)
1934 bgp_process_queue_init ();
1936 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1937 sizeof (struct bgp_process_queue
));
1944 work_queue_add (bm
->process_main_queue
, pqnode
);
1948 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1952 peer
= THREAD_ARG (thread
);
1953 peer
->t_pmax_restart
= NULL
;
1955 if (bgp_debug_neighbor_events(peer
))
1956 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1959 peer_clear (peer
, NULL
);
1965 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1966 safi_t safi
, int always
)
1968 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1971 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
1973 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
1977 zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
1978 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
1979 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
1980 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
1982 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
1988 if (safi
== SAFI_MPLS_VPN
)
1989 safi
= SAFI_MPLS_LABELED_VPN
;
1991 ndata
[0] = (afi
>> 8);
1994 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
1995 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
1996 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
1997 ndata
[6] = (peer
->pmax
[afi
][safi
]);
1999 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
2000 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
2001 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
2004 /* Dynamic peers will just close their connection. */
2005 if (peer_dynamic_neighbor (peer
))
2008 /* restart timer start */
2009 if (peer
->pmax_restart
[afi
][safi
])
2011 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
2013 if (bgp_debug_neighbor_events(peer
))
2014 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
2015 peer
->host
, peer
->v_pmax_restart
);
2017 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
2018 peer
->v_pmax_restart
);
2024 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2026 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
2028 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
2032 zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
2033 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
2034 peer
->pmax
[afi
][safi
]);
2035 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2038 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2042 /* Unconditionally remove the route from the RIB, without taking
2043 * damping into consideration (eg, because the session went down)
2046 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2047 afi_t afi
, safi_t safi
)
2049 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2051 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2052 bgp_info_delete (rn
, ri
); /* keep historical info */
2054 bgp_process (peer
->bgp
, rn
, afi
, safi
);
2058 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2059 afi_t afi
, safi_t safi
)
2061 int status
= BGP_DAMP_NONE
;
2063 /* apply dampening, if result is suppressed, we'll be retaining
2064 * the bgp_info in the RIB for historical reference.
2066 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2067 && peer
->sort
== BGP_PEER_EBGP
)
2068 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
2069 == BGP_DAMP_SUPPRESSED
)
2071 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2075 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2078 static struct bgp_info
*
2079 info_make (int type
, int sub_type
, u_short instance
, struct peer
*peer
, struct attr
*attr
,
2080 struct bgp_node
*rn
)
2082 struct bgp_info
*new;
2084 /* Make new BGP info. */
2085 new = XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
2087 new->instance
= instance
;
2088 new->sub_type
= sub_type
;
2091 new->uptime
= bgp_clock ();
2093 new->addpath_tx_id
= ++peer
->bgp
->addpath_tx_id
;
2098 bgp_info_addpath_rx_str(u_int32_t addpath_id
, char *buf
)
2101 sprintf(buf
, " with addpath ID %d", addpath_id
);
2105 /* Check if received nexthop is valid or not. */
2107 bgp_update_martian_nexthop (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct attr
*attr
)
2109 struct attr_extra
*attre
= attr
->extra
;
2112 /* Only validated for unicast and multicast currently. */
2113 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2116 /* If NEXT_HOP is present, validate it. */
2117 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2119 if (attr
->nexthop
.s_addr
== 0 ||
2120 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2121 bgp_nexthop_self (bgp
, attr
))
2125 /* If MP_NEXTHOP is present, validate it. */
2126 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2127 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2128 * it is not an IPv6 link-local address.
2130 if (attre
&& attre
->mp_nexthop_len
)
2132 switch (attre
->mp_nexthop_len
)
2134 case BGP_ATTR_NHLEN_IPV4
:
2135 case BGP_ATTR_NHLEN_VPNV4
:
2136 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2137 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2141 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2142 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2143 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2144 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2145 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2147 #endif /* HAVE_IPV6 */
2159 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2160 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2161 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2165 int aspath_loop_count
= 0;
2166 struct bgp_node
*rn
;
2168 struct attr new_attr
;
2169 struct attr_extra new_extra
;
2170 struct attr
*attr_new
;
2171 struct bgp_info
*ri
;
2172 struct bgp_info
*new;
2174 char buf
[SU_ADDRSTRLEN
];
2179 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2181 /* When peer's soft reconfiguration enabled. Record input packet in
2183 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2184 && peer
!= bgp
->peer_self
)
2185 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2187 /* Check previously received route. */
2188 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2189 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2190 ri
->addpath_rx_id
== addpath_id
)
2193 /* AS path local-as loop check. */
2194 if (peer
->change_local_as
)
2196 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2197 aspath_loop_count
= 1;
2199 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2201 reason
= "as-path contains our own AS;";
2206 /* AS path loop check. */
2207 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2208 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2209 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2210 > peer
->allowas_in
[afi
][safi
]))
2212 reason
= "as-path contains our own AS;";
2216 /* Route reflector originator ID check. */
2217 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2218 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2220 reason
= "originator is us;";
2224 /* Route reflector cluster ID check. */
2225 if (bgp_cluster_filter (peer
, attr
))
2227 reason
= "reflected from the same cluster;";
2231 /* Apply incoming filter. */
2232 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2238 new_attr
.extra
= &new_extra
;
2239 bgp_attr_dup (&new_attr
, attr
);
2241 /* Apply incoming route-map.
2242 * NB: new_attr may now contain newly allocated values from route-map "set"
2243 * commands, so we need bgp_attr_flush in the error paths, until we intern
2244 * the attr (which takes over the memory references) */
2245 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2247 reason
= "route-map;";
2248 bgp_attr_flush (&new_attr
);
2252 /* next hop check. */
2253 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2255 reason
= "martian or self next-hop;";
2256 bgp_attr_flush (&new_attr
);
2260 attr_new
= bgp_attr_intern (&new_attr
);
2262 /* If the update is implicit withdraw. */
2265 ri
->uptime
= bgp_clock ();
2267 /* Same attribute comes in. */
2268 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2269 && attrhash_cmp (ri
->attr
, attr_new
))
2271 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2272 && peer
->sort
== BGP_PEER_EBGP
2273 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2275 if (bgp_debug_update(peer
, p
, NULL
, 1))
2277 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2278 zlog_debug ("%s rcvd %s/%d%s",
2280 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2281 p
->prefixlen
, buf2
);
2284 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2286 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2287 bgp_process (bgp
, rn
, afi
, safi
);
2290 else /* Duplicate - odd */
2292 if (bgp_debug_update(peer
, p
, NULL
, 1))
2294 if (!peer
->rcvd_attr_printed
)
2296 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2297 peer
->rcvd_attr_printed
= 1;
2300 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2301 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2303 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2304 p
->prefixlen
, buf2
);
2307 /* graceful restart STALE flag unset. */
2308 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2310 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2311 bgp_process (bgp
, rn
, afi
, safi
);
2315 bgp_unlock_node (rn
);
2316 bgp_attr_unintern (&attr_new
);
2321 /* Withdraw/Announce before we fully processed the withdraw */
2322 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2324 if (bgp_debug_update(peer
, p
, NULL
, 1))
2326 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2327 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2329 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2330 p
->prefixlen
, buf2
);
2332 bgp_info_restore (rn
, ri
);
2335 /* Received Logging. */
2336 if (bgp_debug_update(peer
, p
, NULL
, 1))
2338 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2339 zlog_debug ("%s rcvd %s/%d%s",
2341 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2342 p
->prefixlen
, buf2
);
2345 /* graceful restart STALE flag unset. */
2346 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2347 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2349 /* The attribute is changed. */
2350 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2352 /* implicit withdraw, decrement aggregate and pcount here.
2353 * only if update is accepted, they'll increment below.
2355 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2357 /* Update bgp route dampening information. */
2358 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2359 && peer
->sort
== BGP_PEER_EBGP
)
2361 /* This is implicit withdraw so we should update dampening
2363 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2364 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2367 /* Update to new attribute. */
2368 bgp_attr_unintern (&ri
->attr
);
2369 ri
->attr
= attr_new
;
2371 /* Update MPLS tag. */
2372 if (safi
== SAFI_MPLS_VPN
)
2373 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2375 /* Update bgp route dampening information. */
2376 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2377 && peer
->sort
== BGP_PEER_EBGP
)
2379 /* Now we do normal update dampening. */
2380 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2381 if (ret
== BGP_DAMP_SUPPRESSED
)
2383 bgp_unlock_node (rn
);
2388 /* Nexthop reachability check. */
2389 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2391 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2392 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2393 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2398 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2399 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2402 if (BGP_DEBUG(nht
, NHT
))
2404 char buf1
[INET6_ADDRSTRLEN
];
2405 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2406 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2408 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2412 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2414 /* Process change. */
2415 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2417 bgp_process (bgp
, rn
, afi
, safi
);
2418 bgp_unlock_node (rn
);
2421 } // End of implicit withdraw
2423 /* Received Logging. */
2424 if (bgp_debug_update(peer
, p
, NULL
, 1))
2426 if (!peer
->rcvd_attr_printed
)
2428 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2429 peer
->rcvd_attr_printed
= 1;
2432 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2433 zlog_debug ("%s rcvd %s/%d%s",
2435 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2436 p
->prefixlen
, buf2
);
2439 /* Make new BGP info. */
2440 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2442 /* Update MPLS tag. */
2443 if (safi
== SAFI_MPLS_VPN
)
2444 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2446 /* Nexthop reachability check. */
2447 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2449 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2450 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2451 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2456 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2457 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2460 if (BGP_DEBUG(nht
, NHT
))
2462 char buf1
[INET6_ADDRSTRLEN
];
2463 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2464 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2466 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2470 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2473 new->addpath_rx_id
= addpath_id
;
2475 /* Increment prefix */
2476 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2478 /* Register new BGP information. */
2479 bgp_info_add (rn
, new);
2481 /* route_node_get lock */
2482 bgp_unlock_node (rn
);
2484 /* If maximum prefix count is configured and current prefix
2486 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2489 /* Process change. */
2490 bgp_process (bgp
, rn
, afi
, safi
);
2494 /* This BGP update is filtered. Log the reason then update BGP
2497 if (bgp_debug_update(peer
, p
, NULL
, 1))
2499 if (!peer
->rcvd_attr_printed
)
2501 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2502 peer
->rcvd_attr_printed
= 1;
2505 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2506 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2508 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2509 p
->prefixlen
, buf2
, reason
);
2513 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2515 bgp_unlock_node (rn
);
2521 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2522 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2523 struct prefix_rd
*prd
, u_char
*tag
)
2526 char buf
[SU_ADDRSTRLEN
];
2528 struct bgp_node
*rn
;
2529 struct bgp_info
*ri
;
2534 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2536 /* If peer is soft reconfiguration enabled. Record input packet for
2537 further calculation. */
2538 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2539 && peer
!= bgp
->peer_self
)
2540 bgp_adj_in_unset (rn
, peer
, addpath_id
);
2542 /* Lookup withdrawn route. */
2543 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2544 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2545 ri
->addpath_rx_id
== addpath_id
)
2549 if (bgp_debug_update(peer
, p
, NULL
, 1))
2551 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2552 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2554 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2555 p
->prefixlen
, buf2
);
2558 /* Withdraw specified route from routing table. */
2559 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2560 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2561 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2562 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2563 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2566 /* Unlock bgp_node_get() lock. */
2567 bgp_unlock_node (rn
);
2573 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2575 struct update_subgroup
*subgrp
;
2576 subgrp
= peer_subgroup(peer
, afi
, safi
);
2577 subgroup_default_originate(subgrp
, withdraw
);
2582 * bgp_stop_announce_route_timer
2585 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2587 if (!paf
->t_announce_route
)
2590 THREAD_TIMER_OFF (paf
->t_announce_route
);
2594 * bgp_announce_route_timer_expired
2596 * Callback that is invoked when the route announcement timer for a
2600 bgp_announce_route_timer_expired (struct thread
*t
)
2602 struct peer_af
*paf
;
2606 paf
= THREAD_ARG (t
);
2609 assert (paf
->t_announce_route
);
2610 paf
->t_announce_route
= NULL
;
2612 if (peer
->status
!= Established
)
2615 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2618 peer_af_announce_route (paf
, 1);
2623 * bgp_announce_route
2625 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2628 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2630 struct peer_af
*paf
;
2631 struct update_subgroup
*subgrp
;
2633 paf
= peer_af_find (peer
, afi
, safi
);
2636 subgrp
= PAF_SUBGRP(paf
);
2639 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2640 * or a refresh has already been triggered.
2642 if (!subgrp
|| paf
->t_announce_route
)
2646 * Start a timer to stagger/delay the announce. This serves
2647 * two purposes - announcement can potentially be combined for
2648 * multiple peers and the announcement doesn't happen in the
2651 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2652 bgp_announce_route_timer_expired
, paf
,
2653 (subgrp
->peer_count
== 1) ?
2654 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2655 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2659 * Announce routes from all AF tables to a peer.
2661 * This should ONLY be called when there is a need to refresh the
2662 * routes to the peer based on a policy change for this peer alone
2663 * or a route refresh request received from the peer.
2664 * The operation will result in splitting the peer from its existing
2665 * subgroups and putting it in new subgroups.
2668 bgp_announce_route_all (struct peer
*peer
)
2673 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2674 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2675 bgp_announce_route (peer
, afi
, safi
);
2679 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2680 struct bgp_table
*table
, struct prefix_rd
*prd
)
2683 struct bgp_node
*rn
;
2684 struct bgp_adj_in
*ain
;
2687 table
= peer
->bgp
->rib
[afi
][safi
];
2689 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2690 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2692 if (ain
->peer
== peer
)
2694 struct bgp_info
*ri
= rn
->info
;
2695 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
2697 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
2698 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2703 bgp_unlock_node (rn
);
2711 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2713 struct bgp_node
*rn
;
2714 struct bgp_table
*table
;
2716 if (peer
->status
!= Established
)
2719 if (safi
!= SAFI_MPLS_VPN
)
2720 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
2722 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2723 rn
= bgp_route_next (rn
))
2724 if ((table
= rn
->info
) != NULL
)
2726 struct prefix_rd prd
;
2727 prd
.family
= AF_UNSPEC
;
2729 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
2731 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
2736 struct bgp_clear_node_queue
2738 struct bgp_node
*rn
;
2741 static wq_item_status
2742 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2744 struct bgp_clear_node_queue
*cnq
= data
;
2745 struct bgp_node
*rn
= cnq
->rn
;
2746 struct peer
*peer
= wq
->spec
.data
;
2747 struct bgp_info
*ri
;
2748 afi_t afi
= bgp_node_table (rn
)->afi
;
2749 safi_t safi
= bgp_node_table (rn
)->safi
;
2751 assert (rn
&& peer
);
2753 /* It is possible that we have multiple paths for a prefix from a peer
2754 * if that peer is using AddPath.
2756 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2757 if (ri
->peer
== peer
)
2759 /* graceful restart STALE flag set. */
2760 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2761 && peer
->nsf
[afi
][safi
]
2762 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2763 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2764 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2766 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2772 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2774 struct bgp_clear_node_queue
*cnq
= data
;
2775 struct bgp_node
*rn
= cnq
->rn
;
2776 struct bgp_table
*table
= bgp_node_table (rn
);
2778 bgp_unlock_node (rn
);
2779 bgp_table_unlock (table
);
2780 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2784 bgp_clear_node_complete (struct work_queue
*wq
)
2786 struct peer
*peer
= wq
->spec
.data
;
2788 /* Tickle FSM to start moving again */
2789 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2791 peer_unlock (peer
); /* bgp_clear_route */
2795 bgp_clear_node_queue_init (struct peer
*peer
)
2797 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2799 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2800 #undef CLEAR_QUEUE_NAME_LEN
2802 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2804 zlog_err ("%s: Failed to allocate work queue", __func__
);
2807 peer
->clear_node_queue
->spec
.hold
= 10;
2808 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2809 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2810 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2811 peer
->clear_node_queue
->spec
.max_retries
= 0;
2813 /* we only 'lock' this peer reference when the queue is actually active */
2814 peer
->clear_node_queue
->spec
.data
= peer
;
2818 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2819 struct bgp_table
*table
)
2821 struct bgp_node
*rn
;
2825 table
= peer
->bgp
->rib
[afi
][safi
];
2827 /* If still no table => afi/safi isn't configured at all or smth. */
2831 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2833 struct bgp_info
*ri
;
2834 struct bgp_adj_in
*ain
;
2835 struct bgp_adj_in
*ain_next
;
2837 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2838 * queued for every clearing peer, regardless of whether it is
2839 * relevant to the peer at hand.
2841 * Overview: There are 3 different indices which need to be
2842 * scrubbed, potentially, when a peer is removed:
2844 * 1 peer's routes visible via the RIB (ie accepted routes)
2845 * 2 peer's routes visible by the (optional) peer's adj-in index
2846 * 3 other routes visible by the peer's adj-out index
2848 * 3 there is no hurry in scrubbing, once the struct peer is
2849 * removed from bgp->peer, we could just GC such deleted peer's
2850 * adj-outs at our leisure.
2852 * 1 and 2 must be 'scrubbed' in some way, at least made
2853 * invisible via RIB index before peer session is allowed to be
2854 * brought back up. So one needs to know when such a 'search' is
2859 * - there'd be a single global queue or a single RIB walker
2860 * - rather than tracking which route_nodes still need to be
2861 * examined on a peer basis, we'd track which peers still
2864 * Given that our per-peer prefix-counts now should be reliable,
2865 * this may actually be achievable. It doesn't seem to be a huge
2866 * problem at this time,
2868 * It is possible that we have multiple paths for a prefix from a peer
2869 * if that peer is using AddPath.
2874 ain_next
= ain
->next
;
2876 if (ain
->peer
== peer
)
2878 bgp_adj_in_remove (rn
, ain
);
2879 bgp_unlock_node (rn
);
2885 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2886 if (ri
->peer
== peer
)
2888 struct bgp_clear_node_queue
*cnq
;
2890 /* both unlocked in bgp_clear_node_queue_del */
2891 bgp_table_lock (bgp_node_table (rn
));
2893 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2894 sizeof (struct bgp_clear_node_queue
));
2896 work_queue_add (peer
->clear_node_queue
, cnq
);
2904 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2906 struct bgp_node
*rn
;
2907 struct bgp_table
*table
;
2909 if (peer
->clear_node_queue
== NULL
)
2910 bgp_clear_node_queue_init (peer
);
2912 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2913 * Idle until it receives a Clearing_Completed event. This protects
2914 * against peers which flap faster than we can we clear, which could
2917 * a) race with routes from the new session being installed before
2918 * clear_route_node visits the node (to delete the route of that
2920 * b) resource exhaustion, clear_route_node likely leads to an entry
2921 * on the process_main queue. Fast-flapping could cause that queue
2925 /* lock peer in assumption that clear-node-queue will get nodes; if so,
2926 * the unlock will happen upon work-queue completion; other wise, the
2927 * unlock happens at the end of this function.
2929 if (!peer
->clear_node_queue
->thread
)
2932 if (safi
!= SAFI_MPLS_VPN
)
2933 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
2935 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2936 rn
= bgp_route_next (rn
))
2937 if ((table
= rn
->info
) != NULL
)
2938 bgp_clear_route_table (peer
, afi
, safi
, table
);
2940 /* unlock if no nodes got added to the clear-node-queue. */
2941 if (!peer
->clear_node_queue
->thread
)
2947 bgp_clear_route_all (struct peer
*peer
)
2952 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2953 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2954 bgp_clear_route (peer
, afi
, safi
);
2958 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2960 struct bgp_table
*table
;
2961 struct bgp_node
*rn
;
2962 struct bgp_adj_in
*ain
;
2963 struct bgp_adj_in
*ain_next
;
2965 table
= peer
->bgp
->rib
[afi
][safi
];
2967 /* It is possible that we have multiple paths for a prefix from a peer
2968 * if that peer is using AddPath.
2970 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2976 ain_next
= ain
->next
;
2978 if (ain
->peer
== peer
)
2980 bgp_adj_in_remove (rn
, ain
);
2981 bgp_unlock_node (rn
);
2990 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2992 struct bgp_node
*rn
;
2993 struct bgp_info
*ri
;
2994 struct bgp_table
*table
;
2996 table
= peer
->bgp
->rib
[afi
][safi
];
2998 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3000 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3001 if (ri
->peer
== peer
)
3003 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3004 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3010 /* Delete all kernel routes. */
3012 bgp_cleanup_routes (void)
3015 struct listnode
*node
, *nnode
;
3016 struct bgp_node
*rn
;
3017 struct bgp_table
*table
;
3018 struct bgp_info
*ri
;
3020 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
3022 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
3024 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3025 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3026 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3027 && ri
->type
== ZEBRA_ROUTE_BGP
3028 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3029 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3030 bgp_zebra_withdraw (&rn
->p
, ri
,SAFI_UNICAST
);
3032 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
3034 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3035 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3036 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3037 && ri
->type
== ZEBRA_ROUTE_BGP
3038 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3039 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3040 bgp_zebra_withdraw (&rn
->p
, ri
,SAFI_UNICAST
);
3048 bgp_zclient_reset ();
3049 access_list_reset ();
3050 prefix_list_reset ();
3054 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3056 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3057 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3060 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3063 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3072 int addpath_encoded
;
3073 u_int32_t addpath_id
;
3075 /* Check peer status. */
3076 if (peer
->status
!= Established
)
3080 lim
= pnt
+ packet
->length
;
3082 safi
= packet
->safi
;
3084 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3086 for (; pnt
< lim
; pnt
+= psize
)
3088 /* Clear prefix structure. */
3089 memset (&p
, 0, sizeof (struct prefix
));
3091 if (addpath_encoded
)
3094 /* When packet overflow occurs return immediately. */
3095 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3098 addpath_id
= ntohl(*((uint32_t*) pnt
));
3099 pnt
+= BGP_ADDPATH_ID_LEN
;
3102 /* Fetch prefix length. */
3103 p
.prefixlen
= *pnt
++;
3104 p
.family
= afi2family (afi
);
3106 /* Already checked in nlri_sanity_check(). We do double check
3108 if ((afi
== AFI_IP
&& p
.prefixlen
> 32)
3109 || (afi
== AFI_IP6
&& p
.prefixlen
> 128))
3112 /* Packet size overflow check. */
3113 psize
= PSIZE (p
.prefixlen
);
3115 /* When packet overflow occur return immediately. */
3116 if (pnt
+ psize
> lim
)
3119 /* Fetch prefix from NLRI packet. */
3120 memcpy (&p
.u
.prefix
, pnt
, psize
);
3122 /* Check address. */
3123 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3125 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3128 * From draft-ietf-idr-bgp4-22, Section 6.3:
3129 * If a BGP router receives an UPDATE message with a
3130 * semantically incorrect NLRI field, in which a prefix is
3131 * semantically incorrect (eg. an unexpected multicast IP
3132 * address), it should ignore the prefix.
3134 zlog_err ("IPv4 unicast NLRI is multicast address %s",
3135 inet_ntoa (p
.u
.prefix4
));
3142 /* Check address. */
3143 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3145 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3149 zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
3150 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3155 #endif /* HAVE_IPV6 */
3157 /* Normal process. */
3159 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3160 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3162 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3163 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3165 /* Address family configuration mismatch or maximum-prefix count
3171 /* Packet length consistency check. */
3178 /* NLRI encode syntax check routine. */
3180 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, safi_t safi
, u_char
*pnt
,
3181 bgp_size_t length
, int *numpfx
)
3186 int addpath_encoded
;
3190 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3192 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3193 syntactic validity. If the field is syntactically incorrect,
3194 then the Error Subcode is set to Invalid Network Field. */
3199 /* If the NLRI is encoded using addpath then the first 4 bytes are
3200 * the addpath ID. */
3201 if (addpath_encoded
)
3203 if (pnt
+ BGP_ADDPATH_ID_LEN
> end
)
3205 zlog_err ("%s [Error] Update packet error"
3206 " (prefix data addpath overflow)",
3208 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3209 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3212 pnt
+= BGP_ADDPATH_ID_LEN
;
3217 /* Prefix length check. */
3218 if ((afi
== AFI_IP
&& prefixlen
> 32)
3219 || (afi
== AFI_IP6
&& prefixlen
> 128))
3221 zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
3222 peer
->host
, prefixlen
);
3223 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3224 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3228 /* Packet size overflow check. */
3229 psize
= PSIZE (prefixlen
);
3231 if (pnt
+ psize
> end
)
3233 zlog_err ("%s [Error] Update packet error"
3234 " (prefix data overflow prefix size is %d)",
3236 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3237 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3245 /* Packet length consistency check. */
3248 zlog_err ("%s [Error] Update packet error"
3249 " (prefix length mismatch with total length)",
3251 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3252 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3258 static struct bgp_static
*
3259 bgp_static_new (void)
3261 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3265 bgp_static_free (struct bgp_static
*bgp_static
)
3267 if (bgp_static
->rmap
.name
)
3268 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3269 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3273 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3274 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3276 struct bgp_node
*rn
;
3277 struct bgp_info
*ri
;
3278 struct bgp_info
*new;
3279 struct bgp_info info
;
3281 struct attr
*attr_new
;
3284 assert (bgp_static
);
3288 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3290 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3292 attr
.nexthop
= bgp_static
->igpnexthop
;
3293 attr
.med
= bgp_static
->igpmetric
;
3294 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3296 if (bgp_static
->atomic
)
3297 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3299 /* Apply route-map. */
3300 if (bgp_static
->rmap
.name
)
3302 struct attr attr_tmp
= attr
;
3303 info
.peer
= bgp
->peer_self
;
3304 info
.attr
= &attr_tmp
;
3306 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3308 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3310 bgp
->peer_self
->rmap_type
= 0;
3312 if (ret
== RMAP_DENYMATCH
)
3314 /* Free uninterned attribute. */
3315 bgp_attr_flush (&attr_tmp
);
3317 /* Unintern original. */
3318 aspath_unintern (&attr
.aspath
);
3319 bgp_attr_extra_free (&attr
);
3320 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3323 attr_new
= bgp_attr_intern (&attr_tmp
);
3326 attr_new
= bgp_attr_intern (&attr
);
3328 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3329 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3330 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3335 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3336 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3337 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3339 bgp_unlock_node (rn
);
3340 bgp_attr_unintern (&attr_new
);
3341 aspath_unintern (&attr
.aspath
);
3342 bgp_attr_extra_free (&attr
);
3347 /* The attribute is changed. */
3348 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3350 /* Rewrite BGP route information. */
3351 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3352 bgp_info_restore(rn
, ri
);
3354 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3355 bgp_attr_unintern (&ri
->attr
);
3356 ri
->attr
= attr_new
;
3357 ri
->uptime
= bgp_clock ();
3359 /* Nexthop reachability check. */
3360 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3362 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3363 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3366 if (BGP_DEBUG(nht
, NHT
))
3368 char buf1
[INET6_ADDRSTRLEN
];
3369 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3371 zlog_debug("%s(%s): Route not in table, not advertising",
3372 __FUNCTION__
, buf1
);
3374 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3379 /* Delete the NHT structure if any, if we're toggling between
3380 * enabling/disabling import check. We deregister the route
3381 * from NHT to avoid overloading NHT and the process interaction
3383 bgp_unlink_nexthop(ri
);
3384 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3386 /* Process change. */
3387 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3388 bgp_process (bgp
, rn
, afi
, safi
);
3389 bgp_unlock_node (rn
);
3390 aspath_unintern (&attr
.aspath
);
3391 bgp_attr_extra_free (&attr
);
3396 /* Make new BGP info. */
3397 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3399 /* Nexthop reachability check. */
3400 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3402 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3403 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3406 if (BGP_DEBUG(nht
, NHT
))
3408 char buf1
[INET6_ADDRSTRLEN
];
3409 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3411 zlog_debug("%s(%s): Route not in table, not advertising",
3412 __FUNCTION__
, buf1
);
3414 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3419 /* Delete the NHT structure if any, if we're toggling between
3420 * enabling/disabling import check. We deregister the route
3421 * from NHT to avoid overloading NHT and the process interaction
3423 bgp_unlink_nexthop(new);
3425 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3428 /* Aggregate address increment. */
3429 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3431 /* Register new BGP information. */
3432 bgp_info_add (rn
, new);
3434 /* route_node_get lock */
3435 bgp_unlock_node (rn
);
3437 /* Process change. */
3438 bgp_process (bgp
, rn
, afi
, safi
);
3440 /* Unintern original. */
3441 aspath_unintern (&attr
.aspath
);
3442 bgp_attr_extra_free (&attr
);
3446 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3447 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3449 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3453 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3454 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3456 struct bgp_node
*rn
;
3457 struct bgp_info
*new;
3459 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3461 /* Make new BGP info. */
3462 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
,
3463 bgp_attr_default_intern(BGP_ORIGIN_IGP
), rn
);
3465 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3466 new->extra
= bgp_info_extra_new();
3467 memcpy (new->extra
->tag
, tag
, 3);
3469 /* Aggregate address increment. */
3470 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3472 /* Register new BGP information. */
3473 bgp_info_add (rn
, new);
3475 /* route_node_get lock */
3476 bgp_unlock_node (rn
);
3478 /* Process change. */
3479 bgp_process (bgp
, rn
, afi
, safi
);
3483 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3486 struct bgp_node
*rn
;
3487 struct bgp_info
*ri
;
3489 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3491 /* Check selected route and self inserted route. */
3492 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3493 if (ri
->peer
== bgp
->peer_self
3494 && ri
->type
== ZEBRA_ROUTE_BGP
3495 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3498 /* Withdraw static BGP route from routing table. */
3501 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3502 bgp_unlink_nexthop(ri
);
3503 bgp_info_delete (rn
, ri
);
3504 bgp_process (bgp
, rn
, afi
, safi
);
3507 /* Unlock bgp_node_lookup. */
3508 bgp_unlock_node (rn
);
3512 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3513 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3515 struct bgp_node
*rn
;
3516 struct bgp_info
*ri
;
3518 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3520 /* Check selected route and self inserted route. */
3521 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3522 if (ri
->peer
== bgp
->peer_self
3523 && ri
->type
== ZEBRA_ROUTE_BGP
3524 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3527 /* Withdraw static BGP route from routing table. */
3530 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3531 bgp_info_delete (rn
, ri
);
3532 bgp_process (bgp
, rn
, afi
, safi
);
3535 /* Unlock bgp_node_lookup. */
3536 bgp_unlock_node (rn
);
3539 /* Configure static BGP network. When user don't run zebra, static
3540 route should be installed as valid. */
3542 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3543 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3547 struct bgp_static
*bgp_static
;
3548 struct bgp_node
*rn
;
3549 u_char need_update
= 0;
3551 /* Convert IP prefix string to struct prefix. */
3552 ret
= str2prefix (ip_str
, &p
);
3555 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3559 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3561 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3565 #endif /* HAVE_IPV6 */
3569 /* Set BGP static route configuration. */
3570 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3574 /* Configuration change. */
3575 bgp_static
= rn
->info
;
3577 /* Check previous routes are installed into BGP. */
3578 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3581 bgp_static
->backdoor
= backdoor
;
3585 if (bgp_static
->rmap
.name
)
3586 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3587 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3588 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3592 if (bgp_static
->rmap
.name
)
3593 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3594 bgp_static
->rmap
.name
= NULL
;
3595 bgp_static
->rmap
.map
= NULL
;
3596 bgp_static
->valid
= 0;
3598 bgp_unlock_node (rn
);
3602 /* New configuration. */
3603 bgp_static
= bgp_static_new ();
3604 bgp_static
->backdoor
= backdoor
;
3605 bgp_static
->valid
= 0;
3606 bgp_static
->igpmetric
= 0;
3607 bgp_static
->igpnexthop
.s_addr
= 0;
3611 if (bgp_static
->rmap
.name
)
3612 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3613 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3614 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3616 rn
->info
= bgp_static
;
3619 bgp_static
->valid
= 1;
3621 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3623 if (! bgp_static
->backdoor
)
3624 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3629 /* Configure static BGP network. */
3631 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3632 afi_t afi
, safi_t safi
)
3636 struct bgp_static
*bgp_static
;
3637 struct bgp_node
*rn
;
3639 /* Convert IP prefix string to struct prefix. */
3640 ret
= str2prefix (ip_str
, &p
);
3643 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3647 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3649 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3653 #endif /* HAVE_IPV6 */
3657 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3660 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3665 bgp_static
= rn
->info
;
3667 /* Update BGP RIB. */
3668 if (! bgp_static
->backdoor
)
3669 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3671 /* Clear configuration. */
3672 bgp_static_free (bgp_static
);
3674 bgp_unlock_node (rn
);
3675 bgp_unlock_node (rn
);
3681 bgp_static_add (struct bgp
*bgp
)
3685 struct bgp_node
*rn
;
3686 struct bgp_node
*rm
;
3687 struct bgp_table
*table
;
3688 struct bgp_static
*bgp_static
;
3690 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3691 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3692 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3693 if (rn
->info
!= NULL
)
3695 if (safi
== SAFI_MPLS_VPN
)
3699 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3701 bgp_static
= rn
->info
;
3702 bgp_static_update_vpnv4 (bgp
, &rm
->p
,
3703 AFI_IP
, SAFI_MPLS_VPN
,
3704 (struct prefix_rd
*)&rn
->p
,
3710 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
3715 /* Called from bgp_delete(). Delete all static routes from the BGP
3718 bgp_static_delete (struct bgp
*bgp
)
3722 struct bgp_node
*rn
;
3723 struct bgp_node
*rm
;
3724 struct bgp_table
*table
;
3725 struct bgp_static
*bgp_static
;
3727 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3728 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3729 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3730 if (rn
->info
!= NULL
)
3732 if (safi
== SAFI_MPLS_VPN
)
3736 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3738 bgp_static
= rn
->info
;
3739 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3740 AFI_IP
, SAFI_MPLS_VPN
,
3741 (struct prefix_rd
*)&rn
->p
,
3743 bgp_static_free (bgp_static
);
3745 bgp_unlock_node (rn
);
3750 bgp_static
= rn
->info
;
3751 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3752 bgp_static_free (bgp_static
);
3754 bgp_unlock_node (rn
);
3760 bgp_static_redo_import_check (struct bgp
*bgp
)
3764 struct bgp_node
*rn
;
3765 struct bgp_static
*bgp_static
;
3767 /* Use this flag to force reprocessing of the route */
3768 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3769 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3770 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3771 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3772 if (rn
->info
!= NULL
)
3774 bgp_static
= rn
->info
;
3775 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
3777 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3781 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
3783 struct bgp_table
*table
;
3784 struct bgp_node
*rn
;
3785 struct bgp_info
*ri
;
3787 table
= bgp
->rib
[afi
][safi
];
3788 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3790 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3792 if (ri
->peer
== bgp
->peer_self
&&
3793 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
3794 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
3795 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
3796 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
3798 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
3799 bgp_unlink_nexthop(ri
);
3800 bgp_info_delete (rn
, ri
);
3801 bgp_process (bgp
, rn
, afi
, safi
);
3808 * Purge all networks and redistributed routes from routing table.
3809 * Invoked upon the instance going down.
3812 bgp_purge_static_redist_routes (struct bgp
*bgp
)
3817 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3818 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3819 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
3823 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3824 const char *tag_str
)
3828 struct prefix_rd prd
;
3830 struct bgp_node
*prn
;
3831 struct bgp_node
*rn
;
3832 struct bgp_table
*table
;
3833 struct bgp_static
*bgp_static
;
3838 ret
= str2prefix (ip_str
, &p
);
3841 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3846 ret
= str2prefix_rd (rd_str
, &prd
);
3849 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3853 ret
= str2tag (tag_str
, tag
);
3856 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3860 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3861 (struct prefix
*)&prd
);
3862 if (prn
->info
== NULL
)
3863 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3865 bgp_unlock_node (prn
);
3868 rn
= bgp_node_get (table
, &p
);
3872 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3873 bgp_unlock_node (rn
);
3877 /* New configuration. */
3878 bgp_static
= bgp_static_new ();
3879 bgp_static
->valid
= 1;
3880 memcpy (bgp_static
->tag
, tag
, 3);
3881 rn
->info
= bgp_static
;
3883 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3889 /* Configure static BGP network. */
3891 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3892 const char *rd_str
, const char *tag_str
)
3897 struct prefix_rd prd
;
3898 struct bgp_node
*prn
;
3899 struct bgp_node
*rn
;
3900 struct bgp_table
*table
;
3901 struct bgp_static
*bgp_static
;
3906 /* Convert IP prefix string to struct prefix. */
3907 ret
= str2prefix (ip_str
, &p
);
3910 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3915 ret
= str2prefix_rd (rd_str
, &prd
);
3918 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3922 ret
= str2tag (tag_str
, tag
);
3925 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3929 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3930 (struct prefix
*)&prd
);
3931 if (prn
->info
== NULL
)
3932 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3934 bgp_unlock_node (prn
);
3937 rn
= bgp_node_lookup (table
, &p
);
3941 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3943 bgp_static
= rn
->info
;
3944 bgp_static_free (bgp_static
);
3946 bgp_unlock_node (rn
);
3947 bgp_unlock_node (rn
);
3950 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3956 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
3957 const char *rmap_name
)
3959 struct bgp_rmap
*rmap
;
3961 rmap
= &bgp
->table_map
[afi
][safi
];
3965 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
3966 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
3967 rmap
->map
= route_map_lookup_by_name (rmap_name
);
3972 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
3977 bgp_zebra_announce_table(bgp
, afi
, safi
);
3983 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
3984 const char *rmap_name
)
3986 struct bgp_rmap
*rmap
;
3988 rmap
= &bgp
->table_map
[afi
][safi
];
3990 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
3994 bgp_zebra_announce_table(bgp
, afi
, safi
);
4000 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4001 safi_t safi
, int *write
)
4003 if (bgp
->table_map
[afi
][safi
].name
)
4005 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4006 vty_out (vty
, " table-map %s%s",
4007 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4014 DEFUN (bgp_table_map
,
4017 "BGP table to RIB route download filter\n"
4018 "Name of the route map\n")
4020 return bgp_table_map_set (vty
, vty
->index
,
4021 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4023 DEFUN (no_bgp_table_map
,
4024 no_bgp_table_map_cmd
,
4025 "no table-map WORD",
4026 "BGP table to RIB route download filter\n"
4027 "Name of the route map\n")
4029 return bgp_table_map_unset (vty
, vty
->index
,
4030 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4035 "network A.B.C.D/M",
4036 "Specify a network to announce via BGP\n"
4037 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4039 return bgp_static_set (vty
, vty
->index
, argv
[0],
4040 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4043 DEFUN (bgp_network_route_map
,
4044 bgp_network_route_map_cmd
,
4045 "network A.B.C.D/M route-map WORD",
4046 "Specify a network to announce via BGP\n"
4047 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4048 "Route-map to modify the attributes\n"
4049 "Name of the route map\n")
4051 return bgp_static_set (vty
, vty
->index
, argv
[0],
4052 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4055 DEFUN (bgp_network_backdoor
,
4056 bgp_network_backdoor_cmd
,
4057 "network A.B.C.D/M backdoor",
4058 "Specify a network to announce via BGP\n"
4059 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4060 "Specify a BGP backdoor route\n")
4062 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4066 DEFUN (bgp_network_mask
,
4067 bgp_network_mask_cmd
,
4068 "network A.B.C.D mask A.B.C.D",
4069 "Specify a network to announce via BGP\n"
4075 char prefix_str
[BUFSIZ
];
4077 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4080 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4084 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4085 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4088 DEFUN (bgp_network_mask_route_map
,
4089 bgp_network_mask_route_map_cmd
,
4090 "network A.B.C.D mask A.B.C.D route-map WORD",
4091 "Specify a network to announce via BGP\n"
4095 "Route-map to modify the attributes\n"
4096 "Name of the route map\n")
4099 char prefix_str
[BUFSIZ
];
4101 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4104 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4108 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4109 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4112 DEFUN (bgp_network_mask_backdoor
,
4113 bgp_network_mask_backdoor_cmd
,
4114 "network A.B.C.D mask A.B.C.D backdoor",
4115 "Specify a network to announce via BGP\n"
4119 "Specify a BGP backdoor route\n")
4122 char prefix_str
[BUFSIZ
];
4124 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4127 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4131 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4135 DEFUN (bgp_network_mask_natural
,
4136 bgp_network_mask_natural_cmd
,
4138 "Specify a network to announce via BGP\n"
4142 char prefix_str
[BUFSIZ
];
4144 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4147 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4151 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4152 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4155 DEFUN (bgp_network_mask_natural_route_map
,
4156 bgp_network_mask_natural_route_map_cmd
,
4157 "network A.B.C.D route-map WORD",
4158 "Specify a network to announce via BGP\n"
4160 "Route-map to modify the attributes\n"
4161 "Name of the route map\n")
4164 char prefix_str
[BUFSIZ
];
4166 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4169 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4173 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4174 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4177 DEFUN (bgp_network_mask_natural_backdoor
,
4178 bgp_network_mask_natural_backdoor_cmd
,
4179 "network A.B.C.D backdoor",
4180 "Specify a network to announce via BGP\n"
4182 "Specify a BGP backdoor route\n")
4185 char prefix_str
[BUFSIZ
];
4187 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4190 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4194 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4198 DEFUN (no_bgp_network
,
4200 "no network A.B.C.D/M",
4202 "Specify a network to announce via BGP\n"
4203 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4205 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4206 bgp_node_safi (vty
));
4209 ALIAS (no_bgp_network
,
4210 no_bgp_network_route_map_cmd
,
4211 "no network A.B.C.D/M route-map WORD",
4213 "Specify a network to announce via BGP\n"
4214 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4215 "Route-map to modify the attributes\n"
4216 "Name of the route map\n")
4218 ALIAS (no_bgp_network
,
4219 no_bgp_network_backdoor_cmd
,
4220 "no network A.B.C.D/M backdoor",
4222 "Specify a network to announce via BGP\n"
4223 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4224 "Specify a BGP backdoor route\n")
4226 DEFUN (no_bgp_network_mask
,
4227 no_bgp_network_mask_cmd
,
4228 "no network A.B.C.D mask A.B.C.D",
4230 "Specify a network to announce via BGP\n"
4236 char prefix_str
[BUFSIZ
];
4238 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4241 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4245 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4246 bgp_node_safi (vty
));
4249 ALIAS (no_bgp_network_mask
,
4250 no_bgp_network_mask_route_map_cmd
,
4251 "no network A.B.C.D mask A.B.C.D route-map WORD",
4253 "Specify a network to announce via BGP\n"
4257 "Route-map to modify the attributes\n"
4258 "Name of the route map\n")
4260 ALIAS (no_bgp_network_mask
,
4261 no_bgp_network_mask_backdoor_cmd
,
4262 "no network A.B.C.D mask A.B.C.D backdoor",
4264 "Specify a network to announce via BGP\n"
4268 "Specify a BGP backdoor route\n")
4270 DEFUN (no_bgp_network_mask_natural
,
4271 no_bgp_network_mask_natural_cmd
,
4272 "no network A.B.C.D",
4274 "Specify a network to announce via BGP\n"
4278 char prefix_str
[BUFSIZ
];
4280 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4283 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4287 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4288 bgp_node_safi (vty
));
4291 ALIAS (no_bgp_network_mask_natural
,
4292 no_bgp_network_mask_natural_route_map_cmd
,
4293 "no network A.B.C.D route-map WORD",
4295 "Specify a network to announce via BGP\n"
4297 "Route-map to modify the attributes\n"
4298 "Name of the route map\n")
4300 ALIAS (no_bgp_network_mask_natural
,
4301 no_bgp_network_mask_natural_backdoor_cmd
,
4302 "no network A.B.C.D backdoor",
4304 "Specify a network to announce via BGP\n"
4306 "Specify a BGP backdoor route\n")
4309 DEFUN (ipv6_bgp_network
,
4310 ipv6_bgp_network_cmd
,
4311 "network X:X::X:X/M",
4312 "Specify a network to announce via BGP\n"
4313 "IPv6 prefix <network>/<length>\n")
4315 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4319 DEFUN (ipv6_bgp_network_route_map
,
4320 ipv6_bgp_network_route_map_cmd
,
4321 "network X:X::X:X/M route-map WORD",
4322 "Specify a network to announce via BGP\n"
4323 "IPv6 prefix <network>/<length>\n"
4324 "Route-map to modify the attributes\n"
4325 "Name of the route map\n")
4327 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4328 bgp_node_safi (vty
), argv
[1], 0);
4331 DEFUN (no_ipv6_bgp_network
,
4332 no_ipv6_bgp_network_cmd
,
4333 "no network X:X::X:X/M",
4335 "Specify a network to announce via BGP\n"
4336 "IPv6 prefix <network>/<length>\n")
4338 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4341 ALIAS (no_ipv6_bgp_network
,
4342 no_ipv6_bgp_network_route_map_cmd
,
4343 "no network X:X::X:X/M route-map WORD",
4345 "Specify a network to announce via BGP\n"
4346 "IPv6 prefix <network>/<length>\n"
4347 "Route-map to modify the attributes\n"
4348 "Name of the route map\n")
4350 ALIAS (ipv6_bgp_network
,
4351 old_ipv6_bgp_network_cmd
,
4352 "ipv6 bgp network X:X::X:X/M",
4355 "Specify a network to announce via BGP\n"
4356 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4358 ALIAS (no_ipv6_bgp_network
,
4359 old_no_ipv6_bgp_network_cmd
,
4360 "no ipv6 bgp network X:X::X:X/M",
4364 "Specify a network to announce via BGP\n"
4365 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4366 #endif /* HAVE_IPV6 */
4368 /* Aggreagete address:
4370 advertise-map Set condition to advertise attribute
4371 as-set Generate AS set path information
4372 attribute-map Set attributes of aggregate
4373 route-map Set parameters of aggregate
4374 summary-only Filter more specific routes from updates
4375 suppress-map Conditionally filter more specific routes from updates
4378 struct bgp_aggregate
4380 /* Summary-only flag. */
4381 u_char summary_only
;
4383 /* AS set generation. */
4386 /* Route-map for aggregated route. */
4387 struct route_map
*map
;
4389 /* Suppress-count. */
4390 unsigned long count
;
4392 /* SAFI configuration. */
4396 static struct bgp_aggregate
*
4397 bgp_aggregate_new (void)
4399 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4403 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4405 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4408 /* Update an aggregate as routes are added/removed from the BGP table */
4410 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4411 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4412 struct bgp_aggregate
*aggregate
)
4414 struct bgp_table
*table
;
4415 struct bgp_node
*top
;
4416 struct bgp_node
*rn
;
4418 struct aspath
*aspath
= NULL
;
4419 struct aspath
*asmerge
= NULL
;
4420 struct community
*community
= NULL
;
4421 struct community
*commerge
= NULL
;
4422 #if defined(AGGREGATE_NEXTHOP_CHECK)
4423 struct in_addr nexthop
;
4426 struct bgp_info
*ri
;
4427 struct bgp_info
*new;
4429 unsigned long match
= 0;
4430 u_char atomic_aggregate
= 0;
4432 /* Record adding route's nexthop and med. */
4435 #if defined(AGGREGATE_NEXTHOP_CHECK)
4436 nexthop
= rinew
->attr
->nexthop
;
4437 med
= rinew
->attr
->med
;
4441 /* ORIGIN attribute: If at least one route among routes that are
4442 aggregated has ORIGIN with the value INCOMPLETE, then the
4443 aggregated route must have the ORIGIN attribute with the value
4444 INCOMPLETE. Otherwise, if at least one route among routes that
4445 are aggregated has ORIGIN with the value EGP, then the aggregated
4446 route must have the origin attribute with the value EGP. In all
4447 other case the value of the ORIGIN attribute of the aggregated
4448 route is INTERNAL. */
4449 origin
= BGP_ORIGIN_IGP
;
4451 table
= bgp
->rib
[afi
][safi
];
4453 top
= bgp_node_get (table
, p
);
4454 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4455 if (rn
->p
.prefixlen
> p
->prefixlen
)
4459 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4461 if (BGP_INFO_HOLDDOWN (ri
))
4464 if (del
&& ri
== del
)
4467 if (! rinew
&& first
)
4469 #if defined(AGGREGATE_NEXTHOP_CHECK)
4470 nexthop
= ri
->attr
->nexthop
;
4471 med
= ri
->attr
->med
;
4476 #ifdef AGGREGATE_NEXTHOP_CHECK
4477 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4478 || ri
->attr
->med
!= med
)
4481 aspath_free (aspath
);
4483 community_free (community
);
4484 bgp_unlock_node (rn
);
4485 bgp_unlock_node (top
);
4488 #endif /* AGGREGATE_NEXTHOP_CHECK */
4490 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4491 atomic_aggregate
= 1;
4493 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4495 if (aggregate
->summary_only
)
4497 (bgp_info_extra_get (ri
))->suppress
++;
4498 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4504 if (origin
< ri
->attr
->origin
)
4505 origin
= ri
->attr
->origin
;
4507 if (aggregate
->as_set
)
4511 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4512 aspath_free (aspath
);
4516 aspath
= aspath_dup (ri
->attr
->aspath
);
4518 if (ri
->attr
->community
)
4522 commerge
= community_merge (community
,
4523 ri
->attr
->community
);
4524 community
= community_uniq_sort (commerge
);
4525 community_free (commerge
);
4528 community
= community_dup (ri
->attr
->community
);
4534 bgp_process (bgp
, rn
, afi
, safi
);
4536 bgp_unlock_node (top
);
4542 if (aggregate
->summary_only
)
4543 (bgp_info_extra_get (rinew
))->suppress
++;
4545 if (origin
< rinew
->attr
->origin
)
4546 origin
= rinew
->attr
->origin
;
4548 if (aggregate
->as_set
)
4552 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4553 aspath_free (aspath
);
4557 aspath
= aspath_dup (rinew
->attr
->aspath
);
4559 if (rinew
->attr
->community
)
4563 commerge
= community_merge (community
,
4564 rinew
->attr
->community
);
4565 community
= community_uniq_sort (commerge
);
4566 community_free (commerge
);
4569 community
= community_dup (rinew
->attr
->community
);
4574 if (aggregate
->count
> 0)
4576 rn
= bgp_node_get (table
, p
);
4577 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4578 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4580 atomic_aggregate
), rn
);
4581 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4583 bgp_info_add (rn
, new);
4584 bgp_unlock_node (rn
);
4585 bgp_process (bgp
, rn
, afi
, safi
);
4590 aspath_free (aspath
);
4592 community_free (community
);
4596 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4597 struct bgp_aggregate
*);
4600 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4601 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4603 struct bgp_node
*child
;
4604 struct bgp_node
*rn
;
4605 struct bgp_aggregate
*aggregate
;
4606 struct bgp_table
*table
;
4608 /* MPLS-VPN aggregation is not yet supported. */
4609 if (safi
== SAFI_MPLS_VPN
)
4612 table
= bgp
->aggregate
[afi
][safi
];
4614 /* No aggregates configured. */
4615 if (bgp_table_top_nolock (table
) == NULL
)
4618 if (p
->prefixlen
== 0)
4621 if (BGP_INFO_HOLDDOWN (ri
))
4624 child
= bgp_node_get (table
, p
);
4626 /* Aggregate address configuration check. */
4627 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4628 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4630 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4631 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4633 bgp_unlock_node (child
);
4637 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4638 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4640 struct bgp_node
*child
;
4641 struct bgp_node
*rn
;
4642 struct bgp_aggregate
*aggregate
;
4643 struct bgp_table
*table
;
4645 /* MPLS-VPN aggregation is not yet supported. */
4646 if (safi
== SAFI_MPLS_VPN
)
4649 table
= bgp
->aggregate
[afi
][safi
];
4651 /* No aggregates configured. */
4652 if (bgp_table_top_nolock (table
) == NULL
)
4655 if (p
->prefixlen
== 0)
4658 child
= bgp_node_get (table
, p
);
4660 /* Aggregate address configuration check. */
4661 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4662 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4664 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4665 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4667 bgp_unlock_node (child
);
4670 /* Called via bgp_aggregate_set when the user configures aggregate-address */
4672 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4673 struct bgp_aggregate
*aggregate
)
4675 struct bgp_table
*table
;
4676 struct bgp_node
*top
;
4677 struct bgp_node
*rn
;
4678 struct bgp_info
*new;
4679 struct bgp_info
*ri
;
4680 unsigned long match
;
4681 u_char origin
= BGP_ORIGIN_IGP
;
4682 struct aspath
*aspath
= NULL
;
4683 struct aspath
*asmerge
= NULL
;
4684 struct community
*community
= NULL
;
4685 struct community
*commerge
= NULL
;
4686 u_char atomic_aggregate
= 0;
4688 table
= bgp
->rib
[afi
][safi
];
4691 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4693 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4696 /* If routes exists below this node, generate aggregate routes. */
4697 top
= bgp_node_get (table
, p
);
4698 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4699 if (rn
->p
.prefixlen
> p
->prefixlen
)
4703 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4705 if (BGP_INFO_HOLDDOWN (ri
))
4708 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4709 atomic_aggregate
= 1;
4711 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4713 /* summary-only aggregate route suppress aggregated
4714 route announcement. */
4715 if (aggregate
->summary_only
)
4717 (bgp_info_extra_get (ri
))->suppress
++;
4718 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4722 /* If at least one route among routes that are aggregated has
4723 * ORIGIN with the value INCOMPLETE, then the aggregated route
4724 * MUST have the ORIGIN attribute with the value INCOMPLETE.
4725 * Otherwise, if at least one route among routes that are
4726 * aggregated has ORIGIN with the value EGP, then the aggregated
4727 * route MUST have the ORIGIN attribute with the value EGP.
4729 if (origin
< ri
->attr
->origin
)
4730 origin
= ri
->attr
->origin
;
4732 /* as-set aggregate route generate origin, as path,
4733 community aggregation. */
4734 if (aggregate
->as_set
)
4738 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4739 aspath_free (aspath
);
4743 aspath
= aspath_dup (ri
->attr
->aspath
);
4745 if (ri
->attr
->community
)
4749 commerge
= community_merge (community
,
4750 ri
->attr
->community
);
4751 community
= community_uniq_sort (commerge
);
4752 community_free (commerge
);
4755 community
= community_dup (ri
->attr
->community
);
4762 /* If this node is suppressed, process the change. */
4764 bgp_process (bgp
, rn
, afi
, safi
);
4766 bgp_unlock_node (top
);
4768 /* Add aggregate route to BGP table. */
4769 if (aggregate
->count
)
4771 rn
= bgp_node_get (table
, p
);
4772 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4773 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4775 atomic_aggregate
), rn
);
4776 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4778 bgp_info_add (rn
, new);
4779 bgp_unlock_node (rn
);
4781 /* Process change. */
4782 bgp_process (bgp
, rn
, afi
, safi
);
4787 aspath_free (aspath
);
4789 community_free (community
);
4794 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4795 safi_t safi
, struct bgp_aggregate
*aggregate
)
4797 struct bgp_table
*table
;
4798 struct bgp_node
*top
;
4799 struct bgp_node
*rn
;
4800 struct bgp_info
*ri
;
4801 unsigned long match
;
4803 table
= bgp
->rib
[afi
][safi
];
4805 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4807 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4810 /* If routes exists below this node, generate aggregate routes. */
4811 top
= bgp_node_get (table
, p
);
4812 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4813 if (rn
->p
.prefixlen
> p
->prefixlen
)
4817 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4819 if (BGP_INFO_HOLDDOWN (ri
))
4822 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4824 if (aggregate
->summary_only
&& ri
->extra
)
4826 ri
->extra
->suppress
--;
4828 if (ri
->extra
->suppress
== 0)
4830 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4838 /* If this node was suppressed, process the change. */
4840 bgp_process (bgp
, rn
, afi
, safi
);
4842 bgp_unlock_node (top
);
4844 /* Delete aggregate route from BGP table. */
4845 rn
= bgp_node_get (table
, p
);
4847 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4848 if (ri
->peer
== bgp
->peer_self
4849 && ri
->type
== ZEBRA_ROUTE_BGP
4850 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4853 /* Withdraw static BGP route from routing table. */
4856 bgp_info_delete (rn
, ri
);
4857 bgp_process (bgp
, rn
, afi
, safi
);
4860 /* Unlock bgp_node_lookup. */
4861 bgp_unlock_node (rn
);
4864 /* Aggregate route attribute. */
4865 #define AGGREGATE_SUMMARY_ONLY 1
4866 #define AGGREGATE_AS_SET 1
4869 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4870 afi_t afi
, safi_t safi
)
4874 struct bgp_node
*rn
;
4876 struct bgp_aggregate
*aggregate
;
4878 /* Convert string to prefix structure. */
4879 ret
= str2prefix (prefix_str
, &p
);
4882 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4887 /* Get BGP structure. */
4890 /* Old configuration check. */
4891 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4894 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4899 aggregate
= rn
->info
;
4900 if (aggregate
->safi
& SAFI_UNICAST
)
4901 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4902 if (aggregate
->safi
& SAFI_MULTICAST
)
4903 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4905 /* Unlock aggregate address configuration. */
4907 bgp_aggregate_free (aggregate
);
4908 bgp_unlock_node (rn
);
4909 bgp_unlock_node (rn
);
4915 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4916 afi_t afi
, safi_t safi
,
4917 u_char summary_only
, u_char as_set
)
4921 struct bgp_node
*rn
;
4923 struct bgp_aggregate
*aggregate
;
4925 /* Convert string to prefix structure. */
4926 ret
= str2prefix (prefix_str
, &p
);
4929 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4934 /* Get BGP structure. */
4937 /* Old configuration check. */
4938 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4942 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4943 /* try to remove the old entry */
4944 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
4947 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
4948 bgp_unlock_node (rn
);
4953 /* Make aggregate address structure. */
4954 aggregate
= bgp_aggregate_new ();
4955 aggregate
->summary_only
= summary_only
;
4956 aggregate
->as_set
= as_set
;
4957 aggregate
->safi
= safi
;
4958 rn
->info
= aggregate
;
4960 /* Aggregate address insert into BGP routing table. */
4961 if (safi
& SAFI_UNICAST
)
4962 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4963 if (safi
& SAFI_MULTICAST
)
4964 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4969 DEFUN (aggregate_address
,
4970 aggregate_address_cmd
,
4971 "aggregate-address A.B.C.D/M",
4972 "Configure BGP aggregate entries\n"
4973 "Aggregate prefix\n")
4975 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
4978 DEFUN (aggregate_address_mask
,
4979 aggregate_address_mask_cmd
,
4980 "aggregate-address A.B.C.D A.B.C.D",
4981 "Configure BGP aggregate entries\n"
4982 "Aggregate address\n"
4986 char prefix_str
[BUFSIZ
];
4988 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4992 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4996 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5000 DEFUN (aggregate_address_summary_only
,
5001 aggregate_address_summary_only_cmd
,
5002 "aggregate-address A.B.C.D/M summary-only",
5003 "Configure BGP aggregate entries\n"
5004 "Aggregate prefix\n"
5005 "Filter more specific routes from updates\n")
5007 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5008 AGGREGATE_SUMMARY_ONLY
, 0);
5011 DEFUN (aggregate_address_mask_summary_only
,
5012 aggregate_address_mask_summary_only_cmd
,
5013 "aggregate-address A.B.C.D A.B.C.D summary-only",
5014 "Configure BGP aggregate entries\n"
5015 "Aggregate address\n"
5017 "Filter more specific routes from updates\n")
5020 char prefix_str
[BUFSIZ
];
5022 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5026 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5030 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5031 AGGREGATE_SUMMARY_ONLY
, 0);
5034 DEFUN (aggregate_address_as_set
,
5035 aggregate_address_as_set_cmd
,
5036 "aggregate-address A.B.C.D/M as-set",
5037 "Configure BGP aggregate entries\n"
5038 "Aggregate prefix\n"
5039 "Generate AS set path information\n")
5041 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5042 0, AGGREGATE_AS_SET
);
5045 DEFUN (aggregate_address_mask_as_set
,
5046 aggregate_address_mask_as_set_cmd
,
5047 "aggregate-address A.B.C.D A.B.C.D as-set",
5048 "Configure BGP aggregate entries\n"
5049 "Aggregate address\n"
5051 "Generate AS set path information\n")
5054 char prefix_str
[BUFSIZ
];
5056 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5060 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5064 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5065 0, AGGREGATE_AS_SET
);
5069 DEFUN (aggregate_address_as_set_summary
,
5070 aggregate_address_as_set_summary_cmd
,
5071 "aggregate-address A.B.C.D/M as-set summary-only",
5072 "Configure BGP aggregate entries\n"
5073 "Aggregate prefix\n"
5074 "Generate AS set path information\n"
5075 "Filter more specific routes from updates\n")
5077 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5078 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5081 ALIAS (aggregate_address_as_set_summary
,
5082 aggregate_address_summary_as_set_cmd
,
5083 "aggregate-address A.B.C.D/M summary-only as-set",
5084 "Configure BGP aggregate entries\n"
5085 "Aggregate prefix\n"
5086 "Filter more specific routes from updates\n"
5087 "Generate AS set path information\n")
5089 DEFUN (aggregate_address_mask_as_set_summary
,
5090 aggregate_address_mask_as_set_summary_cmd
,
5091 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5092 "Configure BGP aggregate entries\n"
5093 "Aggregate address\n"
5095 "Generate AS set path information\n"
5096 "Filter more specific routes from updates\n")
5099 char prefix_str
[BUFSIZ
];
5101 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5105 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5109 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5110 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5113 ALIAS (aggregate_address_mask_as_set_summary
,
5114 aggregate_address_mask_summary_as_set_cmd
,
5115 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5116 "Configure BGP aggregate entries\n"
5117 "Aggregate address\n"
5119 "Filter more specific routes from updates\n"
5120 "Generate AS set path information\n")
5122 DEFUN (no_aggregate_address
,
5123 no_aggregate_address_cmd
,
5124 "no aggregate-address A.B.C.D/M",
5126 "Configure BGP aggregate entries\n"
5127 "Aggregate prefix\n")
5129 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5132 ALIAS (no_aggregate_address
,
5133 no_aggregate_address_summary_only_cmd
,
5134 "no aggregate-address A.B.C.D/M summary-only",
5136 "Configure BGP aggregate entries\n"
5137 "Aggregate prefix\n"
5138 "Filter more specific routes from updates\n")
5140 ALIAS (no_aggregate_address
,
5141 no_aggregate_address_as_set_cmd
,
5142 "no aggregate-address A.B.C.D/M as-set",
5144 "Configure BGP aggregate entries\n"
5145 "Aggregate prefix\n"
5146 "Generate AS set path information\n")
5148 ALIAS (no_aggregate_address
,
5149 no_aggregate_address_as_set_summary_cmd
,
5150 "no aggregate-address A.B.C.D/M as-set summary-only",
5152 "Configure BGP aggregate entries\n"
5153 "Aggregate prefix\n"
5154 "Generate AS set path information\n"
5155 "Filter more specific routes from updates\n")
5157 ALIAS (no_aggregate_address
,
5158 no_aggregate_address_summary_as_set_cmd
,
5159 "no aggregate-address A.B.C.D/M summary-only as-set",
5161 "Configure BGP aggregate entries\n"
5162 "Aggregate prefix\n"
5163 "Filter more specific routes from updates\n"
5164 "Generate AS set path information\n")
5166 DEFUN (no_aggregate_address_mask
,
5167 no_aggregate_address_mask_cmd
,
5168 "no aggregate-address A.B.C.D A.B.C.D",
5170 "Configure BGP aggregate entries\n"
5171 "Aggregate address\n"
5175 char prefix_str
[BUFSIZ
];
5177 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5181 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5185 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5188 ALIAS (no_aggregate_address_mask
,
5189 no_aggregate_address_mask_summary_only_cmd
,
5190 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5192 "Configure BGP aggregate entries\n"
5193 "Aggregate address\n"
5195 "Filter more specific routes from updates\n")
5197 ALIAS (no_aggregate_address_mask
,
5198 no_aggregate_address_mask_as_set_cmd
,
5199 "no aggregate-address A.B.C.D A.B.C.D as-set",
5201 "Configure BGP aggregate entries\n"
5202 "Aggregate address\n"
5204 "Generate AS set path information\n")
5206 ALIAS (no_aggregate_address_mask
,
5207 no_aggregate_address_mask_as_set_summary_cmd
,
5208 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5210 "Configure BGP aggregate entries\n"
5211 "Aggregate address\n"
5213 "Generate AS set path information\n"
5214 "Filter more specific routes from updates\n")
5216 ALIAS (no_aggregate_address_mask
,
5217 no_aggregate_address_mask_summary_as_set_cmd
,
5218 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5220 "Configure BGP aggregate entries\n"
5221 "Aggregate address\n"
5223 "Filter more specific routes from updates\n"
5224 "Generate AS set path information\n")
5227 DEFUN (ipv6_aggregate_address
,
5228 ipv6_aggregate_address_cmd
,
5229 "aggregate-address X:X::X:X/M",
5230 "Configure BGP aggregate entries\n"
5231 "Aggregate prefix\n")
5233 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5236 DEFUN (ipv6_aggregate_address_summary_only
,
5237 ipv6_aggregate_address_summary_only_cmd
,
5238 "aggregate-address X:X::X:X/M summary-only",
5239 "Configure BGP aggregate entries\n"
5240 "Aggregate prefix\n"
5241 "Filter more specific routes from updates\n")
5243 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5244 AGGREGATE_SUMMARY_ONLY
, 0);
5247 DEFUN (no_ipv6_aggregate_address
,
5248 no_ipv6_aggregate_address_cmd
,
5249 "no aggregate-address X:X::X:X/M",
5251 "Configure BGP aggregate entries\n"
5252 "Aggregate prefix\n")
5254 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5257 DEFUN (no_ipv6_aggregate_address_summary_only
,
5258 no_ipv6_aggregate_address_summary_only_cmd
,
5259 "no aggregate-address X:X::X:X/M summary-only",
5261 "Configure BGP aggregate entries\n"
5262 "Aggregate prefix\n"
5263 "Filter more specific routes from updates\n")
5265 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5268 ALIAS (ipv6_aggregate_address
,
5269 old_ipv6_aggregate_address_cmd
,
5270 "ipv6 bgp aggregate-address X:X::X:X/M",
5273 "Configure BGP aggregate entries\n"
5274 "Aggregate prefix\n")
5276 ALIAS (ipv6_aggregate_address_summary_only
,
5277 old_ipv6_aggregate_address_summary_only_cmd
,
5278 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5281 "Configure BGP aggregate entries\n"
5282 "Aggregate prefix\n"
5283 "Filter more specific routes from updates\n")
5285 ALIAS (no_ipv6_aggregate_address
,
5286 old_no_ipv6_aggregate_address_cmd
,
5287 "no ipv6 bgp aggregate-address X:X::X:X/M",
5291 "Configure BGP aggregate entries\n"
5292 "Aggregate prefix\n")
5294 ALIAS (no_ipv6_aggregate_address_summary_only
,
5295 old_no_ipv6_aggregate_address_summary_only_cmd
,
5296 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5300 "Configure BGP aggregate entries\n"
5301 "Aggregate prefix\n"
5302 "Filter more specific routes from updates\n")
5303 #endif /* HAVE_IPV6 */
5305 /* Redistribute route treatment. */
5307 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5308 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5309 u_int32_t metric
, u_char type
, u_short instance
, u_short tag
)
5311 struct bgp_info
*new;
5312 struct bgp_info
*bi
;
5313 struct bgp_info info
;
5314 struct bgp_node
*bn
;
5316 struct attr
*new_attr
;
5319 struct bgp_redist
*red
;
5321 /* Make default attribute. */
5322 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5324 attr
.nexthop
= *nexthop
;
5325 attr
.nh_ifindex
= ifindex
;
5330 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5331 extra
->mp_nexthop_global
= *nexthop6
;
5332 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5337 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5338 attr
.extra
->tag
= tag
;
5340 afi
= family2afi (p
->family
);
5342 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5345 struct attr attr_new
;
5346 struct attr_extra extra_new
;
5348 /* Copy attribute for modification. */
5349 attr_new
.extra
= &extra_new
;
5350 bgp_attr_dup (&attr_new
, &attr
);
5352 if (red
->redist_metric_flag
)
5353 attr_new
.med
= red
->redist_metric
;
5355 /* Apply route-map. */
5358 info
.peer
= bgp
->peer_self
;
5359 info
.attr
= &attr_new
;
5361 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5363 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5365 bgp
->peer_self
->rmap_type
= 0;
5367 if (ret
== RMAP_DENYMATCH
)
5369 /* Free uninterned attribute. */
5370 bgp_attr_flush (&attr_new
);
5372 /* Unintern original. */
5373 aspath_unintern (&attr
.aspath
);
5374 bgp_attr_extra_free (&attr
);
5375 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5380 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5381 afi
, SAFI_UNICAST
, p
, NULL
);
5383 new_attr
= bgp_attr_intern (&attr_new
);
5385 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5386 if (bi
->peer
== bgp
->peer_self
5387 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5392 /* Ensure the (source route) type is updated. */
5394 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5395 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5397 bgp_attr_unintern (&new_attr
);
5398 aspath_unintern (&attr
.aspath
);
5399 bgp_attr_extra_free (&attr
);
5400 bgp_unlock_node (bn
);
5405 /* The attribute is changed. */
5406 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5408 /* Rewrite BGP route information. */
5409 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5410 bgp_info_restore(bn
, bi
);
5412 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5413 bgp_attr_unintern (&bi
->attr
);
5414 bi
->attr
= new_attr
;
5415 bi
->uptime
= bgp_clock ();
5417 /* Process change. */
5418 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5419 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5420 bgp_unlock_node (bn
);
5421 aspath_unintern (&attr
.aspath
);
5422 bgp_attr_extra_free (&attr
);
5427 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5429 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5431 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5432 bgp_info_add (bn
, new);
5433 bgp_unlock_node (bn
);
5434 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5437 /* Unintern original. */
5438 aspath_unintern (&attr
.aspath
);
5439 bgp_attr_extra_free (&attr
);
5443 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5446 struct bgp_node
*rn
;
5447 struct bgp_info
*ri
;
5448 struct bgp_redist
*red
;
5450 afi
= family2afi (p
->family
);
5452 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5455 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5457 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5458 if (ri
->peer
== bgp
->peer_self
5459 && ri
->type
== type
)
5464 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5465 bgp_info_delete (rn
, ri
);
5466 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5468 bgp_unlock_node (rn
);
5472 /* Withdraw specified route type's route. */
5474 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5476 struct bgp_node
*rn
;
5477 struct bgp_info
*ri
;
5478 struct bgp_table
*table
;
5480 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5482 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5484 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5485 if (ri
->peer
== bgp
->peer_self
5487 && ri
->instance
== instance
)
5492 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5493 bgp_info_delete (rn
, ri
);
5494 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5499 /* Static function to display route. */
5501 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5504 u_int32_t destination
;
5507 if (p
->family
== AF_INET
)
5509 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5510 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5512 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5513 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5514 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5515 || p
->u
.prefix4
.s_addr
== 0)
5517 /* When mask is natural, mask is not displayed. */
5520 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5523 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5528 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5530 vty_out (vty
, "%*s", len
, " ");
5533 enum bgp_display_type
5538 /* Print the short form route status for a bgp_info */
5540 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
5541 json_object
*json_path
)
5546 /* Route status display. */
5547 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5548 json_object_boolean_true_add(json_path
, "removed");
5550 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5551 json_object_boolean_true_add(json_path
, "stale");
5553 if (binfo
->extra
&& binfo
->extra
->suppress
)
5554 json_object_boolean_true_add(json_path
, "suppressed");
5556 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5557 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5558 json_object_boolean_true_add(json_path
, "valid");
5561 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5562 json_object_boolean_true_add(json_path
, "history");
5564 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5565 json_object_boolean_true_add(json_path
, "damped");
5567 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5568 json_object_boolean_true_add(json_path
, "bestpath");
5570 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5571 json_object_boolean_true_add(json_path
, "multipath");
5573 /* Internal route. */
5574 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5575 json_object_string_add(json_path
, "pathFrom", "internal");
5577 json_object_string_add(json_path
, "pathFrom", "external");
5582 /* Route status display. */
5583 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5585 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5587 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5589 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5590 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5596 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5598 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5600 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5602 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5607 /* Internal route. */
5608 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5614 /* called from terminal list command */
5616 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5617 struct bgp_info
*binfo
, int display
, safi_t safi
,
5618 json_object
*json_paths
)
5621 json_object
*json_path
= NULL
;
5622 json_object
*json_nexthops
= NULL
;
5623 json_object
*json_nexthop_global
= NULL
;
5624 json_object
*json_nexthop_ll
= NULL
;
5627 json_path
= json_object_new_object();
5629 /* short status lead text */
5630 route_vty_short_status_out (vty
, binfo
, json_path
);
5634 /* print prefix and mask */
5636 route_vty_out_route (p
, vty
);
5638 vty_out (vty
, "%*s", 17, " ");
5641 /* Print attribute */
5647 if (p
->family
== AF_INET
5648 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5652 json_nexthop_global
= json_object_new_object();
5654 if (safi
== SAFI_MPLS_VPN
)
5655 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5657 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
5659 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
5660 json_object_boolean_true_add(json_nexthop_global
, "used");
5664 if (safi
== SAFI_MPLS_VPN
)
5665 vty_out (vty
, "%-16s",
5666 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5668 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5674 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5681 json_nexthop_global
= json_object_new_object();
5682 json_object_string_add(json_nexthop_global
, "ip",
5683 inet_ntop (AF_INET6
,
5684 &attr
->extra
->mp_nexthop_global
,
5686 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
5687 json_object_string_add(json_nexthop_global
, "scope", "global");
5689 /* We display both LL & GL if both have been received */
5690 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5692 json_nexthop_ll
= json_object_new_object();
5693 json_object_string_add(json_nexthop_ll
, "ip",
5694 inet_ntop (AF_INET6
,
5695 &attr
->extra
->mp_nexthop_local
,
5697 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
5698 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
5700 if (IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
5701 &attr
->extra
->mp_nexthop_local
) != 0)
5702 json_object_boolean_true_add(json_nexthop_ll
, "used");
5704 json_object_boolean_true_add(json_nexthop_global
, "used");
5707 json_object_boolean_true_add(json_nexthop_global
, "used");
5711 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5713 if (binfo
->peer
->conf_if
)
5715 len
= vty_out (vty
, "%s",
5716 binfo
->peer
->conf_if
);
5717 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
5720 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
5722 vty_out (vty
, "%*s", len
, " ");
5726 len
= vty_out (vty
, "%s",
5727 inet_ntop (AF_INET6
,
5728 &attr
->extra
->mp_nexthop_local
,
5733 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5735 vty_out (vty
, "%*s", len
, " ");
5740 len
= vty_out (vty
, "%s",
5741 inet_ntop (AF_INET6
,
5742 &attr
->extra
->mp_nexthop_global
,
5747 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5749 vty_out (vty
, "%*s", len
, " ");
5753 #endif /* HAVE_IPV6 */
5756 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5758 json_object_int_add(json_path
, "med", attr
->med
);
5760 vty_out (vty
, "%10u", attr
->med
);
5766 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5768 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
5770 vty_out (vty
, "%7u", attr
->local_pref
);
5778 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
5780 json_object_int_add(json_path
, "weight", 0);
5783 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5789 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
5791 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5796 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
5798 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5803 json_object_string_add(json_path
, "alert", "No attributes");
5805 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
5810 if (json_nexthop_global
|| json_nexthop_ll
)
5812 json_nexthops
= json_object_new_array();
5814 if (json_nexthop_global
)
5815 json_object_array_add(json_nexthops
, json_nexthop_global
);
5817 if (json_nexthop_ll
)
5818 json_object_array_add(json_nexthops
, json_nexthop_ll
);
5820 json_object_object_add(json_path
, "nexthops", json_nexthops
);
5823 json_object_array_add(json_paths
, json_path
);
5826 vty_out (vty
, "%s", VTY_NEWLINE
);
5829 /* called from terminal list command */
5831 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
5832 u_char use_json
, json_object
*json_ar
)
5834 json_object
*json_status
= NULL
;
5835 json_object
*json_net
= NULL
;
5837 /* Route status display. */
5840 json_status
= json_object_new_object();
5841 json_net
= json_object_new_object();
5850 /* print prefix and mask */
5852 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
5854 route_vty_out_route (p
, vty
);
5856 /* Print attribute */
5861 if (p
->family
== AF_INET
&& (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5863 if (safi
== SAFI_MPLS_VPN
)
5864 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5866 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
5869 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5873 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5876 #endif /* HAVE_IPV6 */
5878 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5879 json_object_int_add(json_net
, "metric", attr
->med
);
5881 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5882 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
5885 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
5887 json_object_int_add(json_net
, "weight", 0);
5891 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
5894 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
5898 if (p
->family
== AF_INET
&& (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5900 if (safi
== SAFI_MPLS_VPN
)
5901 vty_out (vty
, "%-16s",
5902 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5904 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5907 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5912 assert (attr
->extra
);
5914 len
= vty_out (vty
, "%s",
5915 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5919 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5921 vty_out (vty
, "%*s", len
, " ");
5923 #endif /* HAVE_IPV6 */
5924 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5925 vty_out (vty
, "%10u", attr
->med
);
5929 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5930 vty_out (vty
, "%7u", attr
->local_pref
);
5934 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5938 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5941 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5946 json_object_boolean_true_add(json_status
, "*");
5947 json_object_boolean_true_add(json_status
, ">");
5948 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
5949 char buf_cut
[BUFSIZ
];
5950 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
5953 vty_out (vty
, "%s", VTY_NEWLINE
);
5957 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5958 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
5960 json_object
*json_out
= NULL
;
5962 u_int32_t label
= 0;
5968 json_out
= json_object_new_object();
5970 /* short status lead text */
5971 route_vty_short_status_out (vty
, binfo
, json_out
);
5973 /* print prefix and mask */
5977 route_vty_out_route (p
, vty
);
5979 vty_out (vty
, "%*s", 17, " ");
5982 /* Print attribute */
5986 if (p
->family
== AF_INET
5987 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5989 if (safi
== SAFI_MPLS_VPN
)
5992 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5994 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5999 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6001 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6005 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6007 assert (attr
->extra
);
6011 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6014 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6015 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6018 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6021 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6025 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6027 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6029 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6030 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6033 vty_out (vty
, "%s(%s)",
6034 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6036 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6041 #endif /* HAVE_IPV6 */
6044 label
= decode_label (binfo
->extra
->tag
);
6049 json_object_int_add(json_out
, "notag", label
);
6050 json_object_array_add(json
, json_out
);
6054 vty_out (vty
, "notag/%d", label
);
6055 vty_out (vty
, "%s", VTY_NEWLINE
);
6059 /* dampening route */
6061 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6062 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6066 char timebuf
[BGP_UPTIME_LEN
];
6068 /* short status lead text */
6069 route_vty_short_status_out (vty
, binfo
, json
);
6071 /* print prefix and mask */
6075 route_vty_out_route (p
, vty
);
6077 vty_out (vty
, "%*s", 17, " ");
6080 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6085 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6090 json_object_int_add(json
, "peerHost", len
);
6092 vty_out (vty
, "%*s", len
, " ");
6096 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6098 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6100 /* Print attribute */
6108 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6110 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6115 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6117 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6120 vty_out (vty
, "%s", VTY_NEWLINE
);
6125 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6126 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6129 struct bgp_damp_info
*bdi
;
6130 char timebuf
[BGP_UPTIME_LEN
];
6136 bdi
= binfo
->extra
->damp_info
;
6138 /* short status lead text */
6139 route_vty_short_status_out (vty
, binfo
, json
);
6141 /* print prefix and mask */
6145 route_vty_out_route (p
, vty
);
6147 vty_out (vty
, "%*s", 17, " ");
6150 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6155 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6160 json_object_int_add(json
, "peerHost", len
);
6162 vty_out (vty
, "%*s", len
, " ");
6165 len
= vty_out (vty
, "%d", bdi
->flap
);
6175 json_object_int_add(json
, "bdiFlap", len
);
6177 vty_out (vty
, "%*s", len
, " ");
6181 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6183 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6184 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6186 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6187 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6190 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6192 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6197 vty_out (vty
, "%*s ", 8, " ");
6200 /* Print attribute */
6208 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6210 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6215 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6217 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6220 vty_out (vty
, "%s", VTY_NEWLINE
);
6224 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6225 const char *header
, json_object
*json_adv_to
)
6227 char buf1
[INET6_ADDRSTRLEN
];
6228 json_object
*json_peer
= NULL
;
6232 /* 'advertised-to' is a dictionary of peers we have advertised this
6233 * prefix too. The key is the peer's IP or swpX, the value is the
6234 * hostname if we know it and "" if not.
6236 json_peer
= json_object_new_object();
6239 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6242 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6244 json_object_object_add(json_adv_to
,
6245 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6252 vty_out (vty
, "%s", header
);
6256 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6259 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6261 vty_out (vty
, " %s(%s)", peer
->hostname
,
6262 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6267 vty_out (vty
, " %s", peer
->conf_if
);
6269 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6275 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6276 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6277 json_object
*json_paths
)
6279 char buf
[INET6_ADDRSTRLEN
];
6282 int sockunion_vty_out (struct vty
*, union sockunion
*);
6283 #ifdef HAVE_CLOCK_MONOTONIC
6286 json_object
*json_bestpath
= NULL
;
6287 json_object
*json_cluster_list
= NULL
;
6288 json_object
*json_cluster_list_list
= NULL
;
6289 json_object
*json_ext_community
= NULL
;
6290 json_object
*json_last_update
= NULL
;
6291 json_object
*json_nexthop_global
= NULL
;
6292 json_object
*json_nexthop_ll
= NULL
;
6293 json_object
*json_nexthops
= NULL
;
6294 json_object
*json_path
= NULL
;
6295 json_object
*json_peer
= NULL
;
6296 json_object
*json_string
= NULL
;
6297 json_object
*json_adv_to
= NULL
;
6299 struct listnode
*node
, *nnode
;
6301 int addpath_capable
;
6307 json_path
= json_object_new_object();
6308 json_peer
= json_object_new_object();
6309 json_nexthop_global
= json_object_new_object();
6316 /* Line1 display AS-path, Aggregator */
6321 json_object_lock(attr
->aspath
->json
);
6322 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6326 if (attr
->aspath
->segments
)
6327 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6329 vty_out (vty
, " Local");
6333 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6336 json_object_boolean_true_add(json_path
, "removed");
6338 vty_out (vty
, ", (removed)");
6341 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6344 json_object_boolean_true_add(json_path
, "stale");
6346 vty_out (vty
, ", (stale)");
6349 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6353 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6354 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6358 vty_out (vty
, ", (aggregated by %u %s)",
6359 attr
->extra
->aggregator_as
,
6360 inet_ntoa (attr
->extra
->aggregator_addr
));
6364 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6367 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6369 vty_out (vty
, ", (Received from a RR-client)");
6372 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6375 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6377 vty_out (vty
, ", (Received from a RS-client)");
6380 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6383 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6385 vty_out (vty
, ", (history entry)");
6387 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6390 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6392 vty_out (vty
, ", (suppressed due to dampening)");
6396 vty_out (vty
, "%s", VTY_NEWLINE
);
6398 /* Line2 display Next-hop, Neighbor, Router-id */
6399 /* Display the nexthop */
6400 if (p
->family
== AF_INET
6401 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6403 if (safi
== SAFI_MPLS_VPN
)
6406 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6408 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6413 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6415 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6419 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6424 assert (attr
->extra
);
6427 json_object_string_add(json_nexthop_global
, "ip",
6428 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6429 buf
, INET6_ADDRSTRLEN
));
6430 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6431 json_object_string_add(json_nexthop_global
, "scope", "global");
6435 vty_out (vty
, " %s",
6436 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6437 buf
, INET6_ADDRSTRLEN
));
6440 #endif /* HAVE_IPV6 */
6443 /* Display the IGP cost or 'inaccessible' */
6444 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6447 json_object_boolean_false_add(json_nexthop_global
, "accessible");
6449 vty_out (vty
, " (inaccessible)");
6453 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6456 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
6458 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
6461 /* IGP cost is 0, display this only for json */
6465 json_object_int_add(json_nexthop_global
, "metric", 0);
6469 json_object_boolean_true_add(json_nexthop_global
, "accessible");
6472 /* Display peer "from" output */
6473 /* This path was originated locally */
6474 if (binfo
->peer
== bgp
->peer_self
)
6477 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6480 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
6482 vty_out (vty
, " from 0.0.0.0 ");
6487 json_object_string_add(json_peer
, "peerId", "::");
6489 vty_out (vty
, " from :: ");
6493 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
6495 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
6498 /* We RXed this path from one of our peers */
6504 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6505 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6507 if (binfo
->peer
->hostname
)
6508 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
6510 if (binfo
->peer
->domainname
)
6511 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
6513 if (binfo
->peer
->conf_if
)
6514 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
6518 if (binfo
->peer
->conf_if
)
6520 if (binfo
->peer
->hostname
&&
6521 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6522 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6523 binfo
->peer
->conf_if
);
6525 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
6529 if (binfo
->peer
->hostname
&&
6530 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6531 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6534 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6537 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6538 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6540 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6545 vty_out (vty
, "%s", VTY_NEWLINE
);
6548 /* display the link-local nexthop */
6549 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6553 json_nexthop_ll
= json_object_new_object();
6554 json_object_string_add(json_nexthop_ll
, "ip",
6555 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6556 buf
, INET6_ADDRSTRLEN
));
6557 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6558 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6560 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
6561 json_object_boolean_true_add(json_nexthop_ll
, "used");
6565 vty_out (vty
, " (%s) (used)%s",
6566 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6567 buf
, INET6_ADDRSTRLEN
),
6571 /* If we do not have a link-local nexthop then we must flag the global as "used" */
6575 json_object_boolean_true_add(json_nexthop_global
, "used");
6577 #endif /* HAVE_IPV6 */
6579 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
6581 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6583 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6585 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6588 json_object_int_add(json_path
, "med", attr
->med
);
6590 vty_out (vty
, ", metric %u", attr
->med
);
6593 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6596 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6598 vty_out (vty
, ", localpref %u", attr
->local_pref
);
6603 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
6605 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
6608 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6611 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6613 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
6616 if (attr
->extra
&& attr
->extra
->tag
!= 0)
6619 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
6621 vty_out (vty
, ", tag %d", attr
->extra
->tag
);
6624 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6627 json_object_boolean_false_add(json_path
, "valid");
6629 vty_out (vty
, ", invalid");
6631 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6634 json_object_boolean_true_add(json_path
, "valid");
6636 vty_out (vty
, ", valid");
6639 if (binfo
->peer
!= bgp
->peer_self
)
6641 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6643 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
6646 json_object_string_add(json_peer
, "type", "confed-internal");
6648 vty_out (vty
, ", confed-internal");
6653 json_object_string_add(json_peer
, "type", "internal");
6655 vty_out (vty
, ", internal");
6660 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
6663 json_object_string_add(json_peer
, "type", "confed-external");
6665 vty_out (vty
, ", confed-external");
6670 json_object_string_add(json_peer
, "type", "external");
6672 vty_out (vty
, ", external");
6676 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6680 json_object_boolean_true_add(json_path
, "aggregated");
6681 json_object_boolean_true_add(json_path
, "local");
6685 vty_out (vty
, ", aggregated, local");
6688 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
6691 json_object_boolean_true_add(json_path
, "sourced");
6693 vty_out (vty
, ", sourced");
6699 json_object_boolean_true_add(json_path
, "sourced");
6700 json_object_boolean_true_add(json_path
, "local");
6704 vty_out (vty
, ", sourced, local");
6708 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
6711 json_object_boolean_true_add(json_path
, "atomicAggregate");
6713 vty_out (vty
, ", atomic-aggregate");
6716 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
6717 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
6718 bgp_info_mpath_count (binfo
)))
6721 json_object_boolean_true_add(json_path
, "multipath");
6723 vty_out (vty
, ", multipath");
6726 // Mark the bestpath(s)
6727 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
6729 first_as
= aspath_get_firstas(attr
->aspath
);
6734 json_bestpath
= json_object_new_object();
6735 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
6740 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
6742 vty_out (vty
, ", bestpath-from-AS Local");
6746 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6751 json_bestpath
= json_object_new_object();
6752 json_object_boolean_true_add(json_bestpath
, "overall");
6755 vty_out (vty
, ", best");
6759 json_object_object_add(json_path
, "bestpath", json_bestpath
);
6762 vty_out (vty
, "%s", VTY_NEWLINE
);
6764 /* Line 4 display Community */
6765 if (attr
->community
)
6769 json_object_lock(attr
->community
->json
);
6770 json_object_object_add(json_path
, "community", attr
->community
->json
);
6774 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
6779 /* Line 5 display Extended-community */
6780 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
6784 json_ext_community
= json_object_new_object();
6785 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
6786 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
6790 vty_out (vty
, " Extended Community: %s%s",
6791 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
6795 /* Line 6 display Originator, Cluster-id */
6796 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
6797 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
6799 assert (attr
->extra
);
6800 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6803 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
6805 vty_out (vty
, " Originator: %s",
6806 inet_ntoa (attr
->extra
->originator_id
));
6809 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
6815 json_cluster_list
= json_object_new_object();
6816 json_cluster_list_list
= json_object_new_array();
6818 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6820 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6821 json_object_array_add(json_cluster_list_list
, json_string
);
6824 /* struct cluster_list does not have "str" variable like
6825 * aspath and community do. Add this someday if someone
6827 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
6829 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
6830 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
6834 vty_out (vty
, ", Cluster list: ");
6836 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6838 vty_out (vty
, "%s ",
6839 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6845 vty_out (vty
, "%s", VTY_NEWLINE
);
6848 if (binfo
->extra
&& binfo
->extra
->damp_info
)
6849 bgp_damp_info_vty (vty
, binfo
, json_path
);
6851 /* Line 7 display Addpath IDs */
6852 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
6856 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
6857 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
6861 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
6862 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
6867 /* If we used addpath to TX a non-bestpath we need to display
6868 * "Advertised to" on a path-by-path basis */
6869 if (bgp
->addpath_tx_used
[afi
][safi
])
6873 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6875 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
6876 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
6878 if ((addpath_capable
&& has_adj
) ||
6879 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
6881 if (json_path
&& !json_adv_to
)
6882 json_adv_to
= json_object_new_object();
6884 route_vty_out_advertised_to(vty
, peer
, &first
,
6894 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
6901 vty_out (vty
, "%s", VTY_NEWLINE
);
6906 /* Line 8 display Uptime */
6907 #ifdef HAVE_CLOCK_MONOTONIC
6908 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
6911 json_last_update
= json_object_new_object();
6912 json_object_int_add(json_last_update
, "epoch", tbuf
);
6913 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
6914 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
6917 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
6921 json_last_update
= json_object_new_object();
6922 json_object_int_add(json_last_update
, "epoch", tbuf
);
6923 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
6924 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
6927 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
6928 #endif /* HAVE_CLOCK_MONOTONIC */
6931 /* We've constructed the json object for this path, add it to the json
6936 if (json_nexthop_global
|| json_nexthop_ll
)
6938 json_nexthops
= json_object_new_array();
6940 if (json_nexthop_global
)
6941 json_object_array_add(json_nexthops
, json_nexthop_global
);
6943 if (json_nexthop_ll
)
6944 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6946 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6949 json_object_object_add(json_path
, "peer", json_peer
);
6950 json_object_array_add(json_paths
, json_path
);
6953 vty_out (vty
, "%s", VTY_NEWLINE
);
6956 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
6957 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6958 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6962 bgp_show_type_normal
,
6963 bgp_show_type_regexp
,
6964 bgp_show_type_prefix_list
,
6965 bgp_show_type_filter_list
,
6966 bgp_show_type_route_map
,
6967 bgp_show_type_neighbor
,
6968 bgp_show_type_cidr_only
,
6969 bgp_show_type_prefix_longer
,
6970 bgp_show_type_community_all
,
6971 bgp_show_type_community
,
6972 bgp_show_type_community_exact
,
6973 bgp_show_type_community_list
,
6974 bgp_show_type_community_list_exact
,
6975 bgp_show_type_flap_statistics
,
6976 bgp_show_type_flap_address
,
6977 bgp_show_type_flap_prefix
,
6978 bgp_show_type_flap_cidr_only
,
6979 bgp_show_type_flap_regexp
,
6980 bgp_show_type_flap_filter_list
,
6981 bgp_show_type_flap_prefix_list
,
6982 bgp_show_type_flap_prefix_longer
,
6983 bgp_show_type_flap_route_map
,
6984 bgp_show_type_flap_neighbor
,
6985 bgp_show_type_dampend_paths
,
6986 bgp_show_type_damp_neighbor
6990 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
6991 const char *prefix_list_str
, afi_t afi
,
6992 safi_t safi
, enum bgp_show_type type
);
6994 bgp_show_filter_list (struct vty
*vty
, const char *name
,
6995 const char *filter
, afi_t afi
,
6996 safi_t safi
, enum bgp_show_type type
);
6998 bgp_show_route_map (struct vty
*vty
, const char *name
,
6999 const char *rmap_str
, afi_t afi
,
7000 safi_t safi
, enum bgp_show_type type
);
7002 bgp_show_community_list (struct vty
*vty
, const char *name
,
7003 const char *com
, int exact
,
7004 afi_t afi
, safi_t safi
);
7006 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7007 const char *prefix
, afi_t afi
,
7008 safi_t safi
, enum bgp_show_type type
);
7011 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
, struct in_addr
*router_id
,
7012 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7014 struct bgp_info
*ri
;
7015 struct bgp_node
*rn
;
7018 unsigned long output_count
;
7022 json_object
*json
= NULL
;
7023 json_object
*json_paths
= NULL
;
7024 json_object
*json_routes
= NULL
;
7028 json
= json_object_new_object();
7029 json_object_int_add(json
, "tableVersion", table
->version
);
7030 json_object_string_add(json
, "routerId", inet_ntoa (*router_id
));
7031 json_routes
= json_object_new_object();
7034 /* This is first entry point, so reset total line. */
7037 /* Start processing of routes. */
7038 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7039 if (rn
->info
!= NULL
)
7044 json_paths
= json_object_new_array();
7048 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7050 if (type
== bgp_show_type_flap_statistics
7051 || type
== bgp_show_type_flap_address
7052 || type
== bgp_show_type_flap_prefix
7053 || type
== bgp_show_type_flap_cidr_only
7054 || type
== bgp_show_type_flap_regexp
7055 || type
== bgp_show_type_flap_filter_list
7056 || type
== bgp_show_type_flap_prefix_list
7057 || type
== bgp_show_type_flap_prefix_longer
7058 || type
== bgp_show_type_flap_route_map
7059 || type
== bgp_show_type_flap_neighbor
7060 || type
== bgp_show_type_dampend_paths
7061 || type
== bgp_show_type_damp_neighbor
)
7063 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7066 if (type
== bgp_show_type_regexp
7067 || type
== bgp_show_type_flap_regexp
)
7069 regex_t
*regex
= output_arg
;
7071 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7074 if (type
== bgp_show_type_prefix_list
7075 || type
== bgp_show_type_flap_prefix_list
)
7077 struct prefix_list
*plist
= output_arg
;
7079 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7082 if (type
== bgp_show_type_filter_list
7083 || type
== bgp_show_type_flap_filter_list
)
7085 struct as_list
*as_list
= output_arg
;
7087 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7090 if (type
== bgp_show_type_route_map
7091 || type
== bgp_show_type_flap_route_map
)
7093 struct route_map
*rmap
= output_arg
;
7094 struct bgp_info binfo
;
7095 struct attr dummy_attr
;
7096 struct attr_extra dummy_extra
;
7099 dummy_attr
.extra
= &dummy_extra
;
7100 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7102 binfo
.peer
= ri
->peer
;
7103 binfo
.attr
= &dummy_attr
;
7105 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7106 if (ret
== RMAP_DENYMATCH
)
7109 if (type
== bgp_show_type_neighbor
7110 || type
== bgp_show_type_flap_neighbor
7111 || type
== bgp_show_type_damp_neighbor
)
7113 union sockunion
*su
= output_arg
;
7115 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7118 if (type
== bgp_show_type_cidr_only
7119 || type
== bgp_show_type_flap_cidr_only
)
7121 u_int32_t destination
;
7123 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7124 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7126 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7128 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7131 if (type
== bgp_show_type_prefix_longer
7132 || type
== bgp_show_type_flap_prefix_longer
)
7134 struct prefix
*p
= output_arg
;
7136 if (! prefix_match (p
, &rn
->p
))
7139 if (type
== bgp_show_type_community_all
)
7141 if (! ri
->attr
->community
)
7144 if (type
== bgp_show_type_community
)
7146 struct community
*com
= output_arg
;
7148 if (! ri
->attr
->community
||
7149 ! community_match (ri
->attr
->community
, com
))
7152 if (type
== bgp_show_type_community_exact
)
7154 struct community
*com
= output_arg
;
7156 if (! ri
->attr
->community
||
7157 ! community_cmp (ri
->attr
->community
, com
))
7160 if (type
== bgp_show_type_community_list
)
7162 struct community_list
*list
= output_arg
;
7164 if (! community_list_match (ri
->attr
->community
, list
))
7167 if (type
== bgp_show_type_community_list_exact
)
7169 struct community_list
*list
= output_arg
;
7171 if (! community_list_exact_match (ri
->attr
->community
, list
))
7174 if (type
== bgp_show_type_flap_address
7175 || type
== bgp_show_type_flap_prefix
)
7177 struct prefix
*p
= output_arg
;
7179 if (! prefix_match (&rn
->p
, p
))
7182 if (type
== bgp_show_type_flap_prefix
)
7183 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7186 if (type
== bgp_show_type_dampend_paths
7187 || type
== bgp_show_type_damp_neighbor
)
7189 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7190 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7194 if (!use_json
&& header
)
7196 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (*router_id
), VTY_NEWLINE
);
7197 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7198 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7199 if (type
== bgp_show_type_dampend_paths
7200 || type
== bgp_show_type_damp_neighbor
)
7201 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7202 else if (type
== bgp_show_type_flap_statistics
7203 || type
== bgp_show_type_flap_address
7204 || type
== bgp_show_type_flap_prefix
7205 || type
== bgp_show_type_flap_cidr_only
7206 || type
== bgp_show_type_flap_regexp
7207 || type
== bgp_show_type_flap_filter_list
7208 || type
== bgp_show_type_flap_prefix_list
7209 || type
== bgp_show_type_flap_prefix_longer
7210 || type
== bgp_show_type_flap_route_map
7211 || type
== bgp_show_type_flap_neighbor
)
7212 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7214 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7218 if (type
== bgp_show_type_dampend_paths
7219 || type
== bgp_show_type_damp_neighbor
)
7220 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7221 else if (type
== bgp_show_type_flap_statistics
7222 || type
== bgp_show_type_flap_address
7223 || type
== bgp_show_type_flap_prefix
7224 || type
== bgp_show_type_flap_cidr_only
7225 || type
== bgp_show_type_flap_regexp
7226 || type
== bgp_show_type_flap_filter_list
7227 || type
== bgp_show_type_flap_prefix_list
7228 || type
== bgp_show_type_flap_prefix_longer
7229 || type
== bgp_show_type_flap_route_map
7230 || type
== bgp_show_type_flap_neighbor
)
7231 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7233 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7243 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7244 json_object_object_add(json_routes
, buf2
, json_paths
);
7251 json_object_object_add(json
, "routes", json_routes
);
7252 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7253 json_object_free(json
);
7257 /* No route is displayed */
7258 if (output_count
== 0)
7260 if (type
== bgp_show_type_normal
)
7261 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
7264 vty_out (vty
, "%sTotal number of prefixes %ld%s",
7265 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
7272 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7273 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7275 struct bgp_table
*table
;
7279 bgp
= bgp_get_default ();
7285 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7289 table
= bgp
->rib
[afi
][safi
];
7291 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
, use_json
);
7294 /* Header of detailed BGP route information */
7296 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7297 struct bgp_node
*rn
,
7298 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7301 struct bgp_info
*ri
;
7304 struct listnode
*node
, *nnode
;
7305 char buf1
[INET6_ADDRSTRLEN
];
7306 char buf2
[INET6_ADDRSTRLEN
];
7311 int no_advertise
= 0;
7314 json_object
*json_adv_to
= NULL
;
7320 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7321 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7325 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7326 (safi
== SAFI_MPLS_VPN
?
7327 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7328 safi
== SAFI_MPLS_VPN
? ":" : "",
7329 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7330 p
->prefixlen
, VTY_NEWLINE
);
7333 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7336 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7339 if (ri
->extra
&& ri
->extra
->suppress
)
7341 if (ri
->attr
->community
!= NULL
)
7343 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7345 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7347 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7355 vty_out (vty
, "Paths: (%d available", count
);
7358 vty_out (vty
, ", best #%d", best
);
7359 if (safi
== SAFI_UNICAST
)
7360 vty_out (vty
, ", table Default-IP-Routing-Table");
7363 vty_out (vty
, ", no best path");
7366 vty_out (vty
, ", not advertised to any peer");
7368 vty_out (vty
, ", not advertised to EBGP peer");
7370 vty_out (vty
, ", not advertised outside local AS");
7373 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7374 vty_out (vty
, ")%s", VTY_NEWLINE
);
7377 /* If we are not using addpath then we can display Advertised to and that will
7378 * show what peers we advertised the bestpath to. If we are using addpath
7379 * though then we must display Advertised to on a path-by-path basis. */
7380 if (!bgp
->addpath_tx_used
[afi
][safi
])
7382 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7384 if (bgp_adj_out_lookup (peer
, rn
, 0))
7386 if (json
&& !json_adv_to
)
7387 json_adv_to
= json_object_new_object();
7389 route_vty_out_advertised_to(vty
, peer
, &first
,
7390 " Advertised to non peer-group peers:\n ",
7399 json_object_object_add(json
, "advertisedTo", json_adv_to
);
7405 vty_out (vty
, " Not advertised to any peer");
7406 vty_out (vty
, "%s", VTY_NEWLINE
);
7411 /* Display specified route of BGP table. */
7413 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
7414 struct bgp_table
*rib
, const char *ip_str
,
7415 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7416 int prefix_check
, enum bgp_path_type pathtype
,
7422 struct prefix match
;
7423 struct bgp_node
*rn
;
7424 struct bgp_node
*rm
;
7425 struct bgp_info
*ri
;
7426 struct bgp_table
*table
;
7427 json_object
*json
= NULL
;
7428 json_object
*json_paths
= NULL
;
7430 /* Check IP address argument. */
7431 ret
= str2prefix (ip_str
, &match
);
7434 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
7438 match
.family
= afi2family (afi
);
7442 json
= json_object_new_object();
7443 json_paths
= json_object_new_array();
7446 if (safi
== SAFI_MPLS_VPN
)
7448 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
7450 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
7453 if ((table
= rn
->info
) != NULL
)
7457 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
7459 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
7461 bgp_unlock_node (rm
);
7465 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
7469 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
7470 AFI_IP
, SAFI_MPLS_VPN
, json
);
7476 if (pathtype
== BGP_PATH_ALL
||
7477 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7478 (pathtype
== BGP_PATH_MULTIPATH
&&
7479 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7480 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
, json_paths
);
7483 bgp_unlock_node (rm
);
7492 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
7494 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
7496 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7500 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
7505 if (pathtype
== BGP_PATH_ALL
||
7506 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7507 (pathtype
== BGP_PATH_MULTIPATH
&&
7508 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7509 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
7513 bgp_unlock_node (rn
);
7520 json_object_object_add(json
, "paths", json_paths
);
7522 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7523 json_object_free(json
);
7529 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
7537 /* Display specified route of Main RIB */
7539 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
7540 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7541 int prefix_check
, enum bgp_path_type pathtype
,
7546 /* BGP structure lookup. */
7549 bgp
= bgp_lookup_by_name (view_name
);
7552 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
7558 bgp
= bgp_get_default ();
7561 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7566 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
7567 afi
, safi
, prd
, prefix_check
, pathtype
,
7571 /* BGP route print out function. */
7574 "show ip bgp {json}",
7578 "JavaScript Object Notation\n")
7580 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7583 DEFUN (show_ip_bgp_ipv4
,
7584 show_ip_bgp_ipv4_cmd
,
7585 "show ip bgp ipv4 (unicast|multicast) {json}",
7590 "Address Family modifier\n"
7591 "Address Family modifier\n"
7592 "JavaScript Object Notation\n")
7594 u_char uj
= use_json(argc
, argv
);
7596 if (strncmp (argv
[0], "m", 1) == 0)
7597 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
7600 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
7603 ALIAS (show_ip_bgp_ipv4
,
7604 show_bgp_ipv4_safi_cmd
,
7605 "show bgp ipv4 (unicast|multicast) {json}",
7609 "Address Family modifier\n"
7610 "Address Family modifier\n"
7611 "JavaScript Object Notation\n")
7613 DEFUN (show_ip_bgp_route
,
7614 show_ip_bgp_route_cmd
,
7615 "show ip bgp A.B.C.D {json}",
7619 "Network in the BGP routing table to display\n"
7620 "JavaScript Object Notation\n")
7622 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7625 DEFUN (show_ip_bgp_route_pathtype
,
7626 show_ip_bgp_route_pathtype_cmd
,
7627 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
7631 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7632 "Display only the bestpath\n"
7633 "Display only multipaths\n"
7634 "JavaScript Object Notation\n")
7636 u_char uj
= use_json(argc
, argv
);
7638 if (strncmp (argv
[1], "b", 1) == 0)
7639 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7641 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7644 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
7645 show_bgp_ipv4_safi_route_pathtype_cmd
,
7646 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
7650 "Address Family modifier\n"
7651 "Address Family modifier\n"
7652 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7653 "Display only the bestpath\n"
7654 "Display only multipaths\n"
7655 "JavaScript Object Notation\n")
7657 u_char uj
= use_json(argc
, argv
);
7659 if (strncmp (argv
[0], "m", 1) == 0)
7660 if (strncmp (argv
[2], "b", 1) == 0)
7661 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7663 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7665 if (strncmp (argv
[2], "b", 1) == 0)
7666 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7668 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7671 DEFUN (show_ip_bgp_ipv4_route
,
7672 show_ip_bgp_ipv4_route_cmd
,
7673 "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
7678 "Address Family modifier\n"
7679 "Address Family modifier\n"
7680 "Network in the BGP routing table to display\n"
7681 "JavaScript Object Notation\n")
7683 u_char uj
= use_json(argc
, argv
);
7685 if (strncmp (argv
[0], "m", 1) == 0)
7686 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7688 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7691 ALIAS (show_ip_bgp_ipv4_route
,
7692 show_bgp_ipv4_safi_route_cmd
,
7693 "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
7697 "Address Family modifier\n"
7698 "Address Family modifier\n"
7699 "Network in the BGP routing table to display\n"
7700 "JavaScript Object Notation\n")
7702 DEFUN (show_ip_bgp_vpnv4_all_route
,
7703 show_ip_bgp_vpnv4_all_route_cmd
,
7704 "show ip bgp vpnv4 all A.B.C.D {json}",
7708 "Display VPNv4 NLRI specific information\n"
7709 "Display information about all VPNv4 NLRIs\n"
7710 "Network in the BGP routing table to display\n"
7711 "JavaScript Object Notation\n")
7713 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7717 DEFUN (show_ip_bgp_vpnv4_rd_route
,
7718 show_ip_bgp_vpnv4_rd_route_cmd
,
7719 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
7723 "Display VPNv4 NLRI specific information\n"
7724 "Display information for a route distinguisher\n"
7725 "VPN Route Distinguisher\n"
7726 "Network in the BGP routing table to display\n"
7727 "JavaScript Object Notation\n")
7730 struct prefix_rd prd
;
7731 u_char uj
= use_json(argc
, argv
);
7733 ret
= str2prefix_rd (argv
[0], &prd
);
7736 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
7739 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, uj
);
7742 DEFUN (show_ip_bgp_prefix
,
7743 show_ip_bgp_prefix_cmd
,
7744 "show ip bgp A.B.C.D/M {json}",
7748 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7749 "JavaScript Object Notation\n")
7751 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
7754 DEFUN (show_ip_bgp_prefix_pathtype
,
7755 show_ip_bgp_prefix_pathtype_cmd
,
7756 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
7760 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7761 "Display only the bestpath\n"
7762 "Display only multipaths\n"
7763 "JavaScript Object Notation\n")
7765 u_char uj
= use_json(argc
, argv
);
7766 if (strncmp (argv
[1], "b", 1) == 0)
7767 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7769 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7772 DEFUN (show_ip_bgp_ipv4_prefix
,
7773 show_ip_bgp_ipv4_prefix_cmd
,
7774 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
7779 "Address Family modifier\n"
7780 "Address Family modifier\n"
7781 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7782 "JavaScript Object Notation\n")
7784 u_char uj
= use_json(argc
, argv
);
7786 if (strncmp (argv
[0], "m", 1) == 0)
7787 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
7789 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
7792 ALIAS (show_ip_bgp_ipv4_prefix
,
7793 show_bgp_ipv4_safi_prefix_cmd
,
7794 "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
7798 "Address Family modifier\n"
7799 "Address Family modifier\n"
7800 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7801 "JavaScript Object Notation\n")
7803 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
7804 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
7805 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
7810 "Address Family modifier\n"
7811 "Address Family modifier\n"
7812 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7813 "Display only the bestpath\n"
7814 "Display only multipaths\n"
7815 "JavaScript Object Notation\n")
7817 u_char uj
= use_json(argc
, argv
);
7819 if (strncmp (argv
[0], "m", 1) == 0)
7820 if (strncmp (argv
[2], "b", 1) == 0)
7821 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7823 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7825 if (strncmp (argv
[2], "b", 1) == 0)
7826 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7828 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7831 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
7832 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
7833 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
7837 "Address Family modifier\n"
7838 "Address Family modifier\n"
7839 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7840 "Display only the bestpath\n"
7841 "Display only multipaths\n"
7842 "JavaScript Object Notation\n")
7844 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
7845 show_ip_bgp_vpnv4_all_prefix_cmd
,
7846 "show ip bgp vpnv4 all A.B.C.D/M {json}",
7850 "Display VPNv4 NLRI specific information\n"
7851 "Display information about all VPNv4 NLRIs\n"
7852 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7853 "JavaScript Object Notation\n")
7855 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
7858 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
7859 show_ip_bgp_vpnv4_rd_prefix_cmd
,
7860 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
7864 "Display VPNv4 NLRI specific information\n"
7865 "Display information for a route distinguisher\n"
7866 "VPN Route Distinguisher\n"
7867 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7868 "JavaScript Object Notation\n")
7871 struct prefix_rd prd
;
7873 ret
= str2prefix_rd (argv
[0], &prd
);
7876 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
7879 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7882 DEFUN (show_ip_bgp_view
,
7883 show_ip_bgp_instance_cmd
,
7884 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
7888 BGP_INSTANCE_HELP_STR
7889 "JavaScript Object Notation\n")
7893 /* BGP structure lookup. */
7894 bgp
= bgp_lookup_by_name (argv
[1]);
7897 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
7901 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7904 DEFUN (show_ip_bgp_instance_route
,
7905 show_ip_bgp_instance_route_cmd
,
7906 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
7910 BGP_INSTANCE_HELP_STR
7911 "Network in the BGP routing table to display\n"
7912 "JavaScript Object Notation\n")
7914 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7917 DEFUN (show_ip_bgp_instance_route_pathtype
,
7918 show_ip_bgp_instance_route_pathtype_cmd
,
7919 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
7923 BGP_INSTANCE_HELP_STR
7924 "Network in the BGP routing table to display\n"
7925 "Display only the bestpath\n"
7926 "Display only multipaths\n"
7927 "JavaScript Object Notation\n")
7929 u_char uj
= use_json(argc
, argv
);
7931 if (strncmp (argv
[3], "b", 1) == 0)
7932 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7934 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7937 DEFUN (show_ip_bgp_instance_prefix
,
7938 show_ip_bgp_instance_prefix_cmd
,
7939 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
7943 BGP_INSTANCE_HELP_STR
7944 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7945 "JavaScript Object Notation\n")
7947 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
7950 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
7951 show_ip_bgp_instance_prefix_pathtype_cmd
,
7952 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
7956 BGP_INSTANCE_HELP_STR
7957 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7958 "Display only the bestpath\n"
7959 "Display only multipaths\n"
7960 "JavaScript Object Notation\n")
7962 u_char uj
= use_json(argc
, argv
);
7963 if (strncmp (argv
[3], "b", 1) == 0)
7964 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7966 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7975 "JavaScript Object Notation\n")
7977 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
7978 NULL
, use_json(argc
, argv
));
7983 "show bgp ipv6 {json}",
7987 "JavaScript Object Notation\n")
7989 DEFUN (show_bgp_ipv6_safi
,
7990 show_bgp_ipv6_safi_cmd
,
7991 "show bgp ipv6 (unicast|multicast) {json}",
7995 "Address Family modifier\n"
7996 "Address Family modifier\n"
7997 "JavaScript Object Notation\n")
7999 u_char uj
= use_json(argc
, argv
);
8000 if (strncmp (argv
[0], "m", 1) == 0)
8001 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8004 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8008 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8010 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8011 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8012 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8016 DEFUN (show_ipv6_bgp
,
8018 "show ipv6 bgp {json}",
8022 "JavaScript Object Notation\n")
8024 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8025 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8026 NULL
, use_json(argc
, argv
));
8029 DEFUN (show_bgp_route
,
8031 "show bgp X:X::X:X {json}",
8034 "Network in the BGP routing table to display\n"
8035 "JavaScript Object Notation\n")
8037 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8040 ALIAS (show_bgp_route
,
8041 show_bgp_ipv6_route_cmd
,
8042 "show bgp ipv6 X:X::X:X {json}",
8046 "Network in the BGP routing table to display\n"
8047 "JavaScript Object Notation\n")
8049 DEFUN (show_bgp_ipv6_safi_route
,
8050 show_bgp_ipv6_safi_route_cmd
,
8051 "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
8055 "Address Family modifier\n"
8056 "Address Family modifier\n"
8057 "Network in the BGP routing table to display\n"
8058 "JavaScript Object Notation\n")
8060 u_char uj
= use_json(argc
, argv
);
8061 if (strncmp (argv
[0], "m", 1) == 0)
8062 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8064 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8067 DEFUN (show_bgp_route_pathtype
,
8068 show_bgp_route_pathtype_cmd
,
8069 "show bgp X:X::X:X (bestpath|multipath) {json}",
8072 "Network in the BGP routing table to display\n"
8073 "Display only the bestpath\n"
8074 "Display only multipaths\n"
8075 "JavaScript Object Notation\n")
8077 u_char uj
= use_json(argc
, argv
);
8078 if (strncmp (argv
[1], "b", 1) == 0)
8079 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8081 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8084 ALIAS (show_bgp_route_pathtype
,
8085 show_bgp_ipv6_route_pathtype_cmd
,
8086 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8090 "Network in the BGP routing table to display\n"
8091 "Display only the bestpath\n"
8092 "Display only multipaths\n"
8093 "JavaScript Object Notation\n")
8095 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8096 show_bgp_ipv6_safi_route_pathtype_cmd
,
8097 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
8101 "Address Family modifier\n"
8102 "Address Family modifier\n"
8103 "Network in the BGP routing table to display\n"
8104 "Display only the bestpath\n"
8105 "Display only multipaths\n"
8106 "JavaScript Object Notation\n")
8108 u_char uj
= use_json(argc
, argv
);
8109 if (strncmp (argv
[0], "m", 1) == 0)
8110 if (strncmp (argv
[2], "b", 1) == 0)
8111 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8113 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8115 if (strncmp (argv
[2], "b", 1) == 0)
8116 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8118 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8122 DEFUN (show_ipv6_bgp_route
,
8123 show_ipv6_bgp_route_cmd
,
8124 "show ipv6 bgp X:X::X:X {json}",
8128 "Network in the BGP routing table to display\n"
8129 "JavaScript Object Notation\n")
8131 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8132 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8135 DEFUN (show_bgp_prefix
,
8136 show_bgp_prefix_cmd
,
8137 "show bgp X:X::X:X/M {json}",
8140 "IPv6 prefix <network>/<length>\n"
8141 "JavaScript Object Notation\n")
8143 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8146 ALIAS (show_bgp_prefix
,
8147 show_bgp_ipv6_prefix_cmd
,
8148 "show bgp ipv6 X:X::X:X/M {json}",
8152 "IPv6 prefix <network>/<length>\n"
8153 "JavaScript Object Notation\n")
8155 DEFUN (show_bgp_ipv6_safi_prefix
,
8156 show_bgp_ipv6_safi_prefix_cmd
,
8157 "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
8161 "Address Family modifier\n"
8162 "Address Family modifier\n"
8163 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8164 "JavaScript Object Notation\n")
8166 u_char uj
= use_json(argc
, argv
);
8167 if (strncmp (argv
[0], "m", 1) == 0)
8168 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8170 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8173 DEFUN (show_bgp_prefix_pathtype
,
8174 show_bgp_prefix_pathtype_cmd
,
8175 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8178 "IPv6 prefix <network>/<length>\n"
8179 "Display only the bestpath\n"
8180 "Display only multipaths\n"
8181 "JavaScript Object Notation\n")
8183 u_char uj
= use_json(argc
, argv
);
8184 if (strncmp (argv
[1], "b", 1) == 0)
8185 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8187 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8190 ALIAS (show_bgp_prefix_pathtype
,
8191 show_bgp_ipv6_prefix_pathtype_cmd
,
8192 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8196 "IPv6 prefix <network>/<length>\n"
8197 "Display only the bestpath\n"
8198 "Display only multipaths\n"
8199 "JavaScript Object Notation\n")
8201 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8202 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8203 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
8207 "Address Family modifier\n"
8208 "Address Family modifier\n"
8209 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8210 "Display only the bestpath\n"
8211 "Display only multipaths\n"
8212 "JavaScript Object Notation\n")
8214 u_char uj
= use_json(argc
, argv
);
8215 if (strncmp (argv
[0], "m", 1) == 0)
8216 if (strncmp (argv
[2], "b", 1) == 0)
8217 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8219 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8221 if (strncmp (argv
[2], "b", 1) == 0)
8222 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8224 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8228 DEFUN (show_ipv6_bgp_prefix
,
8229 show_ipv6_bgp_prefix_cmd
,
8230 "show ipv6 bgp X:X::X:X/M {json}",
8234 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8235 "JavaScript Object Notation\n")
8237 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8238 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8241 DEFUN (show_bgp_view
,
8242 show_bgp_instance_cmd
,
8243 "show bgp " BGP_INSTANCE_CMD
" {json}",
8246 BGP_INSTANCE_HELP_STR
8247 "JavaScript Object Notation\n")
8251 /* BGP structure lookup. */
8252 bgp
= bgp_lookup_by_name (argv
[1]);
8255 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8259 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8262 ALIAS (show_bgp_view
,
8263 show_bgp_instance_ipv6_cmd
,
8264 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8267 BGP_INSTANCE_HELP_STR
8269 "JavaScript Object Notation\n")
8271 DEFUN (show_bgp_instance_route
,
8272 show_bgp_instance_route_cmd
,
8273 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8276 BGP_INSTANCE_HELP_STR
8277 "Network in the BGP routing table to display\n"
8278 "JavaScript Object Notation\n")
8280 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8283 ALIAS (show_bgp_instance_route
,
8284 show_bgp_instance_ipv6_route_cmd
,
8285 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8288 BGP_INSTANCE_HELP_STR
8290 "Network in the BGP routing table to display\n"
8291 "JavaScript Object Notation\n")
8293 DEFUN (show_bgp_instance_route_pathtype
,
8294 show_bgp_instance_route_pathtype_cmd
,
8295 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8298 BGP_INSTANCE_HELP_STR
8299 "Network in the BGP routing table to display\n"
8300 "Display only the bestpath\n"
8301 "Display only multipaths\n"
8302 "JavaScript Object Notation\n")
8304 u_char uj
= use_json(argc
, argv
);
8305 if (strncmp (argv
[3], "b", 1) == 0)
8306 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8308 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8311 ALIAS (show_bgp_instance_route_pathtype
,
8312 show_bgp_instance_ipv6_route_pathtype_cmd
,
8313 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
8316 BGP_INSTANCE_HELP_STR
8318 "Network in the BGP routing table to display\n"
8319 "Display only the bestpath\n"
8320 "Display only multipaths\n"
8321 "JavaScript Object Notation\n")
8323 DEFUN (show_bgp_instance_prefix
,
8324 show_bgp_instance_prefix_cmd
,
8325 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
8328 BGP_INSTANCE_HELP_STR
8329 "IPv6 prefix <network>/<length>\n"
8330 "JavaScript Object Notation\n")
8332 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8335 ALIAS (show_bgp_instance_prefix
,
8336 show_bgp_instance_ipv6_prefix_cmd
,
8337 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
8340 BGP_INSTANCE_HELP_STR
8342 "IPv6 prefix <network>/<length>\n"
8343 "JavaScript Object Notation\n")
8345 DEFUN (show_bgp_instance_prefix_pathtype
,
8346 show_bgp_instance_prefix_pathtype_cmd
,
8347 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
8350 BGP_INSTANCE_HELP_STR
8351 "IPv6 prefix <network>/<length>\n"
8352 "Display only the bestpath\n"
8353 "Display only multipaths\n"
8354 "JavaScript Object Notation\n")
8356 u_char uj
= use_json(argc
, argv
);
8357 if (strncmp (argv
[3], "b", 1) == 0)
8358 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8360 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8363 ALIAS (show_bgp_instance_prefix_pathtype
,
8364 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
8365 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8368 BGP_INSTANCE_HELP_STR
8370 "IPv6 prefix <network>/<length>\n"
8371 "Display only the bestpath\n"
8372 "Display only multipaths\n"
8373 "JavaScript Object Notation\n")
8375 DEFUN (show_bgp_instance_prefix_list
,
8376 show_bgp_instance_prefix_list_cmd
,
8377 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
8380 BGP_INSTANCE_HELP_STR
8381 "Display routes conforming to the prefix-list\n"
8382 "IPv6 prefix-list name\n")
8384 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8385 bgp_show_type_prefix_list
);
8388 ALIAS (show_bgp_instance_prefix_list
,
8389 show_bgp_instance_ipv6_prefix_list_cmd
,
8390 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
8393 BGP_INSTANCE_HELP_STR
8395 "Display routes conforming to the prefix-list\n"
8396 "IPv6 prefix-list name\n")
8398 DEFUN (show_bgp_instance_filter_list
,
8399 show_bgp_instance_filter_list_cmd
,
8400 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
8403 BGP_INSTANCE_HELP_STR
8404 "Display routes conforming to the filter-list\n"
8405 "Regular expression access list name\n")
8407 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8408 bgp_show_type_filter_list
);
8411 ALIAS (show_bgp_instance_filter_list
,
8412 show_bgp_instance_ipv6_filter_list_cmd
,
8413 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
8416 BGP_INSTANCE_HELP_STR
8418 "Display routes conforming to the filter-list\n"
8419 "Regular expression access list name\n")
8421 DEFUN (show_bgp_instance_route_map
,
8422 show_bgp_instance_route_map_cmd
,
8423 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
8426 BGP_INSTANCE_HELP_STR
8427 "Display routes matching the route-map\n"
8428 "A route-map to match on\n")
8430 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8431 bgp_show_type_route_map
);
8434 ALIAS (show_bgp_instance_route_map
,
8435 show_bgp_instance_ipv6_route_map_cmd
,
8436 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
8439 BGP_INSTANCE_HELP_STR
8441 "Display routes matching the route-map\n"
8442 "A route-map to match on\n")
8444 DEFUN (show_bgp_instance_community_list
,
8445 show_bgp_instance_community_list_cmd
,
8446 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
8449 BGP_INSTANCE_HELP_STR
8450 "Display routes matching the community-list\n"
8451 "community-list number\n"
8452 "community-list name\n")
8454 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
8457 ALIAS (show_bgp_instance_community_list
,
8458 show_bgp_instance_ipv6_community_list_cmd
,
8459 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
8462 BGP_INSTANCE_HELP_STR
8464 "Display routes matching the community-list\n"
8465 "community-list number\n"
8466 "community-list name\n")
8468 DEFUN (show_bgp_instance_prefix_longer
,
8469 show_bgp_instance_prefix_longer_cmd
,
8470 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
8473 BGP_INSTANCE_HELP_STR
8474 "IPv6 prefix <network>/<length>\n"
8475 "Display route and more specific routes\n")
8477 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8478 bgp_show_type_prefix_longer
);
8481 ALIAS (show_bgp_instance_prefix_longer
,
8482 show_bgp_instance_ipv6_prefix_longer_cmd
,
8483 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
8486 BGP_INSTANCE_HELP_STR
8488 "IPv6 prefix <network>/<length>\n"
8489 "Display route and more specific routes\n")
8492 DEFUN (show_ipv6_mbgp
,
8494 "show ipv6 mbgp {json}",
8498 "JavaScript Object Notation\n")
8500 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8501 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8502 NULL
, use_json(argc
, argv
));
8506 DEFUN (show_ipv6_mbgp_route
,
8507 show_ipv6_mbgp_route_cmd
,
8508 "show ipv6 mbgp X:X::X:X {json}",
8512 "Network in the MBGP routing table to display\n"
8513 "JavaScript Object Notation\n")
8515 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8516 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8520 DEFUN (show_ipv6_mbgp_prefix
,
8521 show_ipv6_mbgp_prefix_cmd
,
8522 "show ipv6 mbgp X:X::X:X/M {json}",
8526 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8527 "JavaScript Object Notation\n")
8529 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8530 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8536 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
8537 safi_t safi
, enum bgp_show_type type
)
8547 b
= buffer_new (1024);
8548 for (i
= 0; i
< argc
; i
++)
8551 buffer_putc (b
, ' ');
8554 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
8559 buffer_putstr (b
, argv
[i
]);
8561 buffer_putc (b
, '\0');
8563 regstr
= buffer_getstr (b
);
8566 regex
= bgp_regcomp (regstr
);
8567 XFREE(MTYPE_TMP
, regstr
);
8570 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
8575 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
8576 bgp_regex_free (regex
);
8580 DEFUN (show_ip_bgp_regexp
,
8581 show_ip_bgp_regexp_cmd
,
8582 "show ip bgp regexp .LINE",
8586 "Display routes matching the AS path regular expression\n"
8587 "A regular-expression to match the BGP AS paths\n")
8589 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8590 bgp_show_type_regexp
);
8593 DEFUN (show_ip_bgp_flap_regexp
,
8594 show_ip_bgp_flap_regexp_cmd
,
8595 "show ip bgp flap-statistics regexp .LINE",
8599 "Display flap statistics of routes\n"
8600 "Display routes matching the AS path regular expression\n"
8601 "A regular-expression to match the BGP AS paths\n")
8603 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8604 bgp_show_type_flap_regexp
);
8607 DEFUN (show_ip_bgp_ipv4_regexp
,
8608 show_ip_bgp_ipv4_regexp_cmd
,
8609 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
8614 "Address Family modifier\n"
8615 "Address Family modifier\n"
8616 "Display routes matching the AS path regular expression\n"
8617 "A regular-expression to match the BGP AS paths\n")
8619 if (strncmp (argv
[0], "m", 1) == 0)
8620 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
8621 bgp_show_type_regexp
);
8623 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8624 bgp_show_type_regexp
);
8628 DEFUN (show_bgp_regexp
,
8629 show_bgp_regexp_cmd
,
8630 "show bgp regexp .LINE",
8633 "Display routes matching the AS path regular expression\n"
8634 "A regular-expression to match the BGP AS paths\n")
8636 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
8637 bgp_show_type_regexp
);
8640 ALIAS (show_bgp_regexp
,
8641 show_bgp_ipv6_regexp_cmd
,
8642 "show bgp ipv6 regexp .LINE",
8646 "Display routes matching the AS path regular expression\n"
8647 "A regular-expression to match the BGP AS paths\n")
8650 DEFUN (show_ipv6_bgp_regexp
,
8651 show_ipv6_bgp_regexp_cmd
,
8652 "show ipv6 bgp regexp .LINE",
8656 "Display routes matching the AS path regular expression\n"
8657 "A regular-expression to match the BGP AS paths\n")
8659 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8660 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
8661 bgp_show_type_regexp
);
8665 DEFUN (show_ipv6_mbgp_regexp
,
8666 show_ipv6_mbgp_regexp_cmd
,
8667 "show ipv6 mbgp regexp .LINE",
8671 "Display routes matching the AS path regular expression\n"
8672 "A regular-expression to match the MBGP AS paths\n")
8674 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8675 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
8676 bgp_show_type_regexp
);
8678 #endif /* HAVE_IPV6 */
8681 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
8682 const char *prefix_list_str
, afi_t afi
,
8683 safi_t safi
, enum bgp_show_type type
)
8685 struct prefix_list
*plist
;
8686 struct bgp
*bgp
= NULL
;
8688 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
8690 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
8694 plist
= prefix_list_lookup (afi
, prefix_list_str
);
8697 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
8698 prefix_list_str
, VTY_NEWLINE
);
8702 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
8705 DEFUN (show_ip_bgp_prefix_list
,
8706 show_ip_bgp_prefix_list_cmd
,
8707 "show ip bgp prefix-list WORD",
8711 "Display routes conforming to the prefix-list\n"
8712 "IP prefix-list name\n")
8714 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8715 bgp_show_type_prefix_list
);
8718 DEFUN (show_ip_bgp_instance_prefix_list
,
8719 show_ip_bgp_instance_prefix_list_cmd
,
8720 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
8724 BGP_INSTANCE_HELP_STR
8725 "Display routes conforming to the prefix-list\n"
8726 "IP prefix-list name\n")
8728 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
8729 bgp_show_type_prefix_list
);
8732 DEFUN (show_ip_bgp_flap_prefix_list
,
8733 show_ip_bgp_flap_prefix_list_cmd
,
8734 "show ip bgp flap-statistics prefix-list WORD",
8738 "Display flap statistics of routes\n"
8739 "Display routes conforming to the prefix-list\n"
8740 "IP prefix-list name\n")
8742 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8743 bgp_show_type_flap_prefix_list
);
8746 DEFUN (show_ip_bgp_ipv4_prefix_list
,
8747 show_ip_bgp_ipv4_prefix_list_cmd
,
8748 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8753 "Address Family modifier\n"
8754 "Address Family modifier\n"
8755 "Display routes conforming to the prefix-list\n"
8756 "IP prefix-list name\n")
8758 if (strncmp (argv
[0], "m", 1) == 0)
8759 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8760 bgp_show_type_prefix_list
);
8762 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8763 bgp_show_type_prefix_list
);
8767 DEFUN (show_bgp_prefix_list
,
8768 show_bgp_prefix_list_cmd
,
8769 "show bgp prefix-list WORD",
8772 "Display routes conforming to the prefix-list\n"
8773 "IPv6 prefix-list name\n")
8775 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8776 bgp_show_type_prefix_list
);
8779 ALIAS (show_bgp_prefix_list
,
8780 show_bgp_ipv6_prefix_list_cmd
,
8781 "show bgp ipv6 prefix-list WORD",
8785 "Display routes conforming to the prefix-list\n"
8786 "IPv6 prefix-list name\n")
8789 DEFUN (show_ipv6_bgp_prefix_list
,
8790 show_ipv6_bgp_prefix_list_cmd
,
8791 "show ipv6 bgp prefix-list WORD",
8795 "Display routes matching the prefix-list\n"
8796 "IPv6 prefix-list name\n")
8798 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8799 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8800 bgp_show_type_prefix_list
);
8804 DEFUN (show_ipv6_mbgp_prefix_list
,
8805 show_ipv6_mbgp_prefix_list_cmd
,
8806 "show ipv6 mbgp prefix-list WORD",
8810 "Display routes matching the prefix-list\n"
8811 "IPv6 prefix-list name\n")
8813 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8814 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8815 bgp_show_type_prefix_list
);
8817 #endif /* HAVE_IPV6 */
8820 bgp_show_filter_list (struct vty
*vty
, const char *name
,
8821 const char *filter
, afi_t afi
,
8822 safi_t safi
, enum bgp_show_type type
)
8824 struct as_list
*as_list
;
8825 struct bgp
*bgp
= NULL
;
8827 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
8829 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
8833 as_list
= as_list_lookup (filter
);
8834 if (as_list
== NULL
)
8836 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
8840 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
8843 DEFUN (show_ip_bgp_filter_list
,
8844 show_ip_bgp_filter_list_cmd
,
8845 "show ip bgp filter-list WORD",
8849 "Display routes conforming to the filter-list\n"
8850 "Regular expression access list name\n")
8852 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8853 bgp_show_type_filter_list
);
8856 DEFUN (show_ip_bgp_instance_filter_list
,
8857 show_ip_bgp_instance_filter_list_cmd
,
8858 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
8862 BGP_INSTANCE_HELP_STR
8863 "Display routes conforming to the filter-list\n"
8864 "Regular expression access list name\n")
8866 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
8867 bgp_show_type_filter_list
);
8870 DEFUN (show_ip_bgp_flap_filter_list
,
8871 show_ip_bgp_flap_filter_list_cmd
,
8872 "show ip bgp flap-statistics filter-list WORD",
8876 "Display flap statistics of routes\n"
8877 "Display routes conforming to the filter-list\n"
8878 "Regular expression access list name\n")
8880 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8881 bgp_show_type_flap_filter_list
);
8884 DEFUN (show_ip_bgp_ipv4_filter_list
,
8885 show_ip_bgp_ipv4_filter_list_cmd
,
8886 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
8891 "Address Family modifier\n"
8892 "Address Family modifier\n"
8893 "Display routes conforming to the filter-list\n"
8894 "Regular expression access list name\n")
8896 if (strncmp (argv
[0], "m", 1) == 0)
8897 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8898 bgp_show_type_filter_list
);
8900 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8901 bgp_show_type_filter_list
);
8905 DEFUN (show_bgp_filter_list
,
8906 show_bgp_filter_list_cmd
,
8907 "show bgp filter-list WORD",
8910 "Display routes conforming to the filter-list\n"
8911 "Regular expression access list name\n")
8913 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8914 bgp_show_type_filter_list
);
8917 ALIAS (show_bgp_filter_list
,
8918 show_bgp_ipv6_filter_list_cmd
,
8919 "show bgp ipv6 filter-list WORD",
8923 "Display routes conforming to the filter-list\n"
8924 "Regular expression access list name\n")
8927 DEFUN (show_ipv6_bgp_filter_list
,
8928 show_ipv6_bgp_filter_list_cmd
,
8929 "show ipv6 bgp filter-list WORD",
8933 "Display routes conforming to the filter-list\n"
8934 "Regular expression access list name\n")
8936 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8937 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8938 bgp_show_type_filter_list
);
8942 DEFUN (show_ipv6_mbgp_filter_list
,
8943 show_ipv6_mbgp_filter_list_cmd
,
8944 "show ipv6 mbgp filter-list WORD",
8948 "Display routes conforming to the filter-list\n"
8949 "Regular expression access list name\n")
8951 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8952 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8953 bgp_show_type_filter_list
);
8955 #endif /* HAVE_IPV6 */
8958 bgp_show_route_map (struct vty
*vty
, const char *name
,
8959 const char *rmap_str
, afi_t afi
,
8960 safi_t safi
, enum bgp_show_type type
)
8962 struct route_map
*rmap
;
8963 struct bgp
*bgp
= NULL
;
8965 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
8967 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
8971 rmap
= route_map_lookup_by_name (rmap_str
);
8974 vty_out (vty
, "%% %s is not a valid route-map name%s",
8975 rmap_str
, VTY_NEWLINE
);
8979 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
8982 DEFUN (show_ip_bgp_route_map
,
8983 show_ip_bgp_route_map_cmd
,
8984 "show ip bgp route-map WORD",
8988 "Display routes matching the route-map\n"
8989 "A route-map to match on\n")
8991 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8992 bgp_show_type_route_map
);
8995 DEFUN (show_ip_bgp_instance_route_map
,
8996 show_ip_bgp_instance_route_map_cmd
,
8997 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9001 BGP_INSTANCE_HELP_STR
9002 "Display routes matching the route-map\n"
9003 "A route-map to match on\n")
9005 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9006 bgp_show_type_route_map
);
9009 DEFUN (show_ip_bgp_flap_route_map
,
9010 show_ip_bgp_flap_route_map_cmd
,
9011 "show ip bgp flap-statistics route-map WORD",
9015 "Display flap statistics of routes\n"
9016 "Display routes matching the route-map\n"
9017 "A route-map to match on\n")
9019 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9020 bgp_show_type_flap_route_map
);
9023 DEFUN (show_ip_bgp_ipv4_route_map
,
9024 show_ip_bgp_ipv4_route_map_cmd
,
9025 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9030 "Address Family modifier\n"
9031 "Address Family modifier\n"
9032 "Display routes matching the route-map\n"
9033 "A route-map to match on\n")
9035 if (strncmp (argv
[0], "m", 1) == 0)
9036 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9037 bgp_show_type_route_map
);
9039 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9040 bgp_show_type_route_map
);
9043 DEFUN (show_bgp_route_map
,
9044 show_bgp_route_map_cmd
,
9045 "show bgp route-map WORD",
9048 "Display routes matching the route-map\n"
9049 "A route-map to match on\n")
9051 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9052 bgp_show_type_route_map
);
9055 ALIAS (show_bgp_route_map
,
9056 show_bgp_ipv6_route_map_cmd
,
9057 "show bgp ipv6 route-map WORD",
9061 "Display routes matching the route-map\n"
9062 "A route-map to match on\n")
9064 DEFUN (show_ip_bgp_cidr_only
,
9065 show_ip_bgp_cidr_only_cmd
,
9066 "show ip bgp cidr-only",
9070 "Display only routes with non-natural netmasks\n")
9072 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9073 bgp_show_type_cidr_only
, NULL
, 0);
9076 DEFUN (show_ip_bgp_flap_cidr_only
,
9077 show_ip_bgp_flap_cidr_only_cmd
,
9078 "show ip bgp flap-statistics cidr-only",
9082 "Display flap statistics of routes\n"
9083 "Display only routes with non-natural netmasks\n")
9085 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9086 bgp_show_type_flap_cidr_only
, NULL
, 0);
9089 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9090 show_ip_bgp_ipv4_cidr_only_cmd
,
9091 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9096 "Address Family modifier\n"
9097 "Address Family modifier\n"
9098 "Display only routes with non-natural netmasks\n")
9100 if (strncmp (argv
[0], "m", 1) == 0)
9101 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9102 bgp_show_type_cidr_only
, NULL
, 0);
9104 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9105 bgp_show_type_cidr_only
, NULL
, 0);
9108 DEFUN (show_ip_bgp_community_all
,
9109 show_ip_bgp_community_all_cmd
,
9110 "show ip bgp community",
9114 "Display routes matching the communities\n")
9116 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9117 bgp_show_type_community_all
, NULL
, 0);
9120 DEFUN (show_ip_bgp_ipv4_community_all
,
9121 show_ip_bgp_ipv4_community_all_cmd
,
9122 "show ip bgp ipv4 (unicast|multicast) community",
9127 "Address Family modifier\n"
9128 "Address Family modifier\n"
9129 "Display routes matching the communities\n")
9131 if (strncmp (argv
[0], "m", 1) == 0)
9132 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9133 bgp_show_type_community_all
, NULL
, 0);
9135 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9136 bgp_show_type_community_all
, NULL
, 0);
9140 DEFUN (show_bgp_community_all
,
9141 show_bgp_community_all_cmd
,
9142 "show bgp community",
9145 "Display routes matching the communities\n")
9147 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9148 bgp_show_type_community_all
, NULL
, 0);
9151 ALIAS (show_bgp_community_all
,
9152 show_bgp_ipv6_community_all_cmd
,
9153 "show bgp ipv6 community",
9157 "Display routes matching the communities\n")
9160 DEFUN (show_ipv6_bgp_community_all
,
9161 show_ipv6_bgp_community_all_cmd
,
9162 "show ipv6 bgp community",
9166 "Display routes matching the communities\n")
9168 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9169 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9170 bgp_show_type_community_all
, NULL
, 0);
9174 DEFUN (show_ipv6_mbgp_community_all
,
9175 show_ipv6_mbgp_community_all_cmd
,
9176 "show ipv6 mbgp community",
9180 "Display routes matching the communities\n")
9182 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9183 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9184 bgp_show_type_community_all
, NULL
, 0);
9186 #endif /* HAVE_IPV6 */
9189 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9190 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9192 struct community
*com
;
9199 /* BGP structure lookup */
9202 bgp
= bgp_lookup_by_name (view_name
);
9205 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
9211 bgp
= bgp_get_default ();
9214 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9219 b
= buffer_new (1024);
9220 for (i
= 0; i
< argc
; i
++)
9223 buffer_putc (b
, ' ');
9226 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9231 buffer_putstr (b
, argv
[i
]);
9233 buffer_putc (b
, '\0');
9235 str
= buffer_getstr (b
);
9238 com
= community_str2com (str
);
9239 XFREE (MTYPE_TMP
, str
);
9242 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
9246 return bgp_show (vty
, bgp
, afi
, safi
,
9247 (exact
? bgp_show_type_community_exact
:
9248 bgp_show_type_community
), com
, 0);
9251 DEFUN (show_ip_bgp_community
,
9252 show_ip_bgp_community_cmd
,
9253 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9257 "Display routes matching the communities\n"
9258 "community number\n"
9259 "Do not send outside local AS (well-known community)\n"
9260 "Do not advertise to any peer (well-known community)\n"
9261 "Do not export to next AS (well-known community)\n")
9263 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9266 ALIAS (show_ip_bgp_community
,
9267 show_ip_bgp_community2_cmd
,
9268 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9272 "Display routes matching the communities\n"
9273 "community number\n"
9274 "Do not send outside local AS (well-known community)\n"
9275 "Do not advertise to any peer (well-known community)\n"
9276 "Do not export to next AS (well-known community)\n"
9277 "community number\n"
9278 "Do not send outside local AS (well-known community)\n"
9279 "Do not advertise to any peer (well-known community)\n"
9280 "Do not export to next AS (well-known community)\n")
9282 ALIAS (show_ip_bgp_community
,
9283 show_ip_bgp_community3_cmd
,
9284 "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)",
9288 "Display routes matching the communities\n"
9289 "community number\n"
9290 "Do not send outside local AS (well-known community)\n"
9291 "Do not advertise to any peer (well-known community)\n"
9292 "Do not export to next AS (well-known community)\n"
9293 "community number\n"
9294 "Do not send outside local AS (well-known community)\n"
9295 "Do not advertise to any peer (well-known community)\n"
9296 "Do not export to next AS (well-known community)\n"
9297 "community number\n"
9298 "Do not send outside local AS (well-known community)\n"
9299 "Do not advertise to any peer (well-known community)\n"
9300 "Do not export to next AS (well-known community)\n")
9302 ALIAS (show_ip_bgp_community
,
9303 show_ip_bgp_community4_cmd
,
9304 "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)",
9308 "Display routes matching the communities\n"
9309 "community number\n"
9310 "Do not send outside local AS (well-known community)\n"
9311 "Do not advertise to any peer (well-known community)\n"
9312 "Do not export to next AS (well-known community)\n"
9313 "community number\n"
9314 "Do not send outside local AS (well-known community)\n"
9315 "Do not advertise to any peer (well-known community)\n"
9316 "Do not export to next AS (well-known community)\n"
9317 "community number\n"
9318 "Do not send outside local AS (well-known community)\n"
9319 "Do not advertise to any peer (well-known community)\n"
9320 "Do not export to next AS (well-known community)\n"
9321 "community number\n"
9322 "Do not send outside local AS (well-known community)\n"
9323 "Do not advertise to any peer (well-known community)\n"
9324 "Do not export to next AS (well-known community)\n")
9326 DEFUN (show_ip_bgp_ipv4_community
,
9327 show_ip_bgp_ipv4_community_cmd
,
9328 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9333 "Address Family modifier\n"
9334 "Address Family modifier\n"
9335 "Display routes matching the communities\n"
9336 "community number\n"
9337 "Do not send outside local AS (well-known community)\n"
9338 "Do not advertise to any peer (well-known community)\n"
9339 "Do not export to next AS (well-known community)\n")
9341 if (strncmp (argv
[0], "m", 1) == 0)
9342 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
9344 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9347 ALIAS (show_ip_bgp_ipv4_community
,
9348 show_ip_bgp_ipv4_community2_cmd
,
9349 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9354 "Address Family modifier\n"
9355 "Address Family modifier\n"
9356 "Display routes matching the communities\n"
9357 "community number\n"
9358 "Do not send outside local AS (well-known community)\n"
9359 "Do not advertise to any peer (well-known community)\n"
9360 "Do not export to next AS (well-known community)\n"
9361 "community number\n"
9362 "Do not send outside local AS (well-known community)\n"
9363 "Do not advertise to any peer (well-known community)\n"
9364 "Do not export to next AS (well-known community)\n")
9366 ALIAS (show_ip_bgp_ipv4_community
,
9367 show_ip_bgp_ipv4_community3_cmd
,
9368 "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)",
9373 "Address Family modifier\n"
9374 "Address Family modifier\n"
9375 "Display routes matching the communities\n"
9376 "community number\n"
9377 "Do not send outside local AS (well-known community)\n"
9378 "Do not advertise to any peer (well-known community)\n"
9379 "Do not export to next AS (well-known community)\n"
9380 "community number\n"
9381 "Do not send outside local AS (well-known community)\n"
9382 "Do not advertise to any peer (well-known community)\n"
9383 "Do not export to next AS (well-known community)\n"
9384 "community number\n"
9385 "Do not send outside local AS (well-known community)\n"
9386 "Do not advertise to any peer (well-known community)\n"
9387 "Do not export to next AS (well-known community)\n")
9389 ALIAS (show_ip_bgp_ipv4_community
,
9390 show_ip_bgp_ipv4_community4_cmd
,
9391 "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)",
9396 "Address Family modifier\n"
9397 "Address Family modifier\n"
9398 "Display routes matching the communities\n"
9399 "community number\n"
9400 "Do not send outside local AS (well-known community)\n"
9401 "Do not advertise to any peer (well-known community)\n"
9402 "Do not export to next AS (well-known community)\n"
9403 "community number\n"
9404 "Do not send outside local AS (well-known community)\n"
9405 "Do not advertise to any peer (well-known community)\n"
9406 "Do not export to next AS (well-known community)\n"
9407 "community number\n"
9408 "Do not send outside local AS (well-known community)\n"
9409 "Do not advertise to any peer (well-known community)\n"
9410 "Do not export to next AS (well-known community)\n"
9411 "community number\n"
9412 "Do not send outside local AS (well-known community)\n"
9413 "Do not advertise to any peer (well-known community)\n"
9414 "Do not export to next AS (well-known community)\n")
9416 DEFUN (show_bgp_instance_afi_safi_community_all
,
9417 show_bgp_instance_afi_safi_community_all_cmd
,
9419 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
9421 "show bgp " BGP_INSTANCE_CMD
" ipv4 (unicast|multicast) community",
9425 BGP_INSTANCE_HELP_STR
9430 "Address Family modifier\n"
9431 "Address Family modifier\n"
9432 "Display routes matching the communities\n")
9438 /* BGP structure lookup. */
9439 bgp
= bgp_lookup_by_name (argv
[1]);
9442 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
9447 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9448 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9451 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9453 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
9456 DEFUN (show_bgp_instance_afi_safi_community
,
9457 show_bgp_instance_afi_safi_community_cmd
,
9459 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9461 "show bgp " BGP_INSTANCE_CMD
" ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9465 BGP_INSTANCE_HELP_STR
9470 "Address family modifier\n"
9471 "Address family modifier\n"
9472 "Display routes matching the communities\n"
9473 "community number\n"
9474 "Do not send outside local AS (well-known community)\n"
9475 "Do not advertise to any peer (well-known community)\n"
9476 "Do not export to next AS (well-known community)\n")
9482 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9483 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9484 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
9487 safi
= (strncmp (argv
[2], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9488 return bgp_show_community (vty
, argv
[1], argc
-3, &argv
[3], 0, afi
, safi
);
9492 ALIAS (show_bgp_instance_afi_safi_community
,
9493 show_bgp_instance_afi_safi_community2_cmd
,
9495 "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)",
9497 "show bgp " BGP_INSTANCE_CMD
" ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9501 BGP_INSTANCE_HELP_STR
9506 "Address family modifier\n"
9507 "Address family modifier\n"
9508 "Display routes matching the communities\n"
9509 "community number\n"
9510 "Do not send outside local AS (well-known community)\n"
9511 "Do not advertise to any peer (well-known community)\n"
9512 "Do not export to next AS (well-known community)\n"
9513 "community number\n"
9514 "Do not send outside local AS (well-known community)\n"
9515 "Do not advertise to any peer (well-known community)\n"
9516 "Do not export to next AS (well-known community)\n")
9518 ALIAS (show_bgp_instance_afi_safi_community
,
9519 show_bgp_instance_afi_safi_community3_cmd
,
9521 "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)",
9523 "show bgp " BGP_INSTANCE_CMD
" 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)",
9527 BGP_INSTANCE_HELP_STR
9532 "Address family modifier\n"
9533 "Address family modifier\n"
9534 "Display routes matching the communities\n"
9535 "community number\n"
9536 "Do not send outside local AS (well-known community)\n"
9537 "Do not advertise to any peer (well-known community)\n"
9538 "Do not export to next AS (well-known community)\n"
9539 "community number\n"
9540 "Do not send outside local AS (well-known community)\n"
9541 "Do not advertise to any peer (well-known community)\n"
9542 "Do not export to next AS (well-known community)\n"
9543 "community number\n"
9544 "Do not send outside local AS (well-known community)\n"
9545 "Do not advertise to any peer (well-known community)\n"
9546 "Do not export to next AS (well-known community)\n")
9548 ALIAS (show_bgp_instance_afi_safi_community
,
9549 show_bgp_instance_afi_safi_community4_cmd
,
9551 "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)",
9553 "show bgp " BGP_INSTANCE_CMD
" 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)",
9557 BGP_INSTANCE_HELP_STR
9562 "Address family modifier\n"
9563 "Address family modifier\n"
9564 "Display routes matching the communities\n"
9565 "community number\n"
9566 "Do not send outside local AS (well-known community)\n"
9567 "Do not advertise to any peer (well-known community)\n"
9568 "Do not export to next AS (well-known community)\n"
9569 "community number\n"
9570 "Do not send outside local AS (well-known community)\n"
9571 "Do not advertise to any peer (well-known community)\n"
9572 "Do not export to next AS (well-known community)\n"
9573 "community number\n"
9574 "Do not send outside local AS (well-known community)\n"
9575 "Do not advertise to any peer (well-known community)\n"
9576 "Do not export to next AS (well-known community)\n"
9577 "community number\n"
9578 "Do not send outside local AS (well-known community)\n"
9579 "Do not advertise to any peer (well-known community)\n"
9580 "Do not export to next AS (well-known community)\n")
9582 DEFUN (show_ip_bgp_community_exact
,
9583 show_ip_bgp_community_exact_cmd
,
9584 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9588 "Display routes matching the communities\n"
9589 "community number\n"
9590 "Do not send outside local AS (well-known community)\n"
9591 "Do not advertise to any peer (well-known community)\n"
9592 "Do not export to next AS (well-known community)\n"
9593 "Exact match of the communities")
9595 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
9598 ALIAS (show_ip_bgp_community_exact
,
9599 show_ip_bgp_community2_exact_cmd
,
9600 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9604 "Display routes matching the communities\n"
9605 "community number\n"
9606 "Do not send outside local AS (well-known community)\n"
9607 "Do not advertise to any peer (well-known community)\n"
9608 "Do not export to next AS (well-known community)\n"
9609 "community number\n"
9610 "Do not send outside local AS (well-known community)\n"
9611 "Do not advertise to any peer (well-known community)\n"
9612 "Do not export to next AS (well-known community)\n"
9613 "Exact match of the communities")
9615 ALIAS (show_ip_bgp_community_exact
,
9616 show_ip_bgp_community3_exact_cmd
,
9617 "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",
9621 "Display routes matching the communities\n"
9622 "community number\n"
9623 "Do not send outside local AS (well-known community)\n"
9624 "Do not advertise to any peer (well-known community)\n"
9625 "Do not export to next AS (well-known community)\n"
9626 "community number\n"
9627 "Do not send outside local AS (well-known community)\n"
9628 "Do not advertise to any peer (well-known community)\n"
9629 "Do not export to next AS (well-known community)\n"
9630 "community number\n"
9631 "Do not send outside local AS (well-known community)\n"
9632 "Do not advertise to any peer (well-known community)\n"
9633 "Do not export to next AS (well-known community)\n"
9634 "Exact match of the communities")
9636 ALIAS (show_ip_bgp_community_exact
,
9637 show_ip_bgp_community4_exact_cmd
,
9638 "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",
9642 "Display routes matching the communities\n"
9643 "community number\n"
9644 "Do not send outside local AS (well-known community)\n"
9645 "Do not advertise to any peer (well-known community)\n"
9646 "Do not export to next AS (well-known community)\n"
9647 "community number\n"
9648 "Do not send outside local AS (well-known community)\n"
9649 "Do not advertise to any peer (well-known community)\n"
9650 "Do not export to next AS (well-known community)\n"
9651 "community number\n"
9652 "Do not send outside local AS (well-known community)\n"
9653 "Do not advertise to any peer (well-known community)\n"
9654 "Do not export to next AS (well-known community)\n"
9655 "community number\n"
9656 "Do not send outside local AS (well-known community)\n"
9657 "Do not advertise to any peer (well-known community)\n"
9658 "Do not export to next AS (well-known community)\n"
9659 "Exact match of the communities")
9661 DEFUN (show_ip_bgp_ipv4_community_exact
,
9662 show_ip_bgp_ipv4_community_exact_cmd
,
9663 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9668 "Address Family modifier\n"
9669 "Address Family modifier\n"
9670 "Display routes matching the communities\n"
9671 "community number\n"
9672 "Do not send outside local AS (well-known community)\n"
9673 "Do not advertise to any peer (well-known community)\n"
9674 "Do not export to next AS (well-known community)\n"
9675 "Exact match of the communities")
9677 if (strncmp (argv
[0], "m", 1) == 0)
9678 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
9680 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
9683 ALIAS (show_ip_bgp_ipv4_community_exact
,
9684 show_ip_bgp_ipv4_community2_exact_cmd
,
9685 "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",
9690 "Address Family modifier\n"
9691 "Address Family modifier\n"
9692 "Display routes matching the communities\n"
9693 "community number\n"
9694 "Do not send outside local AS (well-known community)\n"
9695 "Do not advertise to any peer (well-known community)\n"
9696 "Do not export to next AS (well-known community)\n"
9697 "community number\n"
9698 "Do not send outside local AS (well-known community)\n"
9699 "Do not advertise to any peer (well-known community)\n"
9700 "Do not export to next AS (well-known community)\n"
9701 "Exact match of the communities")
9703 ALIAS (show_ip_bgp_ipv4_community_exact
,
9704 show_ip_bgp_ipv4_community3_exact_cmd
,
9705 "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",
9710 "Address Family modifier\n"
9711 "Address Family modifier\n"
9712 "Display routes matching the communities\n"
9713 "community number\n"
9714 "Do not send outside local AS (well-known community)\n"
9715 "Do not advertise to any peer (well-known community)\n"
9716 "Do not export to next AS (well-known community)\n"
9717 "community number\n"
9718 "Do not send outside local AS (well-known community)\n"
9719 "Do not advertise to any peer (well-known community)\n"
9720 "Do not export to next AS (well-known community)\n"
9721 "community number\n"
9722 "Do not send outside local AS (well-known community)\n"
9723 "Do not advertise to any peer (well-known community)\n"
9724 "Do not export to next AS (well-known community)\n"
9725 "Exact match of the communities")
9727 ALIAS (show_ip_bgp_ipv4_community_exact
,
9728 show_ip_bgp_ipv4_community4_exact_cmd
,
9729 "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",
9734 "Address Family modifier\n"
9735 "Address Family modifier\n"
9736 "Display routes matching the communities\n"
9737 "community number\n"
9738 "Do not send outside local AS (well-known community)\n"
9739 "Do not advertise to any peer (well-known community)\n"
9740 "Do not export to next AS (well-known community)\n"
9741 "community number\n"
9742 "Do not send outside local AS (well-known community)\n"
9743 "Do not advertise to any peer (well-known community)\n"
9744 "Do not export to next AS (well-known community)\n"
9745 "community number\n"
9746 "Do not send outside local AS (well-known community)\n"
9747 "Do not advertise to any peer (well-known community)\n"
9748 "Do not export to next AS (well-known community)\n"
9749 "community number\n"
9750 "Do not send outside local AS (well-known community)\n"
9751 "Do not advertise to any peer (well-known community)\n"
9752 "Do not export to next AS (well-known community)\n"
9753 "Exact match of the communities")
9756 DEFUN (show_bgp_community
,
9757 show_bgp_community_cmd
,
9758 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9761 "Display routes matching the communities\n"
9762 "community number\n"
9763 "Do not send outside local AS (well-known community)\n"
9764 "Do not advertise to any peer (well-known community)\n"
9765 "Do not export to next AS (well-known community)\n")
9767 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
9770 ALIAS (show_bgp_community
,
9771 show_bgp_ipv6_community_cmd
,
9772 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9776 "Display routes matching the communities\n"
9777 "community number\n"
9778 "Do not send outside local AS (well-known community)\n"
9779 "Do not advertise to any peer (well-known community)\n"
9780 "Do not export to next AS (well-known community)\n")
9782 ALIAS (show_bgp_community
,
9783 show_bgp_community2_cmd
,
9784 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9787 "Display routes matching the communities\n"
9788 "community number\n"
9789 "Do not send outside local AS (well-known community)\n"
9790 "Do not advertise to any peer (well-known community)\n"
9791 "Do not export to next AS (well-known community)\n"
9792 "community number\n"
9793 "Do not send outside local AS (well-known community)\n"
9794 "Do not advertise to any peer (well-known community)\n"
9795 "Do not export to next AS (well-known community)\n")
9797 ALIAS (show_bgp_community
,
9798 show_bgp_ipv6_community2_cmd
,
9799 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9803 "Display routes matching the communities\n"
9804 "community number\n"
9805 "Do not send outside local AS (well-known community)\n"
9806 "Do not advertise to any peer (well-known community)\n"
9807 "Do not export to next AS (well-known community)\n"
9808 "community number\n"
9809 "Do not send outside local AS (well-known community)\n"
9810 "Do not advertise to any peer (well-known community)\n"
9811 "Do not export to next AS (well-known community)\n")
9813 ALIAS (show_bgp_community
,
9814 show_bgp_community3_cmd
,
9815 "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)",
9818 "Display routes matching the communities\n"
9819 "community number\n"
9820 "Do not send outside local AS (well-known community)\n"
9821 "Do not advertise to any peer (well-known community)\n"
9822 "Do not export to next AS (well-known community)\n"
9823 "community number\n"
9824 "Do not send outside local AS (well-known community)\n"
9825 "Do not advertise to any peer (well-known community)\n"
9826 "Do not export to next AS (well-known community)\n"
9827 "community number\n"
9828 "Do not send outside local AS (well-known community)\n"
9829 "Do not advertise to any peer (well-known community)\n"
9830 "Do not export to next AS (well-known community)\n")
9832 ALIAS (show_bgp_community
,
9833 show_bgp_ipv6_community3_cmd
,
9834 "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)",
9838 "Display routes matching the communities\n"
9839 "community number\n"
9840 "Do not send outside local AS (well-known community)\n"
9841 "Do not advertise to any peer (well-known community)\n"
9842 "Do not export to next AS (well-known community)\n"
9843 "community number\n"
9844 "Do not send outside local AS (well-known community)\n"
9845 "Do not advertise to any peer (well-known community)\n"
9846 "Do not export to next AS (well-known community)\n"
9847 "community number\n"
9848 "Do not send outside local AS (well-known community)\n"
9849 "Do not advertise to any peer (well-known community)\n"
9850 "Do not export to next AS (well-known community)\n")
9852 ALIAS (show_bgp_community
,
9853 show_bgp_community4_cmd
,
9854 "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)",
9857 "Display routes matching the communities\n"
9858 "community number\n"
9859 "Do not send outside local AS (well-known community)\n"
9860 "Do not advertise to any peer (well-known community)\n"
9861 "Do not export to next AS (well-known community)\n"
9862 "community number\n"
9863 "Do not send outside local AS (well-known community)\n"
9864 "Do not advertise to any peer (well-known community)\n"
9865 "Do not export to next AS (well-known community)\n"
9866 "community number\n"
9867 "Do not send outside local AS (well-known community)\n"
9868 "Do not advertise to any peer (well-known community)\n"
9869 "Do not export to next AS (well-known community)\n"
9870 "community number\n"
9871 "Do not send outside local AS (well-known community)\n"
9872 "Do not advertise to any peer (well-known community)\n"
9873 "Do not export to next AS (well-known community)\n")
9875 ALIAS (show_bgp_community
,
9876 show_bgp_ipv6_community4_cmd
,
9877 "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)",
9881 "Display routes matching the communities\n"
9882 "community number\n"
9883 "Do not send outside local AS (well-known community)\n"
9884 "Do not advertise to any peer (well-known community)\n"
9885 "Do not export to next AS (well-known community)\n"
9886 "community number\n"
9887 "Do not send outside local AS (well-known community)\n"
9888 "Do not advertise to any peer (well-known community)\n"
9889 "Do not export to next AS (well-known community)\n"
9890 "community number\n"
9891 "Do not send outside local AS (well-known community)\n"
9892 "Do not advertise to any peer (well-known community)\n"
9893 "Do not export to next AS (well-known community)\n"
9894 "community number\n"
9895 "Do not send outside local AS (well-known community)\n"
9896 "Do not advertise to any peer (well-known community)\n"
9897 "Do not export to next AS (well-known community)\n")
9900 DEFUN (show_ipv6_bgp_community
,
9901 show_ipv6_bgp_community_cmd
,
9902 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
9906 "Display routes matching the communities\n"
9907 "community number\n"
9908 "Do not send outside local AS (well-known community)\n"
9909 "Do not advertise to any peer (well-known community)\n"
9910 "Do not export to next AS (well-known community)\n")
9912 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9913 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
9917 ALIAS (show_ipv6_bgp_community
,
9918 show_ipv6_bgp_community2_cmd
,
9919 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9923 "Display routes matching the communities\n"
9924 "community number\n"
9925 "Do not send outside local AS (well-known community)\n"
9926 "Do not advertise to any peer (well-known community)\n"
9927 "Do not export to next AS (well-known community)\n"
9928 "community number\n"
9929 "Do not send outside local AS (well-known community)\n"
9930 "Do not advertise to any peer (well-known community)\n"
9931 "Do not export to next AS (well-known community)\n")
9934 ALIAS (show_ipv6_bgp_community
,
9935 show_ipv6_bgp_community3_cmd
,
9936 "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)",
9940 "Display routes matching the communities\n"
9941 "community number\n"
9942 "Do not send outside local AS (well-known community)\n"
9943 "Do not advertise to any peer (well-known community)\n"
9944 "Do not export to next AS (well-known community)\n"
9945 "community number\n"
9946 "Do not send outside local AS (well-known community)\n"
9947 "Do not advertise to any peer (well-known community)\n"
9948 "Do not export to next AS (well-known community)\n"
9949 "community number\n"
9950 "Do not send outside local AS (well-known community)\n"
9951 "Do not advertise to any peer (well-known community)\n"
9952 "Do not export to next AS (well-known community)\n")
9955 ALIAS (show_ipv6_bgp_community
,
9956 show_ipv6_bgp_community4_cmd
,
9957 "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)",
9961 "Display routes matching the communities\n"
9962 "community number\n"
9963 "Do not send outside local AS (well-known community)\n"
9964 "Do not advertise to any peer (well-known community)\n"
9965 "Do not export to next AS (well-known community)\n"
9966 "community number\n"
9967 "Do not send outside local AS (well-known community)\n"
9968 "Do not advertise to any peer (well-known community)\n"
9969 "Do not export to next AS (well-known community)\n"
9970 "community number\n"
9971 "Do not send outside local AS (well-known community)\n"
9972 "Do not advertise to any peer (well-known community)\n"
9973 "Do not export to next AS (well-known community)\n"
9974 "community number\n"
9975 "Do not send outside local AS (well-known community)\n"
9976 "Do not advertise to any peer (well-known community)\n"
9977 "Do not export to next AS (well-known community)\n")
9979 DEFUN (show_bgp_community_exact
,
9980 show_bgp_community_exact_cmd
,
9981 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9984 "Display routes matching the communities\n"
9985 "community number\n"
9986 "Do not send outside local AS (well-known community)\n"
9987 "Do not advertise to any peer (well-known community)\n"
9988 "Do not export to next AS (well-known community)\n"
9989 "Exact match of the communities")
9991 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
9994 ALIAS (show_bgp_community_exact
,
9995 show_bgp_ipv6_community_exact_cmd
,
9996 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10000 "Display routes matching the communities\n"
10001 "community number\n"
10002 "Do not send outside local AS (well-known community)\n"
10003 "Do not advertise to any peer (well-known community)\n"
10004 "Do not export to next AS (well-known community)\n"
10005 "Exact match of the communities")
10007 ALIAS (show_bgp_community_exact
,
10008 show_bgp_community2_exact_cmd
,
10009 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10012 "Display routes matching the communities\n"
10013 "community number\n"
10014 "Do not send outside local AS (well-known community)\n"
10015 "Do not advertise to any peer (well-known community)\n"
10016 "Do not export to next AS (well-known community)\n"
10017 "community number\n"
10018 "Do not send outside local AS (well-known community)\n"
10019 "Do not advertise to any peer (well-known community)\n"
10020 "Do not export to next AS (well-known community)\n"
10021 "Exact match of the communities")
10023 ALIAS (show_bgp_community_exact
,
10024 show_bgp_ipv6_community2_exact_cmd
,
10025 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10029 "Display routes matching the communities\n"
10030 "community number\n"
10031 "Do not send outside local AS (well-known community)\n"
10032 "Do not advertise to any peer (well-known community)\n"
10033 "Do not export to next AS (well-known community)\n"
10034 "community number\n"
10035 "Do not send outside local AS (well-known community)\n"
10036 "Do not advertise to any peer (well-known community)\n"
10037 "Do not export to next AS (well-known community)\n"
10038 "Exact match of the communities")
10040 ALIAS (show_bgp_community_exact
,
10041 show_bgp_community3_exact_cmd
,
10042 "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",
10045 "Display routes matching the communities\n"
10046 "community number\n"
10047 "Do not send outside local AS (well-known community)\n"
10048 "Do not advertise to any peer (well-known community)\n"
10049 "Do not export to next AS (well-known community)\n"
10050 "community number\n"
10051 "Do not send outside local AS (well-known community)\n"
10052 "Do not advertise to any peer (well-known community)\n"
10053 "Do not export to next AS (well-known community)\n"
10054 "community number\n"
10055 "Do not send outside local AS (well-known community)\n"
10056 "Do not advertise to any peer (well-known community)\n"
10057 "Do not export to next AS (well-known community)\n"
10058 "Exact match of the communities")
10060 ALIAS (show_bgp_community_exact
,
10061 show_bgp_ipv6_community3_exact_cmd
,
10062 "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",
10066 "Display routes matching the communities\n"
10067 "community number\n"
10068 "Do not send outside local AS (well-known community)\n"
10069 "Do not advertise to any peer (well-known community)\n"
10070 "Do not export to next AS (well-known community)\n"
10071 "community number\n"
10072 "Do not send outside local AS (well-known community)\n"
10073 "Do not advertise to any peer (well-known community)\n"
10074 "Do not export to next AS (well-known community)\n"
10075 "community number\n"
10076 "Do not send outside local AS (well-known community)\n"
10077 "Do not advertise to any peer (well-known community)\n"
10078 "Do not export to next AS (well-known community)\n"
10079 "Exact match of the communities")
10081 ALIAS (show_bgp_community_exact
,
10082 show_bgp_community4_exact_cmd
,
10083 "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",
10086 "Display routes matching the communities\n"
10087 "community number\n"
10088 "Do not send outside local AS (well-known community)\n"
10089 "Do not advertise to any peer (well-known community)\n"
10090 "Do not export to next AS (well-known community)\n"
10091 "community number\n"
10092 "Do not send outside local AS (well-known community)\n"
10093 "Do not advertise to any peer (well-known community)\n"
10094 "Do not export to next AS (well-known community)\n"
10095 "community number\n"
10096 "Do not send outside local AS (well-known community)\n"
10097 "Do not advertise to any peer (well-known community)\n"
10098 "Do not export to next AS (well-known community)\n"
10099 "community number\n"
10100 "Do not send outside local AS (well-known community)\n"
10101 "Do not advertise to any peer (well-known community)\n"
10102 "Do not export to next AS (well-known community)\n"
10103 "Exact match of the communities")
10105 ALIAS (show_bgp_community_exact
,
10106 show_bgp_ipv6_community4_exact_cmd
,
10107 "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",
10111 "Display routes matching the communities\n"
10112 "community number\n"
10113 "Do not send outside local AS (well-known community)\n"
10114 "Do not advertise to any peer (well-known community)\n"
10115 "Do not export to next AS (well-known community)\n"
10116 "community number\n"
10117 "Do not send outside local AS (well-known community)\n"
10118 "Do not advertise to any peer (well-known community)\n"
10119 "Do not export to next AS (well-known community)\n"
10120 "community number\n"
10121 "Do not send outside local AS (well-known community)\n"
10122 "Do not advertise to any peer (well-known community)\n"
10123 "Do not export to next AS (well-known community)\n"
10124 "community number\n"
10125 "Do not send outside local AS (well-known community)\n"
10126 "Do not advertise to any peer (well-known community)\n"
10127 "Do not export to next AS (well-known community)\n"
10128 "Exact match of the communities")
10131 DEFUN (show_ipv6_bgp_community_exact
,
10132 show_ipv6_bgp_community_exact_cmd
,
10133 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10137 "Display routes matching the communities\n"
10138 "community number\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"
10142 "Exact match of the communities")
10144 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10145 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10149 ALIAS (show_ipv6_bgp_community_exact
,
10150 show_ipv6_bgp_community2_exact_cmd
,
10151 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10155 "Display routes matching the communities\n"
10156 "community number\n"
10157 "Do not send outside local AS (well-known community)\n"
10158 "Do not advertise to any peer (well-known community)\n"
10159 "Do not export to next AS (well-known community)\n"
10160 "community number\n"
10161 "Do not send outside local AS (well-known community)\n"
10162 "Do not advertise to any peer (well-known community)\n"
10163 "Do not export to next AS (well-known community)\n"
10164 "Exact match of the communities")
10167 ALIAS (show_ipv6_bgp_community_exact
,
10168 show_ipv6_bgp_community3_exact_cmd
,
10169 "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",
10173 "Display routes matching the communities\n"
10174 "community number\n"
10175 "Do not send outside local AS (well-known community)\n"
10176 "Do not advertise to any peer (well-known community)\n"
10177 "Do not export to next AS (well-known community)\n"
10178 "community number\n"
10179 "Do not send outside local AS (well-known community)\n"
10180 "Do not advertise to any peer (well-known community)\n"
10181 "Do not export to next AS (well-known community)\n"
10182 "community number\n"
10183 "Do not send outside local AS (well-known community)\n"
10184 "Do not advertise to any peer (well-known community)\n"
10185 "Do not export to next AS (well-known community)\n"
10186 "Exact match of the communities")
10189 ALIAS (show_ipv6_bgp_community_exact
,
10190 show_ipv6_bgp_community4_exact_cmd
,
10191 "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",
10195 "Display routes matching the communities\n"
10196 "community number\n"
10197 "Do not send outside local AS (well-known community)\n"
10198 "Do not advertise to any peer (well-known community)\n"
10199 "Do not export to next AS (well-known community)\n"
10200 "community number\n"
10201 "Do not send outside local AS (well-known community)\n"
10202 "Do not advertise to any peer (well-known community)\n"
10203 "Do not export to next AS (well-known community)\n"
10204 "community number\n"
10205 "Do not send outside local AS (well-known community)\n"
10206 "Do not advertise to any peer (well-known community)\n"
10207 "Do not export to next AS (well-known community)\n"
10208 "community number\n"
10209 "Do not send outside local AS (well-known community)\n"
10210 "Do not advertise to any peer (well-known community)\n"
10211 "Do not export to next AS (well-known community)\n"
10212 "Exact match of the communities")
10215 DEFUN (show_ipv6_mbgp_community
,
10216 show_ipv6_mbgp_community_cmd
,
10217 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10221 "Display routes matching the communities\n"
10222 "community number\n"
10223 "Do not send outside local AS (well-known community)\n"
10224 "Do not advertise to any peer (well-known community)\n"
10225 "Do not export to next AS (well-known community)\n")
10227 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10228 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10232 ALIAS (show_ipv6_mbgp_community
,
10233 show_ipv6_mbgp_community2_cmd
,
10234 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10238 "Display routes matching the communities\n"
10239 "community number\n"
10240 "Do not send outside local AS (well-known community)\n"
10241 "Do not advertise to any peer (well-known community)\n"
10242 "Do not export to next AS (well-known community)\n"
10243 "community number\n"
10244 "Do not send outside local AS (well-known community)\n"
10245 "Do not advertise to any peer (well-known community)\n"
10246 "Do not export to next AS (well-known community)\n")
10249 ALIAS (show_ipv6_mbgp_community
,
10250 show_ipv6_mbgp_community3_cmd
,
10251 "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)",
10255 "Display routes matching the communities\n"
10256 "community number\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"
10260 "community number\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"
10264 "community number\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")
10270 ALIAS (show_ipv6_mbgp_community
,
10271 show_ipv6_mbgp_community4_cmd
,
10272 "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)",
10276 "Display routes matching the communities\n"
10277 "community number\n"
10278 "Do not send outside local AS (well-known community)\n"
10279 "Do not advertise to any peer (well-known community)\n"
10280 "Do not export to next AS (well-known community)\n"
10281 "community number\n"
10282 "Do not send outside local AS (well-known community)\n"
10283 "Do not advertise to any peer (well-known community)\n"
10284 "Do not export to next AS (well-known community)\n"
10285 "community number\n"
10286 "Do not send outside local AS (well-known community)\n"
10287 "Do not advertise to any peer (well-known community)\n"
10288 "Do not export to next AS (well-known community)\n"
10289 "community number\n"
10290 "Do not send outside local AS (well-known community)\n"
10291 "Do not advertise to any peer (well-known community)\n"
10292 "Do not export to next AS (well-known community)\n")
10295 DEFUN (show_ipv6_mbgp_community_exact
,
10296 show_ipv6_mbgp_community_exact_cmd
,
10297 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10301 "Display routes matching the communities\n"
10302 "community number\n"
10303 "Do not send outside local AS (well-known community)\n"
10304 "Do not advertise to any peer (well-known community)\n"
10305 "Do not export to next AS (well-known community)\n"
10306 "Exact match of the communities")
10308 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10309 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
10313 ALIAS (show_ipv6_mbgp_community_exact
,
10314 show_ipv6_mbgp_community2_exact_cmd
,
10315 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10319 "Display routes matching the communities\n"
10320 "community number\n"
10321 "Do not send outside local AS (well-known community)\n"
10322 "Do not advertise to any peer (well-known community)\n"
10323 "Do not export to next AS (well-known community)\n"
10324 "community number\n"
10325 "Do not send outside local AS (well-known community)\n"
10326 "Do not advertise to any peer (well-known community)\n"
10327 "Do not export to next AS (well-known community)\n"
10328 "Exact match of the communities")
10331 ALIAS (show_ipv6_mbgp_community_exact
,
10332 show_ipv6_mbgp_community3_exact_cmd
,
10333 "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",
10337 "Display routes matching the communities\n"
10338 "community number\n"
10339 "Do not send outside local AS (well-known community)\n"
10340 "Do not advertise to any peer (well-known community)\n"
10341 "Do not export to next AS (well-known community)\n"
10342 "community number\n"
10343 "Do not send outside local AS (well-known community)\n"
10344 "Do not advertise to any peer (well-known community)\n"
10345 "Do not export to next AS (well-known community)\n"
10346 "community number\n"
10347 "Do not send outside local AS (well-known community)\n"
10348 "Do not advertise to any peer (well-known community)\n"
10349 "Do not export to next AS (well-known community)\n"
10350 "Exact match of the communities")
10353 ALIAS (show_ipv6_mbgp_community_exact
,
10354 show_ipv6_mbgp_community4_exact_cmd
,
10355 "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",
10359 "Display routes matching the communities\n"
10360 "community number\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"
10364 "community number\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"
10368 "community number\n"
10369 "Do not send outside local AS (well-known community)\n"
10370 "Do not advertise to any peer (well-known community)\n"
10371 "Do not export to next AS (well-known community)\n"
10372 "community number\n"
10373 "Do not send outside local AS (well-known community)\n"
10374 "Do not advertise to any peer (well-known community)\n"
10375 "Do not export to next AS (well-known community)\n"
10376 "Exact match of the communities")
10377 #endif /* HAVE_IPV6 */
10380 bgp_show_community_list (struct vty
*vty
, const char *name
,
10381 const char *com
, int exact
,
10382 afi_t afi
, safi_t safi
)
10384 struct community_list
*list
;
10385 struct bgp
*bgp
= NULL
;
10387 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
10389 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
10390 return CMD_WARNING
;
10393 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
10396 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
10398 return CMD_WARNING
;
10401 return bgp_show (vty
, bgp
, afi
, safi
,
10402 (exact
? bgp_show_type_community_list_exact
:
10403 bgp_show_type_community_list
), list
, 0);
10406 DEFUN (show_ip_bgp_community_list
,
10407 show_ip_bgp_community_list_cmd
,
10408 "show ip bgp community-list (<1-500>|WORD)",
10412 "Display routes matching the community-list\n"
10413 "community-list number\n"
10414 "community-list name\n")
10416 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
10419 DEFUN (show_ip_bgp_instance_community_list
,
10420 show_ip_bgp_instance_community_list_cmd
,
10421 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
10425 BGP_INSTANCE_HELP_STR
10426 "Display routes matching the community-list\n"
10427 "community-list number\n"
10428 "community-list name\n")
10430 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
10433 DEFUN (show_ip_bgp_ipv4_community_list
,
10434 show_ip_bgp_ipv4_community_list_cmd
,
10435 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10440 "Address Family modifier\n"
10441 "Address Family modifier\n"
10442 "Display routes matching the community-list\n"
10443 "community-list number\n"
10444 "community-list name\n")
10446 if (strncmp (argv
[0], "m", 1) == 0)
10447 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
10449 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
10452 DEFUN (show_ip_bgp_community_list_exact
,
10453 show_ip_bgp_community_list_exact_cmd
,
10454 "show ip bgp community-list (<1-500>|WORD) exact-match",
10458 "Display routes matching the community-list\n"
10459 "community-list number\n"
10460 "community-list name\n"
10461 "Exact match of the communities\n")
10463 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
10466 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
10467 show_ip_bgp_ipv4_community_list_exact_cmd
,
10468 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10473 "Address Family modifier\n"
10474 "Address Family modifier\n"
10475 "Display routes matching the community-list\n"
10476 "community-list number\n"
10477 "community-list name\n"
10478 "Exact match of the communities\n")
10480 if (strncmp (argv
[0], "m", 1) == 0)
10481 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
10483 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
10487 DEFUN (show_bgp_community_list
,
10488 show_bgp_community_list_cmd
,
10489 "show bgp community-list (<1-500>|WORD)",
10492 "Display routes matching the community-list\n"
10493 "community-list number\n"
10494 "community-list name\n")
10496 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10499 ALIAS (show_bgp_community_list
,
10500 show_bgp_ipv6_community_list_cmd
,
10501 "show bgp ipv6 community-list (<1-500>|WORD)",
10505 "Display routes matching the community-list\n"
10506 "community-list number\n"
10507 "community-list name\n")
10510 DEFUN (show_ipv6_bgp_community_list
,
10511 show_ipv6_bgp_community_list_cmd
,
10512 "show ipv6 bgp community-list WORD",
10516 "Display routes matching the community-list\n"
10517 "community-list name\n")
10519 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10520 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10524 DEFUN (show_ipv6_mbgp_community_list
,
10525 show_ipv6_mbgp_community_list_cmd
,
10526 "show ipv6 mbgp community-list WORD",
10530 "Display routes matching the community-list\n"
10531 "community-list name\n")
10533 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10534 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
10537 DEFUN (show_bgp_community_list_exact
,
10538 show_bgp_community_list_exact_cmd
,
10539 "show bgp community-list (<1-500>|WORD) exact-match",
10542 "Display routes matching the community-list\n"
10543 "community-list number\n"
10544 "community-list name\n"
10545 "Exact match of the communities\n")
10547 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10550 ALIAS (show_bgp_community_list_exact
,
10551 show_bgp_ipv6_community_list_exact_cmd
,
10552 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10556 "Display routes matching the community-list\n"
10557 "community-list number\n"
10558 "community-list name\n"
10559 "Exact match of the communities\n")
10562 DEFUN (show_ipv6_bgp_community_list_exact
,
10563 show_ipv6_bgp_community_list_exact_cmd
,
10564 "show ipv6 bgp community-list WORD exact-match",
10568 "Display routes matching the community-list\n"
10569 "community-list name\n"
10570 "Exact match of the communities\n")
10572 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10573 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10577 DEFUN (show_ipv6_mbgp_community_list_exact
,
10578 show_ipv6_mbgp_community_list_exact_cmd
,
10579 "show ipv6 mbgp community-list WORD exact-match",
10583 "Display routes matching the community-list\n"
10584 "community-list name\n"
10585 "Exact match of the communities\n")
10587 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10588 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
10590 #endif /* HAVE_IPV6 */
10593 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
10594 const char *prefix
, afi_t afi
,
10595 safi_t safi
, enum bgp_show_type type
)
10599 struct bgp
*bgp
= NULL
;
10601 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
10603 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
10604 return CMD_WARNING
;
10609 ret
= str2prefix (prefix
, p
);
10612 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
10613 return CMD_WARNING
;
10616 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
10621 DEFUN (show_ip_bgp_prefix_longer
,
10622 show_ip_bgp_prefix_longer_cmd
,
10623 "show ip bgp A.B.C.D/M longer-prefixes",
10627 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10628 "Display route and more specific routes\n")
10630 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10631 bgp_show_type_prefix_longer
);
10634 DEFUN (show_ip_bgp_instance_prefix_longer
,
10635 show_ip_bgp_instance_prefix_longer_cmd
,
10636 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
10640 BGP_INSTANCE_HELP_STR
10641 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10642 "Display route and more specific routes\n")
10644 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
10645 bgp_show_type_prefix_longer
);
10648 DEFUN (show_ip_bgp_flap_prefix_longer
,
10649 show_ip_bgp_flap_prefix_longer_cmd
,
10650 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
10654 "Display flap statistics of routes\n"
10655 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10656 "Display route and more specific routes\n")
10658 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10659 bgp_show_type_flap_prefix_longer
);
10662 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
10663 show_ip_bgp_ipv4_prefix_longer_cmd
,
10664 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
10669 "Address Family modifier\n"
10670 "Address Family modifier\n"
10671 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10672 "Display route and more specific routes\n")
10674 if (strncmp (argv
[0], "m", 1) == 0)
10675 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
10676 bgp_show_type_prefix_longer
);
10678 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
10679 bgp_show_type_prefix_longer
);
10682 DEFUN (show_ip_bgp_flap_address
,
10683 show_ip_bgp_flap_address_cmd
,
10684 "show ip bgp flap-statistics A.B.C.D",
10688 "Display flap statistics of routes\n"
10689 "Network in the BGP routing table to display\n")
10691 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10692 bgp_show_type_flap_address
);
10695 DEFUN (show_ip_bgp_flap_prefix
,
10696 show_ip_bgp_flap_prefix_cmd
,
10697 "show ip bgp flap-statistics A.B.C.D/M",
10701 "Display flap statistics of routes\n"
10702 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10704 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10705 bgp_show_type_flap_prefix
);
10708 DEFUN (show_bgp_prefix_longer
,
10709 show_bgp_prefix_longer_cmd
,
10710 "show bgp X:X::X:X/M longer-prefixes",
10713 "IPv6 prefix <network>/<length>\n"
10714 "Display route and more specific routes\n")
10716 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
10717 bgp_show_type_prefix_longer
);
10720 ALIAS (show_bgp_prefix_longer
,
10721 show_bgp_ipv6_prefix_longer_cmd
,
10722 "show bgp ipv6 X:X::X:X/M longer-prefixes",
10726 "IPv6 prefix <network>/<length>\n"
10727 "Display route and more specific routes\n")
10730 DEFUN (show_ipv6_bgp_prefix_longer
,
10731 show_ipv6_bgp_prefix_longer_cmd
,
10732 "show ipv6 bgp X:X::X:X/M longer-prefixes",
10736 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
10737 "Display route and more specific routes\n")
10739 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10740 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
10741 bgp_show_type_prefix_longer
);
10745 DEFUN (show_ipv6_mbgp_prefix_longer
,
10746 show_ipv6_mbgp_prefix_longer_cmd
,
10747 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
10751 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
10752 "Display route and more specific routes\n")
10754 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10755 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
10756 bgp_show_type_prefix_longer
);
10758 #endif /* HAVE_IPV6 */
10760 static struct peer
*
10761 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
10762 const char *ip_str
, u_char use_json
)
10767 union sockunion su
;
10769 /* BGP structure lookup. */
10772 bgp
= bgp_lookup_by_name (view_name
);
10777 json_object
*json_no
= NULL
;
10778 json_no
= json_object_new_object();
10779 json_object_string_add(json_no
, "warning", "Can't find BGP view");
10780 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10781 json_object_free(json_no
);
10784 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
10790 bgp
= bgp_get_default ();
10795 json_object
*json_no
= NULL
;
10796 json_no
= json_object_new_object();
10797 json_object_string_add(json_no
, "warning", "No BGP process configured");
10798 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10799 json_object_free(json_no
);
10802 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10807 /* Get peer sockunion. */
10808 ret
= str2sockunion (ip_str
, &su
);
10811 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
10814 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
10820 json_object
*json_no
= NULL
;
10821 json_no
= json_object_new_object();
10822 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
10823 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10824 json_object_free(json_no
);
10827 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
10834 /* Peer structure lookup. */
10835 peer
= peer_lookup (bgp
, &su
);
10840 json_object
*json_no
= NULL
;
10841 json_no
= json_object_new_object();
10842 json_object_string_add(json_no
, "warning","No such neighbor");
10843 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10844 json_object_free(json_no
);
10847 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
10856 BGP_STATS_MAXBITLEN
= 0,
10858 BGP_STATS_PREFIXES
,
10860 BGP_STATS_UNAGGREGATEABLE
,
10861 BGP_STATS_MAX_AGGREGATEABLE
,
10862 BGP_STATS_AGGREGATES
,
10864 BGP_STATS_ASPATH_COUNT
,
10865 BGP_STATS_ASPATH_MAXHOPS
,
10866 BGP_STATS_ASPATH_TOTHOPS
,
10867 BGP_STATS_ASPATH_MAXSIZE
,
10868 BGP_STATS_ASPATH_TOTSIZE
,
10869 BGP_STATS_ASN_HIGHEST
,
10873 static const char *table_stats_strs
[] =
10875 [BGP_STATS_PREFIXES
] = "Total Prefixes",
10876 [BGP_STATS_TOTPLEN
] = "Average prefix length",
10877 [BGP_STATS_RIB
] = "Total Advertisements",
10878 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
10879 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
10880 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
10881 [BGP_STATS_SPACE
] = "Address space advertised",
10882 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
10883 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
10884 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
10885 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
10886 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
10887 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
10888 [BGP_STATS_MAX
] = NULL
,
10891 struct bgp_table_stats
10893 struct bgp_table
*table
;
10894 unsigned long long counts
[BGP_STATS_MAX
];
10898 #define TALLY_SIGFIG 100000
10899 static unsigned long
10900 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
10902 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
10903 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
10904 unsigned long ret
= newtot
/ count
;
10906 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
10914 bgp_table_stats_walker (struct thread
*t
)
10916 struct bgp_node
*rn
;
10917 struct bgp_node
*top
;
10918 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
10919 unsigned int space
= 0;
10921 if (!(top
= bgp_table_top (ts
->table
)))
10924 switch (top
->p
.family
)
10927 space
= IPV4_MAX_BITLEN
;
10930 space
= IPV6_MAX_BITLEN
;
10934 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
10936 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
10938 struct bgp_info
*ri
;
10939 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
10940 unsigned int rinum
= 0;
10948 ts
->counts
[BGP_STATS_PREFIXES
]++;
10949 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
10952 ts
->counts
[BGP_STATS_AVGPLEN
]
10953 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
10954 ts
->counts
[BGP_STATS_AVGPLEN
],
10958 /* check if the prefix is included by any other announcements */
10959 while (prn
&& !prn
->info
)
10960 prn
= bgp_node_parent_nolock (prn
);
10962 if (prn
== NULL
|| prn
== top
)
10964 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
10965 /* announced address space */
10967 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
10969 else if (prn
->info
)
10970 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
10972 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
10975 ts
->counts
[BGP_STATS_RIB
]++;
10978 (CHECK_FLAG (ri
->attr
->flag
,
10979 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
10980 ts
->counts
[BGP_STATS_AGGREGATES
]++;
10982 /* as-path stats */
10983 if (ri
->attr
&& ri
->attr
->aspath
)
10985 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
10986 unsigned int size
= aspath_size (ri
->attr
->aspath
);
10987 as_t highest
= aspath_highest (ri
->attr
->aspath
);
10989 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
10991 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
10992 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
10994 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
10995 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
10997 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
10998 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11000 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11001 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11002 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11004 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11005 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11006 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11009 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11010 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11018 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11020 struct bgp_table_stats ts
;
11023 if (!bgp
->rib
[afi
][safi
])
11025 vty_out (vty
, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s",
11026 afi
, safi
, VTY_NEWLINE
);
11027 return CMD_WARNING
;
11030 memset (&ts
, 0, sizeof (ts
));
11031 ts
.table
= bgp
->rib
[afi
][safi
];
11032 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11034 vty_out (vty
, "BGP %s RIB statistics%s%s",
11035 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11037 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11039 if (!table_stats_strs
[i
])
11045 case BGP_STATS_ASPATH_AVGHOPS
:
11046 case BGP_STATS_ASPATH_AVGSIZE
:
11047 case BGP_STATS_AVGPLEN
:
11048 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11049 vty_out (vty
, "%12.2f",
11050 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11053 case BGP_STATS_ASPATH_TOTHOPS
:
11054 case BGP_STATS_ASPATH_TOTSIZE
:
11055 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11056 vty_out (vty
, "%12.2f",
11058 (float)ts
.counts
[i
] /
11059 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11062 case BGP_STATS_TOTPLEN
:
11063 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11064 vty_out (vty
, "%12.2f",
11066 (float)ts
.counts
[i
] /
11067 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11070 case BGP_STATS_SPACE
:
11071 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11072 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11073 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11075 vty_out (vty
, "%30s: ", "%% announced ");
11076 vty_out (vty
, "%12.2f%s",
11077 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11078 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11080 vty_out (vty
, "%30s: ", "/8 equivalent ");
11081 vty_out (vty
, "%12.2f%s",
11082 (float)ts
.counts
[BGP_STATS_SPACE
] /
11083 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11085 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11087 vty_out (vty
, "%30s: ", "/24 equivalent ");
11088 vty_out (vty
, "%12.2f",
11089 (float)ts
.counts
[BGP_STATS_SPACE
] /
11090 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11093 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11094 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11097 vty_out (vty
, "%s", VTY_NEWLINE
);
11099 return CMD_SUCCESS
;
11103 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11104 const char *afi_str
, const char *safi_str
)
11111 bgp
= bgp_lookup_by_name (name
);
11113 bgp
= bgp_get_default ();
11117 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
11118 return CMD_WARNING
;
11120 if (strncmp (afi_str
, "ipv", 3) == 0)
11122 if (strncmp (afi_str
, "ipv4", 4) == 0)
11124 else if (strncmp (afi_str
, "ipv6", 4) == 0)
11128 vty_out (vty
, "%% Invalid address family %s%s",
11129 afi_str
, VTY_NEWLINE
);
11130 return CMD_WARNING
;
11132 if (strncmp (safi_str
, "m", 1) == 0)
11133 safi
= SAFI_MULTICAST
;
11134 else if (strncmp (safi_str
, "u", 1) == 0)
11135 safi
= SAFI_UNICAST
;
11136 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
11137 safi
= SAFI_MPLS_VPN
;
11140 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11141 safi_str
, VTY_NEWLINE
);
11142 return CMD_WARNING
;
11147 vty_out (vty
, "%% Invalid address family %s%s",
11148 afi_str
, VTY_NEWLINE
);
11149 return CMD_WARNING
;
11152 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11155 DEFUN (show_bgp_statistics
,
11156 show_bgp_statistics_cmd
,
11157 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
11162 "Address Family modifier\n"
11163 "Address Family modifier\n"
11164 "BGP RIB advertisement statistics\n")
11166 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11169 ALIAS (show_bgp_statistics
,
11170 show_bgp_statistics_vpnv4_cmd
,
11171 "show bgp (ipv4) (vpnv4) statistics",
11175 "Address Family modifier\n"
11176 "BGP RIB advertisement statistics\n")
11178 DEFUN (show_bgp_statistics_view
,
11179 show_bgp_statistics_view_cmd
,
11180 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) statistics",
11183 BGP_INSTANCE_HELP_STR
11186 "Address Family modifier\n"
11187 "Address Family modifier\n"
11188 "BGP RIB advertisement statistics\n")
11190 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11193 ALIAS (show_bgp_statistics_view
,
11194 show_bgp_statistics_view_vpnv4_cmd
,
11195 "show bgp " BGP_INSTANCE_CMD
" (ipv4) (vpnv4) statistics",
11198 BGP_INSTANCE_HELP_STR
11200 "Address Family modifier\n"
11201 "BGP RIB advertisement statistics\n")
11213 PCOUNT_PFCNT
, /* the figure we display to users */
11217 static const char *pcount_strs
[] =
11219 [PCOUNT_ADJ_IN
] = "Adj-in",
11220 [PCOUNT_DAMPED
] = "Damped",
11221 [PCOUNT_REMOVED
] = "Removed",
11222 [PCOUNT_HISTORY
] = "History",
11223 [PCOUNT_STALE
] = "Stale",
11224 [PCOUNT_VALID
] = "Valid",
11225 [PCOUNT_ALL
] = "All RIB",
11226 [PCOUNT_COUNTED
] = "PfxCt counted",
11227 [PCOUNT_PFCNT
] = "Useable",
11228 [PCOUNT_MAX
] = NULL
,
11231 struct peer_pcounts
11233 unsigned int count
[PCOUNT_MAX
];
11234 const struct peer
*peer
;
11235 const struct bgp_table
*table
;
11239 bgp_peer_count_walker (struct thread
*t
)
11241 struct bgp_node
*rn
;
11242 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11243 const struct peer
*peer
= pc
->peer
;
11245 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11247 struct bgp_adj_in
*ain
;
11248 struct bgp_info
*ri
;
11250 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11251 if (ain
->peer
== peer
)
11252 pc
->count
[PCOUNT_ADJ_IN
]++;
11254 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11256 char buf
[SU_ADDRSTRLEN
];
11258 if (ri
->peer
!= peer
)
11261 pc
->count
[PCOUNT_ALL
]++;
11263 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11264 pc
->count
[PCOUNT_DAMPED
]++;
11265 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11266 pc
->count
[PCOUNT_HISTORY
]++;
11267 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
11268 pc
->count
[PCOUNT_REMOVED
]++;
11269 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
11270 pc
->count
[PCOUNT_STALE
]++;
11271 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
11272 pc
->count
[PCOUNT_VALID
]++;
11273 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11274 pc
->count
[PCOUNT_PFCNT
]++;
11276 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
11278 pc
->count
[PCOUNT_COUNTED
]++;
11279 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11280 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
11282 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11283 buf
, SU_ADDRSTRLEN
),
11289 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11290 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
11292 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11293 buf
, SU_ADDRSTRLEN
),
11303 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
11305 struct peer_pcounts pcounts
= { .peer
= peer
};
11307 json_object
*json
= NULL
;
11308 json_object
*json_loop
= NULL
;
11312 json
= json_object_new_object();
11313 json_loop
= json_object_new_object();
11316 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
11317 || !peer
->bgp
->rib
[afi
][safi
])
11321 json_object_string_add(json
, "warning", "No such neighbor or address family");
11322 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11323 json_object_free(json
);
11326 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11328 return CMD_WARNING
;
11331 memset (&pcounts
, 0, sizeof(pcounts
));
11332 pcounts
.peer
= peer
;
11333 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
11335 /* in-place call via thread subsystem so as to record execution time
11336 * * stats for the thread-walk (i.e. ensure this can't be blamed on
11337 * * on just vty_read()).
11339 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
11343 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
11344 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
11345 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
11347 for (i
= 0; i
< PCOUNT_MAX
; i
++)
11348 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
11350 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
11352 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
11354 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
11355 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
11357 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11358 json_object_free(json
);
11363 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
11365 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
11366 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
11371 vty_out (vty
, "Prefix counts for %s, %s%s",
11372 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
11375 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
11376 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
11377 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
11379 for (i
= 0; i
< PCOUNT_MAX
; i
++)
11380 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
11382 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
11384 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
11385 peer
->host
, VTY_NEWLINE
);
11386 vty_out (vty
, "Please report this bug, with the above command output%s",
11391 return CMD_SUCCESS
;
11394 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
11395 show_ip_bgp_neighbor_prefix_counts_cmd
,
11396 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11400 "Detailed information on TCP and BGP neighbor connections\n"
11401 "Neighbor to display information about\n"
11402 "Neighbor to display information about\n"
11403 "Neighbor on bgp configured interface\n"
11404 "Display detailed prefix count information\n"
11405 "JavaScript Object Notation\n")
11408 u_char uj
= use_json(argc
, argv
);
11410 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11412 return CMD_WARNING
;
11414 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11417 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
11418 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
11419 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11423 BGP_INSTANCE_HELP_STR
11424 "Detailed information on TCP and BGP neighbor connections\n"
11425 "Neighbor to display information about\n"
11426 "Neighbor to display information about\n"
11427 "Neighbor on bgp configured interface\n"
11428 "Display detailed prefix count information\n"
11429 "JavaScript Object Notation\n")
11432 u_char uj
= use_json(argc
, argv
);
11434 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11436 return CMD_WARNING
;
11438 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11441 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
11442 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
11443 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11447 "Detailed information on TCP and BGP neighbor connections\n"
11448 "Neighbor to display information about\n"
11449 "Neighbor to display information about\n"
11450 "Neighbor on bgp configured interface\n"
11451 "Display detailed prefix count information\n"
11452 "JavaScript Object Notation\n")
11455 u_char uj
= use_json(argc
, argv
);
11457 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11459 return CMD_WARNING
;
11461 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11464 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
11465 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
11466 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11469 BGP_INSTANCE_HELP_STR
11471 "Detailed information on TCP and BGP neighbor connections\n"
11472 "Neighbor to display information about\n"
11473 "Neighbor to display information about\n"
11474 "Neighbor on bgp configured interface\n"
11475 "Display detailed prefix count information\n"
11476 "JavaScript Object Notation\n")
11479 u_char uj
= use_json(argc
, argv
);
11481 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11483 return CMD_WARNING
;
11485 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11488 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
11489 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
11490 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11495 "Address Family modifier\n"
11496 "Address Family modifier\n"
11497 "Detailed information on TCP and BGP neighbor connections\n"
11498 "Neighbor to display information about\n"
11499 "Neighbor to display information about\n"
11500 "Neighbor on bgp configured interface\n"
11501 "Display detailed prefix count information\n"
11502 "JavaScript Object Notation\n")
11505 u_char uj
= use_json(argc
, argv
);
11507 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11509 return CMD_WARNING
;
11511 if (strncmp (argv
[0], "m", 1) == 0)
11512 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, uj
);
11514 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11517 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
11518 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
11519 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11524 "Address Family modifier\n"
11525 "Address Family modifier\n"
11526 "Detailed information on TCP and BGP neighbor connections\n"
11527 "Neighbor to display information about\n"
11528 "Neighbor to display information about\n"
11529 "Neighbor on bgp configured interface\n"
11530 "Display detailed prefix count information\n"
11531 "JavaScript Object Notation\n")
11534 u_char uj
= use_json(argc
, argv
);
11536 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11538 return CMD_WARNING
;
11540 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
, uj
);
11544 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
11545 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
11547 struct bgp_table
*table
;
11548 struct bgp_adj_in
*ain
;
11549 struct bgp_adj_out
*adj
;
11550 unsigned long output_count
;
11551 unsigned long filtered_count
;
11552 struct bgp_node
*rn
;
11557 struct attr_extra extra
;
11559 struct update_subgroup
*subgrp
;
11560 json_object
*json_scode
= NULL
;
11561 json_object
*json_ocode
= NULL
;
11562 json_object
*json_ar
= NULL
;
11563 struct peer_af
*paf
;
11567 json_scode
= json_object_new_object();
11568 json_ocode
= json_object_new_object();
11569 json_ar
= json_object_new_object();
11571 json_object_string_add(json_scode
, "suppressed", "s");
11572 json_object_string_add(json_scode
, "damped", "d");
11573 json_object_string_add(json_scode
, "history", "h");
11574 json_object_string_add(json_scode
, "valid", "*");
11575 json_object_string_add(json_scode
, "best", ">");
11576 json_object_string_add(json_scode
, "multipath", "=");
11577 json_object_string_add(json_scode
, "internal", "i");
11578 json_object_string_add(json_scode
, "ribFailure", "r");
11579 json_object_string_add(json_scode
, "stale", "S");
11580 json_object_string_add(json_scode
, "removed", "R");
11582 json_object_string_add(json_ocode
, "igp", "i");
11583 json_object_string_add(json_ocode
, "egp", "e");
11584 json_object_string_add(json_ocode
, "incomplete", "?");
11593 json_object_string_add(json
, "alert", "no BGP");
11594 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11595 json_object_free(json
);
11598 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
11602 table
= bgp
->rib
[afi
][safi
];
11604 output_count
= filtered_count
= 0;
11605 subgrp
= peer_subgroup(peer
, afi
, safi
);
11607 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11611 json_object_int_add(json
, "bgpTableVersion", table
->version
);
11612 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11613 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11614 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11615 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
11619 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11620 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11621 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11623 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
11624 VTY_NEWLINE
, VTY_NEWLINE
);
11629 attr
.extra
= &extra
;
11630 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
11634 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11636 if (ain
->peer
== peer
)
11642 json_object_int_add(json
, "bgpTableVersion", 0);
11643 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11644 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11645 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11649 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11650 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11651 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11658 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
11663 bgp_attr_dup(&attr
, ain
->attr
);
11664 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
11666 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
11677 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
11678 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
11679 if (paf
->peer
== peer
)
11685 json_object_int_add(json
, "bgpTableVersion", table
->version
);
11686 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11687 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11688 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11692 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
11693 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11694 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11695 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11703 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
11709 bgp_attr_dup(&attr
, adj
->attr
);
11710 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
11711 if (ret
!= RMAP_DENY
)
11713 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
11723 json_object_object_add(json
, "advertisedRoutes", json_ar
);
11725 if (output_count
!= 0)
11728 json_object_int_add(json
, "totalPrefixCounter", output_count
);
11730 vty_out (vty
, "%sTotal number of prefixes %ld%s",
11731 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
11735 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11736 json_object_free(json
);
11742 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
11743 int in
, const char *rmap_name
, u_char use_json
)
11745 json_object
*json
= NULL
;
11748 json
= json_object_new_object();
11750 if (!peer
|| !peer
->afc
[afi
][safi
])
11754 json_object_string_add(json
, "warning", "No such neighbor or address family");
11755 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11756 json_object_free(json
);
11759 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11761 return CMD_WARNING
;
11764 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11768 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
11769 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11770 json_object_free(json
);
11773 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
11775 return CMD_WARNING
;
11778 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
11780 return CMD_SUCCESS
;
11783 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
11784 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
11785 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11789 BGP_INSTANCE_HELP_STR
11790 "Detailed information on TCP and BGP neighbor connections\n"
11791 "Neighbor to display information about\n"
11792 "Neighbor to display information about\n"
11793 "Display the routes advertised to a BGP neighbor\n"
11794 "JavaScript Object Notation\n")
11797 u_char uj
= use_json(argc
, argv
);
11799 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
11800 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11802 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11805 return CMD_WARNING
;
11807 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
11810 DEFUN (show_ip_bgp_neighbor_advertised_route
,
11811 show_ip_bgp_neighbor_advertised_route_cmd
,
11812 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11816 "Detailed information on TCP and BGP neighbor connections\n"
11817 "Neighbor to display information about\n"
11818 "Neighbor to display information about\n"
11819 "Neighbor on bgp configured interface\n"
11820 "Display the routes advertised to a BGP neighbor\n"
11821 "JavaScript Object Notation\n")
11825 const char *rmap_name
= NULL
;
11826 u_char uj
= use_json(argc
, argv
);
11828 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11831 return CMD_WARNING
;
11833 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
11835 rmap_name
= argv
[1];
11837 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
11840 ALIAS (show_ip_bgp_neighbor_advertised_route
,
11841 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
11842 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
11846 "Detailed information on TCP and BGP neighbor connections\n"
11847 "Neighbor to display information about\n"
11848 "Neighbor to display information about\n"
11849 "Neighbor on bgp configured interface\n"
11850 "Display the routes advertised to a BGP neighbor\n"
11851 "JavaScript Object Notation\n")
11853 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
11854 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
11855 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
11859 BGP_INSTANCE_HELP_STR
11860 "Detailed information on TCP and BGP neighbor connections\n"
11861 "Neighbor to display information about\n"
11862 "Neighbor to display information about\n"
11863 "Neighbor on bgp configured interface\n"
11864 "Display the routes advertised to a BGP neighbor\n"
11865 "JavaScript Object Notation\n")
11866 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
11867 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
11868 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11873 "Address Family modifier\n"
11874 "Address Family modifier\n"
11875 "Detailed information on TCP and BGP neighbor connections\n"
11876 "Neighbor to display information about\n"
11877 "Neighbor to display information about\n"
11878 "Neighbor on bgp configured interface\n"
11879 "Display the routes advertised to a BGP neighbor\n"
11880 "JavaScript Object Notation\n")
11883 const char *rmap_name
= NULL
;
11884 u_char uj
= use_json(argc
, argv
);
11886 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11888 return CMD_WARNING
;
11890 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
11891 rmap_name
= argv
[2];
11893 if (strncmp (argv
[0], "m", 1) == 0)
11894 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0, rmap_name
, uj
);
11896 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
11899 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
11900 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
11901 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
11906 "Address Family modifier\n"
11907 "Address Family modifier\n"
11908 "Detailed information on TCP and BGP neighbor connections\n"
11909 "Neighbor to display information about\n"
11910 "Neighbor to display information about\n"
11911 "Neighbor on bgp configured interface\n"
11912 "Display the routes advertised to a BGP neighbor\n"
11913 "Route-map to control what is displayed\n"
11914 "JavaScript Object Notation\n")
11917 DEFUN (show_bgp_instance_neighbor_advertised_route
,
11918 show_bgp_instance_neighbor_advertised_route_cmd
,
11919 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11922 BGP_INSTANCE_HELP_STR
11923 "Detailed information on TCP and BGP neighbor connections\n"
11924 "Neighbor to display information about\n"
11925 "Neighbor to display information about\n"
11926 "Neighbor on bgp configured interface\n"
11927 "Display the routes advertised to a BGP neighbor\n"
11928 "JavaScript Object Notation\n")
11931 u_char uj
= use_json(argc
, argv
);
11933 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
11934 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11936 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11939 return CMD_WARNING
;
11941 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
11944 ALIAS (show_bgp_instance_neighbor_advertised_route
,
11945 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
11946 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11949 BGP_INSTANCE_HELP_STR
11951 "Detailed information on TCP and BGP neighbor connections\n"
11952 "Neighbor to display information about\n"
11953 "Neighbor to display information about\n"
11954 "Neighbor on bgp configured interface\n"
11955 "Display the routes advertised to a BGP neighbor\n"
11956 "JavaScript Object Notation\n")
11958 DEFUN (show_bgp_neighbor_advertised_route
,
11959 show_bgp_neighbor_advertised_route_cmd
,
11960 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11963 "Detailed information on TCP and BGP neighbor connections\n"
11964 "Neighbor to display information about\n"
11965 "Neighbor to display information about\n"
11966 "Neighbor on bgp configured interface\n"
11967 "Display the routes advertised to a BGP neighbor\n"
11968 "JavaScript Object Notation\n")
11972 const char *rmap_name
= NULL
;
11973 u_char uj
= use_json(argc
, argv
);
11975 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11978 return CMD_WARNING
;
11980 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
11981 rmap_name
= argv
[1];
11983 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
11986 ALIAS (show_bgp_neighbor_advertised_route
,
11987 show_bgp_ipv6_neighbor_advertised_route_cmd
,
11988 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11992 "Detailed information on TCP and BGP neighbor connections\n"
11993 "Neighbor to display information about\n"
11994 "Neighbor to display information about\n"
11995 "Neighbor on bgp configured interface\n"
11996 "Display the routes advertised to a BGP neighbor\n"
11997 "JavaScript Object Notation\n")
12000 ALIAS (show_bgp_neighbor_advertised_route
,
12001 ipv6_bgp_neighbor_advertised_route_cmd
,
12002 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12006 "Detailed information on TCP and BGP neighbor connections\n"
12007 "Neighbor to display information about\n"
12008 "Neighbor to display information about\n"
12009 "Neighbor on bgp configured interface\n"
12010 "Display the routes advertised to a BGP neighbor\n"
12011 "JavaScript Object Notation\n")
12014 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12015 ipv6_mbgp_neighbor_advertised_route_cmd
,
12016 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12020 "Detailed information on TCP and BGP neighbor connections\n"
12021 "Neighbor to display information about\n"
12022 "Neighbor to display information about\n"
12023 "Neighbor on bgp configured interface\n"
12024 "Neighbor on bgp configured interface\n"
12025 "Display the routes advertised to a BGP neighbor\n"
12026 "JavaScript Object Notation\n")
12029 u_char uj
= use_json(argc
, argv
);
12031 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12033 return CMD_WARNING
;
12035 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12036 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12038 #endif /* HAVE_IPV6 */
12040 DEFUN (show_bgp_instance_neighbor_received_routes
,
12041 show_bgp_instance_neighbor_received_routes_cmd
,
12042 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12045 BGP_INSTANCE_HELP_STR
12046 "Detailed information on TCP and BGP neighbor connections\n"
12047 "Neighbor to display information about\n"
12048 "Neighbor to display information about\n"
12049 "Neighbor on bgp configured interface\n"
12050 "Display the received routes from neighbor\n"
12051 "JavaScript Object Notation\n")
12054 u_char uj
= use_json(argc
, argv
);
12056 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12058 return CMD_WARNING
;
12060 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12063 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12064 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12065 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12069 BGP_INSTANCE_HELP_STR
12070 "Detailed information on TCP and BGP neighbor connections\n"
12071 "Neighbor to display information about\n"
12072 "Neighbor to display information about\n"
12073 "Neighbor on bgp configured interface\n"
12074 "Display the received routes from neighbor\n"
12075 "JavaScript Object Notation\n")
12078 u_char uj
= use_json(argc
, argv
);
12080 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12082 return CMD_WARNING
;
12084 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12087 ALIAS (show_bgp_instance_neighbor_received_routes
,
12088 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12089 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12092 BGP_INSTANCE_HELP_STR
12094 "Detailed information on TCP and BGP neighbor connections\n"
12095 "Neighbor to display information about\n"
12096 "Neighbor to display information about\n"
12097 "Neighbor on bgp configured interface\n"
12098 "Display the received routes from neighbor\n"
12099 "JavaScript Object Notation\n")
12101 DEFUN (show_ip_bgp_neighbor_received_routes
,
12102 show_ip_bgp_neighbor_received_routes_cmd
,
12103 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12107 "Detailed information on TCP and BGP neighbor connections\n"
12108 "Neighbor to display information about\n"
12109 "Neighbor to display information about\n"
12110 "Neighbor on bgp configured interface\n"
12111 "Display the received routes from neighbor\n"
12112 "JavaScript Object Notation\n")
12116 const char *rmap_name
= NULL
;
12117 u_char uj
= use_json(argc
, argv
);
12119 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12122 return CMD_WARNING
;
12124 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12125 rmap_name
= argv
[1];
12127 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12130 ALIAS (show_ip_bgp_neighbor_received_routes
,
12131 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12132 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12136 "Detailed information on TCP and BGP neighbor connections\n"
12137 "Neighbor to display information about\n"
12138 "Neighbor to display information about\n"
12139 "Neighbor on bgp configured interface\n"
12140 "Display the received routes from neighbor\n"
12141 "JavaScript Object Notation\n")
12143 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12144 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12145 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12149 BGP_INSTANCE_HELP_STR
12150 "Detailed information on TCP and BGP neighbor connections\n"
12151 "Neighbor to display information about\n"
12152 "Neighbor to display information about\n"
12153 "Neighbor on bgp configured interface\n"
12154 "Display the received routes from neighbor\n"
12155 "JavaScript Object Notation\n")
12157 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12158 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12159 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12164 "Address Family modifier\n"
12165 "Address Family modifier\n"
12166 "Detailed information on TCP and BGP neighbor connections\n"
12167 "Neighbor to display information about\n"
12168 "Neighbor to display information about\n"
12169 "Neighbor on bgp configured interface\n"
12170 "Display the received routes from neighbor\n"
12171 "JavaScript Object Notation\n")
12174 const char *rmap_name
= NULL
;
12175 u_char uj
= use_json(argc
, argv
);
12177 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12179 return CMD_WARNING
;
12181 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12182 rmap_name
= argv
[2];
12184 if (strncmp (argv
[0], "m", 1) == 0)
12185 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1, rmap_name
, uj
);
12187 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12190 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12191 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12192 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12197 "Address Family modifier\n"
12198 "Address Family modifier\n"
12199 "Detailed information on TCP and BGP neighbor connections\n"
12200 "Neighbor to display information about\n"
12201 "Neighbor to display information about\n"
12202 "Neighbor on bgp configured interface\n"
12203 "Display the received routes from neighbor\n"
12204 "JavaScript Object Notation\n")
12206 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12207 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12209 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12211 "show bgp " BGP_INSTANCE_CMD
" ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12215 BGP_INSTANCE_HELP_STR
12220 "Address family modifier\n"
12221 "Address family modifier\n"
12222 "Detailed information on TCP and BGP neighbor connections\n"
12223 "Neighbor to display information about\n"
12224 "Neighbor to display information about\n"
12225 "Neighbor on bgp configured interface\n"
12226 "Display the advertised routes to neighbor\n"
12227 "Display the received routes from neighbor\n"
12228 "JavaScript Object Notation\n")
12234 u_char uj
= use_json(argc
, argv
);
12236 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12239 return CMD_WARNING
;
12241 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
12242 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
12243 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12245 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12248 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12249 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12250 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12254 "Detailed information on TCP and BGP neighbor connections\n"
12255 "Neighbor to display information about\n"
12256 "Neighbor to display information about\n"
12257 "Neighbor on bgp configured interface\n"
12258 "Display information received from a BGP neighbor\n"
12259 "Display the prefixlist filter\n"
12260 "JavaScript Object Notation\n")
12263 union sockunion su
;
12266 u_char uj
= use_json(argc
, argv
);
12268 ret
= str2sockunion (argv
[0], &su
);
12271 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12276 json_object
*json_no
= NULL
;
12277 json_object
*json_sub
= NULL
;
12278 json_no
= json_object_new_object();
12279 json_sub
= json_object_new_object();
12280 json_object_string_add(json_no
, "warning", "Malformed address or name");
12281 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12282 json_object_object_add(json_no
, "detail", json_sub
);
12283 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12284 json_object_free(json_no
);
12287 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12288 return CMD_WARNING
;
12293 peer
= peer_lookup (NULL
, &su
);
12298 json_object
*json_no
= NULL
;
12299 json_no
= json_object_new_object();
12300 json_object_string_add(json_no
, "warning", "Peer not found");
12301 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12302 json_object_free(json_no
);
12305 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12306 return CMD_WARNING
;
12310 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12311 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12315 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12316 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12322 json_object
*json_no
= NULL
;
12323 json_no
= json_object_new_object();
12324 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12325 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12326 json_object_free(json_no
);
12329 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12332 return CMD_SUCCESS
;
12335 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
12336 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
12337 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12342 "Address Family modifier\n"
12343 "Address Family modifier\n"
12344 "Detailed information on TCP and BGP neighbor connections\n"
12345 "Neighbor to display information about\n"
12346 "Neighbor to display information about\n"
12347 "Neighbor on bgp configured interface\n"
12348 "Display information received from a BGP neighbor\n"
12349 "Display the prefixlist filter\n"
12350 "JavaScript Object Notation\n")
12353 union sockunion su
;
12356 u_char uj
= use_json(argc
, argv
);
12358 ret
= str2sockunion (argv
[1], &su
);
12361 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
12366 json_object
*json_no
= NULL
;
12367 json_object
*json_sub
= NULL
;
12368 json_no
= json_object_new_object();
12369 json_sub
= json_object_new_object();
12370 json_object_string_add(json_no
, "warning", "Malformed address or name");
12371 json_object_string_add(json_sub
, "warningCause", argv
[1]);
12372 json_object_object_add(json_no
, "detail", json_sub
);
12373 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12374 json_object_free(json_no
);
12377 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
12378 return CMD_WARNING
;
12383 peer
= peer_lookup (NULL
, &su
);
12388 json_object
*json_no
= NULL
;
12389 json_no
= json_object_new_object();
12390 json_object_string_add(json_no
, "warning", "Peer not found");
12391 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12392 json_object_free(json_no
);
12395 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12396 return CMD_WARNING
;
12400 if (strncmp (argv
[0], "m", 1) == 0)
12402 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
12403 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12407 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
12408 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12414 json_object
*json_no
= NULL
;
12415 json_no
= json_object_new_object();
12416 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12417 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12418 json_object_free(json_no
);
12421 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12426 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12427 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12431 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12432 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12438 json_object
*json_no
= NULL
;
12439 json_no
= json_object_new_object();
12440 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12441 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12442 json_object_free(json_no
);
12445 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12449 return CMD_SUCCESS
;
12452 DEFUN (show_bgp_neighbor_received_routes
,
12453 show_bgp_neighbor_received_routes_cmd
,
12454 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12457 "Detailed information on TCP and BGP neighbor connections\n"
12458 "Neighbor to display information about\n"
12459 "Neighbor to display information about\n"
12460 "Neighbor on bgp configured interface\n"
12461 "Display the received routes from neighbor\n"
12462 "JavaScript Object Notation\n")
12465 const char *rmap_name
= NULL
;
12466 u_char uj
= use_json(argc
, argv
);
12468 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12471 return CMD_WARNING
;
12473 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12474 rmap_name
= argv
[1];
12476 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12479 ALIAS (show_bgp_neighbor_received_routes
,
12480 show_bgp_ipv6_neighbor_received_routes_cmd
,
12481 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12485 "Detailed information on TCP and BGP neighbor connections\n"
12486 "Neighbor to display information about\n"
12487 "Neighbor to display information about\n"
12488 "Neighbor on bgp configured interface\n"
12489 "Display the received routes from neighbor\n"
12490 "JavaScript Object Notation\n")
12492 DEFUN (show_bgp_neighbor_received_prefix_filter
,
12493 show_bgp_neighbor_received_prefix_filter_cmd
,
12494 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12497 "Detailed information on TCP and BGP neighbor connections\n"
12498 "Neighbor to display information about\n"
12499 "Neighbor to display information about\n"
12500 "Neighbor on bgp configured interface\n"
12501 "Display information received from a BGP neighbor\n"
12502 "Display the prefixlist filter\n"
12503 "JavaScript Object Notation\n")
12506 union sockunion su
;
12509 u_char uj
= use_json(argc
, argv
);
12511 ret
= str2sockunion (argv
[0], &su
);
12514 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12519 json_object
*json_no
= NULL
;
12520 json_object
*json_sub
= NULL
;
12521 json_no
= json_object_new_object();
12522 json_sub
= json_object_new_object();
12523 json_object_string_add(json_no
, "warning", "Malformed address or name");
12524 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12525 json_object_object_add(json_no
, "detail", json_sub
);
12526 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12527 json_object_free(json_no
);
12530 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12531 return CMD_WARNING
;
12536 peer
= peer_lookup (NULL
, &su
);
12541 json_object
*json_no
= NULL
;
12542 json_no
= json_object_new_object();
12543 json_object_string_add(json_no
, "warning", "No Peer");
12544 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12545 json_object_free(json_no
);
12548 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12549 return CMD_WARNING
;
12553 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
12554 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
12558 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
12559 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
12565 json_object
*json_no
= NULL
;
12566 json_no
= json_object_new_object();
12567 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12568 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12569 json_object_free(json_no
);
12572 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12575 return CMD_SUCCESS
;
12578 ALIAS (show_bgp_neighbor_received_prefix_filter
,
12579 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
12580 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12584 "Detailed information on TCP and BGP neighbor connections\n"
12585 "Neighbor to display information about\n"
12586 "Neighbor to display information about\n"
12587 "Neighbor on bgp configured interface\n"
12588 "Display information received from a BGP neighbor\n"
12589 "Display the prefixlist filter\n"
12590 "JavaScript Object Notation\n")
12593 ALIAS (show_bgp_neighbor_received_routes
,
12594 ipv6_bgp_neighbor_received_routes_cmd
,
12595 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12599 "Detailed information on TCP and BGP neighbor connections\n"
12600 "Neighbor to display information about\n"
12601 "Neighbor to display information about\n"
12602 "Neighbor on bgp configured interface\n"
12603 "Display the received routes from neighbor\n"
12604 "JavaScript Object Notation\n")
12607 DEFUN (ipv6_mbgp_neighbor_received_routes
,
12608 ipv6_mbgp_neighbor_received_routes_cmd
,
12609 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12613 "Detailed information on TCP and BGP neighbor connections\n"
12614 "Neighbor to display information about\n"
12615 "Neighbor to display information about\n"
12616 "Neighbor on bgp configured interface\n"
12617 "Display the received routes from neighbor\n"
12618 "JavaScript Object Notation\n")
12621 u_char uj
= use_json(argc
, argv
);
12623 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12625 return CMD_WARNING
;
12627 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12628 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
12631 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
12632 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
12633 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12636 BGP_INSTANCE_HELP_STR
12637 "Detailed information on TCP and BGP neighbor connections\n"
12638 "Neighbor to display information about\n"
12639 "Neighbor to display information about\n"
12640 "Neighbor on bgp configured interface\n"
12641 "Display information received from a BGP neighbor\n"
12642 "Display the prefixlist filter\n"
12643 "JavaScript Object Notation\n")
12646 union sockunion su
;
12650 u_char uj
= use_json(argc
, argv
);
12652 /* BGP structure lookup. */
12653 bgp
= bgp_lookup_by_name (argv
[1]);
12658 json_object
*json_no
= NULL
;
12659 json_no
= json_object_new_object();
12660 json_object_string_add(json_no
, "warning", "Can't find BGP view");
12661 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12662 json_object_free(json_no
);
12665 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
12666 return CMD_WARNING
;
12669 ret
= str2sockunion (argv
[2], &su
);
12672 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
12677 json_object
*json_no
= NULL
;
12678 json_object
*json_sub
= NULL
;
12679 json_no
= json_object_new_object();
12680 json_sub
= json_object_new_object();
12681 json_object_string_add(json_no
, "warning", "Malformed address or name");
12682 json_object_string_add(json_sub
, "warningCause", argv
[2]);
12683 json_object_object_add(json_no
, "detail", json_sub
);
12684 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12685 json_object_free(json_no
);
12688 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
12689 return CMD_WARNING
;
12694 peer
= peer_lookup (bgp
, &su
);
12699 json_object
*json_no
= NULL
;
12700 json_no
= json_object_new_object();
12701 json_object_boolean_true_add(json_no
, "noPeer");
12702 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12703 json_object_free(json_no
);
12706 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12707 return CMD_WARNING
;
12712 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
12713 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
12717 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
12718 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
12721 return CMD_SUCCESS
;
12723 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
12724 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
12725 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12728 BGP_INSTANCE_HELP_STR
12730 "Detailed information on TCP and BGP neighbor connections\n"
12731 "Neighbor to display information about\n"
12732 "Neighbor to display information about\n"
12733 "Neighbor on bgp configured interface\n"
12734 "Display information received from a BGP neighbor\n"
12735 "Display the prefixlist filter\n"
12736 "JavaScript Object NOtation\n")
12737 #endif /* HAVE_IPV6 */
12740 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
12741 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
12743 if (! peer
|| ! peer
->afc
[afi
][safi
])
12747 json_object
*json_no
= NULL
;
12748 json_no
= json_object_new_object();
12749 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
12750 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12751 json_object_free(json_no
);
12754 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12755 return CMD_WARNING
;
12758 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
12761 DEFUN (show_ip_bgp_neighbor_routes
,
12762 show_ip_bgp_neighbor_routes_cmd
,
12763 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12767 "Detailed information on TCP and BGP neighbor connections\n"
12768 "Neighbor to display information about\n"
12769 "Neighbor to display information about\n"
12770 "Neighbor on bgp configured interface\n"
12771 "Display routes learned from neighbor\n"
12772 "JavaScript Object Notation\n")
12775 u_char uj
= use_json(argc
, argv
);
12777 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12779 return CMD_WARNING
;
12781 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12782 bgp_show_type_neighbor
, uj
);
12785 DEFUN (show_ip_bgp_instance_neighbor_routes
,
12786 show_ip_bgp_instance_neighbor_routes_cmd
,
12787 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12791 BGP_INSTANCE_HELP_STR
12792 "Detailed information on TCP and BGP neighbor connections\n"
12793 "Neighbor to display information about\n"
12794 "Neighbor to display information about\n"
12795 "Neighbor on bgp configured interface\n"
12796 "Display routes learned from neighbor\n"
12797 "JavaScript Object Notation\n")
12800 u_char uj
= use_json(argc
, argv
);
12802 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12804 return CMD_WARNING
;
12806 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12807 bgp_show_type_neighbor
, uj
);
12810 DEFUN (show_ip_bgp_neighbor_flap
,
12811 show_ip_bgp_neighbor_flap_cmd
,
12812 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
12816 "Detailed information on TCP and BGP neighbor connections\n"
12817 "Neighbor to display information about\n"
12818 "Neighbor to display information about\n"
12819 "Neighbor on bgp configured interface\n"
12820 "Display flap statistics of the routes learned from neighbor\n"
12821 "JavaScript Object Notation\n")
12824 u_char uj
= use_json(argc
, argv
);
12826 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12828 return CMD_WARNING
;
12830 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12831 bgp_show_type_flap_neighbor
, uj
);
12834 DEFUN (show_ip_bgp_neighbor_damp
,
12835 show_ip_bgp_neighbor_damp_cmd
,
12836 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
12840 "Detailed information on TCP and BGP neighbor connections\n"
12841 "Neighbor to display information about\n"
12842 "Neighbor to display information about\n"
12843 "Neighbor on bgp configured interface\n"
12844 "Display the dampened routes received from neighbor\n"
12845 "JavaScript Object Notation\n")
12848 u_char uj
= use_json(argc
, argv
);
12850 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12852 return CMD_WARNING
;
12854 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12855 bgp_show_type_damp_neighbor
, uj
);
12858 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
12859 show_ip_bgp_ipv4_neighbor_routes_cmd
,
12860 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12865 "Address Family modifier\n"
12866 "Address Family modifier\n"
12867 "Detailed information on TCP and BGP neighbor connections\n"
12868 "Neighbor to display information about\n"
12869 "Neighbor to display information about\n"
12870 "Neighbor on bgp configured interface\n"
12871 "Display routes learned from neighbor\n"
12872 "JavaScript Object Notation\n")
12875 u_char uj
= use_json(argc
, argv
);
12877 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12879 return CMD_WARNING
;
12881 if (strncmp (argv
[0], "m", 1) == 0)
12882 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
12883 bgp_show_type_neighbor
, uj
);
12885 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12886 bgp_show_type_neighbor
, uj
);
12890 DEFUN (show_bgp_instance_neighbor_routes
,
12891 show_bgp_instance_neighbor_routes_cmd
,
12892 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12895 BGP_INSTANCE_HELP_STR
12896 "Detailed information on TCP and BGP neighbor connections\n"
12897 "Neighbor to display information about\n"
12898 "Neighbor to display information about\n"
12899 "Neighbor on bgp configured interface\n"
12900 "Display routes learned from neighbor\n"
12901 "JavaScript Object Notation\n")
12904 u_char uj
= use_json(argc
, argv
);
12906 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12908 return CMD_WARNING
;
12910 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
12911 bgp_show_type_neighbor
, uj
);
12914 ALIAS (show_bgp_instance_neighbor_routes
,
12915 show_bgp_instance_ipv6_neighbor_routes_cmd
,
12916 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12919 BGP_INSTANCE_HELP_STR
12921 "Detailed information on TCP and BGP neighbor connections\n"
12922 "Neighbor to display information about\n"
12923 "Neighbor to display information about\n"
12924 "Neighbor on bgp configured interface\n"
12925 "Display routes learned from neighbor\n"
12926 "JavaScript Object Notation\n")
12928 DEFUN (show_bgp_instance_neighbor_damp
,
12929 show_bgp_instance_neighbor_damp_cmd
,
12930 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
12933 BGP_INSTANCE_HELP_STR
12934 "Detailed information on TCP and BGP neighbor connections\n"
12935 "Neighbor to display information about\n"
12936 "Neighbor to display information about\n"
12937 "Neighbor on bgp configured interface\n"
12938 "Display the dampened routes received from neighbor\n"
12939 "JavaScript Object Notation\n")
12942 u_char uj
= use_json(argc
, argv
);
12944 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
12945 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12946 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12948 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12951 return CMD_WARNING
;
12953 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
12954 bgp_show_type_damp_neighbor
, uj
);
12957 ALIAS (show_bgp_instance_neighbor_damp
,
12958 show_bgp_instance_ipv6_neighbor_damp_cmd
,
12959 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
12962 BGP_INSTANCE_HELP_STR
12964 "Detailed information on TCP and BGP neighbor connections\n"
12965 "Neighbor to display information about\n"
12966 "Neighbor to display information about\n"
12967 "Neighbor on bgp configured interface\n"
12968 "Display the dampened routes received from neighbor\n"
12969 "JavaScript Object Notation\n")
12971 DEFUN (show_bgp_instance_neighbor_flap
,
12972 show_bgp_instance_neighbor_flap_cmd
,
12973 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
12976 BGP_INSTANCE_HELP_STR
12977 "Detailed information on TCP and BGP neighbor connections\n"
12978 "Neighbor to display information about\n"
12979 "Neighbor to display information about\n"
12980 "Neighbor on bgp configured interface\n"
12981 "Display flap statistics of the routes learned from neighbor\n"
12982 "JavaScript Object Notation\n")
12985 u_char uj
= use_json(argc
, argv
);
12987 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
12988 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12989 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12991 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12994 return CMD_WARNING
;
12996 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
12997 bgp_show_type_flap_neighbor
, uj
);
13000 ALIAS (show_bgp_instance_neighbor_flap
,
13001 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13002 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13005 BGP_INSTANCE_HELP_STR
13007 "Detailed information on TCP and BGP neighbor connections\n"
13008 "Neighbor to display information about\n"
13009 "Neighbor to display information about\n"
13010 "Neighbor on bgp configured interface\n"
13011 "Display flap statistics of the routes learned from neighbor\n"
13012 "JavaScript Object Notation\n")
13014 DEFUN (show_bgp_neighbor_routes
,
13015 show_bgp_neighbor_routes_cmd
,
13016 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13019 "Detailed information on TCP and BGP neighbor connections\n"
13020 "Neighbor to display information about\n"
13021 "Neighbor to display information about\n"
13022 "Neighbor on bgp configured interface\n"
13023 "Display routes learned from neighbor\n"
13024 "JavaScript Object Notation\n")
13027 u_char uj
= use_json(argc
, argv
);
13029 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13031 return CMD_WARNING
;
13033 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13034 bgp_show_type_neighbor
, uj
);
13038 ALIAS (show_bgp_neighbor_routes
,
13039 show_bgp_ipv6_neighbor_routes_cmd
,
13040 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13044 "Detailed information on TCP and BGP neighbor connections\n"
13045 "Neighbor to display information about\n"
13046 "Neighbor to display information about\n"
13047 "Neighbor on bgp configured interface\n"
13048 "Display routes learned from neighbor\n"
13049 "JavaScript Object Notation\n")
13052 ALIAS (show_bgp_neighbor_routes
,
13053 ipv6_bgp_neighbor_routes_cmd
,
13054 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13058 "Detailed information on TCP and BGP neighbor connections\n"
13059 "Neighbor to display information about\n"
13060 "Neighbor to display information about\n"
13061 "Neighbor on bgp configured interface\n"
13062 "Display routes learned from neighbor\n"
13063 "JavaScript Object Notation\n")
13066 DEFUN (ipv6_mbgp_neighbor_routes
,
13067 ipv6_mbgp_neighbor_routes_cmd
,
13068 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13072 "Detailed information on TCP and BGP neighbor connections\n"
13073 "Neighbor to display information about\n"
13074 "Neighbor to display information about\n"
13075 "Neighbor on bgp configured interface\n"
13076 "Display routes learned from neighbor\n"
13077 "JavaScript Object Notation\n")
13080 u_char uj
= use_json(argc
, argv
);
13082 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13084 return CMD_WARNING
;
13086 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13087 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13088 bgp_show_type_neighbor
, uj
);
13091 ALIAS (show_bgp_instance_neighbor_flap
,
13092 show_bgp_neighbor_flap_cmd
,
13093 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13096 "Detailed information on TCP and BGP neighbor connections\n"
13097 "Neighbor to display information about\n"
13098 "Neighbor to display information about\n"
13099 "Neighbor on bgp configured interface\n"
13100 "Display flap statistics of the routes learned from neighbor\n"
13101 "JavaScript Object Notation\n")
13103 ALIAS (show_bgp_instance_neighbor_flap
,
13104 show_bgp_ipv6_neighbor_flap_cmd
,
13105 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13109 "Detailed information on TCP and BGP neighbor connections\n"
13110 "Neighbor to display information about\n"
13111 "Neighbor to display information about\n"
13112 "Neighbor on bgp configured interface\n"
13113 "Display flap statistics of the routes learned from neighbor\n"
13114 "JavaScript Object Notation\n")
13116 ALIAS (show_bgp_instance_neighbor_damp
,
13117 show_bgp_neighbor_damp_cmd
,
13118 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13121 "Detailed information on TCP and BGP neighbor connections\n"
13122 "Neighbor to display information about\n"
13123 "Neighbor to display information about\n"
13124 "Neighbor on bgp configured interface\n"
13125 "Display the dampened routes received from neighbor\n"
13126 "JavaScript Object Notation\n")
13128 ALIAS (show_bgp_instance_neighbor_damp
,
13129 show_bgp_ipv6_neighbor_damp_cmd
,
13130 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13134 "Detailed information on TCP and BGP neighbor connections\n"
13135 "Neighbor to display information about\n"
13136 "Neighbor to display information about\n"
13137 "Neighbor on bgp configured interface\n"
13138 "Display the dampened routes received from neighbor\n"
13139 "JavaScript Object Notation\n")
13141 #endif /* HAVE_IPV6 */
13143 struct bgp_table
*bgp_distance_table
;
13145 struct bgp_distance
13147 /* Distance value for the IP source prefix. */
13150 /* Name of the access-list to be matched. */
13154 static struct bgp_distance
*
13155 bgp_distance_new (void)
13157 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13161 bgp_distance_free (struct bgp_distance
*bdistance
)
13163 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13167 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13168 const char *ip_str
, const char *access_list_str
)
13171 struct prefix_ipv4 p
;
13173 struct bgp_node
*rn
;
13174 struct bgp_distance
*bdistance
;
13176 ret
= str2prefix_ipv4 (ip_str
, &p
);
13179 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13180 return CMD_WARNING
;
13183 distance
= atoi (distance_str
);
13185 /* Get BGP distance node. */
13186 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
13189 bdistance
= rn
->info
;
13190 bgp_unlock_node (rn
);
13194 bdistance
= bgp_distance_new ();
13195 rn
->info
= bdistance
;
13198 /* Set distance value. */
13199 bdistance
->distance
= distance
;
13201 /* Reset access-list configuration. */
13202 if (bdistance
->access_list
)
13204 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13205 bdistance
->access_list
= NULL
;
13207 if (access_list_str
)
13208 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13210 return CMD_SUCCESS
;
13214 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13215 const char *ip_str
, const char *access_list_str
)
13218 struct prefix_ipv4 p
;
13219 struct bgp_node
*rn
;
13220 struct bgp_distance
*bdistance
;
13222 ret
= str2prefix_ipv4 (ip_str
, &p
);
13225 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13226 return CMD_WARNING
;
13229 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
13232 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13233 return CMD_WARNING
;
13236 bdistance
= rn
->info
;
13238 if (bdistance
->access_list
)
13239 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13240 bgp_distance_free (bdistance
);
13243 bgp_unlock_node (rn
);
13244 bgp_unlock_node (rn
);
13246 return CMD_SUCCESS
;
13249 /* Apply BGP information to distance method. */
13251 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
13253 struct bgp_node
*rn
;
13254 struct prefix_ipv4 q
;
13256 struct bgp_distance
*bdistance
;
13257 struct access_list
*alist
;
13258 struct bgp_static
*bgp_static
;
13263 if (p
->family
!= AF_INET
)
13266 peer
= rinfo
->peer
;
13268 if (peer
->su
.sa
.sa_family
!= AF_INET
)
13271 memset (&q
, 0, sizeof (struct prefix_ipv4
));
13272 q
.family
= AF_INET
;
13273 q
.prefix
= peer
->su
.sin
.sin_addr
;
13274 q
.prefixlen
= IPV4_MAX_BITLEN
;
13276 /* Check source address. */
13277 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
13280 bdistance
= rn
->info
;
13281 bgp_unlock_node (rn
);
13283 if (bdistance
->access_list
)
13285 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
13286 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13287 return bdistance
->distance
;
13290 return bdistance
->distance
;
13293 /* Backdoor check. */
13294 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
13297 bgp_static
= rn
->info
;
13298 bgp_unlock_node (rn
);
13300 if (bgp_static
->backdoor
)
13302 if (bgp
->distance_local
)
13303 return bgp
->distance_local
;
13305 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13309 if (peer
->sort
== BGP_PEER_EBGP
)
13311 if (bgp
->distance_ebgp
)
13312 return bgp
->distance_ebgp
;
13313 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
13317 if (bgp
->distance_ibgp
)
13318 return bgp
->distance_ibgp
;
13319 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13323 DEFUN (bgp_distance
,
13325 "distance bgp <1-255> <1-255> <1-255>",
13326 "Define an administrative distance\n"
13328 "Distance for routes external to the AS\n"
13329 "Distance for routes internal to the AS\n"
13330 "Distance for local routes\n")
13336 bgp
->distance_ebgp
= atoi (argv
[0]);
13337 bgp
->distance_ibgp
= atoi (argv
[1]);
13338 bgp
->distance_local
= atoi (argv
[2]);
13339 return CMD_SUCCESS
;
13342 DEFUN (no_bgp_distance
,
13343 no_bgp_distance_cmd
,
13344 "no distance bgp <1-255> <1-255> <1-255>",
13346 "Define an administrative distance\n"
13348 "Distance for routes external to the AS\n"
13349 "Distance for routes internal to the AS\n"
13350 "Distance for local routes\n")
13356 bgp
->distance_ebgp
= 0;
13357 bgp
->distance_ibgp
= 0;
13358 bgp
->distance_local
= 0;
13359 return CMD_SUCCESS
;
13362 ALIAS (no_bgp_distance
,
13363 no_bgp_distance2_cmd
,
13366 "Define an administrative distance\n"
13369 DEFUN (bgp_distance_source
,
13370 bgp_distance_source_cmd
,
13371 "distance <1-255> A.B.C.D/M",
13372 "Define an administrative distance\n"
13373 "Administrative distance\n"
13374 "IP source prefix\n")
13376 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
13377 return CMD_SUCCESS
;
13380 DEFUN (no_bgp_distance_source
,
13381 no_bgp_distance_source_cmd
,
13382 "no distance <1-255> A.B.C.D/M",
13384 "Define an administrative distance\n"
13385 "Administrative distance\n"
13386 "IP source prefix\n")
13388 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
13389 return CMD_SUCCESS
;
13392 DEFUN (bgp_distance_source_access_list
,
13393 bgp_distance_source_access_list_cmd
,
13394 "distance <1-255> A.B.C.D/M WORD",
13395 "Define an administrative distance\n"
13396 "Administrative distance\n"
13397 "IP source prefix\n"
13398 "Access list name\n")
13400 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
13401 return CMD_SUCCESS
;
13404 DEFUN (no_bgp_distance_source_access_list
,
13405 no_bgp_distance_source_access_list_cmd
,
13406 "no distance <1-255> A.B.C.D/M WORD",
13408 "Define an administrative distance\n"
13409 "Administrative distance\n"
13410 "IP source prefix\n"
13411 "Access list name\n")
13413 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
13414 return CMD_SUCCESS
;
13417 DEFUN (bgp_damp_set
,
13419 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
13420 "BGP Specific commands\n"
13421 "Enable route-flap dampening\n"
13422 "Half-life time for the penalty\n"
13423 "Value to start reusing a route\n"
13424 "Value to start suppressing a route\n"
13425 "Maximum duration to suppress a stable route\n")
13428 int half
= DEFAULT_HALF_LIFE
* 60;
13429 int reuse
= DEFAULT_REUSE
;
13430 int suppress
= DEFAULT_SUPPRESS
;
13431 int max
= 4 * half
;
13435 half
= atoi (argv
[0]) * 60;
13436 reuse
= atoi (argv
[1]);
13437 suppress
= atoi (argv
[2]);
13438 max
= atoi (argv
[3]) * 60;
13440 else if (argc
== 1)
13442 half
= atoi (argv
[0]) * 60;
13447 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
13448 half
, reuse
, suppress
, max
);
13451 ALIAS (bgp_damp_set
,
13453 "bgp dampening <1-45>",
13454 "BGP Specific commands\n"
13455 "Enable route-flap dampening\n"
13456 "Half-life time for the penalty\n")
13458 ALIAS (bgp_damp_set
,
13461 "BGP Specific commands\n"
13462 "Enable route-flap dampening\n")
13464 DEFUN (bgp_damp_unset
,
13465 bgp_damp_unset_cmd
,
13466 "no bgp dampening",
13468 "BGP Specific commands\n"
13469 "Enable route-flap dampening\n")
13474 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
13477 ALIAS (bgp_damp_unset
,
13478 bgp_damp_unset2_cmd
,
13479 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
13481 "BGP Specific commands\n"
13482 "Enable route-flap dampening\n"
13483 "Half-life time for the penalty\n"
13484 "Value to start reusing a route\n"
13485 "Value to start suppressing a route\n"
13486 "Maximum duration to suppress a stable route\n")
13488 ALIAS (bgp_damp_unset
,
13489 bgp_damp_unset3_cmd
,
13490 "no bgp dampening <1-45>",
13492 "BGP Specific commands\n"
13493 "Enable route-flap dampening\n"
13494 "Half-life time for the penalty\n")
13496 DEFUN (show_ip_bgp_dampened_paths
,
13497 show_ip_bgp_dampened_paths_cmd
,
13498 "show ip bgp dampened-paths",
13502 "Display paths suppressed due to dampening\n")
13504 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
13508 DEFUN (show_ip_bgp_flap_statistics
,
13509 show_ip_bgp_flap_statistics_cmd
,
13510 "show ip bgp flap-statistics",
13514 "Display flap statistics of routes\n")
13516 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
13517 bgp_show_type_flap_statistics
, NULL
, 0);
13520 /* Display specified route of BGP table. */
13522 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
13523 const char *ip_str
, afi_t afi
, safi_t safi
,
13524 struct prefix_rd
*prd
, int prefix_check
)
13527 struct prefix match
;
13528 struct bgp_node
*rn
;
13529 struct bgp_node
*rm
;
13530 struct bgp_info
*ri
;
13531 struct bgp_info
*ri_temp
;
13533 struct bgp_table
*table
;
13535 /* BGP structure lookup. */
13538 bgp
= bgp_lookup_by_name (view_name
);
13541 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
13542 return CMD_WARNING
;
13547 bgp
= bgp_get_default ();
13550 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
13551 return CMD_WARNING
;
13555 /* Check IP address argument. */
13556 ret
= str2prefix (ip_str
, &match
);
13559 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
13560 return CMD_WARNING
;
13563 match
.family
= afi2family (afi
);
13565 if (safi
== SAFI_MPLS_VPN
)
13567 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
13569 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
13572 if ((table
= rn
->info
) != NULL
)
13573 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
13575 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
13580 if (ri
->extra
&& ri
->extra
->damp_info
)
13582 ri_temp
= ri
->next
;
13583 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
13591 bgp_unlock_node (rm
);
13597 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
13599 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
13604 if (ri
->extra
&& ri
->extra
->damp_info
)
13606 ri_temp
= ri
->next
;
13607 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
13615 bgp_unlock_node (rn
);
13619 return CMD_SUCCESS
;
13622 DEFUN (clear_ip_bgp_dampening
,
13623 clear_ip_bgp_dampening_cmd
,
13624 "clear ip bgp dampening",
13628 "Clear route flap dampening information\n")
13630 bgp_damp_info_clean ();
13631 return CMD_SUCCESS
;
13634 DEFUN (clear_ip_bgp_dampening_prefix
,
13635 clear_ip_bgp_dampening_prefix_cmd
,
13636 "clear ip bgp dampening A.B.C.D/M",
13640 "Clear route flap dampening information\n"
13641 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13643 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
13644 SAFI_UNICAST
, NULL
, 1);
13647 DEFUN (clear_ip_bgp_dampening_address
,
13648 clear_ip_bgp_dampening_address_cmd
,
13649 "clear ip bgp dampening A.B.C.D",
13653 "Clear route flap dampening information\n"
13654 "Network to clear damping information\n")
13656 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
13657 SAFI_UNICAST
, NULL
, 0);
13660 DEFUN (clear_ip_bgp_dampening_address_mask
,
13661 clear_ip_bgp_dampening_address_mask_cmd
,
13662 "clear ip bgp dampening A.B.C.D A.B.C.D",
13666 "Clear route flap dampening information\n"
13667 "Network to clear damping information\n"
13671 char prefix_str
[BUFSIZ
];
13673 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
13676 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
13677 return CMD_WARNING
;
13680 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
13681 SAFI_UNICAST
, NULL
, 0);
13685 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
13686 afi_t afi
, safi_t safi
, int *write
)
13688 struct bgp_node
*prn
;
13689 struct bgp_node
*rn
;
13690 struct bgp_table
*table
;
13692 struct prefix_rd
*prd
;
13693 struct bgp_static
*bgp_static
;
13695 char buf
[SU_ADDRSTRLEN
];
13696 char rdbuf
[RD_ADDRSTRLEN
];
13698 /* Network configuration. */
13699 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
13700 if ((table
= prn
->info
) != NULL
)
13701 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
13702 if ((bgp_static
= rn
->info
) != NULL
)
13705 prd
= (struct prefix_rd
*) &prn
->p
;
13707 /* "address-family" display. */
13708 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13710 /* "network" configuration display. */
13711 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
13712 label
= decode_label (bgp_static
->tag
);
13714 vty_out (vty
, " network %s/%d rd %s tag %d",
13715 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13718 vty_out (vty
, "%s", VTY_NEWLINE
);
13723 /* Configuration of static route announcement and aggregate
13726 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
13727 afi_t afi
, safi_t safi
, int *write
)
13729 struct bgp_node
*rn
;
13731 struct bgp_static
*bgp_static
;
13732 struct bgp_aggregate
*bgp_aggregate
;
13733 char buf
[SU_ADDRSTRLEN
];
13735 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
13736 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
13738 /* Network configuration. */
13739 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
13740 if ((bgp_static
= rn
->info
) != NULL
)
13744 /* "address-family" display. */
13745 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13747 /* "network" configuration display. */
13748 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
13750 u_int32_t destination
;
13751 struct in_addr netmask
;
13753 destination
= ntohl (p
->u
.prefix4
.s_addr
);
13754 masklen2ip (p
->prefixlen
, &netmask
);
13755 vty_out (vty
, " network %s",
13756 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
13758 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
13759 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
13760 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
13761 || p
->u
.prefix4
.s_addr
== 0)
13763 /* Natural mask is not display. */
13766 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
13770 vty_out (vty
, " network %s/%d",
13771 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13775 if (bgp_static
->rmap
.name
)
13776 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
13779 if (bgp_static
->backdoor
)
13780 vty_out (vty
, " backdoor");
13783 vty_out (vty
, "%s", VTY_NEWLINE
);
13786 /* Aggregate-address configuration. */
13787 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
13788 if ((bgp_aggregate
= rn
->info
) != NULL
)
13792 /* "address-family" display. */
13793 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13795 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
13797 struct in_addr netmask
;
13799 masklen2ip (p
->prefixlen
, &netmask
);
13800 vty_out (vty
, " aggregate-address %s %s",
13801 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13802 inet_ntoa (netmask
));
13806 vty_out (vty
, " aggregate-address %s/%d",
13807 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13811 if (bgp_aggregate
->as_set
)
13812 vty_out (vty
, " as-set");
13814 if (bgp_aggregate
->summary_only
)
13815 vty_out (vty
, " summary-only");
13817 vty_out (vty
, "%s", VTY_NEWLINE
);
13824 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
13826 struct bgp_node
*rn
;
13827 struct bgp_distance
*bdistance
;
13829 /* Distance configuration. */
13830 if (bgp
->distance_ebgp
13831 && bgp
->distance_ibgp
13832 && bgp
->distance_local
13833 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
13834 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
13835 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
13836 vty_out (vty
, " distance bgp %d %d %d%s",
13837 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
13840 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
13841 if ((bdistance
= rn
->info
) != NULL
)
13843 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
13844 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
13845 bdistance
->access_list
? bdistance
->access_list
: "",
13852 /* Allocate routing table structure and install commands. */
13854 bgp_route_init (void)
13856 /* Init BGP distance table. */
13857 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
13859 /* IPv4 BGP commands. */
13860 install_element (BGP_NODE
, &bgp_table_map_cmd
);
13861 install_element (BGP_NODE
, &bgp_network_cmd
);
13862 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
13863 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
13864 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
13865 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
13866 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
13867 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
13868 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
13869 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
13870 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
13871 install_element (BGP_NODE
, &no_bgp_network_cmd
);
13872 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
13873 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
13874 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
13875 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
13876 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
13877 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
13878 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
13879 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
13881 install_element (BGP_NODE
, &aggregate_address_cmd
);
13882 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
13883 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
13884 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
13885 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
13886 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
13887 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
13888 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
13889 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
13890 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
13891 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
13892 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
13893 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
13894 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
13895 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
13896 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
13897 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
13898 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
13899 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
13900 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
13902 /* IPv4 unicast configuration. */
13903 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
13904 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
13905 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
13906 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
13907 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
13908 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
13909 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
13910 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
13911 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
13912 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
13913 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
13914 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
13915 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
13916 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
13918 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
13919 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
13920 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
13921 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
13922 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
13923 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
13924 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
13925 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
13926 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
13927 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
13928 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
13929 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
13930 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
13931 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
13932 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
13933 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
13934 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
13935 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
13936 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
13937 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
13939 /* IPv4 multicast configuration. */
13940 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
13941 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
13942 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
13943 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
13944 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
13945 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
13946 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
13947 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
13948 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
13949 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
13950 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
13951 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
13952 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
13953 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
13954 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
13955 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
13956 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
13957 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
13958 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
13959 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
13960 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
13961 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
13962 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
13963 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
13964 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
13965 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
13966 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
13967 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
13968 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
13969 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
13970 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
13971 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
13972 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
13973 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
13975 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
13976 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
13977 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
13978 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
13979 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
13980 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
13981 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
13982 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
13983 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
13984 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
13985 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
13986 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
13987 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
13988 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
13989 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
13990 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
13991 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
13992 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
13993 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
13994 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
13995 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
13996 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
13997 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
13999 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14000 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14001 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14002 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14003 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14004 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14005 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14006 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14007 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14008 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14009 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14010 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14011 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14012 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14013 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14014 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14015 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14016 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14017 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14018 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14019 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14020 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14021 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14022 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14023 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14024 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14025 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14026 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14027 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14028 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14029 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14030 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14031 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14032 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14033 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14034 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14035 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14036 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14037 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14038 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14039 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14040 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14041 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14042 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14043 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14044 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14045 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14046 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14047 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14048 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14049 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14050 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14051 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14052 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14053 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14054 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14055 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14056 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14057 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14058 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14059 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14060 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14061 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14062 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14063 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14064 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14065 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14066 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14067 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14068 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14069 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14070 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14071 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14072 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14074 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
14075 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
14076 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14077 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14078 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14079 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14080 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14081 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14082 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14083 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
14084 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14085 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14086 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14087 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14088 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14089 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14090 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14091 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14092 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14093 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14094 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14095 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
14096 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
14097 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
14098 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
14099 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14100 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14101 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14102 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14103 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14104 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14105 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14106 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14107 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14108 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
14109 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
14110 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
14111 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
14112 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14113 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14114 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14115 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14117 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
14118 install_element (ENABLE_NODE
, &show_ip_bgp_instance_cmd
);
14119 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
14120 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
14121 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
14122 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_cmd
);
14123 install_element (ENABLE_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14124 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14125 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14126 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14127 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14128 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14129 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14130 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
14131 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14132 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14133 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14134 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14135 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14136 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14137 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14138 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14139 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14141 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
14142 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14143 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
14144 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14145 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14146 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
14147 install_element (ENABLE_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14148 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14149 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
14150 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14151 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14152 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
14153 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14154 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
14155 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14156 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
14157 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
14158 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
14159 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
14160 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14161 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14162 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14163 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14164 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14165 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14166 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14167 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14168 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14169 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
14170 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
14171 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
14172 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
14173 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14174 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14175 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14176 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14177 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
14178 install_element (ENABLE_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14179 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14180 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14181 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14182 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14183 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14184 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14185 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14186 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14187 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14188 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14189 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14190 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14191 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14192 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14193 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14194 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14195 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14196 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14197 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14198 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14199 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14200 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14201 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14202 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14203 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14204 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14205 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
14206 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14207 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14208 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14209 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14210 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14211 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14212 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14213 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14214 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14216 /* BGP dampening clear commands */
14217 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14218 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14219 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14220 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14223 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14224 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14225 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14226 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
14228 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14229 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14231 /* New config IPv6 BGP commands. */
14232 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14233 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14234 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14235 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14236 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14237 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14239 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14240 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14241 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14242 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14244 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14245 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14247 /* Old config IPv6 BGP commands. */
14248 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14249 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14251 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14252 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14253 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14254 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14256 install_element (VIEW_NODE
, &show_bgp_cmd
);
14257 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14258 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14259 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14260 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14261 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14262 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14263 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14264 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14265 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14266 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14267 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14268 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14269 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14270 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14271 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14272 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14273 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14274 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14275 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14276 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14277 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14278 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14279 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14280 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14281 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14282 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14283 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14284 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14285 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14286 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14287 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14288 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14289 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14290 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14291 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14292 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14293 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14294 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14295 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14296 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14297 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14298 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14299 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14300 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14301 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14302 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14303 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14304 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14305 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14306 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14307 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14308 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14309 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14310 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14311 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14312 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14313 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14314 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14315 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14316 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14317 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14318 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14319 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14320 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14321 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14322 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14323 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14324 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14325 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14326 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14327 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14328 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14329 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14330 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14331 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14332 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14333 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14334 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14335 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14336 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14337 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14338 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14339 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14340 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14341 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14342 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14343 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14344 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14345 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14346 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14349 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
14351 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
14352 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
14353 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14354 install_element (RESTRICTED_NODE
, &show_bgp_route_pathtype_cmd
);
14355 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14356 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14357 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
14358 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
14359 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14360 install_element (RESTRICTED_NODE
, &show_bgp_prefix_pathtype_cmd
);
14361 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14362 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14363 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
14364 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
14365 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
14366 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
14367 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
14368 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
14369 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
14370 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
14371 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
14372 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14373 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
14374 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14375 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
14376 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14377 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
14378 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14379 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_cmd
);
14380 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14381 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14382 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14383 install_element (RESTRICTED_NODE
, &show_bgp_instance_prefix_cmd
);
14384 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14385 install_element (RESTRICTED_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14386 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14388 install_element (ENABLE_NODE
, &show_bgp_cmd
);
14389 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
14390 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
14391 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
14392 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
14393 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14394 install_element (ENABLE_NODE
, &show_bgp_route_pathtype_cmd
);
14395 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14396 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14397 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
14398 install_element (ENABLE_NODE
, &show_bgp_prefix_pathtype_cmd
);
14399 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14400 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14401 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
14402 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14403 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
14404 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
14405 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
14406 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14407 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
14408 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14409 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
14410 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
14411 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
14412 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
14413 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
14414 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
14415 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
14416 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
14417 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
14418 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
14419 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
14420 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
14421 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
14422 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14423 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
14424 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14425 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
14426 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14427 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
14428 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14429 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
14430 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
14431 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
14432 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14433 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
14434 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14435 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14436 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14437 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14438 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14439 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
14440 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14441 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14442 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14443 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
14444 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14445 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
14446 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14447 install_element (ENABLE_NODE
, &show_bgp_instance_cmd
);
14448 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_cmd
);
14449 install_element (ENABLE_NODE
, &show_bgp_instance_route_cmd
);
14450 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14451 install_element (ENABLE_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14452 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14453 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_cmd
);
14454 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14455 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14456 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14457 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_list_cmd
);
14458 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14459 install_element (ENABLE_NODE
, &show_bgp_instance_filter_list_cmd
);
14460 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14461 install_element (ENABLE_NODE
, &show_bgp_instance_route_map_cmd
);
14462 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14463 install_element (ENABLE_NODE
, &show_bgp_instance_community_list_cmd
);
14464 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14465 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14466 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14467 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14468 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14469 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14470 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14471 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14472 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14473 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14474 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14475 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14476 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14477 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14478 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14481 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
14482 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
14483 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
14484 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
14487 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
14488 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
14489 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
14490 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
14491 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14492 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14493 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
14494 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
14495 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
14496 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
14497 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
14498 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14499 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14500 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14501 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14502 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
14503 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14504 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14505 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
14506 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
14507 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14508 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14509 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14510 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14511 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14512 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
14513 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
14514 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
14515 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
14516 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14517 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14518 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14519 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
14520 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
14521 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
14522 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14525 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
14526 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
14527 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
14528 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
14529 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14530 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14531 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
14532 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
14533 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
14534 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
14535 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
14536 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14537 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14538 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14539 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14540 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
14541 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14542 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14543 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
14544 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
14545 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14546 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14547 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14548 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14549 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14550 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
14551 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
14552 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
14553 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
14554 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14555 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14556 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14557 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
14558 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
14559 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
14560 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14563 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14564 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14565 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14566 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14569 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14570 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14571 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14572 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14575 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14576 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14577 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14578 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14579 #endif /* HAVE_IPV6 */
14581 install_element (BGP_NODE
, &bgp_distance_cmd
);
14582 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
14583 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
14584 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
14585 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
14586 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
14587 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
14589 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
14590 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
14591 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
14592 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
14593 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
14594 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
14595 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
14596 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
14597 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
14598 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
14599 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
14600 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
14604 bgp_route_finish (void)
14606 bgp_table_unlock (bgp_distance_table
);
14607 bgp_distance_table
= NULL
;