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 /* locally configured routes to advertise do not have su_remote */
807 if (new->peer
->su_remote
== NULL
)
809 if (exist
->peer
->su_remote
== NULL
)
812 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
817 zlog_debug("%s: %s loses to %s due to Neighor IP comparison",
818 pfx_buf
, new_buf
, exist_buf
);
825 zlog_debug("%s: %s wins over %s due to Neighor IP comparison",
826 pfx_buf
, new_buf
, exist_buf
);
831 zlog_debug("%s: %s wins over %s due to nothing left to compare",
832 pfx_buf
, new_buf
, exist_buf
);
837 static enum filter_type
838 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
839 afi_t afi
, safi_t safi
)
841 struct bgp_filter
*filter
;
843 filter
= &peer
->filter
[afi
][safi
];
845 #define FILTER_EXIST_WARN(F,f,filter) \
846 if (BGP_DEBUG (update, UPDATE_IN) \
847 && !(F ## _IN (filter))) \
848 zlog_warn ("%s: Could not find configured input %s-list %s!", \
849 peer->host, #f, F ## _IN_NAME(filter));
851 if (DISTRIBUTE_IN_NAME (filter
)) {
852 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
854 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
858 if (PREFIX_LIST_IN_NAME (filter
)) {
859 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
861 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
865 if (FILTER_LIST_IN_NAME (filter
)) {
866 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
868 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
872 return FILTER_PERMIT
;
873 #undef FILTER_EXIST_WARN
876 static enum filter_type
877 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
878 afi_t afi
, safi_t safi
)
880 struct bgp_filter
*filter
;
882 filter
= &peer
->filter
[afi
][safi
];
884 #define FILTER_EXIST_WARN(F,f,filter) \
885 if (BGP_DEBUG (update, UPDATE_OUT) \
886 && !(F ## _OUT (filter))) \
887 zlog_warn ("%s: Could not find configured output %s-list %s!", \
888 peer->host, #f, F ## _OUT_NAME(filter));
890 if (DISTRIBUTE_OUT_NAME (filter
)) {
891 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
893 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
897 if (PREFIX_LIST_OUT_NAME (filter
)) {
898 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
900 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
904 if (FILTER_LIST_OUT_NAME (filter
)) {
905 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
907 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
911 return FILTER_PERMIT
;
912 #undef FILTER_EXIST_WARN
915 /* If community attribute includes no_export then return 1. */
917 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
921 /* NO_ADVERTISE check. */
922 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
925 /* NO_EXPORT check. */
926 if (peer
->sort
== BGP_PEER_EBGP
&&
927 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
930 /* NO_EXPORT_SUBCONFED check. */
931 if (peer
->sort
== BGP_PEER_EBGP
932 || peer
->sort
== BGP_PEER_CONFED
)
933 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
939 /* Route reflection loop check. */
941 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
943 struct in_addr cluster_id
;
945 if (attr
->extra
&& attr
->extra
->cluster
)
947 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
948 cluster_id
= peer
->bgp
->cluster_id
;
950 cluster_id
= peer
->bgp
->router_id
;
952 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
959 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
960 afi_t afi
, safi_t safi
, const char *rmap_name
)
962 struct bgp_filter
*filter
;
963 struct bgp_info info
;
964 route_map_result_t ret
;
965 struct route_map
*rmap
= NULL
;
967 filter
= &peer
->filter
[afi
][safi
];
969 /* Apply default weight value. */
971 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
975 rmap
= route_map_lookup_by_name(rmap_name
);
982 if (ROUTE_MAP_IN_NAME(filter
))
984 rmap
= ROUTE_MAP_IN (filter
);
991 /* Route map apply. */
994 /* Duplicate current value to new strucutre for modification. */
998 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
1000 /* Apply BGP route map to the attribute. */
1001 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1003 peer
->rmap_type
= 0;
1005 if (ret
== RMAP_DENYMATCH
)
1007 /* Free newly generated AS path and community by route-map. */
1008 bgp_attr_flush (attr
);
1016 bgp_output_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1017 afi_t afi
, safi_t safi
, const char *rmap_name
)
1019 struct bgp_filter
*filter
;
1020 struct bgp_info info
;
1021 route_map_result_t ret
;
1022 struct route_map
*rmap
= NULL
;
1024 filter
= &peer
->filter
[afi
][safi
];
1026 /* Apply default weight value. */
1028 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
;
1032 rmap
= route_map_lookup_by_name(rmap_name
);
1039 if (ROUTE_MAP_OUT_NAME(filter
))
1041 rmap
= ROUTE_MAP_OUT (filter
);
1048 /* Route map apply. */
1051 /* Duplicate current value to new strucutre for modification. */
1055 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1057 /* Apply BGP route map to the attribute. */
1058 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1060 peer
->rmap_type
= 0;
1062 if (ret
== RMAP_DENYMATCH
)
1063 /* caller has multiple error paths with bgp_attr_flush() */
1069 /* If this is an EBGP peer with remove-private-AS */
1071 bgp_peer_remove_private_as(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1072 struct peer
*peer
, struct attr
*attr
)
1074 if (peer
->sort
== BGP_PEER_EBGP
&&
1075 (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_REPLACE
) ||
1077 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
) ||
1078 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)))
1080 // Take action on the entire aspath
1081 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1082 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
1084 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
1085 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1087 // The entire aspath consists of private ASNs so create an empty aspath
1088 else if (aspath_private_as_check (attr
->aspath
))
1089 attr
->aspath
= aspath_empty_get ();
1091 // There are some public and some private ASNs, remove the private ASNs
1093 attr
->aspath
= aspath_remove_private_asns (attr
->aspath
);
1096 // 'all' was not specified so the entire aspath must be private ASNs
1097 // for us to do anything
1098 else if (aspath_private_as_check (attr
->aspath
))
1100 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
1101 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1103 attr
->aspath
= aspath_empty_get ();
1108 /* If this is an EBGP peer with as-override */
1110 bgp_peer_as_override(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1111 struct peer
*peer
, struct attr
*attr
)
1113 if (peer
->sort
== BGP_PEER_EBGP
&&
1114 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
))
1116 if (aspath_single_asn_check (attr
->aspath
, peer
->as
))
1117 attr
->aspath
= aspath_replace_specific_asn (attr
->aspath
, peer
->as
, bgp
->as
);
1122 subgroup_announce_reset_nhop (u_char family
, struct attr
*attr
)
1124 if (family
== AF_INET
)
1125 attr
->nexthop
.s_addr
= 0;
1127 if (family
== AF_INET6
)
1128 memset (&attr
->extra
->mp_nexthop_global
, 0, IPV6_MAX_BYTELEN
);
1133 subgroup_announce_check (struct bgp_info
*ri
, struct update_subgroup
*subgrp
,
1134 struct prefix
*p
, struct attr
*attr
)
1136 struct bgp_filter
*filter
;
1139 struct peer
*onlypeer
;
1141 struct attr
*riattr
;
1142 struct peer_af
*paf
;
1143 char buf
[SU_ADDRSTRLEN
];
1150 if (DISABLE_BGP_ANNOUNCE
)
1153 afi
= SUBGRP_AFI(subgrp
);
1154 safi
= SUBGRP_SAFI(subgrp
);
1155 peer
= SUBGRP_PEER(subgrp
);
1157 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_LONESOUL
))
1158 onlypeer
= SUBGRP_PFIRST(subgrp
)->peer
;
1161 filter
= &peer
->filter
[afi
][safi
];
1162 bgp
= SUBGRP_INST(subgrp
);
1163 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
1165 /* With addpath we may be asked to TX all kinds of paths so make sure
1167 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
) ||
1168 CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
) ||
1169 CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
1174 /* If this is not the bestpath then check to see if there is an enabled addpath
1175 * feature that requires us to advertise it */
1176 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1178 if (! bgp_addpath_tx_path(peer
, afi
, safi
, ri
))
1184 /* Aggregate-address suppress check. */
1185 if (ri
->extra
&& ri
->extra
->suppress
)
1186 if (! UNSUPPRESS_MAP_NAME (filter
))
1191 /* Do not send back route to sender. */
1192 if (onlypeer
&& from
== onlypeer
)
1197 /* Do not send the default route in the BGP table if the neighbor is
1198 * configured for default-originate */
1199 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
1201 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1204 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1206 #endif /* HAVE_IPV6 */
1209 /* Transparency check. */
1210 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
1211 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
1216 /* If community is not disabled check the no-export and local. */
1217 if (! transparent
&& bgp_community_filter (peer
, riattr
))
1219 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1220 zlog_debug ("subgrpannouncecheck: community filter check fail");
1224 /* If the attribute has originator-id and it is same as remote
1227 riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
) &&
1228 (IPV4_ADDR_SAME (&onlypeer
->remote_id
, &riattr
->extra
->originator_id
)))
1230 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1231 zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as "
1234 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1239 /* ORF prefix-list filter check */
1240 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1241 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1242 || CHECK_FLAG (peer
->af_cap
[afi
][safi
],
1243 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1244 if (peer
->orf_plist
[afi
][safi
])
1246 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1248 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1249 zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF",
1251 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1257 /* Output filter check. */
1258 if (bgp_output_filter (peer
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
1260 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1261 zlog_debug ("%s [Update:SEND] %s/%d is filtered",
1263 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1268 #ifdef BGP_SEND_ASPATH_CHECK
1269 /* AS path loop check. */
1270 if (onlypeer
&& aspath_loop_check (riattr
->aspath
, onlypeer
->as
))
1272 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1273 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u "
1274 "that is part of AS path.",
1275 onlypeer
->host
, onlypeer
->as
);
1278 #endif /* BGP_SEND_ASPATH_CHECK */
1280 /* If we're a CONFED we need to loop check the CONFED ID too */
1281 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
1283 if (aspath_loop_check(riattr
->aspath
, bgp
->confed_id
))
1285 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1286 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u"
1294 /* Route-Reflect check. */
1295 if (from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1300 /* IBGP reflection check. */
1303 /* A route from a Client peer. */
1304 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
1306 /* Reflect to all the Non-Client peers and also to the
1307 Client peers other than the originator. Originator check
1308 is already done. So there is noting to do. */
1309 /* no bgp client-to-client reflection check. */
1310 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
1311 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1312 PEER_FLAG_REFLECTOR_CLIENT
))
1317 /* A route from a Non-client peer. Reflect to all other
1319 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1320 PEER_FLAG_REFLECTOR_CLIENT
))
1325 /* For modify attribute, copy it to temporary structure. */
1326 bgp_attr_dup (attr
, riattr
);
1328 /* If local-preference is not set. */
1329 if ((peer
->sort
== BGP_PEER_IBGP
1330 || peer
->sort
== BGP_PEER_CONFED
)
1331 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
1333 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1334 attr
->local_pref
= bgp
->default_local_pref
;
1337 /* If originator-id is not set and the route is to be reflected,
1338 set the originator id */
1339 if (reflect
&& (!(attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))))
1341 attr
->extra
= bgp_attr_extra_get(attr
);
1342 IPV4_ADDR_COPY(&(attr
->extra
->originator_id
), &(from
->remote_id
));
1343 SET_FLAG(attr
->flag
, BGP_ATTR_ORIGINATOR_ID
);
1346 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
1347 if (peer
->sort
== BGP_PEER_EBGP
1348 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
1350 if (from
!= bgp
->peer_self
&& ! transparent
1351 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
1352 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
1355 /* Since the nexthop attribute can vary per peer, it is not explicitly set
1356 * in announce check, only certain flags and length (or number of nexthops
1357 * -- for IPv6/MP_REACH) are set here in order to guide the update formation
1358 * code in setting the nexthop(s) on a per peer basis in reformat_peer().
1359 * Typically, the source nexthop in the attribute is preserved but in the
1360 * scenarios where we know it will always be overwritten, we reset the
1361 * nexthop to "0" in an attempt to achieve better Update packing. An
1362 * example of this is when a prefix from each of 2 IBGP peers needs to be
1363 * announced to an EBGP peer (and they have the same attributes barring
1367 SET_FLAG(attr
->rmap_change_flags
, BATTR_REFLECTED
);
1370 /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
1371 * the peer (group) is configured to receive link-local nexthop unchanged
1372 * and it is available in the prefix OR we're not reflecting the route and
1373 * the peer (group) to whom we're going to announce is on a shared network
1374 * and this is either a self-originated route or the peer is EBGP.
1376 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1378 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
1379 if ((CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1380 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) &&
1381 IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
)) ||
1382 (!reflect
&& peer
->shared_network
&&
1383 (from
== bgp
->peer_self
|| peer
->sort
== BGP_PEER_EBGP
)))
1385 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
1388 /* Clear off link-local nexthop in source, whenever it is not needed to
1389 * ensure more prefixes share the same attribute for announcement.
1391 if (!(CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1392 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)))
1393 memset (&attr
->extra
->mp_nexthop_local
, 0, IPV6_MAX_BYTELEN
);
1395 #endif /* HAVE_IPV6 */
1397 bgp_peer_remove_private_as(bgp
, afi
, safi
, peer
, attr
);
1398 bgp_peer_as_override(bgp
, afi
, safi
, peer
, attr
);
1400 /* Route map & unsuppress-map apply. */
1401 if (ROUTE_MAP_OUT_NAME (filter
)
1402 || (ri
->extra
&& ri
->extra
->suppress
) )
1404 struct bgp_info info
;
1405 struct attr dummy_attr
;
1406 struct attr_extra dummy_extra
;
1408 dummy_attr
.extra
= &dummy_extra
;
1412 /* don't confuse inbound and outbound setting */
1413 RESET_FLAG(attr
->rmap_change_flags
);
1416 * The route reflector is not allowed to modify the attributes
1417 * of the reflected IBGP routes unless explicitly allowed.
1419 if ((from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1420 && !bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
))
1422 bgp_attr_dup (&dummy_attr
, attr
);
1423 info
.attr
= &dummy_attr
;
1426 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1428 if (ri
->extra
&& ri
->extra
->suppress
)
1429 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1431 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1433 peer
->rmap_type
= 0;
1435 if (ret
== RMAP_DENYMATCH
)
1437 bgp_attr_flush (attr
);
1442 /* After route-map has been applied, we check to see if the nexthop to
1443 * be carried in the attribute (that is used for the announcement) can
1444 * be cleared off or not. We do this in all cases where we would be
1445 * setting the nexthop to "ourselves". For IPv6, we only need to consider
1446 * the global nexthop here; the link-local nexthop would have been cleared
1447 * already, and if not, it is required by the update formation code.
1448 * Also see earlier comments in this function.
1451 * If route-map has performed some operation on the nexthop or the peer
1452 * configuration says to pass it unchanged, we cannot reset the nexthop
1453 * here, so only attempt to do it if these aren't true. Note that the
1454 * route-map handler itself might have cleared the nexthop, if for example,
1455 * it is configured as 'peer-address'.
1457 if (!bgp_rmap_nhop_changed(attr
->rmap_change_flags
,
1458 riattr
->rmap_change_flags
) &&
1460 !CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
))
1462 /* We can reset the nexthop, if setting (or forcing) it to 'self' */
1463 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
) ||
1464 CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_FORCE_NEXTHOP_SELF
))
1467 CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1468 PEER_FLAG_FORCE_NEXTHOP_SELF
))
1469 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ?
1470 AF_INET6
: p
->family
), attr
);
1472 else if (peer
->sort
== BGP_PEER_EBGP
)
1474 /* Can also reset the nexthop if announcing to EBGP, but only if
1475 * no peer in the subgroup is on a shared subnet.
1476 * Note: 3rd party nexthop currently implemented for IPv4 only.
1478 SUBGRP_FOREACH_PEER (subgrp
, paf
)
1480 if (bgp_multiaccess_check_v4 (riattr
->nexthop
, paf
->peer
))
1484 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ? AF_INET6
: p
->family
), attr
);
1486 /* If IPv6/MP and nexthop does not have any override and happens to
1487 * be a link-local address, reset it so that we don't pass along the
1488 * source's link-local IPv6 address to recipients who may not be on
1489 * the same interface.
1491 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1493 if (IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_global
))
1494 subgroup_announce_reset_nhop (AF_INET6
, attr
);
1501 struct bgp_info_pair
1503 struct bgp_info
*old
;
1504 struct bgp_info
*new;
1508 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
,
1509 struct bgp_maxpaths_cfg
*mpath_cfg
,
1510 struct bgp_info_pair
*result
)
1512 struct bgp_info
*new_select
;
1513 struct bgp_info
*old_select
;
1514 struct bgp_info
*ri
;
1515 struct bgp_info
*ri1
;
1516 struct bgp_info
*ri2
;
1517 struct bgp_info
*nextri
= NULL
;
1518 int paths_eq
, do_mpath
, debug
;
1519 struct list mp_list
;
1520 char pfx_buf
[PREFIX2STR_BUFFER
];
1521 char path_buf
[PATH_ADDPATH_STR_BUFFER
];
1523 result
->old
= result
->new = NULL
;
1525 if (rn
->info
== NULL
)
1527 char buf
[PREFIX2STR_BUFFER
];
1528 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1530 prefix2str (&(bgp_node_to_rnode (rn
)->p
), buf
, sizeof(buf
)));
1534 bgp_mp_list_init (&mp_list
);
1535 do_mpath
= (mpath_cfg
->maxpaths_ebgp
> 1 || mpath_cfg
->maxpaths_ibgp
> 1);
1537 debug
= bgp_debug_bestpath(&rn
->p
);
1540 prefix2str (&rn
->p
, pfx_buf
, sizeof (pfx_buf
));
1542 /* bgp deterministic-med */
1544 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1547 /* Clear BGP_INFO_DMED_SELECTED for all paths */
1548 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1549 bgp_info_unset_flag (rn
, ri1
, BGP_INFO_DMED_SELECTED
);
1551 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1553 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1555 if (BGP_INFO_HOLDDOWN (ri1
))
1557 if (ri1
->peer
&& ri1
->peer
!= bgp
->peer_self
)
1558 if (ri1
->peer
->status
!= Established
)
1564 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1566 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1568 if (BGP_INFO_HOLDDOWN (ri2
))
1571 ri2
->peer
!= bgp
->peer_self
&&
1572 !CHECK_FLAG (ri2
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1573 if (ri2
->peer
->status
!= Established
)
1576 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1577 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1580 if (bgp_info_cmp (bgp
, ri2
, new_select
, &paths_eq
,
1581 mpath_cfg
, debug
, pfx_buf
))
1583 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1587 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1591 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1592 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1596 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1597 zlog_debug("%s: %s is the bestpath from AS %d",
1598 pfx_buf
, path_buf
, aspath_get_firstas(new_select
->attr
->aspath
));
1603 /* Check old selected route and new selected route. */
1606 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1608 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1611 if (BGP_INFO_HOLDDOWN (ri
))
1613 /* reap REMOVED routes, if needs be
1614 * selected route must stay for a while longer though
1616 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1617 && (ri
!= old_select
))
1618 bgp_info_reap (rn
, ri
);
1624 ri
->peer
!= bgp
->peer_self
&&
1625 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1626 if (ri
->peer
->status
!= Established
)
1629 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1630 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1632 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1636 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1638 if (bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
))
1644 /* Now that we know which path is the bestpath see if any of the other paths
1645 * qualify as multipaths
1647 if (do_mpath
&& new_select
)
1651 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1652 zlog_debug("%s: %s is the bestpath, now find multipaths", pfx_buf
, path_buf
);
1655 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1659 bgp_info_path_with_addpath_rx_str (ri
, path_buf
);
1661 if (ri
== new_select
)
1664 zlog_debug("%s: %s is the bestpath, add to the multipath list",
1666 bgp_mp_list_add (&mp_list
, ri
);
1670 if (BGP_INFO_HOLDDOWN (ri
))
1674 ri
->peer
!= bgp
->peer_self
&&
1675 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1676 if (ri
->peer
->status
!= Established
)
1679 if (!bgp_info_nexthop_cmp (ri
, new_select
))
1682 zlog_debug("%s: %s has the same nexthop as the bestpath, skip it",
1687 bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
);
1692 zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list",
1694 bgp_mp_list_add (&mp_list
, ri
);
1699 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1700 bgp_info_mpath_aggregate_update (new_select
, old_select
);
1701 bgp_mp_list_clear (&mp_list
);
1703 result
->old
= old_select
;
1704 result
->new = new_select
;
1710 * A new route/change in bestpath of an existing route. Evaluate the path
1711 * for advertisement to the subgroup.
1714 subgroup_process_announce_selected (struct update_subgroup
*subgrp
,
1715 struct bgp_info
*selected
,
1716 struct bgp_node
*rn
,
1717 u_int32_t addpath_tx_id
)
1720 struct peer
*onlypeer
;
1722 struct attr_extra extra
;
1727 afi
= SUBGRP_AFI(subgrp
);
1728 safi
= SUBGRP_SAFI(subgrp
);
1729 onlypeer
= ((SUBGRP_PCOUNT(subgrp
) == 1) ?
1730 (SUBGRP_PFIRST(subgrp
))->peer
: NULL
);
1732 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1733 if (onlypeer
&& CHECK_FLAG (onlypeer
->af_sflags
[afi
][safi
],
1734 PEER_STATUS_ORF_WAIT_REFRESH
))
1737 /* It's initialized in bgp_announce_check() */
1738 attr
.extra
= &extra
;
1740 /* Announcement to the subgroup. If the route is filtered withdraw it. */
1743 if (subgroup_announce_check(selected
, subgrp
, p
, &attr
))
1744 bgp_adj_out_set_subgroup(rn
, subgrp
, &attr
, selected
);
1746 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, selected
->addpath_tx_id
);
1749 /* If selected is NULL we must withdraw the path using addpath_tx_id */
1752 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, addpath_tx_id
);
1758 struct bgp_process_queue
1761 struct bgp_node
*rn
;
1766 static wq_item_status
1767 bgp_process_main (struct work_queue
*wq
, void *data
)
1769 struct bgp_process_queue
*pq
= data
;
1770 struct bgp
*bgp
= pq
->bgp
;
1771 struct bgp_node
*rn
= pq
->rn
;
1772 afi_t afi
= pq
->afi
;
1773 safi_t safi
= pq
->safi
;
1774 struct prefix
*p
= &rn
->p
;
1775 struct bgp_info
*new_select
;
1776 struct bgp_info
*old_select
;
1777 struct bgp_info_pair old_and_new
;
1779 /* Is it end of initial update? (after startup) */
1782 quagga_timestamp(3, bgp
->update_delay_zebra_resume_time
,
1783 sizeof(bgp
->update_delay_zebra_resume_time
));
1785 bgp
->main_zebra_update_hold
= 0;
1786 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1787 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1789 bgp_zebra_announce_table(bgp
, afi
, safi
);
1791 bgp
->main_peers_update_hold
= 0;
1793 bgp_start_routeadv(bgp
);
1797 /* Best path selection. */
1798 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1799 old_select
= old_and_new
.old
;
1800 new_select
= old_and_new
.new;
1802 /* Nothing to do. */
1803 if (old_select
&& old_select
== new_select
&&
1804 !CHECK_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
) &&
1805 !CHECK_FLAG(old_select
->flags
, BGP_INFO_ATTR_CHANGED
) &&
1806 !bgp
->addpath_tx_used
[afi
][safi
])
1808 if (CHECK_FLAG (old_select
->flags
, BGP_INFO_IGP_CHANGED
) ||
1809 CHECK_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
))
1810 bgp_zebra_announce (p
, old_select
, bgp
, afi
, safi
);
1812 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1813 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1817 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1818 UNSET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
1820 /* bestpath has changed; bump version */
1821 if (old_select
|| new_select
)
1823 bgp_bump_version(rn
);
1825 if (!bgp
->t_rmap_def_originate_eval
)
1828 THREAD_TIMER_ON(bm
->master
, bgp
->t_rmap_def_originate_eval
,
1829 update_group_refresh_default_originate_route_map
,
1830 bgp
, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER
);
1835 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1838 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1839 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1840 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1843 group_announce_route(bgp
, afi
, safi
, rn
, new_select
);
1846 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) &&
1847 (bgp
->inst_type
!= BGP_INSTANCE_TYPE_VIEW
) &&
1848 !bgp_option_check (BGP_OPT_NO_FIB
))
1851 && new_select
->type
== ZEBRA_ROUTE_BGP
1852 && (new_select
->sub_type
== BGP_ROUTE_NORMAL
||
1853 new_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1854 bgp_zebra_announce (p
, new_select
, bgp
, afi
, safi
);
1857 /* Withdraw the route from the kernel. */
1859 && old_select
->type
== ZEBRA_ROUTE_BGP
1860 && (old_select
->sub_type
== BGP_ROUTE_NORMAL
||
1861 old_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1862 bgp_zebra_withdraw (p
, old_select
, safi
);
1866 /* Reap old select bgp_info, if it has been removed */
1867 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
1868 bgp_info_reap (rn
, old_select
);
1870 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1875 bgp_processq_del (struct work_queue
*wq
, void *data
)
1877 struct bgp_process_queue
*pq
= data
;
1878 struct bgp_table
*table
;
1880 bgp_unlock (pq
->bgp
);
1883 table
= bgp_node_table (pq
->rn
);
1884 bgp_unlock_node (pq
->rn
);
1885 bgp_table_unlock (table
);
1887 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
1891 bgp_process_queue_init (void)
1893 if (!bm
->process_main_queue
)
1895 bm
->process_main_queue
1896 = work_queue_new (bm
->master
, "process_main_queue");
1898 if ( !bm
->process_main_queue
)
1900 zlog_err ("%s: Failed to allocate work queue", __func__
);
1905 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
1906 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
1907 bm
->process_main_queue
->spec
.max_retries
= 0;
1908 bm
->process_main_queue
->spec
.hold
= 50;
1909 /* Use a higher yield value of 50ms for main queue processing */
1910 bm
->process_main_queue
->spec
.yield
= 50 * 1000L;
1914 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
1916 struct bgp_process_queue
*pqnode
;
1918 /* already scheduled for processing? */
1919 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
1922 if (rn
->info
== NULL
)
1924 /* XXX: Perhaps remove before next release, after we've flushed out
1927 assert (rn
->info
!= NULL
);
1928 char buf
[PREFIX2STR_BUFFER
];
1929 zlog_warn ("%s: Called for route_node %s with no routing entries!",
1931 prefix2str (&(bgp_node_to_rnode (rn
)->p
), buf
, sizeof(buf
)));
1935 if (bm
->process_main_queue
== NULL
)
1936 bgp_process_queue_init ();
1938 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1939 sizeof (struct bgp_process_queue
));
1943 /* all unlocked in bgp_processq_del */
1944 bgp_table_lock (bgp_node_table (rn
));
1945 pqnode
->rn
= bgp_lock_node (rn
);
1949 pqnode
->safi
= safi
;
1950 work_queue_add (bm
->process_main_queue
, pqnode
);
1951 SET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1956 bgp_add_eoiu_mark (struct bgp
*bgp
)
1958 struct bgp_process_queue
*pqnode
;
1960 if (bm
->process_main_queue
== NULL
)
1961 bgp_process_queue_init ();
1963 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
1964 sizeof (struct bgp_process_queue
));
1971 work_queue_add (bm
->process_main_queue
, pqnode
);
1975 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
1979 peer
= THREAD_ARG (thread
);
1980 peer
->t_pmax_restart
= NULL
;
1982 if (bgp_debug_neighbor_events(peer
))
1983 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
1986 peer_clear (peer
, NULL
);
1992 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
1993 safi_t safi
, int always
)
1995 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
1998 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
2000 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
2004 zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
2005 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
2006 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
2007 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2009 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
2015 if (safi
== SAFI_MPLS_VPN
)
2016 safi
= SAFI_MPLS_LABELED_VPN
;
2018 ndata
[0] = (afi
>> 8);
2021 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
2022 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
2023 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
2024 ndata
[6] = (peer
->pmax
[afi
][safi
]);
2026 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
2027 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
2028 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
2031 /* Dynamic peers will just close their connection. */
2032 if (peer_dynamic_neighbor (peer
))
2035 /* restart timer start */
2036 if (peer
->pmax_restart
[afi
][safi
])
2038 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
2040 if (bgp_debug_neighbor_events(peer
))
2041 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
2042 peer
->host
, peer
->v_pmax_restart
);
2044 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
2045 peer
->v_pmax_restart
);
2051 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2053 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
2055 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
2059 zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
2060 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
2061 peer
->pmax
[afi
][safi
]);
2062 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2065 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2069 /* Unconditionally remove the route from the RIB, without taking
2070 * damping into consideration (eg, because the session went down)
2073 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2074 afi_t afi
, safi_t safi
)
2076 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2078 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2079 bgp_info_delete (rn
, ri
); /* keep historical info */
2081 bgp_process (peer
->bgp
, rn
, afi
, safi
);
2085 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2086 afi_t afi
, safi_t safi
)
2088 int status
= BGP_DAMP_NONE
;
2090 /* apply dampening, if result is suppressed, we'll be retaining
2091 * the bgp_info in the RIB for historical reference.
2093 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2094 && peer
->sort
== BGP_PEER_EBGP
)
2095 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
2096 == BGP_DAMP_SUPPRESSED
)
2098 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2102 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2105 static struct bgp_info
*
2106 info_make (int type
, int sub_type
, u_short instance
, struct peer
*peer
, struct attr
*attr
,
2107 struct bgp_node
*rn
)
2109 struct bgp_info
*new;
2111 /* Make new BGP info. */
2112 new = XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
2114 new->instance
= instance
;
2115 new->sub_type
= sub_type
;
2118 new->uptime
= bgp_clock ();
2120 new->addpath_tx_id
= ++peer
->bgp
->addpath_tx_id
;
2125 bgp_info_addpath_rx_str(u_int32_t addpath_id
, char *buf
)
2128 sprintf(buf
, " with addpath ID %d", addpath_id
);
2132 /* Check if received nexthop is valid or not. */
2134 bgp_update_martian_nexthop (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct attr
*attr
)
2136 struct attr_extra
*attre
= attr
->extra
;
2139 /* Only validated for unicast and multicast currently. */
2140 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2143 /* If NEXT_HOP is present, validate it. */
2144 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2146 if (attr
->nexthop
.s_addr
== 0 ||
2147 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2148 bgp_nexthop_self (bgp
, attr
))
2152 /* If MP_NEXTHOP is present, validate it. */
2153 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2154 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2155 * it is not an IPv6 link-local address.
2157 if (attre
&& attre
->mp_nexthop_len
)
2159 switch (attre
->mp_nexthop_len
)
2161 case BGP_ATTR_NHLEN_IPV4
:
2162 case BGP_ATTR_NHLEN_VPNV4
:
2163 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2164 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2168 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2169 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2170 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2171 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2172 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2174 #endif /* HAVE_IPV6 */
2186 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2187 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2188 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2192 int aspath_loop_count
= 0;
2193 struct bgp_node
*rn
;
2195 struct attr new_attr
;
2196 struct attr_extra new_extra
;
2197 struct attr
*attr_new
;
2198 struct bgp_info
*ri
;
2199 struct bgp_info
*new;
2201 char buf
[SU_ADDRSTRLEN
];
2206 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2208 /* When peer's soft reconfiguration enabled. Record input packet in
2210 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2211 && peer
!= bgp
->peer_self
)
2212 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2214 /* Check previously received route. */
2215 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2216 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2217 ri
->addpath_rx_id
== addpath_id
)
2220 /* AS path local-as loop check. */
2221 if (peer
->change_local_as
)
2223 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2224 aspath_loop_count
= 1;
2226 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2228 reason
= "as-path contains our own AS;";
2233 /* AS path loop check. */
2234 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2235 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2236 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
)
2237 > peer
->allowas_in
[afi
][safi
]))
2239 reason
= "as-path contains our own AS;";
2243 /* Route reflector originator ID check. */
2244 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2245 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2247 reason
= "originator is us;";
2251 /* Route reflector cluster ID check. */
2252 if (bgp_cluster_filter (peer
, attr
))
2254 reason
= "reflected from the same cluster;";
2258 /* Apply incoming filter. */
2259 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2265 new_attr
.extra
= &new_extra
;
2266 bgp_attr_dup (&new_attr
, attr
);
2268 /* Apply incoming route-map.
2269 * NB: new_attr may now contain newly allocated values from route-map "set"
2270 * commands, so we need bgp_attr_flush in the error paths, until we intern
2271 * the attr (which takes over the memory references) */
2272 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2274 reason
= "route-map;";
2275 bgp_attr_flush (&new_attr
);
2279 /* next hop check. */
2280 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2282 reason
= "martian or self next-hop;";
2283 bgp_attr_flush (&new_attr
);
2287 attr_new
= bgp_attr_intern (&new_attr
);
2289 /* If the update is implicit withdraw. */
2292 ri
->uptime
= bgp_clock ();
2294 /* Same attribute comes in. */
2295 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2296 && attrhash_cmp (ri
->attr
, attr_new
))
2298 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2299 && peer
->sort
== BGP_PEER_EBGP
2300 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2302 if (bgp_debug_update(peer
, p
, NULL
, 1))
2304 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2305 zlog_debug ("%s rcvd %s/%d%s",
2307 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2308 p
->prefixlen
, buf2
);
2311 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2313 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2314 bgp_process (bgp
, rn
, afi
, safi
);
2317 else /* Duplicate - odd */
2319 if (bgp_debug_update(peer
, p
, NULL
, 1))
2321 if (!peer
->rcvd_attr_printed
)
2323 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2324 peer
->rcvd_attr_printed
= 1;
2327 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2328 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2330 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2331 p
->prefixlen
, buf2
);
2334 /* graceful restart STALE flag unset. */
2335 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2337 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2338 bgp_process (bgp
, rn
, afi
, safi
);
2342 bgp_unlock_node (rn
);
2343 bgp_attr_unintern (&attr_new
);
2348 /* Withdraw/Announce before we fully processed the withdraw */
2349 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2351 if (bgp_debug_update(peer
, p
, NULL
, 1))
2353 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2354 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2356 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2357 p
->prefixlen
, buf2
);
2359 bgp_info_restore (rn
, ri
);
2362 /* Received Logging. */
2363 if (bgp_debug_update(peer
, p
, NULL
, 1))
2365 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2366 zlog_debug ("%s rcvd %s/%d%s",
2368 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2369 p
->prefixlen
, buf2
);
2372 /* graceful restart STALE flag unset. */
2373 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2374 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2376 /* The attribute is changed. */
2377 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2379 /* implicit withdraw, decrement aggregate and pcount here.
2380 * only if update is accepted, they'll increment below.
2382 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2384 /* Update bgp route dampening information. */
2385 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2386 && peer
->sort
== BGP_PEER_EBGP
)
2388 /* This is implicit withdraw so we should update dampening
2390 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2391 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2394 /* Update to new attribute. */
2395 bgp_attr_unintern (&ri
->attr
);
2396 ri
->attr
= attr_new
;
2398 /* Update MPLS tag. */
2399 if (safi
== SAFI_MPLS_VPN
)
2400 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2402 /* Update bgp route dampening information. */
2403 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2404 && peer
->sort
== BGP_PEER_EBGP
)
2406 /* Now we do normal update dampening. */
2407 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2408 if (ret
== BGP_DAMP_SUPPRESSED
)
2410 bgp_unlock_node (rn
);
2415 /* Nexthop reachability check. */
2416 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2418 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2419 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2420 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2425 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2426 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2429 if (BGP_DEBUG(nht
, NHT
))
2431 char buf1
[INET6_ADDRSTRLEN
];
2432 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2433 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2435 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2439 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2441 /* Process change. */
2442 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2444 bgp_process (bgp
, rn
, afi
, safi
);
2445 bgp_unlock_node (rn
);
2448 } // End of implicit withdraw
2450 /* Received Logging. */
2451 if (bgp_debug_update(peer
, p
, NULL
, 1))
2453 if (!peer
->rcvd_attr_printed
)
2455 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2456 peer
->rcvd_attr_printed
= 1;
2459 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2460 zlog_debug ("%s rcvd %s/%d%s",
2462 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2463 p
->prefixlen
, buf2
);
2466 /* Make new BGP info. */
2467 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2469 /* Update MPLS tag. */
2470 if (safi
== SAFI_MPLS_VPN
)
2471 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2473 /* Nexthop reachability check. */
2474 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2476 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2477 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2478 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2483 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2484 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2487 if (BGP_DEBUG(nht
, NHT
))
2489 char buf1
[INET6_ADDRSTRLEN
];
2490 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2491 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2493 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2497 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2500 new->addpath_rx_id
= addpath_id
;
2502 /* Increment prefix */
2503 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2505 /* Register new BGP information. */
2506 bgp_info_add (rn
, new);
2508 /* route_node_get lock */
2509 bgp_unlock_node (rn
);
2511 /* If maximum prefix count is configured and current prefix
2513 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2516 /* Process change. */
2517 bgp_process (bgp
, rn
, afi
, safi
);
2521 /* This BGP update is filtered. Log the reason then update BGP
2524 if (bgp_debug_update(peer
, p
, NULL
, 1))
2526 if (!peer
->rcvd_attr_printed
)
2528 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2529 peer
->rcvd_attr_printed
= 1;
2532 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2533 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2535 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2536 p
->prefixlen
, buf2
, reason
);
2540 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2542 bgp_unlock_node (rn
);
2548 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2549 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2550 struct prefix_rd
*prd
, u_char
*tag
)
2553 char buf
[SU_ADDRSTRLEN
];
2555 struct bgp_node
*rn
;
2556 struct bgp_info
*ri
;
2561 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2563 /* If peer is soft reconfiguration enabled. Record input packet for
2564 further calculation. */
2565 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2566 && peer
!= bgp
->peer_self
)
2567 bgp_adj_in_unset (rn
, peer
, addpath_id
);
2569 /* Lookup withdrawn route. */
2570 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2571 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2572 ri
->addpath_rx_id
== addpath_id
)
2576 if (bgp_debug_update(peer
, p
, NULL
, 1))
2578 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2579 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2581 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2582 p
->prefixlen
, buf2
);
2585 /* Withdraw specified route from routing table. */
2586 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2587 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2588 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2589 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2590 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2593 /* Unlock bgp_node_get() lock. */
2594 bgp_unlock_node (rn
);
2600 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2602 struct update_subgroup
*subgrp
;
2603 subgrp
= peer_subgroup(peer
, afi
, safi
);
2604 subgroup_default_originate(subgrp
, withdraw
);
2609 * bgp_stop_announce_route_timer
2612 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2614 if (!paf
->t_announce_route
)
2617 THREAD_TIMER_OFF (paf
->t_announce_route
);
2621 * bgp_announce_route_timer_expired
2623 * Callback that is invoked when the route announcement timer for a
2627 bgp_announce_route_timer_expired (struct thread
*t
)
2629 struct peer_af
*paf
;
2633 paf
= THREAD_ARG (t
);
2636 assert (paf
->t_announce_route
);
2637 paf
->t_announce_route
= NULL
;
2639 if (peer
->status
!= Established
)
2642 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2645 peer_af_announce_route (paf
, 1);
2650 * bgp_announce_route
2652 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2655 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2657 struct peer_af
*paf
;
2658 struct update_subgroup
*subgrp
;
2660 paf
= peer_af_find (peer
, afi
, safi
);
2663 subgrp
= PAF_SUBGRP(paf
);
2666 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2667 * or a refresh has already been triggered.
2669 if (!subgrp
|| paf
->t_announce_route
)
2673 * Start a timer to stagger/delay the announce. This serves
2674 * two purposes - announcement can potentially be combined for
2675 * multiple peers and the announcement doesn't happen in the
2678 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2679 bgp_announce_route_timer_expired
, paf
,
2680 (subgrp
->peer_count
== 1) ?
2681 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2682 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2686 * Announce routes from all AF tables to a peer.
2688 * This should ONLY be called when there is a need to refresh the
2689 * routes to the peer based on a policy change for this peer alone
2690 * or a route refresh request received from the peer.
2691 * The operation will result in splitting the peer from its existing
2692 * subgroups and putting it in new subgroups.
2695 bgp_announce_route_all (struct peer
*peer
)
2700 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2701 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2702 bgp_announce_route (peer
, afi
, safi
);
2706 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2707 struct bgp_table
*table
, struct prefix_rd
*prd
)
2710 struct bgp_node
*rn
;
2711 struct bgp_adj_in
*ain
;
2714 table
= peer
->bgp
->rib
[afi
][safi
];
2716 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2717 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2719 if (ain
->peer
== peer
)
2721 struct bgp_info
*ri
= rn
->info
;
2722 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
2724 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
2725 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2730 bgp_unlock_node (rn
);
2738 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2740 struct bgp_node
*rn
;
2741 struct bgp_table
*table
;
2743 if (peer
->status
!= Established
)
2746 if (safi
!= SAFI_MPLS_VPN
)
2747 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
2749 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2750 rn
= bgp_route_next (rn
))
2751 if ((table
= rn
->info
) != NULL
)
2753 struct prefix_rd prd
;
2754 prd
.family
= AF_UNSPEC
;
2756 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
2758 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
2763 struct bgp_clear_node_queue
2765 struct bgp_node
*rn
;
2768 static wq_item_status
2769 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2771 struct bgp_clear_node_queue
*cnq
= data
;
2772 struct bgp_node
*rn
= cnq
->rn
;
2773 struct peer
*peer
= wq
->spec
.data
;
2774 struct bgp_info
*ri
;
2775 afi_t afi
= bgp_node_table (rn
)->afi
;
2776 safi_t safi
= bgp_node_table (rn
)->safi
;
2778 assert (rn
&& peer
);
2780 /* It is possible that we have multiple paths for a prefix from a peer
2781 * if that peer is using AddPath.
2783 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2784 if (ri
->peer
== peer
)
2786 /* graceful restart STALE flag set. */
2787 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2788 && peer
->nsf
[afi
][safi
]
2789 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2790 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2791 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2793 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2799 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2801 struct bgp_clear_node_queue
*cnq
= data
;
2802 struct bgp_node
*rn
= cnq
->rn
;
2803 struct bgp_table
*table
= bgp_node_table (rn
);
2805 bgp_unlock_node (rn
);
2806 bgp_table_unlock (table
);
2807 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2811 bgp_clear_node_complete (struct work_queue
*wq
)
2813 struct peer
*peer
= wq
->spec
.data
;
2815 /* Tickle FSM to start moving again */
2816 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2818 peer_unlock (peer
); /* bgp_clear_route */
2822 bgp_clear_node_queue_init (struct peer
*peer
)
2824 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2826 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2827 #undef CLEAR_QUEUE_NAME_LEN
2829 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2831 zlog_err ("%s: Failed to allocate work queue", __func__
);
2834 peer
->clear_node_queue
->spec
.hold
= 10;
2835 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2836 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2837 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2838 peer
->clear_node_queue
->spec
.max_retries
= 0;
2840 /* we only 'lock' this peer reference when the queue is actually active */
2841 peer
->clear_node_queue
->spec
.data
= peer
;
2845 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2846 struct bgp_table
*table
)
2848 struct bgp_node
*rn
;
2852 table
= peer
->bgp
->rib
[afi
][safi
];
2854 /* If still no table => afi/safi isn't configured at all or smth. */
2858 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2860 struct bgp_info
*ri
;
2861 struct bgp_adj_in
*ain
;
2862 struct bgp_adj_in
*ain_next
;
2864 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2865 * queued for every clearing peer, regardless of whether it is
2866 * relevant to the peer at hand.
2868 * Overview: There are 3 different indices which need to be
2869 * scrubbed, potentially, when a peer is removed:
2871 * 1 peer's routes visible via the RIB (ie accepted routes)
2872 * 2 peer's routes visible by the (optional) peer's adj-in index
2873 * 3 other routes visible by the peer's adj-out index
2875 * 3 there is no hurry in scrubbing, once the struct peer is
2876 * removed from bgp->peer, we could just GC such deleted peer's
2877 * adj-outs at our leisure.
2879 * 1 and 2 must be 'scrubbed' in some way, at least made
2880 * invisible via RIB index before peer session is allowed to be
2881 * brought back up. So one needs to know when such a 'search' is
2886 * - there'd be a single global queue or a single RIB walker
2887 * - rather than tracking which route_nodes still need to be
2888 * examined on a peer basis, we'd track which peers still
2891 * Given that our per-peer prefix-counts now should be reliable,
2892 * this may actually be achievable. It doesn't seem to be a huge
2893 * problem at this time,
2895 * It is possible that we have multiple paths for a prefix from a peer
2896 * if that peer is using AddPath.
2901 ain_next
= ain
->next
;
2903 if (ain
->peer
== peer
)
2905 bgp_adj_in_remove (rn
, ain
);
2906 bgp_unlock_node (rn
);
2912 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2913 if (ri
->peer
== peer
)
2915 struct bgp_clear_node_queue
*cnq
;
2917 /* both unlocked in bgp_clear_node_queue_del */
2918 bgp_table_lock (bgp_node_table (rn
));
2920 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2921 sizeof (struct bgp_clear_node_queue
));
2923 work_queue_add (peer
->clear_node_queue
, cnq
);
2931 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2933 struct bgp_node
*rn
;
2934 struct bgp_table
*table
;
2936 if (peer
->clear_node_queue
== NULL
)
2937 bgp_clear_node_queue_init (peer
);
2939 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2940 * Idle until it receives a Clearing_Completed event. This protects
2941 * against peers which flap faster than we can we clear, which could
2944 * a) race with routes from the new session being installed before
2945 * clear_route_node visits the node (to delete the route of that
2947 * b) resource exhaustion, clear_route_node likely leads to an entry
2948 * on the process_main queue. Fast-flapping could cause that queue
2952 /* lock peer in assumption that clear-node-queue will get nodes; if so,
2953 * the unlock will happen upon work-queue completion; other wise, the
2954 * unlock happens at the end of this function.
2956 if (!peer
->clear_node_queue
->thread
)
2959 if (safi
!= SAFI_MPLS_VPN
)
2960 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
2962 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2963 rn
= bgp_route_next (rn
))
2964 if ((table
= rn
->info
) != NULL
)
2965 bgp_clear_route_table (peer
, afi
, safi
, table
);
2967 /* unlock if no nodes got added to the clear-node-queue. */
2968 if (!peer
->clear_node_queue
->thread
)
2974 bgp_clear_route_all (struct peer
*peer
)
2979 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2980 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2981 bgp_clear_route (peer
, afi
, safi
);
2985 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2987 struct bgp_table
*table
;
2988 struct bgp_node
*rn
;
2989 struct bgp_adj_in
*ain
;
2990 struct bgp_adj_in
*ain_next
;
2992 table
= peer
->bgp
->rib
[afi
][safi
];
2994 /* It is possible that we have multiple paths for a prefix from a peer
2995 * if that peer is using AddPath.
2997 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3003 ain_next
= ain
->next
;
3005 if (ain
->peer
== peer
)
3007 bgp_adj_in_remove (rn
, ain
);
3008 bgp_unlock_node (rn
);
3017 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3019 struct bgp_node
*rn
;
3020 struct bgp_info
*ri
;
3021 struct bgp_table
*table
;
3023 table
= peer
->bgp
->rib
[afi
][safi
];
3025 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3027 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3028 if (ri
->peer
== peer
)
3030 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3031 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3037 /* Delete all kernel routes. */
3039 bgp_cleanup_routes (void)
3042 struct listnode
*node
, *nnode
;
3043 struct bgp_node
*rn
;
3044 struct bgp_table
*table
;
3045 struct bgp_info
*ri
;
3047 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
3049 table
= bgp
->rib
[AFI_IP
][SAFI_UNICAST
];
3051 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3052 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3053 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3054 && ri
->type
== ZEBRA_ROUTE_BGP
3055 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3056 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3057 bgp_zebra_withdraw (&rn
->p
, ri
,SAFI_UNICAST
);
3059 table
= bgp
->rib
[AFI_IP6
][SAFI_UNICAST
];
3061 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3062 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3063 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3064 && ri
->type
== ZEBRA_ROUTE_BGP
3065 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3066 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3067 bgp_zebra_withdraw (&rn
->p
, ri
,SAFI_UNICAST
);
3075 bgp_zclient_reset ();
3076 access_list_reset ();
3077 prefix_list_reset ();
3081 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3083 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3084 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3087 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3090 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3099 int addpath_encoded
;
3100 u_int32_t addpath_id
;
3102 /* Check peer status. */
3103 if (peer
->status
!= Established
)
3107 lim
= pnt
+ packet
->length
;
3109 safi
= packet
->safi
;
3111 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3113 for (; pnt
< lim
; pnt
+= psize
)
3115 /* Clear prefix structure. */
3116 memset (&p
, 0, sizeof (struct prefix
));
3118 if (addpath_encoded
)
3121 /* When packet overflow occurs return immediately. */
3122 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3125 addpath_id
= ntohl(*((uint32_t*) pnt
));
3126 pnt
+= BGP_ADDPATH_ID_LEN
;
3129 /* Fetch prefix length. */
3130 p
.prefixlen
= *pnt
++;
3131 p
.family
= afi2family (afi
);
3133 /* Already checked in nlri_sanity_check(). We do double check
3135 if ((afi
== AFI_IP
&& p
.prefixlen
> 32)
3136 || (afi
== AFI_IP6
&& p
.prefixlen
> 128))
3139 /* Packet size overflow check. */
3140 psize
= PSIZE (p
.prefixlen
);
3142 /* When packet overflow occur return immediately. */
3143 if (pnt
+ psize
> lim
)
3146 /* Fetch prefix from NLRI packet. */
3147 memcpy (&p
.u
.prefix
, pnt
, psize
);
3149 /* Check address. */
3150 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3152 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3155 * From draft-ietf-idr-bgp4-22, Section 6.3:
3156 * If a BGP router receives an UPDATE message with a
3157 * semantically incorrect NLRI field, in which a prefix is
3158 * semantically incorrect (eg. an unexpected multicast IP
3159 * address), it should ignore the prefix.
3161 zlog_err ("IPv4 unicast NLRI is multicast address %s",
3162 inet_ntoa (p
.u
.prefix4
));
3169 /* Check address. */
3170 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3172 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3176 zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
3177 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3182 #endif /* HAVE_IPV6 */
3184 /* Normal process. */
3186 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3187 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3189 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3190 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3192 /* Address family configuration mismatch or maximum-prefix count
3198 /* Packet length consistency check. */
3205 /* NLRI encode syntax check routine. */
3207 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, safi_t safi
, u_char
*pnt
,
3208 bgp_size_t length
, int *numpfx
)
3213 int addpath_encoded
;
3217 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3219 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3220 syntactic validity. If the field is syntactically incorrect,
3221 then the Error Subcode is set to Invalid Network Field. */
3226 /* If the NLRI is encoded using addpath then the first 4 bytes are
3227 * the addpath ID. */
3228 if (addpath_encoded
)
3230 if (pnt
+ BGP_ADDPATH_ID_LEN
> end
)
3232 zlog_err ("%s [Error] Update packet error"
3233 " (prefix data addpath overflow)",
3235 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3236 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3239 pnt
+= BGP_ADDPATH_ID_LEN
;
3244 /* Prefix length check. */
3245 if ((afi
== AFI_IP
&& prefixlen
> 32)
3246 || (afi
== AFI_IP6
&& prefixlen
> 128))
3248 zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
3249 peer
->host
, prefixlen
);
3250 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3251 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3255 /* Packet size overflow check. */
3256 psize
= PSIZE (prefixlen
);
3258 if (pnt
+ psize
> end
)
3260 zlog_err ("%s [Error] Update packet error"
3261 " (prefix data overflow prefix size is %d)",
3263 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3264 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3272 /* Packet length consistency check. */
3275 zlog_err ("%s [Error] Update packet error"
3276 " (prefix length mismatch with total length)",
3278 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3279 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3285 static struct bgp_static
*
3286 bgp_static_new (void)
3288 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3292 bgp_static_free (struct bgp_static
*bgp_static
)
3294 if (bgp_static
->rmap
.name
)
3295 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3296 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3300 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3301 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3303 struct bgp_node
*rn
;
3304 struct bgp_info
*ri
;
3305 struct bgp_info
*new;
3306 struct bgp_info info
;
3308 struct attr
*attr_new
;
3311 assert (bgp_static
);
3315 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3317 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3319 attr
.nexthop
= bgp_static
->igpnexthop
;
3320 attr
.med
= bgp_static
->igpmetric
;
3321 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3323 if (bgp_static
->atomic
)
3324 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3326 /* Apply route-map. */
3327 if (bgp_static
->rmap
.name
)
3329 struct attr attr_tmp
= attr
;
3330 info
.peer
= bgp
->peer_self
;
3331 info
.attr
= &attr_tmp
;
3333 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3335 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3337 bgp
->peer_self
->rmap_type
= 0;
3339 if (ret
== RMAP_DENYMATCH
)
3341 /* Free uninterned attribute. */
3342 bgp_attr_flush (&attr_tmp
);
3344 /* Unintern original. */
3345 aspath_unintern (&attr
.aspath
);
3346 bgp_attr_extra_free (&attr
);
3347 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3350 attr_new
= bgp_attr_intern (&attr_tmp
);
3353 attr_new
= bgp_attr_intern (&attr
);
3355 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3356 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3357 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3362 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3363 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3364 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3366 bgp_unlock_node (rn
);
3367 bgp_attr_unintern (&attr_new
);
3368 aspath_unintern (&attr
.aspath
);
3369 bgp_attr_extra_free (&attr
);
3374 /* The attribute is changed. */
3375 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3377 /* Rewrite BGP route information. */
3378 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3379 bgp_info_restore(rn
, ri
);
3381 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3382 bgp_attr_unintern (&ri
->attr
);
3383 ri
->attr
= attr_new
;
3384 ri
->uptime
= bgp_clock ();
3386 /* Nexthop reachability check. */
3387 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3389 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3390 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3393 if (BGP_DEBUG(nht
, NHT
))
3395 char buf1
[INET6_ADDRSTRLEN
];
3396 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3398 zlog_debug("%s(%s): Route not in table, not advertising",
3399 __FUNCTION__
, buf1
);
3401 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3406 /* Delete the NHT structure if any, if we're toggling between
3407 * enabling/disabling import check. We deregister the route
3408 * from NHT to avoid overloading NHT and the process interaction
3410 bgp_unlink_nexthop(ri
);
3411 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3413 /* Process change. */
3414 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3415 bgp_process (bgp
, rn
, afi
, safi
);
3416 bgp_unlock_node (rn
);
3417 aspath_unintern (&attr
.aspath
);
3418 bgp_attr_extra_free (&attr
);
3423 /* Make new BGP info. */
3424 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3426 /* Nexthop reachability check. */
3427 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3429 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3430 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3433 if (BGP_DEBUG(nht
, NHT
))
3435 char buf1
[INET6_ADDRSTRLEN
];
3436 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3438 zlog_debug("%s(%s): Route not in table, not advertising",
3439 __FUNCTION__
, buf1
);
3441 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3446 /* Delete the NHT structure if any, if we're toggling between
3447 * enabling/disabling import check. We deregister the route
3448 * from NHT to avoid overloading NHT and the process interaction
3450 bgp_unlink_nexthop(new);
3452 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3455 /* Aggregate address increment. */
3456 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3458 /* Register new BGP information. */
3459 bgp_info_add (rn
, new);
3461 /* route_node_get lock */
3462 bgp_unlock_node (rn
);
3464 /* Process change. */
3465 bgp_process (bgp
, rn
, afi
, safi
);
3467 /* Unintern original. */
3468 aspath_unintern (&attr
.aspath
);
3469 bgp_attr_extra_free (&attr
);
3473 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3474 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3476 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3480 bgp_static_update_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3481 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3483 struct bgp_node
*rn
;
3484 struct bgp_info
*new;
3486 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3488 /* Make new BGP info. */
3489 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
,
3490 bgp_attr_default_intern(BGP_ORIGIN_IGP
), rn
);
3492 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3493 new->extra
= bgp_info_extra_new();
3494 memcpy (new->extra
->tag
, tag
, 3);
3496 /* Aggregate address increment. */
3497 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3499 /* Register new BGP information. */
3500 bgp_info_add (rn
, new);
3502 /* route_node_get lock */
3503 bgp_unlock_node (rn
);
3505 /* Process change. */
3506 bgp_process (bgp
, rn
, afi
, safi
);
3510 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3513 struct bgp_node
*rn
;
3514 struct bgp_info
*ri
;
3516 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3518 /* Check selected route and self inserted route. */
3519 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3520 if (ri
->peer
== bgp
->peer_self
3521 && ri
->type
== ZEBRA_ROUTE_BGP
3522 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3525 /* Withdraw static BGP route from routing table. */
3528 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3529 bgp_unlink_nexthop(ri
);
3530 bgp_info_delete (rn
, ri
);
3531 bgp_process (bgp
, rn
, afi
, safi
);
3534 /* Unlock bgp_node_lookup. */
3535 bgp_unlock_node (rn
);
3539 bgp_static_withdraw_vpnv4 (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3540 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3542 struct bgp_node
*rn
;
3543 struct bgp_info
*ri
;
3545 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3547 /* Check selected route and self inserted route. */
3548 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3549 if (ri
->peer
== bgp
->peer_self
3550 && ri
->type
== ZEBRA_ROUTE_BGP
3551 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3554 /* Withdraw static BGP route from routing table. */
3557 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3558 bgp_info_delete (rn
, ri
);
3559 bgp_process (bgp
, rn
, afi
, safi
);
3562 /* Unlock bgp_node_lookup. */
3563 bgp_unlock_node (rn
);
3566 /* Configure static BGP network. When user don't run zebra, static
3567 route should be installed as valid. */
3569 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3570 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3574 struct bgp_static
*bgp_static
;
3575 struct bgp_node
*rn
;
3576 u_char need_update
= 0;
3578 /* Convert IP prefix string to struct prefix. */
3579 ret
= str2prefix (ip_str
, &p
);
3582 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3586 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3588 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3592 #endif /* HAVE_IPV6 */
3596 /* Set BGP static route configuration. */
3597 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3601 /* Configuration change. */
3602 bgp_static
= rn
->info
;
3604 /* Check previous routes are installed into BGP. */
3605 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3608 bgp_static
->backdoor
= backdoor
;
3612 if (bgp_static
->rmap
.name
)
3613 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3614 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3615 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3619 if (bgp_static
->rmap
.name
)
3620 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3621 bgp_static
->rmap
.name
= NULL
;
3622 bgp_static
->rmap
.map
= NULL
;
3623 bgp_static
->valid
= 0;
3625 bgp_unlock_node (rn
);
3629 /* New configuration. */
3630 bgp_static
= bgp_static_new ();
3631 bgp_static
->backdoor
= backdoor
;
3632 bgp_static
->valid
= 0;
3633 bgp_static
->igpmetric
= 0;
3634 bgp_static
->igpnexthop
.s_addr
= 0;
3638 if (bgp_static
->rmap
.name
)
3639 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3640 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3641 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3643 rn
->info
= bgp_static
;
3646 bgp_static
->valid
= 1;
3648 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3650 if (! bgp_static
->backdoor
)
3651 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3656 /* Configure static BGP network. */
3658 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3659 afi_t afi
, safi_t safi
)
3663 struct bgp_static
*bgp_static
;
3664 struct bgp_node
*rn
;
3666 /* Convert IP prefix string to struct prefix. */
3667 ret
= str2prefix (ip_str
, &p
);
3670 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3674 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3676 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3680 #endif /* HAVE_IPV6 */
3684 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3687 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3692 bgp_static
= rn
->info
;
3694 /* Update BGP RIB. */
3695 if (! bgp_static
->backdoor
)
3696 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3698 /* Clear configuration. */
3699 bgp_static_free (bgp_static
);
3701 bgp_unlock_node (rn
);
3702 bgp_unlock_node (rn
);
3708 bgp_static_add (struct bgp
*bgp
)
3712 struct bgp_node
*rn
;
3713 struct bgp_node
*rm
;
3714 struct bgp_table
*table
;
3715 struct bgp_static
*bgp_static
;
3717 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3718 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3719 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3720 if (rn
->info
!= NULL
)
3722 if (safi
== SAFI_MPLS_VPN
)
3726 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3728 bgp_static
= rn
->info
;
3729 bgp_static_update_vpnv4 (bgp
, &rm
->p
,
3730 AFI_IP
, SAFI_MPLS_VPN
,
3731 (struct prefix_rd
*)&rn
->p
,
3737 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
3742 /* Called from bgp_delete(). Delete all static routes from the BGP
3745 bgp_static_delete (struct bgp
*bgp
)
3749 struct bgp_node
*rn
;
3750 struct bgp_node
*rm
;
3751 struct bgp_table
*table
;
3752 struct bgp_static
*bgp_static
;
3754 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3755 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3756 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3757 if (rn
->info
!= NULL
)
3759 if (safi
== SAFI_MPLS_VPN
)
3763 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3765 bgp_static
= rn
->info
;
3766 bgp_static_withdraw_vpnv4 (bgp
, &rm
->p
,
3767 AFI_IP
, SAFI_MPLS_VPN
,
3768 (struct prefix_rd
*)&rn
->p
,
3770 bgp_static_free (bgp_static
);
3772 bgp_unlock_node (rn
);
3777 bgp_static
= rn
->info
;
3778 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3779 bgp_static_free (bgp_static
);
3781 bgp_unlock_node (rn
);
3787 bgp_static_redo_import_check (struct bgp
*bgp
)
3791 struct bgp_node
*rn
;
3792 struct bgp_static
*bgp_static
;
3794 /* Use this flag to force reprocessing of the route */
3795 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3796 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3797 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3798 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3799 if (rn
->info
!= NULL
)
3801 bgp_static
= rn
->info
;
3802 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
3804 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3808 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
3810 struct bgp_table
*table
;
3811 struct bgp_node
*rn
;
3812 struct bgp_info
*ri
;
3814 table
= bgp
->rib
[afi
][safi
];
3815 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3817 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3819 if (ri
->peer
== bgp
->peer_self
&&
3820 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
3821 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
3822 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
3823 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
3825 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
3826 bgp_unlink_nexthop(ri
);
3827 bgp_info_delete (rn
, ri
);
3828 bgp_process (bgp
, rn
, afi
, safi
);
3835 * Purge all networks and redistributed routes from routing table.
3836 * Invoked upon the instance going down.
3839 bgp_purge_static_redist_routes (struct bgp
*bgp
)
3844 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3845 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3846 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
3850 bgp_static_set_vpnv4 (struct vty
*vty
, const char *ip_str
, const char *rd_str
,
3851 const char *tag_str
)
3855 struct prefix_rd prd
;
3857 struct bgp_node
*prn
;
3858 struct bgp_node
*rn
;
3859 struct bgp_table
*table
;
3860 struct bgp_static
*bgp_static
;
3865 ret
= str2prefix (ip_str
, &p
);
3868 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3873 ret
= str2prefix_rd (rd_str
, &prd
);
3876 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3880 ret
= str2tag (tag_str
, tag
);
3883 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3887 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3888 (struct prefix
*)&prd
);
3889 if (prn
->info
== NULL
)
3890 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3892 bgp_unlock_node (prn
);
3895 rn
= bgp_node_get (table
, &p
);
3899 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
3900 bgp_unlock_node (rn
);
3904 /* New configuration. */
3905 bgp_static
= bgp_static_new ();
3906 bgp_static
->valid
= 1;
3907 memcpy (bgp_static
->tag
, tag
, 3);
3908 rn
->info
= bgp_static
;
3910 bgp_static_update_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3916 /* Configure static BGP network. */
3918 bgp_static_unset_vpnv4 (struct vty
*vty
, const char *ip_str
,
3919 const char *rd_str
, const char *tag_str
)
3924 struct prefix_rd prd
;
3925 struct bgp_node
*prn
;
3926 struct bgp_node
*rn
;
3927 struct bgp_table
*table
;
3928 struct bgp_static
*bgp_static
;
3933 /* Convert IP prefix string to struct prefix. */
3934 ret
= str2prefix (ip_str
, &p
);
3937 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3942 ret
= str2prefix_rd (rd_str
, &prd
);
3945 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
3949 ret
= str2tag (tag_str
, tag
);
3952 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
3956 prn
= bgp_node_get (bgp
->route
[AFI_IP
][SAFI_MPLS_VPN
],
3957 (struct prefix
*)&prd
);
3958 if (prn
->info
== NULL
)
3959 prn
->info
= bgp_table_init (AFI_IP
, SAFI_MPLS_VPN
);
3961 bgp_unlock_node (prn
);
3964 rn
= bgp_node_lookup (table
, &p
);
3968 bgp_static_withdraw_vpnv4 (bgp
, &p
, AFI_IP
, SAFI_MPLS_VPN
, &prd
, tag
);
3970 bgp_static
= rn
->info
;
3971 bgp_static_free (bgp_static
);
3973 bgp_unlock_node (rn
);
3974 bgp_unlock_node (rn
);
3977 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
3983 bgp_table_map_set (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
];
3992 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
3993 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
3994 rmap
->map
= route_map_lookup_by_name (rmap_name
);
3999 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4004 bgp_zebra_announce_table(bgp
, afi
, safi
);
4010 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4011 const char *rmap_name
)
4013 struct bgp_rmap
*rmap
;
4015 rmap
= &bgp
->table_map
[afi
][safi
];
4017 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4021 bgp_zebra_announce_table(bgp
, afi
, safi
);
4027 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4028 safi_t safi
, int *write
)
4030 if (bgp
->table_map
[afi
][safi
].name
)
4032 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4033 vty_out (vty
, " table-map %s%s",
4034 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4041 DEFUN (bgp_table_map
,
4044 "BGP table to RIB route download filter\n"
4045 "Name of the route map\n")
4047 return bgp_table_map_set (vty
, vty
->index
,
4048 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4050 DEFUN (no_bgp_table_map
,
4051 no_bgp_table_map_cmd
,
4052 "no table-map WORD",
4053 "BGP table to RIB route download filter\n"
4054 "Name of the route map\n")
4056 return bgp_table_map_unset (vty
, vty
->index
,
4057 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4062 "network A.B.C.D/M",
4063 "Specify a network to announce via BGP\n"
4064 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4066 return bgp_static_set (vty
, vty
->index
, argv
[0],
4067 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4070 DEFUN (bgp_network_route_map
,
4071 bgp_network_route_map_cmd
,
4072 "network A.B.C.D/M route-map WORD",
4073 "Specify a network to announce via BGP\n"
4074 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4075 "Route-map to modify the attributes\n"
4076 "Name of the route map\n")
4078 return bgp_static_set (vty
, vty
->index
, argv
[0],
4079 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4082 DEFUN (bgp_network_backdoor
,
4083 bgp_network_backdoor_cmd
,
4084 "network A.B.C.D/M backdoor",
4085 "Specify a network to announce via BGP\n"
4086 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4087 "Specify a BGP backdoor route\n")
4089 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4093 DEFUN (bgp_network_mask
,
4094 bgp_network_mask_cmd
,
4095 "network A.B.C.D mask A.B.C.D",
4096 "Specify a network to announce via BGP\n"
4102 char prefix_str
[BUFSIZ
];
4104 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4107 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4111 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4112 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4115 DEFUN (bgp_network_mask_route_map
,
4116 bgp_network_mask_route_map_cmd
,
4117 "network A.B.C.D mask A.B.C.D route-map WORD",
4118 "Specify a network to announce via BGP\n"
4122 "Route-map to modify the attributes\n"
4123 "Name of the route map\n")
4126 char prefix_str
[BUFSIZ
];
4128 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4131 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4135 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4136 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4139 DEFUN (bgp_network_mask_backdoor
,
4140 bgp_network_mask_backdoor_cmd
,
4141 "network A.B.C.D mask A.B.C.D backdoor",
4142 "Specify a network to announce via BGP\n"
4146 "Specify a BGP backdoor route\n")
4149 char prefix_str
[BUFSIZ
];
4151 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4154 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4158 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4162 DEFUN (bgp_network_mask_natural
,
4163 bgp_network_mask_natural_cmd
,
4165 "Specify a network to announce via BGP\n"
4169 char prefix_str
[BUFSIZ
];
4171 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4174 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4178 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4179 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4182 DEFUN (bgp_network_mask_natural_route_map
,
4183 bgp_network_mask_natural_route_map_cmd
,
4184 "network A.B.C.D route-map WORD",
4185 "Specify a network to announce via BGP\n"
4187 "Route-map to modify the attributes\n"
4188 "Name of the route map\n")
4191 char prefix_str
[BUFSIZ
];
4193 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4196 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4200 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4201 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4204 DEFUN (bgp_network_mask_natural_backdoor
,
4205 bgp_network_mask_natural_backdoor_cmd
,
4206 "network A.B.C.D backdoor",
4207 "Specify a network to announce via BGP\n"
4209 "Specify a BGP backdoor route\n")
4212 char prefix_str
[BUFSIZ
];
4214 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4217 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4221 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4225 DEFUN (no_bgp_network
,
4227 "no network A.B.C.D/M",
4229 "Specify a network to announce via BGP\n"
4230 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4232 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4233 bgp_node_safi (vty
));
4236 ALIAS (no_bgp_network
,
4237 no_bgp_network_route_map_cmd
,
4238 "no network A.B.C.D/M route-map WORD",
4240 "Specify a network to announce via BGP\n"
4241 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4242 "Route-map to modify the attributes\n"
4243 "Name of the route map\n")
4245 ALIAS (no_bgp_network
,
4246 no_bgp_network_backdoor_cmd
,
4247 "no network A.B.C.D/M backdoor",
4249 "Specify a network to announce via BGP\n"
4250 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4251 "Specify a BGP backdoor route\n")
4253 DEFUN (no_bgp_network_mask
,
4254 no_bgp_network_mask_cmd
,
4255 "no network A.B.C.D mask A.B.C.D",
4257 "Specify a network to announce via BGP\n"
4263 char prefix_str
[BUFSIZ
];
4265 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4268 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4272 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4273 bgp_node_safi (vty
));
4276 ALIAS (no_bgp_network_mask
,
4277 no_bgp_network_mask_route_map_cmd
,
4278 "no network A.B.C.D mask A.B.C.D route-map WORD",
4280 "Specify a network to announce via BGP\n"
4284 "Route-map to modify the attributes\n"
4285 "Name of the route map\n")
4287 ALIAS (no_bgp_network_mask
,
4288 no_bgp_network_mask_backdoor_cmd
,
4289 "no network A.B.C.D mask A.B.C.D backdoor",
4291 "Specify a network to announce via BGP\n"
4295 "Specify a BGP backdoor route\n")
4297 DEFUN (no_bgp_network_mask_natural
,
4298 no_bgp_network_mask_natural_cmd
,
4299 "no network A.B.C.D",
4301 "Specify a network to announce via BGP\n"
4305 char prefix_str
[BUFSIZ
];
4307 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4310 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4314 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4315 bgp_node_safi (vty
));
4318 ALIAS (no_bgp_network_mask_natural
,
4319 no_bgp_network_mask_natural_route_map_cmd
,
4320 "no network A.B.C.D route-map WORD",
4322 "Specify a network to announce via BGP\n"
4324 "Route-map to modify the attributes\n"
4325 "Name of the route map\n")
4327 ALIAS (no_bgp_network_mask_natural
,
4328 no_bgp_network_mask_natural_backdoor_cmd
,
4329 "no network A.B.C.D backdoor",
4331 "Specify a network to announce via BGP\n"
4333 "Specify a BGP backdoor route\n")
4336 DEFUN (ipv6_bgp_network
,
4337 ipv6_bgp_network_cmd
,
4338 "network X:X::X:X/M",
4339 "Specify a network to announce via BGP\n"
4340 "IPv6 prefix <network>/<length>\n")
4342 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4346 DEFUN (ipv6_bgp_network_route_map
,
4347 ipv6_bgp_network_route_map_cmd
,
4348 "network X:X::X:X/M route-map WORD",
4349 "Specify a network to announce via BGP\n"
4350 "IPv6 prefix <network>/<length>\n"
4351 "Route-map to modify the attributes\n"
4352 "Name of the route map\n")
4354 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4355 bgp_node_safi (vty
), argv
[1], 0);
4358 DEFUN (no_ipv6_bgp_network
,
4359 no_ipv6_bgp_network_cmd
,
4360 "no network X:X::X:X/M",
4362 "Specify a network to announce via BGP\n"
4363 "IPv6 prefix <network>/<length>\n")
4365 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4368 ALIAS (no_ipv6_bgp_network
,
4369 no_ipv6_bgp_network_route_map_cmd
,
4370 "no network X:X::X:X/M route-map WORD",
4372 "Specify a network to announce via BGP\n"
4373 "IPv6 prefix <network>/<length>\n"
4374 "Route-map to modify the attributes\n"
4375 "Name of the route map\n")
4377 ALIAS (ipv6_bgp_network
,
4378 old_ipv6_bgp_network_cmd
,
4379 "ipv6 bgp network X:X::X:X/M",
4382 "Specify a network to announce via BGP\n"
4383 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4385 ALIAS (no_ipv6_bgp_network
,
4386 old_no_ipv6_bgp_network_cmd
,
4387 "no ipv6 bgp network X:X::X:X/M",
4391 "Specify a network to announce via BGP\n"
4392 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4393 #endif /* HAVE_IPV6 */
4395 /* Aggreagete address:
4397 advertise-map Set condition to advertise attribute
4398 as-set Generate AS set path information
4399 attribute-map Set attributes of aggregate
4400 route-map Set parameters of aggregate
4401 summary-only Filter more specific routes from updates
4402 suppress-map Conditionally filter more specific routes from updates
4405 struct bgp_aggregate
4407 /* Summary-only flag. */
4408 u_char summary_only
;
4410 /* AS set generation. */
4413 /* Route-map for aggregated route. */
4414 struct route_map
*map
;
4416 /* Suppress-count. */
4417 unsigned long count
;
4419 /* SAFI configuration. */
4423 static struct bgp_aggregate
*
4424 bgp_aggregate_new (void)
4426 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4430 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4432 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4435 /* Update an aggregate as routes are added/removed from the BGP table */
4437 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4438 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4439 struct bgp_aggregate
*aggregate
)
4441 struct bgp_table
*table
;
4442 struct bgp_node
*top
;
4443 struct bgp_node
*rn
;
4445 struct aspath
*aspath
= NULL
;
4446 struct aspath
*asmerge
= NULL
;
4447 struct community
*community
= NULL
;
4448 struct community
*commerge
= NULL
;
4449 #if defined(AGGREGATE_NEXTHOP_CHECK)
4450 struct in_addr nexthop
;
4453 struct bgp_info
*ri
;
4454 struct bgp_info
*new;
4456 unsigned long match
= 0;
4457 u_char atomic_aggregate
= 0;
4459 /* Record adding route's nexthop and med. */
4462 #if defined(AGGREGATE_NEXTHOP_CHECK)
4463 nexthop
= rinew
->attr
->nexthop
;
4464 med
= rinew
->attr
->med
;
4468 /* ORIGIN attribute: If at least one route among routes that are
4469 aggregated has ORIGIN with the value INCOMPLETE, then the
4470 aggregated route must have the ORIGIN attribute with the value
4471 INCOMPLETE. Otherwise, if at least one route among routes that
4472 are aggregated has ORIGIN with the value EGP, then the aggregated
4473 route must have the origin attribute with the value EGP. In all
4474 other case the value of the ORIGIN attribute of the aggregated
4475 route is INTERNAL. */
4476 origin
= BGP_ORIGIN_IGP
;
4478 table
= bgp
->rib
[afi
][safi
];
4480 top
= bgp_node_get (table
, p
);
4481 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4482 if (rn
->p
.prefixlen
> p
->prefixlen
)
4486 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4488 if (BGP_INFO_HOLDDOWN (ri
))
4491 if (del
&& ri
== del
)
4494 if (! rinew
&& first
)
4496 #if defined(AGGREGATE_NEXTHOP_CHECK)
4497 nexthop
= ri
->attr
->nexthop
;
4498 med
= ri
->attr
->med
;
4503 #ifdef AGGREGATE_NEXTHOP_CHECK
4504 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4505 || ri
->attr
->med
!= med
)
4508 aspath_free (aspath
);
4510 community_free (community
);
4511 bgp_unlock_node (rn
);
4512 bgp_unlock_node (top
);
4515 #endif /* AGGREGATE_NEXTHOP_CHECK */
4517 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4518 atomic_aggregate
= 1;
4520 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4522 if (aggregate
->summary_only
)
4524 (bgp_info_extra_get (ri
))->suppress
++;
4525 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4531 if (origin
< ri
->attr
->origin
)
4532 origin
= ri
->attr
->origin
;
4534 if (aggregate
->as_set
)
4538 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4539 aspath_free (aspath
);
4543 aspath
= aspath_dup (ri
->attr
->aspath
);
4545 if (ri
->attr
->community
)
4549 commerge
= community_merge (community
,
4550 ri
->attr
->community
);
4551 community
= community_uniq_sort (commerge
);
4552 community_free (commerge
);
4555 community
= community_dup (ri
->attr
->community
);
4561 bgp_process (bgp
, rn
, afi
, safi
);
4563 bgp_unlock_node (top
);
4569 if (aggregate
->summary_only
)
4570 (bgp_info_extra_get (rinew
))->suppress
++;
4572 if (origin
< rinew
->attr
->origin
)
4573 origin
= rinew
->attr
->origin
;
4575 if (aggregate
->as_set
)
4579 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4580 aspath_free (aspath
);
4584 aspath
= aspath_dup (rinew
->attr
->aspath
);
4586 if (rinew
->attr
->community
)
4590 commerge
= community_merge (community
,
4591 rinew
->attr
->community
);
4592 community
= community_uniq_sort (commerge
);
4593 community_free (commerge
);
4596 community
= community_dup (rinew
->attr
->community
);
4601 if (aggregate
->count
> 0)
4603 rn
= bgp_node_get (table
, p
);
4604 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4605 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4607 atomic_aggregate
), rn
);
4608 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4610 bgp_info_add (rn
, new);
4611 bgp_unlock_node (rn
);
4612 bgp_process (bgp
, rn
, afi
, safi
);
4617 aspath_free (aspath
);
4619 community_free (community
);
4623 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4624 struct bgp_aggregate
*);
4627 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4628 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4630 struct bgp_node
*child
;
4631 struct bgp_node
*rn
;
4632 struct bgp_aggregate
*aggregate
;
4633 struct bgp_table
*table
;
4635 /* MPLS-VPN aggregation is not yet supported. */
4636 if (safi
== SAFI_MPLS_VPN
)
4639 table
= bgp
->aggregate
[afi
][safi
];
4641 /* No aggregates configured. */
4642 if (bgp_table_top_nolock (table
) == NULL
)
4645 if (p
->prefixlen
== 0)
4648 if (BGP_INFO_HOLDDOWN (ri
))
4651 child
= bgp_node_get (table
, p
);
4653 /* Aggregate address configuration check. */
4654 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4655 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4657 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4658 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4660 bgp_unlock_node (child
);
4664 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4665 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4667 struct bgp_node
*child
;
4668 struct bgp_node
*rn
;
4669 struct bgp_aggregate
*aggregate
;
4670 struct bgp_table
*table
;
4672 /* MPLS-VPN aggregation is not yet supported. */
4673 if (safi
== SAFI_MPLS_VPN
)
4676 table
= bgp
->aggregate
[afi
][safi
];
4678 /* No aggregates configured. */
4679 if (bgp_table_top_nolock (table
) == NULL
)
4682 if (p
->prefixlen
== 0)
4685 child
= bgp_node_get (table
, p
);
4687 /* Aggregate address configuration check. */
4688 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4689 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4691 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4692 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4694 bgp_unlock_node (child
);
4697 /* Called via bgp_aggregate_set when the user configures aggregate-address */
4699 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4700 struct bgp_aggregate
*aggregate
)
4702 struct bgp_table
*table
;
4703 struct bgp_node
*top
;
4704 struct bgp_node
*rn
;
4705 struct bgp_info
*new;
4706 struct bgp_info
*ri
;
4707 unsigned long match
;
4708 u_char origin
= BGP_ORIGIN_IGP
;
4709 struct aspath
*aspath
= NULL
;
4710 struct aspath
*asmerge
= NULL
;
4711 struct community
*community
= NULL
;
4712 struct community
*commerge
= NULL
;
4713 u_char atomic_aggregate
= 0;
4715 table
= bgp
->rib
[afi
][safi
];
4718 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4720 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4723 /* If routes exists below this node, generate aggregate routes. */
4724 top
= bgp_node_get (table
, p
);
4725 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4726 if (rn
->p
.prefixlen
> p
->prefixlen
)
4730 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4732 if (BGP_INFO_HOLDDOWN (ri
))
4735 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4736 atomic_aggregate
= 1;
4738 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4740 /* summary-only aggregate route suppress aggregated
4741 route announcement. */
4742 if (aggregate
->summary_only
)
4744 (bgp_info_extra_get (ri
))->suppress
++;
4745 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4749 /* If at least one route among routes that are aggregated has
4750 * ORIGIN with the value INCOMPLETE, then the aggregated route
4751 * MUST have the ORIGIN attribute with the value INCOMPLETE.
4752 * Otherwise, if at least one route among routes that are
4753 * aggregated has ORIGIN with the value EGP, then the aggregated
4754 * route MUST have the ORIGIN attribute with the value EGP.
4756 if (origin
< ri
->attr
->origin
)
4757 origin
= ri
->attr
->origin
;
4759 /* as-set aggregate route generate origin, as path,
4760 community aggregation. */
4761 if (aggregate
->as_set
)
4765 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4766 aspath_free (aspath
);
4770 aspath
= aspath_dup (ri
->attr
->aspath
);
4772 if (ri
->attr
->community
)
4776 commerge
= community_merge (community
,
4777 ri
->attr
->community
);
4778 community
= community_uniq_sort (commerge
);
4779 community_free (commerge
);
4782 community
= community_dup (ri
->attr
->community
);
4789 /* If this node is suppressed, process the change. */
4791 bgp_process (bgp
, rn
, afi
, safi
);
4793 bgp_unlock_node (top
);
4795 /* Add aggregate route to BGP table. */
4796 if (aggregate
->count
)
4798 rn
= bgp_node_get (table
, p
);
4799 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4800 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4802 atomic_aggregate
), rn
);
4803 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4805 bgp_info_add (rn
, new);
4806 bgp_unlock_node (rn
);
4808 /* Process change. */
4809 bgp_process (bgp
, rn
, afi
, safi
);
4814 aspath_free (aspath
);
4816 community_free (community
);
4821 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
4822 safi_t safi
, struct bgp_aggregate
*aggregate
)
4824 struct bgp_table
*table
;
4825 struct bgp_node
*top
;
4826 struct bgp_node
*rn
;
4827 struct bgp_info
*ri
;
4828 unsigned long match
;
4830 table
= bgp
->rib
[afi
][safi
];
4832 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4834 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4837 /* If routes exists below this node, generate aggregate routes. */
4838 top
= bgp_node_get (table
, p
);
4839 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4840 if (rn
->p
.prefixlen
> p
->prefixlen
)
4844 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4846 if (BGP_INFO_HOLDDOWN (ri
))
4849 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4851 if (aggregate
->summary_only
&& ri
->extra
)
4853 ri
->extra
->suppress
--;
4855 if (ri
->extra
->suppress
== 0)
4857 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4865 /* If this node was suppressed, process the change. */
4867 bgp_process (bgp
, rn
, afi
, safi
);
4869 bgp_unlock_node (top
);
4871 /* Delete aggregate route from BGP table. */
4872 rn
= bgp_node_get (table
, p
);
4874 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4875 if (ri
->peer
== bgp
->peer_self
4876 && ri
->type
== ZEBRA_ROUTE_BGP
4877 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
4880 /* Withdraw static BGP route from routing table. */
4883 bgp_info_delete (rn
, ri
);
4884 bgp_process (bgp
, rn
, afi
, safi
);
4887 /* Unlock bgp_node_lookup. */
4888 bgp_unlock_node (rn
);
4891 /* Aggregate route attribute. */
4892 #define AGGREGATE_SUMMARY_ONLY 1
4893 #define AGGREGATE_AS_SET 1
4896 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
4897 afi_t afi
, safi_t safi
)
4901 struct bgp_node
*rn
;
4903 struct bgp_aggregate
*aggregate
;
4905 /* Convert string to prefix structure. */
4906 ret
= str2prefix (prefix_str
, &p
);
4909 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4914 /* Get BGP structure. */
4917 /* Old configuration check. */
4918 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
4921 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
4926 aggregate
= rn
->info
;
4927 if (aggregate
->safi
& SAFI_UNICAST
)
4928 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4929 if (aggregate
->safi
& SAFI_MULTICAST
)
4930 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4932 /* Unlock aggregate address configuration. */
4934 bgp_aggregate_free (aggregate
);
4935 bgp_unlock_node (rn
);
4936 bgp_unlock_node (rn
);
4942 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
4943 afi_t afi
, safi_t safi
,
4944 u_char summary_only
, u_char as_set
)
4948 struct bgp_node
*rn
;
4950 struct bgp_aggregate
*aggregate
;
4952 /* Convert string to prefix structure. */
4953 ret
= str2prefix (prefix_str
, &p
);
4956 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
4961 /* Get BGP structure. */
4964 /* Old configuration check. */
4965 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
4969 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
4970 /* try to remove the old entry */
4971 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
4974 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
4975 bgp_unlock_node (rn
);
4980 /* Make aggregate address structure. */
4981 aggregate
= bgp_aggregate_new ();
4982 aggregate
->summary_only
= summary_only
;
4983 aggregate
->as_set
= as_set
;
4984 aggregate
->safi
= safi
;
4985 rn
->info
= aggregate
;
4987 /* Aggregate address insert into BGP routing table. */
4988 if (safi
& SAFI_UNICAST
)
4989 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
4990 if (safi
& SAFI_MULTICAST
)
4991 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
4996 DEFUN (aggregate_address
,
4997 aggregate_address_cmd
,
4998 "aggregate-address A.B.C.D/M",
4999 "Configure BGP aggregate entries\n"
5000 "Aggregate prefix\n")
5002 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5005 DEFUN (aggregate_address_mask
,
5006 aggregate_address_mask_cmd
,
5007 "aggregate-address A.B.C.D A.B.C.D",
5008 "Configure BGP aggregate entries\n"
5009 "Aggregate address\n"
5013 char prefix_str
[BUFSIZ
];
5015 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5019 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5023 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5027 DEFUN (aggregate_address_summary_only
,
5028 aggregate_address_summary_only_cmd
,
5029 "aggregate-address A.B.C.D/M summary-only",
5030 "Configure BGP aggregate entries\n"
5031 "Aggregate prefix\n"
5032 "Filter more specific routes from updates\n")
5034 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5035 AGGREGATE_SUMMARY_ONLY
, 0);
5038 DEFUN (aggregate_address_mask_summary_only
,
5039 aggregate_address_mask_summary_only_cmd
,
5040 "aggregate-address A.B.C.D A.B.C.D summary-only",
5041 "Configure BGP aggregate entries\n"
5042 "Aggregate address\n"
5044 "Filter more specific routes from updates\n")
5047 char prefix_str
[BUFSIZ
];
5049 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5053 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5057 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5058 AGGREGATE_SUMMARY_ONLY
, 0);
5061 DEFUN (aggregate_address_as_set
,
5062 aggregate_address_as_set_cmd
,
5063 "aggregate-address A.B.C.D/M as-set",
5064 "Configure BGP aggregate entries\n"
5065 "Aggregate prefix\n"
5066 "Generate AS set path information\n")
5068 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5069 0, AGGREGATE_AS_SET
);
5072 DEFUN (aggregate_address_mask_as_set
,
5073 aggregate_address_mask_as_set_cmd
,
5074 "aggregate-address A.B.C.D A.B.C.D as-set",
5075 "Configure BGP aggregate entries\n"
5076 "Aggregate address\n"
5078 "Generate AS set path information\n")
5081 char prefix_str
[BUFSIZ
];
5083 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5087 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5091 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5092 0, AGGREGATE_AS_SET
);
5096 DEFUN (aggregate_address_as_set_summary
,
5097 aggregate_address_as_set_summary_cmd
,
5098 "aggregate-address A.B.C.D/M as-set summary-only",
5099 "Configure BGP aggregate entries\n"
5100 "Aggregate prefix\n"
5101 "Generate AS set path information\n"
5102 "Filter more specific routes from updates\n")
5104 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5105 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5108 ALIAS (aggregate_address_as_set_summary
,
5109 aggregate_address_summary_as_set_cmd
,
5110 "aggregate-address A.B.C.D/M summary-only as-set",
5111 "Configure BGP aggregate entries\n"
5112 "Aggregate prefix\n"
5113 "Filter more specific routes from updates\n"
5114 "Generate AS set path information\n")
5116 DEFUN (aggregate_address_mask_as_set_summary
,
5117 aggregate_address_mask_as_set_summary_cmd
,
5118 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5119 "Configure BGP aggregate entries\n"
5120 "Aggregate address\n"
5122 "Generate AS set path information\n"
5123 "Filter more specific routes from updates\n")
5126 char prefix_str
[BUFSIZ
];
5128 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5132 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5136 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5137 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5140 ALIAS (aggregate_address_mask_as_set_summary
,
5141 aggregate_address_mask_summary_as_set_cmd
,
5142 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5143 "Configure BGP aggregate entries\n"
5144 "Aggregate address\n"
5146 "Filter more specific routes from updates\n"
5147 "Generate AS set path information\n")
5149 DEFUN (no_aggregate_address
,
5150 no_aggregate_address_cmd
,
5151 "no aggregate-address A.B.C.D/M",
5153 "Configure BGP aggregate entries\n"
5154 "Aggregate prefix\n")
5156 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5159 ALIAS (no_aggregate_address
,
5160 no_aggregate_address_summary_only_cmd
,
5161 "no aggregate-address A.B.C.D/M summary-only",
5163 "Configure BGP aggregate entries\n"
5164 "Aggregate prefix\n"
5165 "Filter more specific routes from updates\n")
5167 ALIAS (no_aggregate_address
,
5168 no_aggregate_address_as_set_cmd
,
5169 "no aggregate-address A.B.C.D/M as-set",
5171 "Configure BGP aggregate entries\n"
5172 "Aggregate prefix\n"
5173 "Generate AS set path information\n")
5175 ALIAS (no_aggregate_address
,
5176 no_aggregate_address_as_set_summary_cmd
,
5177 "no aggregate-address A.B.C.D/M as-set summary-only",
5179 "Configure BGP aggregate entries\n"
5180 "Aggregate prefix\n"
5181 "Generate AS set path information\n"
5182 "Filter more specific routes from updates\n")
5184 ALIAS (no_aggregate_address
,
5185 no_aggregate_address_summary_as_set_cmd
,
5186 "no aggregate-address A.B.C.D/M summary-only as-set",
5188 "Configure BGP aggregate entries\n"
5189 "Aggregate prefix\n"
5190 "Filter more specific routes from updates\n"
5191 "Generate AS set path information\n")
5193 DEFUN (no_aggregate_address_mask
,
5194 no_aggregate_address_mask_cmd
,
5195 "no aggregate-address A.B.C.D A.B.C.D",
5197 "Configure BGP aggregate entries\n"
5198 "Aggregate address\n"
5202 char prefix_str
[BUFSIZ
];
5204 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5208 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5212 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5215 ALIAS (no_aggregate_address_mask
,
5216 no_aggregate_address_mask_summary_only_cmd
,
5217 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5219 "Configure BGP aggregate entries\n"
5220 "Aggregate address\n"
5222 "Filter more specific routes from updates\n")
5224 ALIAS (no_aggregate_address_mask
,
5225 no_aggregate_address_mask_as_set_cmd
,
5226 "no aggregate-address A.B.C.D A.B.C.D as-set",
5228 "Configure BGP aggregate entries\n"
5229 "Aggregate address\n"
5231 "Generate AS set path information\n")
5233 ALIAS (no_aggregate_address_mask
,
5234 no_aggregate_address_mask_as_set_summary_cmd
,
5235 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5237 "Configure BGP aggregate entries\n"
5238 "Aggregate address\n"
5240 "Generate AS set path information\n"
5241 "Filter more specific routes from updates\n")
5243 ALIAS (no_aggregate_address_mask
,
5244 no_aggregate_address_mask_summary_as_set_cmd
,
5245 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5247 "Configure BGP aggregate entries\n"
5248 "Aggregate address\n"
5250 "Filter more specific routes from updates\n"
5251 "Generate AS set path information\n")
5254 DEFUN (ipv6_aggregate_address
,
5255 ipv6_aggregate_address_cmd
,
5256 "aggregate-address X:X::X:X/M",
5257 "Configure BGP aggregate entries\n"
5258 "Aggregate prefix\n")
5260 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5263 DEFUN (ipv6_aggregate_address_summary_only
,
5264 ipv6_aggregate_address_summary_only_cmd
,
5265 "aggregate-address X:X::X:X/M summary-only",
5266 "Configure BGP aggregate entries\n"
5267 "Aggregate prefix\n"
5268 "Filter more specific routes from updates\n")
5270 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5271 AGGREGATE_SUMMARY_ONLY
, 0);
5274 DEFUN (no_ipv6_aggregate_address
,
5275 no_ipv6_aggregate_address_cmd
,
5276 "no aggregate-address X:X::X:X/M",
5278 "Configure BGP aggregate entries\n"
5279 "Aggregate prefix\n")
5281 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5284 DEFUN (no_ipv6_aggregate_address_summary_only
,
5285 no_ipv6_aggregate_address_summary_only_cmd
,
5286 "no aggregate-address X:X::X:X/M summary-only",
5288 "Configure BGP aggregate entries\n"
5289 "Aggregate prefix\n"
5290 "Filter more specific routes from updates\n")
5292 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5295 ALIAS (ipv6_aggregate_address
,
5296 old_ipv6_aggregate_address_cmd
,
5297 "ipv6 bgp aggregate-address X:X::X:X/M",
5300 "Configure BGP aggregate entries\n"
5301 "Aggregate prefix\n")
5303 ALIAS (ipv6_aggregate_address_summary_only
,
5304 old_ipv6_aggregate_address_summary_only_cmd
,
5305 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5308 "Configure BGP aggregate entries\n"
5309 "Aggregate prefix\n"
5310 "Filter more specific routes from updates\n")
5312 ALIAS (no_ipv6_aggregate_address
,
5313 old_no_ipv6_aggregate_address_cmd
,
5314 "no ipv6 bgp aggregate-address X:X::X:X/M",
5318 "Configure BGP aggregate entries\n"
5319 "Aggregate prefix\n")
5321 ALIAS (no_ipv6_aggregate_address_summary_only
,
5322 old_no_ipv6_aggregate_address_summary_only_cmd
,
5323 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5327 "Configure BGP aggregate entries\n"
5328 "Aggregate prefix\n"
5329 "Filter more specific routes from updates\n")
5330 #endif /* HAVE_IPV6 */
5332 /* Redistribute route treatment. */
5334 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5335 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5336 u_int32_t metric
, u_char type
, u_short instance
, u_short tag
)
5338 struct bgp_info
*new;
5339 struct bgp_info
*bi
;
5340 struct bgp_info info
;
5341 struct bgp_node
*bn
;
5343 struct attr
*new_attr
;
5346 struct bgp_redist
*red
;
5348 /* Make default attribute. */
5349 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5351 attr
.nexthop
= *nexthop
;
5352 attr
.nh_ifindex
= ifindex
;
5357 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5358 extra
->mp_nexthop_global
= *nexthop6
;
5359 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5364 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5365 attr
.extra
->tag
= tag
;
5367 afi
= family2afi (p
->family
);
5369 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5372 struct attr attr_new
;
5373 struct attr_extra extra_new
;
5375 /* Copy attribute for modification. */
5376 attr_new
.extra
= &extra_new
;
5377 bgp_attr_dup (&attr_new
, &attr
);
5379 if (red
->redist_metric_flag
)
5380 attr_new
.med
= red
->redist_metric
;
5382 /* Apply route-map. */
5385 info
.peer
= bgp
->peer_self
;
5386 info
.attr
= &attr_new
;
5388 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5390 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5392 bgp
->peer_self
->rmap_type
= 0;
5394 if (ret
== RMAP_DENYMATCH
)
5396 /* Free uninterned attribute. */
5397 bgp_attr_flush (&attr_new
);
5399 /* Unintern original. */
5400 aspath_unintern (&attr
.aspath
);
5401 bgp_attr_extra_free (&attr
);
5402 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5407 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5408 afi
, SAFI_UNICAST
, p
, NULL
);
5410 new_attr
= bgp_attr_intern (&attr_new
);
5412 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5413 if (bi
->peer
== bgp
->peer_self
5414 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5419 /* Ensure the (source route) type is updated. */
5421 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5422 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5424 bgp_attr_unintern (&new_attr
);
5425 aspath_unintern (&attr
.aspath
);
5426 bgp_attr_extra_free (&attr
);
5427 bgp_unlock_node (bn
);
5432 /* The attribute is changed. */
5433 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5435 /* Rewrite BGP route information. */
5436 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5437 bgp_info_restore(bn
, bi
);
5439 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5440 bgp_attr_unintern (&bi
->attr
);
5441 bi
->attr
= new_attr
;
5442 bi
->uptime
= bgp_clock ();
5444 /* Process change. */
5445 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5446 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5447 bgp_unlock_node (bn
);
5448 aspath_unintern (&attr
.aspath
);
5449 bgp_attr_extra_free (&attr
);
5454 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5456 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5458 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5459 bgp_info_add (bn
, new);
5460 bgp_unlock_node (bn
);
5461 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5464 /* Unintern original. */
5465 aspath_unintern (&attr
.aspath
);
5466 bgp_attr_extra_free (&attr
);
5470 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5473 struct bgp_node
*rn
;
5474 struct bgp_info
*ri
;
5475 struct bgp_redist
*red
;
5477 afi
= family2afi (p
->family
);
5479 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5482 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5484 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5485 if (ri
->peer
== bgp
->peer_self
5486 && ri
->type
== type
)
5491 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5492 bgp_info_delete (rn
, ri
);
5493 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5495 bgp_unlock_node (rn
);
5499 /* Withdraw specified route type's route. */
5501 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5503 struct bgp_node
*rn
;
5504 struct bgp_info
*ri
;
5505 struct bgp_table
*table
;
5507 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5509 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5511 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5512 if (ri
->peer
== bgp
->peer_self
5514 && ri
->instance
== instance
)
5519 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5520 bgp_info_delete (rn
, ri
);
5521 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5526 /* Static function to display route. */
5528 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5531 u_int32_t destination
;
5534 if (p
->family
== AF_INET
)
5536 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5537 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5539 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5540 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5541 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5542 || p
->u
.prefix4
.s_addr
== 0)
5544 /* When mask is natural, mask is not displayed. */
5547 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5550 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5555 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5557 vty_out (vty
, "%*s", len
, " ");
5560 enum bgp_display_type
5565 /* Print the short form route status for a bgp_info */
5567 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
5568 json_object
*json_path
)
5573 /* Route status display. */
5574 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5575 json_object_boolean_true_add(json_path
, "removed");
5577 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5578 json_object_boolean_true_add(json_path
, "stale");
5580 if (binfo
->extra
&& binfo
->extra
->suppress
)
5581 json_object_boolean_true_add(json_path
, "suppressed");
5583 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5584 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5585 json_object_boolean_true_add(json_path
, "valid");
5588 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5589 json_object_boolean_true_add(json_path
, "history");
5591 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5592 json_object_boolean_true_add(json_path
, "damped");
5594 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5595 json_object_boolean_true_add(json_path
, "bestpath");
5597 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5598 json_object_boolean_true_add(json_path
, "multipath");
5600 /* Internal route. */
5601 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5602 json_object_string_add(json_path
, "pathFrom", "internal");
5604 json_object_string_add(json_path
, "pathFrom", "external");
5609 /* Route status display. */
5610 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5612 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5614 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5616 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5617 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5623 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5625 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5627 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5629 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5634 /* Internal route. */
5635 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5641 /* called from terminal list command */
5643 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5644 struct bgp_info
*binfo
, int display
, safi_t safi
,
5645 json_object
*json_paths
)
5648 json_object
*json_path
= NULL
;
5649 json_object
*json_nexthops
= NULL
;
5650 json_object
*json_nexthop_global
= NULL
;
5651 json_object
*json_nexthop_ll
= NULL
;
5654 json_path
= json_object_new_object();
5656 /* short status lead text */
5657 route_vty_short_status_out (vty
, binfo
, json_path
);
5661 /* print prefix and mask */
5663 route_vty_out_route (p
, vty
);
5665 vty_out (vty
, "%*s", 17, " ");
5668 /* Print attribute */
5674 if (p
->family
== AF_INET
5675 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5679 json_nexthop_global
= json_object_new_object();
5681 if (safi
== SAFI_MPLS_VPN
)
5682 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5684 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
5686 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
5687 json_object_boolean_true_add(json_nexthop_global
, "used");
5691 if (safi
== SAFI_MPLS_VPN
)
5692 vty_out (vty
, "%-16s",
5693 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5695 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5701 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5708 json_nexthop_global
= json_object_new_object();
5709 json_object_string_add(json_nexthop_global
, "ip",
5710 inet_ntop (AF_INET6
,
5711 &attr
->extra
->mp_nexthop_global
,
5713 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
5714 json_object_string_add(json_nexthop_global
, "scope", "global");
5716 /* We display both LL & GL if both have been received */
5717 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5719 json_nexthop_ll
= json_object_new_object();
5720 json_object_string_add(json_nexthop_ll
, "ip",
5721 inet_ntop (AF_INET6
,
5722 &attr
->extra
->mp_nexthop_local
,
5724 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
5725 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
5727 if (IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
5728 &attr
->extra
->mp_nexthop_local
) != 0)
5729 json_object_boolean_true_add(json_nexthop_ll
, "used");
5731 json_object_boolean_true_add(json_nexthop_global
, "used");
5734 json_object_boolean_true_add(json_nexthop_global
, "used");
5738 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5740 if (binfo
->peer
->conf_if
)
5742 len
= vty_out (vty
, "%s",
5743 binfo
->peer
->conf_if
);
5744 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
5747 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
5749 vty_out (vty
, "%*s", len
, " ");
5753 len
= vty_out (vty
, "%s",
5754 inet_ntop (AF_INET6
,
5755 &attr
->extra
->mp_nexthop_local
,
5760 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5762 vty_out (vty
, "%*s", len
, " ");
5767 len
= vty_out (vty
, "%s",
5768 inet_ntop (AF_INET6
,
5769 &attr
->extra
->mp_nexthop_global
,
5774 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5776 vty_out (vty
, "%*s", len
, " ");
5780 #endif /* HAVE_IPV6 */
5783 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5785 json_object_int_add(json_path
, "med", attr
->med
);
5787 vty_out (vty
, "%10u", attr
->med
);
5793 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5795 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
5797 vty_out (vty
, "%7u", attr
->local_pref
);
5805 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
5807 json_object_int_add(json_path
, "weight", 0);
5810 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5816 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
5818 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5823 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
5825 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5830 json_object_string_add(json_path
, "alert", "No attributes");
5832 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
5837 if (json_nexthop_global
|| json_nexthop_ll
)
5839 json_nexthops
= json_object_new_array();
5841 if (json_nexthop_global
)
5842 json_object_array_add(json_nexthops
, json_nexthop_global
);
5844 if (json_nexthop_ll
)
5845 json_object_array_add(json_nexthops
, json_nexthop_ll
);
5847 json_object_object_add(json_path
, "nexthops", json_nexthops
);
5850 json_object_array_add(json_paths
, json_path
);
5853 vty_out (vty
, "%s", VTY_NEWLINE
);
5856 /* called from terminal list command */
5858 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
5859 u_char use_json
, json_object
*json_ar
)
5861 json_object
*json_status
= NULL
;
5862 json_object
*json_net
= NULL
;
5864 /* Route status display. */
5867 json_status
= json_object_new_object();
5868 json_net
= json_object_new_object();
5877 /* print prefix and mask */
5879 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
5881 route_vty_out_route (p
, vty
);
5883 /* Print attribute */
5888 if (p
->family
== AF_INET
&& (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5890 if (safi
== SAFI_MPLS_VPN
)
5891 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5893 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
5896 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5900 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5903 #endif /* HAVE_IPV6 */
5905 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5906 json_object_int_add(json_net
, "metric", attr
->med
);
5908 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5909 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
5912 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
5914 json_object_int_add(json_net
, "weight", 0);
5918 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
5921 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
5925 if (p
->family
== AF_INET
&& (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5927 if (safi
== SAFI_MPLS_VPN
)
5928 vty_out (vty
, "%-16s",
5929 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5931 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5934 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5939 assert (attr
->extra
);
5941 len
= vty_out (vty
, "%s",
5942 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
5946 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5948 vty_out (vty
, "%*s", len
, " ");
5950 #endif /* HAVE_IPV6 */
5951 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5952 vty_out (vty
, "%10u", attr
->med
);
5956 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5957 vty_out (vty
, "%7u", attr
->local_pref
);
5961 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
5965 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
5968 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
5973 json_object_boolean_true_add(json_status
, "*");
5974 json_object_boolean_true_add(json_status
, ">");
5975 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
5976 char buf_cut
[BUFSIZ
];
5977 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
5980 vty_out (vty
, "%s", VTY_NEWLINE
);
5984 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
5985 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
5987 json_object
*json_out
= NULL
;
5989 u_int32_t label
= 0;
5995 json_out
= json_object_new_object();
5997 /* short status lead text */
5998 route_vty_short_status_out (vty
, binfo
, json_out
);
6000 /* print prefix and mask */
6004 route_vty_out_route (p
, vty
);
6006 vty_out (vty
, "%*s", 17, " ");
6009 /* Print attribute */
6013 if (p
->family
== AF_INET
6014 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6016 if (safi
== SAFI_MPLS_VPN
)
6019 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6021 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6026 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6028 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6032 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6034 assert (attr
->extra
);
6038 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6041 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6042 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6045 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6048 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6052 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6054 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6056 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6057 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6060 vty_out (vty
, "%s(%s)",
6061 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6063 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6068 #endif /* HAVE_IPV6 */
6071 label
= decode_label (binfo
->extra
->tag
);
6076 json_object_int_add(json_out
, "notag", label
);
6077 json_object_array_add(json
, json_out
);
6081 vty_out (vty
, "notag/%d", label
);
6082 vty_out (vty
, "%s", VTY_NEWLINE
);
6086 /* dampening route */
6088 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6089 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6093 char timebuf
[BGP_UPTIME_LEN
];
6095 /* short status lead text */
6096 route_vty_short_status_out (vty
, binfo
, json
);
6098 /* print prefix and mask */
6102 route_vty_out_route (p
, vty
);
6104 vty_out (vty
, "%*s", 17, " ");
6107 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6112 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6117 json_object_int_add(json
, "peerHost", len
);
6119 vty_out (vty
, "%*s", len
, " ");
6123 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6125 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6127 /* Print attribute */
6135 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6137 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6142 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6144 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6147 vty_out (vty
, "%s", VTY_NEWLINE
);
6152 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6153 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6156 struct bgp_damp_info
*bdi
;
6157 char timebuf
[BGP_UPTIME_LEN
];
6163 bdi
= binfo
->extra
->damp_info
;
6165 /* short status lead text */
6166 route_vty_short_status_out (vty
, binfo
, json
);
6168 /* print prefix and mask */
6172 route_vty_out_route (p
, vty
);
6174 vty_out (vty
, "%*s", 17, " ");
6177 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6182 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6187 json_object_int_add(json
, "peerHost", len
);
6189 vty_out (vty
, "%*s", len
, " ");
6192 len
= vty_out (vty
, "%d", bdi
->flap
);
6202 json_object_int_add(json
, "bdiFlap", len
);
6204 vty_out (vty
, "%*s", len
, " ");
6208 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6210 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6211 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6213 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6214 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6217 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6219 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6224 vty_out (vty
, "%*s ", 8, " ");
6227 /* Print attribute */
6235 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6237 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6242 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6244 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6247 vty_out (vty
, "%s", VTY_NEWLINE
);
6251 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6252 const char *header
, json_object
*json_adv_to
)
6254 char buf1
[INET6_ADDRSTRLEN
];
6255 json_object
*json_peer
= NULL
;
6259 /* 'advertised-to' is a dictionary of peers we have advertised this
6260 * prefix too. The key is the peer's IP or swpX, the value is the
6261 * hostname if we know it and "" if not.
6263 json_peer
= json_object_new_object();
6266 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6269 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6271 json_object_object_add(json_adv_to
,
6272 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6279 vty_out (vty
, "%s", header
);
6283 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6286 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6288 vty_out (vty
, " %s(%s)", peer
->hostname
,
6289 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6294 vty_out (vty
, " %s", peer
->conf_if
);
6296 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6302 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6303 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6304 json_object
*json_paths
)
6306 char buf
[INET6_ADDRSTRLEN
];
6309 int sockunion_vty_out (struct vty
*, union sockunion
*);
6310 #ifdef HAVE_CLOCK_MONOTONIC
6313 json_object
*json_bestpath
= NULL
;
6314 json_object
*json_cluster_list
= NULL
;
6315 json_object
*json_cluster_list_list
= NULL
;
6316 json_object
*json_ext_community
= NULL
;
6317 json_object
*json_last_update
= NULL
;
6318 json_object
*json_nexthop_global
= NULL
;
6319 json_object
*json_nexthop_ll
= NULL
;
6320 json_object
*json_nexthops
= NULL
;
6321 json_object
*json_path
= NULL
;
6322 json_object
*json_peer
= NULL
;
6323 json_object
*json_string
= NULL
;
6324 json_object
*json_adv_to
= NULL
;
6326 struct listnode
*node
, *nnode
;
6328 int addpath_capable
;
6334 json_path
= json_object_new_object();
6335 json_peer
= json_object_new_object();
6336 json_nexthop_global
= json_object_new_object();
6343 /* Line1 display AS-path, Aggregator */
6348 json_object_lock(attr
->aspath
->json
);
6349 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6353 if (attr
->aspath
->segments
)
6354 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6356 vty_out (vty
, " Local");
6360 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6363 json_object_boolean_true_add(json_path
, "removed");
6365 vty_out (vty
, ", (removed)");
6368 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6371 json_object_boolean_true_add(json_path
, "stale");
6373 vty_out (vty
, ", (stale)");
6376 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6380 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6381 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6385 vty_out (vty
, ", (aggregated by %u %s)",
6386 attr
->extra
->aggregator_as
,
6387 inet_ntoa (attr
->extra
->aggregator_addr
));
6391 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6394 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6396 vty_out (vty
, ", (Received from a RR-client)");
6399 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6402 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6404 vty_out (vty
, ", (Received from a RS-client)");
6407 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6410 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6412 vty_out (vty
, ", (history entry)");
6414 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6417 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6419 vty_out (vty
, ", (suppressed due to dampening)");
6423 vty_out (vty
, "%s", VTY_NEWLINE
);
6425 /* Line2 display Next-hop, Neighbor, Router-id */
6426 /* Display the nexthop */
6427 if (p
->family
== AF_INET
6428 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6430 if (safi
== SAFI_MPLS_VPN
)
6433 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6435 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6440 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6442 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6446 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6451 assert (attr
->extra
);
6454 json_object_string_add(json_nexthop_global
, "ip",
6455 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6456 buf
, INET6_ADDRSTRLEN
));
6457 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6458 json_object_string_add(json_nexthop_global
, "scope", "global");
6462 vty_out (vty
, " %s",
6463 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6464 buf
, INET6_ADDRSTRLEN
));
6467 #endif /* HAVE_IPV6 */
6470 /* Display the IGP cost or 'inaccessible' */
6471 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6474 json_object_boolean_false_add(json_nexthop_global
, "accessible");
6476 vty_out (vty
, " (inaccessible)");
6480 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6483 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
6485 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
6488 /* IGP cost is 0, display this only for json */
6492 json_object_int_add(json_nexthop_global
, "metric", 0);
6496 json_object_boolean_true_add(json_nexthop_global
, "accessible");
6499 /* Display peer "from" output */
6500 /* This path was originated locally */
6501 if (binfo
->peer
== bgp
->peer_self
)
6504 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6507 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
6509 vty_out (vty
, " from 0.0.0.0 ");
6514 json_object_string_add(json_peer
, "peerId", "::");
6516 vty_out (vty
, " from :: ");
6520 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
6522 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
6525 /* We RXed this path from one of our peers */
6531 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6532 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6534 if (binfo
->peer
->hostname
)
6535 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
6537 if (binfo
->peer
->domainname
)
6538 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
6540 if (binfo
->peer
->conf_if
)
6541 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
6545 if (binfo
->peer
->conf_if
)
6547 if (binfo
->peer
->hostname
&&
6548 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6549 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6550 binfo
->peer
->conf_if
);
6552 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
6556 if (binfo
->peer
->hostname
&&
6557 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6558 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6561 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6564 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6565 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6567 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6572 vty_out (vty
, "%s", VTY_NEWLINE
);
6575 /* display the link-local nexthop */
6576 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6580 json_nexthop_ll
= json_object_new_object();
6581 json_object_string_add(json_nexthop_ll
, "ip",
6582 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6583 buf
, INET6_ADDRSTRLEN
));
6584 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6585 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6587 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
6588 json_object_boolean_true_add(json_nexthop_ll
, "used");
6592 vty_out (vty
, " (%s) (used)%s",
6593 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6594 buf
, INET6_ADDRSTRLEN
),
6598 /* If we do not have a link-local nexthop then we must flag the global as "used" */
6602 json_object_boolean_true_add(json_nexthop_global
, "used");
6604 #endif /* HAVE_IPV6 */
6606 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
6608 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6610 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6612 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6615 json_object_int_add(json_path
, "med", attr
->med
);
6617 vty_out (vty
, ", metric %u", attr
->med
);
6620 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6623 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6625 vty_out (vty
, ", localpref %u", attr
->local_pref
);
6630 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
6632 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
6635 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6638 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6640 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
6643 if (attr
->extra
&& attr
->extra
->tag
!= 0)
6646 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
6648 vty_out (vty
, ", tag %d", attr
->extra
->tag
);
6651 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6654 json_object_boolean_false_add(json_path
, "valid");
6656 vty_out (vty
, ", invalid");
6658 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6661 json_object_boolean_true_add(json_path
, "valid");
6663 vty_out (vty
, ", valid");
6666 if (binfo
->peer
!= bgp
->peer_self
)
6668 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6670 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
6673 json_object_string_add(json_peer
, "type", "confed-internal");
6675 vty_out (vty
, ", confed-internal");
6680 json_object_string_add(json_peer
, "type", "internal");
6682 vty_out (vty
, ", internal");
6687 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
6690 json_object_string_add(json_peer
, "type", "confed-external");
6692 vty_out (vty
, ", confed-external");
6697 json_object_string_add(json_peer
, "type", "external");
6699 vty_out (vty
, ", external");
6703 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6707 json_object_boolean_true_add(json_path
, "aggregated");
6708 json_object_boolean_true_add(json_path
, "local");
6712 vty_out (vty
, ", aggregated, local");
6715 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
6718 json_object_boolean_true_add(json_path
, "sourced");
6720 vty_out (vty
, ", sourced");
6726 json_object_boolean_true_add(json_path
, "sourced");
6727 json_object_boolean_true_add(json_path
, "local");
6731 vty_out (vty
, ", sourced, local");
6735 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
6738 json_object_boolean_true_add(json_path
, "atomicAggregate");
6740 vty_out (vty
, ", atomic-aggregate");
6743 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
6744 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
6745 bgp_info_mpath_count (binfo
)))
6748 json_object_boolean_true_add(json_path
, "multipath");
6750 vty_out (vty
, ", multipath");
6753 // Mark the bestpath(s)
6754 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
6756 first_as
= aspath_get_firstas(attr
->aspath
);
6761 json_bestpath
= json_object_new_object();
6762 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
6767 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
6769 vty_out (vty
, ", bestpath-from-AS Local");
6773 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6778 json_bestpath
= json_object_new_object();
6779 json_object_boolean_true_add(json_bestpath
, "overall");
6782 vty_out (vty
, ", best");
6786 json_object_object_add(json_path
, "bestpath", json_bestpath
);
6789 vty_out (vty
, "%s", VTY_NEWLINE
);
6791 /* Line 4 display Community */
6792 if (attr
->community
)
6796 json_object_lock(attr
->community
->json
);
6797 json_object_object_add(json_path
, "community", attr
->community
->json
);
6801 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
6806 /* Line 5 display Extended-community */
6807 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
6811 json_ext_community
= json_object_new_object();
6812 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
6813 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
6817 vty_out (vty
, " Extended Community: %s%s",
6818 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
6822 /* Line 6 display Originator, Cluster-id */
6823 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
6824 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
6826 assert (attr
->extra
);
6827 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6830 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
6832 vty_out (vty
, " Originator: %s",
6833 inet_ntoa (attr
->extra
->originator_id
));
6836 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
6842 json_cluster_list
= json_object_new_object();
6843 json_cluster_list_list
= json_object_new_array();
6845 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6847 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6848 json_object_array_add(json_cluster_list_list
, json_string
);
6851 /* struct cluster_list does not have "str" variable like
6852 * aspath and community do. Add this someday if someone
6854 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
6856 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
6857 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
6861 vty_out (vty
, ", Cluster list: ");
6863 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
6865 vty_out (vty
, "%s ",
6866 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
6872 vty_out (vty
, "%s", VTY_NEWLINE
);
6875 if (binfo
->extra
&& binfo
->extra
->damp_info
)
6876 bgp_damp_info_vty (vty
, binfo
, json_path
);
6878 /* Line 7 display Addpath IDs */
6879 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
6883 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
6884 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
6888 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
6889 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
6894 /* If we used addpath to TX a non-bestpath we need to display
6895 * "Advertised to" on a path-by-path basis */
6896 if (bgp
->addpath_tx_used
[afi
][safi
])
6900 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
6902 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
6903 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
6905 if ((addpath_capable
&& has_adj
) ||
6906 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
6908 if (json_path
&& !json_adv_to
)
6909 json_adv_to
= json_object_new_object();
6911 route_vty_out_advertised_to(vty
, peer
, &first
,
6921 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
6928 vty_out (vty
, "%s", VTY_NEWLINE
);
6933 /* Line 8 display Uptime */
6934 #ifdef HAVE_CLOCK_MONOTONIC
6935 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
6938 json_last_update
= json_object_new_object();
6939 json_object_int_add(json_last_update
, "epoch", tbuf
);
6940 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
6941 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
6944 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
6948 json_last_update
= json_object_new_object();
6949 json_object_int_add(json_last_update
, "epoch", tbuf
);
6950 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
6951 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
6954 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
6955 #endif /* HAVE_CLOCK_MONOTONIC */
6958 /* We've constructed the json object for this path, add it to the json
6963 if (json_nexthop_global
|| json_nexthop_ll
)
6965 json_nexthops
= json_object_new_array();
6967 if (json_nexthop_global
)
6968 json_object_array_add(json_nexthops
, json_nexthop_global
);
6970 if (json_nexthop_ll
)
6971 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6973 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6976 json_object_object_add(json_path
, "peer", json_peer
);
6977 json_object_array_add(json_paths
, json_path
);
6980 vty_out (vty
, "%s", VTY_NEWLINE
);
6983 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
6984 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
6985 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
6989 bgp_show_type_normal
,
6990 bgp_show_type_regexp
,
6991 bgp_show_type_prefix_list
,
6992 bgp_show_type_filter_list
,
6993 bgp_show_type_route_map
,
6994 bgp_show_type_neighbor
,
6995 bgp_show_type_cidr_only
,
6996 bgp_show_type_prefix_longer
,
6997 bgp_show_type_community_all
,
6998 bgp_show_type_community
,
6999 bgp_show_type_community_exact
,
7000 bgp_show_type_community_list
,
7001 bgp_show_type_community_list_exact
,
7002 bgp_show_type_flap_statistics
,
7003 bgp_show_type_flap_address
,
7004 bgp_show_type_flap_prefix
,
7005 bgp_show_type_flap_cidr_only
,
7006 bgp_show_type_flap_regexp
,
7007 bgp_show_type_flap_filter_list
,
7008 bgp_show_type_flap_prefix_list
,
7009 bgp_show_type_flap_prefix_longer
,
7010 bgp_show_type_flap_route_map
,
7011 bgp_show_type_flap_neighbor
,
7012 bgp_show_type_dampend_paths
,
7013 bgp_show_type_damp_neighbor
7017 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7018 const char *prefix_list_str
, afi_t afi
,
7019 safi_t safi
, enum bgp_show_type type
);
7021 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7022 const char *filter
, afi_t afi
,
7023 safi_t safi
, enum bgp_show_type type
);
7025 bgp_show_route_map (struct vty
*vty
, const char *name
,
7026 const char *rmap_str
, afi_t afi
,
7027 safi_t safi
, enum bgp_show_type type
);
7029 bgp_show_community_list (struct vty
*vty
, const char *name
,
7030 const char *com
, int exact
,
7031 afi_t afi
, safi_t safi
);
7033 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7034 const char *prefix
, afi_t afi
,
7035 safi_t safi
, enum bgp_show_type type
);
7038 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
,
7039 struct in_addr
*router_id
, enum bgp_show_type type
,
7040 void *output_arg
, u_char use_json
, json_object
*json
)
7042 struct bgp_info
*ri
;
7043 struct bgp_node
*rn
;
7046 unsigned long output_count
;
7050 json_object
*json_paths
= NULL
;
7051 json_object
*json_routes
= NULL
;
7056 json
= json_object_new_object();
7058 json_object_int_add(json
, "tableVersion", table
->version
);
7059 json_object_string_add(json
, "routerId", inet_ntoa (*router_id
));
7060 json_routes
= json_object_new_object();
7063 /* This is first entry point, so reset total line. */
7066 /* Start processing of routes. */
7067 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7068 if (rn
->info
!= NULL
)
7073 json_paths
= json_object_new_array();
7077 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7079 if (type
== bgp_show_type_flap_statistics
7080 || type
== bgp_show_type_flap_address
7081 || type
== bgp_show_type_flap_prefix
7082 || type
== bgp_show_type_flap_cidr_only
7083 || type
== bgp_show_type_flap_regexp
7084 || type
== bgp_show_type_flap_filter_list
7085 || type
== bgp_show_type_flap_prefix_list
7086 || type
== bgp_show_type_flap_prefix_longer
7087 || type
== bgp_show_type_flap_route_map
7088 || type
== bgp_show_type_flap_neighbor
7089 || type
== bgp_show_type_dampend_paths
7090 || type
== bgp_show_type_damp_neighbor
)
7092 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7095 if (type
== bgp_show_type_regexp
7096 || type
== bgp_show_type_flap_regexp
)
7098 regex_t
*regex
= output_arg
;
7100 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7103 if (type
== bgp_show_type_prefix_list
7104 || type
== bgp_show_type_flap_prefix_list
)
7106 struct prefix_list
*plist
= output_arg
;
7108 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7111 if (type
== bgp_show_type_filter_list
7112 || type
== bgp_show_type_flap_filter_list
)
7114 struct as_list
*as_list
= output_arg
;
7116 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7119 if (type
== bgp_show_type_route_map
7120 || type
== bgp_show_type_flap_route_map
)
7122 struct route_map
*rmap
= output_arg
;
7123 struct bgp_info binfo
;
7124 struct attr dummy_attr
;
7125 struct attr_extra dummy_extra
;
7128 dummy_attr
.extra
= &dummy_extra
;
7129 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7131 binfo
.peer
= ri
->peer
;
7132 binfo
.attr
= &dummy_attr
;
7134 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7135 if (ret
== RMAP_DENYMATCH
)
7138 if (type
== bgp_show_type_neighbor
7139 || type
== bgp_show_type_flap_neighbor
7140 || type
== bgp_show_type_damp_neighbor
)
7142 union sockunion
*su
= output_arg
;
7144 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7147 if (type
== bgp_show_type_cidr_only
7148 || type
== bgp_show_type_flap_cidr_only
)
7150 u_int32_t destination
;
7152 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7153 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7155 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7157 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7160 if (type
== bgp_show_type_prefix_longer
7161 || type
== bgp_show_type_flap_prefix_longer
)
7163 struct prefix
*p
= output_arg
;
7165 if (! prefix_match (p
, &rn
->p
))
7168 if (type
== bgp_show_type_community_all
)
7170 if (! ri
->attr
->community
)
7173 if (type
== bgp_show_type_community
)
7175 struct community
*com
= output_arg
;
7177 if (! ri
->attr
->community
||
7178 ! community_match (ri
->attr
->community
, com
))
7181 if (type
== bgp_show_type_community_exact
)
7183 struct community
*com
= output_arg
;
7185 if (! ri
->attr
->community
||
7186 ! community_cmp (ri
->attr
->community
, com
))
7189 if (type
== bgp_show_type_community_list
)
7191 struct community_list
*list
= output_arg
;
7193 if (! community_list_match (ri
->attr
->community
, list
))
7196 if (type
== bgp_show_type_community_list_exact
)
7198 struct community_list
*list
= output_arg
;
7200 if (! community_list_exact_match (ri
->attr
->community
, list
))
7203 if (type
== bgp_show_type_flap_address
7204 || type
== bgp_show_type_flap_prefix
)
7206 struct prefix
*p
= output_arg
;
7208 if (! prefix_match (&rn
->p
, p
))
7211 if (type
== bgp_show_type_flap_prefix
)
7212 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7215 if (type
== bgp_show_type_dampend_paths
7216 || type
== bgp_show_type_damp_neighbor
)
7218 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7219 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7223 if (!use_json
&& header
)
7225 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (*router_id
), VTY_NEWLINE
);
7226 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7227 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7228 if (type
== bgp_show_type_dampend_paths
7229 || type
== bgp_show_type_damp_neighbor
)
7230 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7231 else if (type
== bgp_show_type_flap_statistics
7232 || type
== bgp_show_type_flap_address
7233 || type
== bgp_show_type_flap_prefix
7234 || type
== bgp_show_type_flap_cidr_only
7235 || type
== bgp_show_type_flap_regexp
7236 || type
== bgp_show_type_flap_filter_list
7237 || type
== bgp_show_type_flap_prefix_list
7238 || type
== bgp_show_type_flap_prefix_longer
7239 || type
== bgp_show_type_flap_route_map
7240 || type
== bgp_show_type_flap_neighbor
)
7241 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7243 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7247 if (type
== bgp_show_type_dampend_paths
7248 || type
== bgp_show_type_damp_neighbor
)
7249 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7250 else if (type
== bgp_show_type_flap_statistics
7251 || type
== bgp_show_type_flap_address
7252 || type
== bgp_show_type_flap_prefix
7253 || type
== bgp_show_type_flap_cidr_only
7254 || type
== bgp_show_type_flap_regexp
7255 || type
== bgp_show_type_flap_filter_list
7256 || type
== bgp_show_type_flap_prefix_list
7257 || type
== bgp_show_type_flap_prefix_longer
7258 || type
== bgp_show_type_flap_route_map
7259 || type
== bgp_show_type_flap_neighbor
)
7260 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7262 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7272 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7273 json_object_object_add(json_routes
, buf2
, json_paths
);
7280 json_object_object_add(json
, "routes", json_routes
);
7281 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7282 json_object_free(json
);
7286 /* No route is displayed */
7287 if (output_count
== 0)
7289 if (type
== bgp_show_type_normal
)
7290 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
7293 vty_out (vty
, "%sTotal number of prefixes %ld%s",
7294 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
7301 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7302 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7304 struct bgp_table
*table
;
7308 bgp
= bgp_get_default ();
7314 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7318 table
= bgp
->rib
[afi
][safi
];
7320 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
,
7325 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7328 struct listnode
*node
, *nnode
;
7330 struct bgp_table
*table
;
7331 json_object
*json
= NULL
;
7335 vty_out (vty
, "{%s", VTY_NEWLINE
);
7337 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7341 if (!(json
= json_object_new_object()))
7343 zlog_err("Unable to allocate memory for JSON object");
7345 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
7349 json_object_int_add(json
, "vrfId",
7350 (bgp
->vrf_id
== VRF_UNKNOWN
)
7351 ? -1 : bgp
->vrf_id
);
7352 json_object_string_add(json
, "vrfName",
7353 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7354 ? "Default" : bgp
->name
);
7356 vty_out (vty
, ",%s", VTY_NEWLINE
);
7360 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7361 ? "Default" : bgp
->name
);
7365 vty_out (vty
, "%sInstance %s:%s",
7367 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7368 ? "Default" : bgp
->name
,
7371 table
= bgp
->rib
[afi
][safi
];
7372 bgp_show_table (vty
, table
, &bgp
->router_id
,
7373 bgp_show_type_normal
, NULL
, use_json
, json
);
7378 vty_out (vty
, "}%s", VTY_NEWLINE
);
7381 /* Header of detailed BGP route information */
7383 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7384 struct bgp_node
*rn
,
7385 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7388 struct bgp_info
*ri
;
7391 struct listnode
*node
, *nnode
;
7392 char buf1
[INET6_ADDRSTRLEN
];
7393 char buf2
[INET6_ADDRSTRLEN
];
7398 int no_advertise
= 0;
7401 json_object
*json_adv_to
= NULL
;
7407 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7408 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7412 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7413 (safi
== SAFI_MPLS_VPN
?
7414 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7415 safi
== SAFI_MPLS_VPN
? ":" : "",
7416 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7417 p
->prefixlen
, VTY_NEWLINE
);
7420 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7423 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7426 if (ri
->extra
&& ri
->extra
->suppress
)
7428 if (ri
->attr
->community
!= NULL
)
7430 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7432 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7434 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7442 vty_out (vty
, "Paths: (%d available", count
);
7445 vty_out (vty
, ", best #%d", best
);
7446 if (safi
== SAFI_UNICAST
)
7447 vty_out (vty
, ", table Default-IP-Routing-Table");
7450 vty_out (vty
, ", no best path");
7453 vty_out (vty
, ", not advertised to any peer");
7455 vty_out (vty
, ", not advertised to EBGP peer");
7457 vty_out (vty
, ", not advertised outside local AS");
7460 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7461 vty_out (vty
, ")%s", VTY_NEWLINE
);
7464 /* If we are not using addpath then we can display Advertised to and that will
7465 * show what peers we advertised the bestpath to. If we are using addpath
7466 * though then we must display Advertised to on a path-by-path basis. */
7467 if (!bgp
->addpath_tx_used
[afi
][safi
])
7469 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7471 if (bgp_adj_out_lookup (peer
, rn
, 0))
7473 if (json
&& !json_adv_to
)
7474 json_adv_to
= json_object_new_object();
7476 route_vty_out_advertised_to(vty
, peer
, &first
,
7477 " Advertised to non peer-group peers:\n ",
7486 json_object_object_add(json
, "advertisedTo", json_adv_to
);
7492 vty_out (vty
, " Not advertised to any peer");
7493 vty_out (vty
, "%s", VTY_NEWLINE
);
7498 /* Display specified route of BGP table. */
7500 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
7501 struct bgp_table
*rib
, const char *ip_str
,
7502 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7503 int prefix_check
, enum bgp_path_type pathtype
,
7509 struct prefix match
;
7510 struct bgp_node
*rn
;
7511 struct bgp_node
*rm
;
7512 struct bgp_info
*ri
;
7513 struct bgp_table
*table
;
7514 json_object
*json
= NULL
;
7515 json_object
*json_paths
= NULL
;
7517 /* Check IP address argument. */
7518 ret
= str2prefix (ip_str
, &match
);
7521 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
7525 match
.family
= afi2family (afi
);
7529 json
= json_object_new_object();
7530 json_paths
= json_object_new_array();
7533 if (safi
== SAFI_MPLS_VPN
)
7535 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
7537 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
7540 if ((table
= rn
->info
) != NULL
)
7544 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
7546 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
7548 bgp_unlock_node (rm
);
7552 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
7556 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
7557 AFI_IP
, SAFI_MPLS_VPN
, json
);
7563 if (pathtype
== BGP_PATH_ALL
||
7564 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7565 (pathtype
== BGP_PATH_MULTIPATH
&&
7566 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7567 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
, json_paths
);
7570 bgp_unlock_node (rm
);
7579 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
7581 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
7583 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7587 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
7592 if (pathtype
== BGP_PATH_ALL
||
7593 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7594 (pathtype
== BGP_PATH_MULTIPATH
&&
7595 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7596 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
7600 bgp_unlock_node (rn
);
7607 json_object_object_add(json
, "paths", json_paths
);
7609 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7610 json_object_free(json
);
7616 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
7624 /* Display specified route of Main RIB */
7626 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
7627 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7628 int prefix_check
, enum bgp_path_type pathtype
,
7633 /* BGP structure lookup. */
7636 bgp
= bgp_lookup_by_name (view_name
);
7639 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
7645 bgp
= bgp_get_default ();
7648 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7653 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
7654 afi
, safi
, prd
, prefix_check
, pathtype
,
7658 /* BGP route print out function. */
7661 "show ip bgp {json}",
7665 "JavaScript Object Notation\n")
7667 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7670 DEFUN (show_ip_bgp_ipv4
,
7671 show_ip_bgp_ipv4_cmd
,
7672 "show ip bgp ipv4 (unicast|multicast) {json}",
7677 "Address Family modifier\n"
7678 "Address Family modifier\n"
7679 "JavaScript Object Notation\n")
7681 u_char uj
= use_json(argc
, argv
);
7683 if (strncmp (argv
[0], "m", 1) == 0)
7684 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
7687 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
7690 ALIAS (show_ip_bgp_ipv4
,
7691 show_bgp_ipv4_safi_cmd
,
7692 "show bgp ipv4 (unicast|multicast) {json}",
7696 "Address Family modifier\n"
7697 "Address Family modifier\n"
7698 "JavaScript Object Notation\n")
7700 DEFUN (show_ip_bgp_route
,
7701 show_ip_bgp_route_cmd
,
7702 "show ip bgp A.B.C.D {json}",
7706 "Network in the BGP routing table to display\n"
7707 "JavaScript Object Notation\n")
7709 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7712 DEFUN (show_ip_bgp_route_pathtype
,
7713 show_ip_bgp_route_pathtype_cmd
,
7714 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
7718 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7719 "Display only the bestpath\n"
7720 "Display only multipaths\n"
7721 "JavaScript Object Notation\n")
7723 u_char uj
= use_json(argc
, argv
);
7725 if (strncmp (argv
[1], "b", 1) == 0)
7726 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7728 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7731 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
7732 show_bgp_ipv4_safi_route_pathtype_cmd
,
7733 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
7737 "Address Family modifier\n"
7738 "Address Family modifier\n"
7739 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7740 "Display only the bestpath\n"
7741 "Display only multipaths\n"
7742 "JavaScript Object Notation\n")
7744 u_char uj
= use_json(argc
, argv
);
7746 if (strncmp (argv
[0], "m", 1) == 0)
7747 if (strncmp (argv
[2], "b", 1) == 0)
7748 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7750 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7752 if (strncmp (argv
[2], "b", 1) == 0)
7753 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7755 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7758 DEFUN (show_ip_bgp_ipv4_route
,
7759 show_ip_bgp_ipv4_route_cmd
,
7760 "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
7765 "Address Family modifier\n"
7766 "Address Family modifier\n"
7767 "Network in the BGP routing table to display\n"
7768 "JavaScript Object Notation\n")
7770 u_char uj
= use_json(argc
, argv
);
7772 if (strncmp (argv
[0], "m", 1) == 0)
7773 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7775 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7778 ALIAS (show_ip_bgp_ipv4_route
,
7779 show_bgp_ipv4_safi_route_cmd
,
7780 "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
7784 "Address Family modifier\n"
7785 "Address Family modifier\n"
7786 "Network in the BGP routing table to display\n"
7787 "JavaScript Object Notation\n")
7789 DEFUN (show_ip_bgp_vpnv4_all_route
,
7790 show_ip_bgp_vpnv4_all_route_cmd
,
7791 "show ip bgp vpnv4 all A.B.C.D {json}",
7795 "Display VPNv4 NLRI specific information\n"
7796 "Display information about all VPNv4 NLRIs\n"
7797 "Network in the BGP routing table to display\n"
7798 "JavaScript Object Notation\n")
7800 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7804 DEFUN (show_ip_bgp_vpnv4_rd_route
,
7805 show_ip_bgp_vpnv4_rd_route_cmd
,
7806 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
7810 "Display VPNv4 NLRI specific information\n"
7811 "Display information for a route distinguisher\n"
7812 "VPN Route Distinguisher\n"
7813 "Network in the BGP routing table to display\n"
7814 "JavaScript Object Notation\n")
7817 struct prefix_rd prd
;
7818 u_char uj
= use_json(argc
, argv
);
7820 ret
= str2prefix_rd (argv
[0], &prd
);
7823 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
7826 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, uj
);
7829 DEFUN (show_ip_bgp_prefix
,
7830 show_ip_bgp_prefix_cmd
,
7831 "show ip bgp A.B.C.D/M {json}",
7835 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7836 "JavaScript Object Notation\n")
7838 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
7841 DEFUN (show_ip_bgp_prefix_pathtype
,
7842 show_ip_bgp_prefix_pathtype_cmd
,
7843 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
7847 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7848 "Display only the bestpath\n"
7849 "Display only multipaths\n"
7850 "JavaScript Object Notation\n")
7852 u_char uj
= use_json(argc
, argv
);
7853 if (strncmp (argv
[1], "b", 1) == 0)
7854 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7856 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7859 DEFUN (show_ip_bgp_ipv4_prefix
,
7860 show_ip_bgp_ipv4_prefix_cmd
,
7861 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
7866 "Address Family modifier\n"
7867 "Address Family modifier\n"
7868 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7869 "JavaScript Object Notation\n")
7871 u_char uj
= use_json(argc
, argv
);
7873 if (strncmp (argv
[0], "m", 1) == 0)
7874 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
7876 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
7879 ALIAS (show_ip_bgp_ipv4_prefix
,
7880 show_bgp_ipv4_safi_prefix_cmd
,
7881 "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
7885 "Address Family modifier\n"
7886 "Address Family modifier\n"
7887 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7888 "JavaScript Object Notation\n")
7890 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
7891 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
7892 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
7897 "Address Family modifier\n"
7898 "Address Family modifier\n"
7899 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7900 "Display only the bestpath\n"
7901 "Display only multipaths\n"
7902 "JavaScript Object Notation\n")
7904 u_char uj
= use_json(argc
, argv
);
7906 if (strncmp (argv
[0], "m", 1) == 0)
7907 if (strncmp (argv
[2], "b", 1) == 0)
7908 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7910 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7912 if (strncmp (argv
[2], "b", 1) == 0)
7913 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
7915 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
7918 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
7919 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
7920 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
7924 "Address Family modifier\n"
7925 "Address Family modifier\n"
7926 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7927 "Display only the bestpath\n"
7928 "Display only multipaths\n"
7929 "JavaScript Object Notation\n")
7931 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
7932 show_ip_bgp_vpnv4_all_prefix_cmd
,
7933 "show ip bgp vpnv4 all A.B.C.D/M {json}",
7937 "Display VPNv4 NLRI specific information\n"
7938 "Display information about all VPNv4 NLRIs\n"
7939 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7940 "JavaScript Object Notation\n")
7942 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
7945 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
7946 show_ip_bgp_vpnv4_rd_prefix_cmd
,
7947 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
7951 "Display VPNv4 NLRI specific information\n"
7952 "Display information for a route distinguisher\n"
7953 "VPN Route Distinguisher\n"
7954 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7955 "JavaScript Object Notation\n")
7958 struct prefix_rd prd
;
7960 ret
= str2prefix_rd (argv
[0], &prd
);
7963 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
7966 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7969 DEFUN (show_ip_bgp_view
,
7970 show_ip_bgp_instance_cmd
,
7971 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
7975 BGP_INSTANCE_HELP_STR
7976 "JavaScript Object Notation\n")
7980 /* BGP structure lookup. */
7981 bgp
= bgp_lookup_by_name (argv
[1]);
7984 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
7988 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7991 DEFUN (show_ip_bgp_instance_all
,
7992 show_ip_bgp_instance_all_cmd
,
7993 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
7997 BGP_INSTANCE_ALL_HELP_STR
7998 "JavaScript Object Notation\n")
8000 u_char uj
= use_json(argc
, argv
);
8002 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8006 DEFUN (show_ip_bgp_instance_route
,
8007 show_ip_bgp_instance_route_cmd
,
8008 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8012 BGP_INSTANCE_HELP_STR
8013 "Network in the BGP routing table to display\n"
8014 "JavaScript Object Notation\n")
8016 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8019 DEFUN (show_ip_bgp_instance_route_pathtype
,
8020 show_ip_bgp_instance_route_pathtype_cmd
,
8021 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8025 BGP_INSTANCE_HELP_STR
8026 "Network in the BGP routing table to display\n"
8027 "Display only the bestpath\n"
8028 "Display only multipaths\n"
8029 "JavaScript Object Notation\n")
8031 u_char uj
= use_json(argc
, argv
);
8033 if (strncmp (argv
[3], "b", 1) == 0)
8034 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8036 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8039 DEFUN (show_ip_bgp_instance_prefix
,
8040 show_ip_bgp_instance_prefix_cmd
,
8041 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8045 BGP_INSTANCE_HELP_STR
8046 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8047 "JavaScript Object Notation\n")
8049 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8052 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8053 show_ip_bgp_instance_prefix_pathtype_cmd
,
8054 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8058 BGP_INSTANCE_HELP_STR
8059 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8060 "Display only the bestpath\n"
8061 "Display only multipaths\n"
8062 "JavaScript Object Notation\n")
8064 u_char uj
= use_json(argc
, argv
);
8065 if (strncmp (argv
[3], "b", 1) == 0)
8066 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8068 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8077 "JavaScript Object Notation\n")
8079 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8080 NULL
, use_json(argc
, argv
));
8085 "show bgp ipv6 {json}",
8089 "JavaScript Object Notation\n")
8091 DEFUN (show_bgp_ipv6_safi
,
8092 show_bgp_ipv6_safi_cmd
,
8093 "show bgp ipv6 (unicast|multicast) {json}",
8097 "Address Family modifier\n"
8098 "Address Family modifier\n"
8099 "JavaScript Object Notation\n")
8101 u_char uj
= use_json(argc
, argv
);
8102 if (strncmp (argv
[0], "m", 1) == 0)
8103 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8106 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8110 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8112 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8113 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8114 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8118 DEFUN (show_ipv6_bgp
,
8120 "show ipv6 bgp {json}",
8124 "JavaScript Object Notation\n")
8126 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8127 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8128 NULL
, use_json(argc
, argv
));
8131 DEFUN (show_bgp_route
,
8133 "show bgp X:X::X:X {json}",
8136 "Network in the BGP routing table to display\n"
8137 "JavaScript Object Notation\n")
8139 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8142 ALIAS (show_bgp_route
,
8143 show_bgp_ipv6_route_cmd
,
8144 "show bgp ipv6 X:X::X:X {json}",
8148 "Network in the BGP routing table to display\n"
8149 "JavaScript Object Notation\n")
8151 DEFUN (show_bgp_ipv6_safi_route
,
8152 show_bgp_ipv6_safi_route_cmd
,
8153 "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
8157 "Address Family modifier\n"
8158 "Address Family modifier\n"
8159 "Network in the BGP routing table to display\n"
8160 "JavaScript Object Notation\n")
8162 u_char uj
= use_json(argc
, argv
);
8163 if (strncmp (argv
[0], "m", 1) == 0)
8164 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8166 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8169 DEFUN (show_bgp_route_pathtype
,
8170 show_bgp_route_pathtype_cmd
,
8171 "show bgp X:X::X:X (bestpath|multipath) {json}",
8174 "Network in the BGP routing table to display\n"
8175 "Display only the bestpath\n"
8176 "Display only multipaths\n"
8177 "JavaScript Object Notation\n")
8179 u_char uj
= use_json(argc
, argv
);
8180 if (strncmp (argv
[1], "b", 1) == 0)
8181 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8183 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8186 ALIAS (show_bgp_route_pathtype
,
8187 show_bgp_ipv6_route_pathtype_cmd
,
8188 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8192 "Network in the BGP routing table to display\n"
8193 "Display only the bestpath\n"
8194 "Display only multipaths\n"
8195 "JavaScript Object Notation\n")
8197 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8198 show_bgp_ipv6_safi_route_pathtype_cmd
,
8199 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
8203 "Address Family modifier\n"
8204 "Address Family modifier\n"
8205 "Network in the BGP routing table to display\n"
8206 "Display only the bestpath\n"
8207 "Display only multipaths\n"
8208 "JavaScript Object Notation\n")
8210 u_char uj
= use_json(argc
, argv
);
8211 if (strncmp (argv
[0], "m", 1) == 0)
8212 if (strncmp (argv
[2], "b", 1) == 0)
8213 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8215 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8217 if (strncmp (argv
[2], "b", 1) == 0)
8218 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8220 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8224 DEFUN (show_ipv6_bgp_route
,
8225 show_ipv6_bgp_route_cmd
,
8226 "show ipv6 bgp X:X::X:X {json}",
8230 "Network in the BGP routing table to display\n"
8231 "JavaScript Object Notation\n")
8233 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8234 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8237 DEFUN (show_bgp_prefix
,
8238 show_bgp_prefix_cmd
,
8239 "show bgp X:X::X:X/M {json}",
8242 "IPv6 prefix <network>/<length>\n"
8243 "JavaScript Object Notation\n")
8245 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8248 ALIAS (show_bgp_prefix
,
8249 show_bgp_ipv6_prefix_cmd
,
8250 "show bgp ipv6 X:X::X:X/M {json}",
8254 "IPv6 prefix <network>/<length>\n"
8255 "JavaScript Object Notation\n")
8257 DEFUN (show_bgp_ipv6_safi_prefix
,
8258 show_bgp_ipv6_safi_prefix_cmd
,
8259 "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
8263 "Address Family modifier\n"
8264 "Address Family modifier\n"
8265 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8266 "JavaScript Object Notation\n")
8268 u_char uj
= use_json(argc
, argv
);
8269 if (strncmp (argv
[0], "m", 1) == 0)
8270 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8272 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8275 DEFUN (show_bgp_prefix_pathtype
,
8276 show_bgp_prefix_pathtype_cmd
,
8277 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8280 "IPv6 prefix <network>/<length>\n"
8281 "Display only the bestpath\n"
8282 "Display only multipaths\n"
8283 "JavaScript Object Notation\n")
8285 u_char uj
= use_json(argc
, argv
);
8286 if (strncmp (argv
[1], "b", 1) == 0)
8287 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8289 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8292 ALIAS (show_bgp_prefix_pathtype
,
8293 show_bgp_ipv6_prefix_pathtype_cmd
,
8294 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8298 "IPv6 prefix <network>/<length>\n"
8299 "Display only the bestpath\n"
8300 "Display only multipaths\n"
8301 "JavaScript Object Notation\n")
8303 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8304 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8305 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
8309 "Address Family modifier\n"
8310 "Address Family modifier\n"
8311 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8312 "Display only the bestpath\n"
8313 "Display only multipaths\n"
8314 "JavaScript Object Notation\n")
8316 u_char uj
= use_json(argc
, argv
);
8317 if (strncmp (argv
[0], "m", 1) == 0)
8318 if (strncmp (argv
[2], "b", 1) == 0)
8319 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8321 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8323 if (strncmp (argv
[2], "b", 1) == 0)
8324 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8326 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8330 DEFUN (show_ipv6_bgp_prefix
,
8331 show_ipv6_bgp_prefix_cmd
,
8332 "show ipv6 bgp X:X::X:X/M {json}",
8336 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8337 "JavaScript Object Notation\n")
8339 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8340 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8343 DEFUN (show_bgp_view
,
8344 show_bgp_instance_cmd
,
8345 "show bgp " BGP_INSTANCE_CMD
" {json}",
8348 BGP_INSTANCE_HELP_STR
8349 "JavaScript Object Notation\n")
8353 /* BGP structure lookup. */
8354 bgp
= bgp_lookup_by_name (argv
[1]);
8357 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8361 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8364 DEFUN (show_bgp_instance_all
,
8365 show_bgp_instance_all_cmd
,
8366 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8369 BGP_INSTANCE_ALL_HELP_STR
8370 "JavaScript Object Notation\n")
8372 u_char uj
= use_json(argc
, argv
);
8374 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8378 ALIAS (show_bgp_view
,
8379 show_bgp_instance_ipv6_cmd
,
8380 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8383 BGP_INSTANCE_HELP_STR
8385 "JavaScript Object Notation\n")
8387 DEFUN (show_bgp_instance_route
,
8388 show_bgp_instance_route_cmd
,
8389 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8392 BGP_INSTANCE_HELP_STR
8393 "Network in the BGP routing table to display\n"
8394 "JavaScript Object Notation\n")
8396 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8399 ALIAS (show_bgp_instance_route
,
8400 show_bgp_instance_ipv6_route_cmd
,
8401 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8404 BGP_INSTANCE_HELP_STR
8406 "Network in the BGP routing table to display\n"
8407 "JavaScript Object Notation\n")
8409 DEFUN (show_bgp_instance_route_pathtype
,
8410 show_bgp_instance_route_pathtype_cmd
,
8411 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8414 BGP_INSTANCE_HELP_STR
8415 "Network in the BGP routing table to display\n"
8416 "Display only the bestpath\n"
8417 "Display only multipaths\n"
8418 "JavaScript Object Notation\n")
8420 u_char uj
= use_json(argc
, argv
);
8421 if (strncmp (argv
[3], "b", 1) == 0)
8422 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8424 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8427 ALIAS (show_bgp_instance_route_pathtype
,
8428 show_bgp_instance_ipv6_route_pathtype_cmd
,
8429 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
8432 BGP_INSTANCE_HELP_STR
8434 "Network in the BGP routing table to display\n"
8435 "Display only the bestpath\n"
8436 "Display only multipaths\n"
8437 "JavaScript Object Notation\n")
8439 DEFUN (show_bgp_instance_prefix
,
8440 show_bgp_instance_prefix_cmd
,
8441 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
8444 BGP_INSTANCE_HELP_STR
8445 "IPv6 prefix <network>/<length>\n"
8446 "JavaScript Object Notation\n")
8448 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8451 ALIAS (show_bgp_instance_prefix
,
8452 show_bgp_instance_ipv6_prefix_cmd
,
8453 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
8456 BGP_INSTANCE_HELP_STR
8458 "IPv6 prefix <network>/<length>\n"
8459 "JavaScript Object Notation\n")
8461 DEFUN (show_bgp_instance_prefix_pathtype
,
8462 show_bgp_instance_prefix_pathtype_cmd
,
8463 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
8466 BGP_INSTANCE_HELP_STR
8467 "IPv6 prefix <network>/<length>\n"
8468 "Display only the bestpath\n"
8469 "Display only multipaths\n"
8470 "JavaScript Object Notation\n")
8472 u_char uj
= use_json(argc
, argv
);
8473 if (strncmp (argv
[3], "b", 1) == 0)
8474 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8476 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8479 ALIAS (show_bgp_instance_prefix_pathtype
,
8480 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
8481 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8484 BGP_INSTANCE_HELP_STR
8486 "IPv6 prefix <network>/<length>\n"
8487 "Display only the bestpath\n"
8488 "Display only multipaths\n"
8489 "JavaScript Object Notation\n")
8491 DEFUN (show_bgp_instance_prefix_list
,
8492 show_bgp_instance_prefix_list_cmd
,
8493 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
8496 BGP_INSTANCE_HELP_STR
8497 "Display routes conforming to the prefix-list\n"
8498 "IPv6 prefix-list name\n")
8500 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8501 bgp_show_type_prefix_list
);
8504 ALIAS (show_bgp_instance_prefix_list
,
8505 show_bgp_instance_ipv6_prefix_list_cmd
,
8506 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
8509 BGP_INSTANCE_HELP_STR
8511 "Display routes conforming to the prefix-list\n"
8512 "IPv6 prefix-list name\n")
8514 DEFUN (show_bgp_instance_filter_list
,
8515 show_bgp_instance_filter_list_cmd
,
8516 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
8519 BGP_INSTANCE_HELP_STR
8520 "Display routes conforming to the filter-list\n"
8521 "Regular expression access list name\n")
8523 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8524 bgp_show_type_filter_list
);
8527 ALIAS (show_bgp_instance_filter_list
,
8528 show_bgp_instance_ipv6_filter_list_cmd
,
8529 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
8532 BGP_INSTANCE_HELP_STR
8534 "Display routes conforming to the filter-list\n"
8535 "Regular expression access list name\n")
8537 DEFUN (show_bgp_instance_route_map
,
8538 show_bgp_instance_route_map_cmd
,
8539 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
8542 BGP_INSTANCE_HELP_STR
8543 "Display routes matching the route-map\n"
8544 "A route-map to match on\n")
8546 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8547 bgp_show_type_route_map
);
8550 ALIAS (show_bgp_instance_route_map
,
8551 show_bgp_instance_ipv6_route_map_cmd
,
8552 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
8555 BGP_INSTANCE_HELP_STR
8557 "Display routes matching the route-map\n"
8558 "A route-map to match on\n")
8560 DEFUN (show_bgp_instance_community_list
,
8561 show_bgp_instance_community_list_cmd
,
8562 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
8565 BGP_INSTANCE_HELP_STR
8566 "Display routes matching the community-list\n"
8567 "community-list number\n"
8568 "community-list name\n")
8570 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
8573 ALIAS (show_bgp_instance_community_list
,
8574 show_bgp_instance_ipv6_community_list_cmd
,
8575 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
8578 BGP_INSTANCE_HELP_STR
8580 "Display routes matching the community-list\n"
8581 "community-list number\n"
8582 "community-list name\n")
8584 DEFUN (show_bgp_instance_prefix_longer
,
8585 show_bgp_instance_prefix_longer_cmd
,
8586 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
8589 BGP_INSTANCE_HELP_STR
8590 "IPv6 prefix <network>/<length>\n"
8591 "Display route and more specific routes\n")
8593 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8594 bgp_show_type_prefix_longer
);
8597 ALIAS (show_bgp_instance_prefix_longer
,
8598 show_bgp_instance_ipv6_prefix_longer_cmd
,
8599 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
8602 BGP_INSTANCE_HELP_STR
8604 "IPv6 prefix <network>/<length>\n"
8605 "Display route and more specific routes\n")
8608 DEFUN (show_ipv6_mbgp
,
8610 "show ipv6 mbgp {json}",
8614 "JavaScript Object Notation\n")
8616 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8617 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8618 NULL
, use_json(argc
, argv
));
8622 DEFUN (show_ipv6_mbgp_route
,
8623 show_ipv6_mbgp_route_cmd
,
8624 "show ipv6 mbgp X:X::X:X {json}",
8628 "Network in the MBGP routing table to display\n"
8629 "JavaScript Object Notation\n")
8631 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8632 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8636 DEFUN (show_ipv6_mbgp_prefix
,
8637 show_ipv6_mbgp_prefix_cmd
,
8638 "show ipv6 mbgp X:X::X:X/M {json}",
8642 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8643 "JavaScript Object Notation\n")
8645 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8646 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8652 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
8653 safi_t safi
, enum bgp_show_type type
)
8663 b
= buffer_new (1024);
8664 for (i
= 0; i
< argc
; i
++)
8667 buffer_putc (b
, ' ');
8670 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
8675 buffer_putstr (b
, argv
[i
]);
8677 buffer_putc (b
, '\0');
8679 regstr
= buffer_getstr (b
);
8682 regex
= bgp_regcomp (regstr
);
8683 XFREE(MTYPE_TMP
, regstr
);
8686 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
8691 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
8692 bgp_regex_free (regex
);
8696 DEFUN (show_ip_bgp_regexp
,
8697 show_ip_bgp_regexp_cmd
,
8698 "show ip bgp regexp .LINE",
8702 "Display routes matching the AS path regular expression\n"
8703 "A regular-expression to match the BGP AS paths\n")
8705 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8706 bgp_show_type_regexp
);
8709 DEFUN (show_ip_bgp_flap_regexp
,
8710 show_ip_bgp_flap_regexp_cmd
,
8711 "show ip bgp flap-statistics regexp .LINE",
8715 "Display flap statistics of routes\n"
8716 "Display routes matching the AS path regular expression\n"
8717 "A regular-expression to match the BGP AS paths\n")
8719 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8720 bgp_show_type_flap_regexp
);
8723 ALIAS (show_ip_bgp_flap_regexp
,
8724 show_ip_bgp_damp_flap_regexp_cmd
,
8725 "show ip bgp dampening flap-statistics regexp .LINE",
8729 "Display detailed information about dampening\n"
8730 "Display flap statistics of routes\n"
8731 "Display routes matching the AS path regular expression\n"
8732 "A regular-expression to match the BGP AS paths\n")
8734 DEFUN (show_ip_bgp_ipv4_regexp
,
8735 show_ip_bgp_ipv4_regexp_cmd
,
8736 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
8741 "Address Family modifier\n"
8742 "Address Family modifier\n"
8743 "Display routes matching the AS path regular expression\n"
8744 "A regular-expression to match the BGP AS paths\n")
8746 if (strncmp (argv
[0], "m", 1) == 0)
8747 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
8748 bgp_show_type_regexp
);
8750 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8751 bgp_show_type_regexp
);
8755 DEFUN (show_bgp_regexp
,
8756 show_bgp_regexp_cmd
,
8757 "show bgp regexp .LINE",
8760 "Display routes matching the AS path regular expression\n"
8761 "A regular-expression to match the BGP AS paths\n")
8763 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
8764 bgp_show_type_regexp
);
8767 ALIAS (show_bgp_regexp
,
8768 show_bgp_ipv6_regexp_cmd
,
8769 "show bgp ipv6 regexp .LINE",
8773 "Display routes matching the AS path regular expression\n"
8774 "A regular-expression to match the BGP AS paths\n")
8777 DEFUN (show_ipv6_bgp_regexp
,
8778 show_ipv6_bgp_regexp_cmd
,
8779 "show ipv6 bgp regexp .LINE",
8783 "Display routes matching the AS path regular expression\n"
8784 "A regular-expression to match the BGP AS paths\n")
8786 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8787 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
8788 bgp_show_type_regexp
);
8792 DEFUN (show_ipv6_mbgp_regexp
,
8793 show_ipv6_mbgp_regexp_cmd
,
8794 "show ipv6 mbgp regexp .LINE",
8798 "Display routes matching the AS path regular expression\n"
8799 "A regular-expression to match the MBGP AS paths\n")
8801 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8802 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
8803 bgp_show_type_regexp
);
8805 #endif /* HAVE_IPV6 */
8808 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
8809 const char *prefix_list_str
, afi_t afi
,
8810 safi_t safi
, enum bgp_show_type type
)
8812 struct prefix_list
*plist
;
8813 struct bgp
*bgp
= NULL
;
8815 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
8817 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
8821 plist
= prefix_list_lookup (afi
, prefix_list_str
);
8824 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
8825 prefix_list_str
, VTY_NEWLINE
);
8829 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
8832 DEFUN (show_ip_bgp_prefix_list
,
8833 show_ip_bgp_prefix_list_cmd
,
8834 "show ip bgp prefix-list WORD",
8838 "Display routes conforming to the prefix-list\n"
8839 "IP prefix-list name\n")
8841 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8842 bgp_show_type_prefix_list
);
8845 DEFUN (show_ip_bgp_instance_prefix_list
,
8846 show_ip_bgp_instance_prefix_list_cmd
,
8847 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
8851 BGP_INSTANCE_HELP_STR
8852 "Display routes conforming to the prefix-list\n"
8853 "IP prefix-list name\n")
8855 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
8856 bgp_show_type_prefix_list
);
8859 DEFUN (show_ip_bgp_flap_prefix_list
,
8860 show_ip_bgp_flap_prefix_list_cmd
,
8861 "show ip bgp flap-statistics prefix-list WORD",
8865 "Display flap statistics of routes\n"
8866 "Display routes conforming to the prefix-list\n"
8867 "IP prefix-list name\n")
8869 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8870 bgp_show_type_flap_prefix_list
);
8873 ALIAS (show_ip_bgp_flap_prefix_list
,
8874 show_ip_bgp_damp_flap_prefix_list_cmd
,
8875 "show ip bgp dampening flap-statistics prefix-list WORD",
8879 "Display detailed information about dampening\n"
8880 "Display flap statistics of routes\n"
8881 "Display routes conforming to the prefix-list\n"
8882 "IP prefix-list name\n")
8884 DEFUN (show_ip_bgp_ipv4_prefix_list
,
8885 show_ip_bgp_ipv4_prefix_list_cmd
,
8886 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
8891 "Address Family modifier\n"
8892 "Address Family modifier\n"
8893 "Display routes conforming to the prefix-list\n"
8894 "IP prefix-list name\n")
8896 if (strncmp (argv
[0], "m", 1) == 0)
8897 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
8898 bgp_show_type_prefix_list
);
8900 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
8901 bgp_show_type_prefix_list
);
8905 DEFUN (show_bgp_prefix_list
,
8906 show_bgp_prefix_list_cmd
,
8907 "show bgp prefix-list WORD",
8910 "Display routes conforming to the prefix-list\n"
8911 "IPv6 prefix-list name\n")
8913 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8914 bgp_show_type_prefix_list
);
8917 ALIAS (show_bgp_prefix_list
,
8918 show_bgp_ipv6_prefix_list_cmd
,
8919 "show bgp ipv6 prefix-list WORD",
8923 "Display routes conforming to the prefix-list\n"
8924 "IPv6 prefix-list name\n")
8927 DEFUN (show_ipv6_bgp_prefix_list
,
8928 show_ipv6_bgp_prefix_list_cmd
,
8929 "show ipv6 bgp prefix-list WORD",
8933 "Display routes matching the prefix-list\n"
8934 "IPv6 prefix-list name\n")
8936 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8937 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
8938 bgp_show_type_prefix_list
);
8942 DEFUN (show_ipv6_mbgp_prefix_list
,
8943 show_ipv6_mbgp_prefix_list_cmd
,
8944 "show ipv6 mbgp prefix-list WORD",
8948 "Display routes matching the prefix-list\n"
8949 "IPv6 prefix-list name\n")
8951 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8952 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
8953 bgp_show_type_prefix_list
);
8955 #endif /* HAVE_IPV6 */
8958 bgp_show_filter_list (struct vty
*vty
, const char *name
,
8959 const char *filter
, afi_t afi
,
8960 safi_t safi
, enum bgp_show_type type
)
8962 struct as_list
*as_list
;
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 as_list
= as_list_lookup (filter
);
8972 if (as_list
== NULL
)
8974 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
8978 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
8981 DEFUN (show_ip_bgp_filter_list
,
8982 show_ip_bgp_filter_list_cmd
,
8983 "show ip bgp filter-list WORD",
8987 "Display routes conforming to the filter-list\n"
8988 "Regular expression access list name\n")
8990 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
8991 bgp_show_type_filter_list
);
8994 DEFUN (show_ip_bgp_instance_filter_list
,
8995 show_ip_bgp_instance_filter_list_cmd
,
8996 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9000 BGP_INSTANCE_HELP_STR
9001 "Display routes conforming to the filter-list\n"
9002 "Regular expression access list name\n")
9004 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9005 bgp_show_type_filter_list
);
9008 DEFUN (show_ip_bgp_flap_filter_list
,
9009 show_ip_bgp_flap_filter_list_cmd
,
9010 "show ip bgp flap-statistics filter-list WORD",
9014 "Display flap statistics of routes\n"
9015 "Display routes conforming to the filter-list\n"
9016 "Regular expression access list name\n")
9018 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9019 bgp_show_type_flap_filter_list
);
9022 ALIAS (show_ip_bgp_flap_filter_list
,
9023 show_ip_bgp_damp_flap_filter_list_cmd
,
9024 "show ip bgp dampening flap-statistics filter-list WORD",
9028 "Display detailed information about dampening\n"
9029 "Display flap statistics of routes\n"
9030 "Display routes conforming to the filter-list\n"
9031 "Regular expression access list name\n")
9033 DEFUN (show_ip_bgp_ipv4_filter_list
,
9034 show_ip_bgp_ipv4_filter_list_cmd
,
9035 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9040 "Address Family modifier\n"
9041 "Address Family modifier\n"
9042 "Display routes conforming to the filter-list\n"
9043 "Regular expression access list name\n")
9045 if (strncmp (argv
[0], "m", 1) == 0)
9046 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9047 bgp_show_type_filter_list
);
9049 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9050 bgp_show_type_filter_list
);
9054 DEFUN (show_bgp_filter_list
,
9055 show_bgp_filter_list_cmd
,
9056 "show bgp filter-list WORD",
9059 "Display routes conforming to the filter-list\n"
9060 "Regular expression access list name\n")
9062 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9063 bgp_show_type_filter_list
);
9066 ALIAS (show_bgp_filter_list
,
9067 show_bgp_ipv6_filter_list_cmd
,
9068 "show bgp ipv6 filter-list WORD",
9072 "Display routes conforming to the filter-list\n"
9073 "Regular expression access list name\n")
9076 DEFUN (show_ipv6_bgp_filter_list
,
9077 show_ipv6_bgp_filter_list_cmd
,
9078 "show ipv6 bgp filter-list WORD",
9082 "Display routes conforming to the filter-list\n"
9083 "Regular expression access list name\n")
9085 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9086 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9087 bgp_show_type_filter_list
);
9091 DEFUN (show_ipv6_mbgp_filter_list
,
9092 show_ipv6_mbgp_filter_list_cmd
,
9093 "show ipv6 mbgp filter-list WORD",
9097 "Display routes conforming to the filter-list\n"
9098 "Regular expression access list name\n")
9100 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9101 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9102 bgp_show_type_filter_list
);
9104 #endif /* HAVE_IPV6 */
9106 DEFUN (show_ip_bgp_dampening_info
,
9107 show_ip_bgp_dampening_params_cmd
,
9108 "show ip bgp dampening parameters",
9112 "Display detailed information about dampening\n"
9113 "Display detail of configured dampening parameters\n")
9115 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9119 bgp_show_route_map (struct vty
*vty
, const char *name
,
9120 const char *rmap_str
, afi_t afi
,
9121 safi_t safi
, enum bgp_show_type type
)
9123 struct route_map
*rmap
;
9124 struct bgp
*bgp
= NULL
;
9126 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9128 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9132 rmap
= route_map_lookup_by_name (rmap_str
);
9135 vty_out (vty
, "%% %s is not a valid route-map name%s",
9136 rmap_str
, VTY_NEWLINE
);
9140 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9143 DEFUN (show_ip_bgp_route_map
,
9144 show_ip_bgp_route_map_cmd
,
9145 "show ip bgp route-map WORD",
9149 "Display routes matching the route-map\n"
9150 "A route-map to match on\n")
9152 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9153 bgp_show_type_route_map
);
9156 DEFUN (show_ip_bgp_instance_route_map
,
9157 show_ip_bgp_instance_route_map_cmd
,
9158 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9162 BGP_INSTANCE_HELP_STR
9163 "Display routes matching the route-map\n"
9164 "A route-map to match on\n")
9166 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9167 bgp_show_type_route_map
);
9170 DEFUN (show_ip_bgp_flap_route_map
,
9171 show_ip_bgp_flap_route_map_cmd
,
9172 "show ip bgp flap-statistics route-map WORD",
9176 "Display flap statistics of routes\n"
9177 "Display routes matching the route-map\n"
9178 "A route-map to match on\n")
9180 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9181 bgp_show_type_flap_route_map
);
9184 ALIAS (show_ip_bgp_flap_route_map
,
9185 show_ip_bgp_damp_flap_route_map_cmd
,
9186 "show ip bgp dampening flap-statistics route-map WORD",
9190 "Display detailed information about dampening\n"
9191 "Display flap statistics of routes\n"
9192 "Display routes matching the route-map\n"
9193 "A route-map to match on\n")
9195 DEFUN (show_ip_bgp_ipv4_route_map
,
9196 show_ip_bgp_ipv4_route_map_cmd
,
9197 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9202 "Address Family modifier\n"
9203 "Address Family modifier\n"
9204 "Display routes matching the route-map\n"
9205 "A route-map to match on\n")
9207 if (strncmp (argv
[0], "m", 1) == 0)
9208 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9209 bgp_show_type_route_map
);
9211 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9212 bgp_show_type_route_map
);
9215 DEFUN (show_bgp_route_map
,
9216 show_bgp_route_map_cmd
,
9217 "show bgp route-map WORD",
9220 "Display routes matching the route-map\n"
9221 "A route-map to match on\n")
9223 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9224 bgp_show_type_route_map
);
9227 ALIAS (show_bgp_route_map
,
9228 show_bgp_ipv6_route_map_cmd
,
9229 "show bgp ipv6 route-map WORD",
9233 "Display routes matching the route-map\n"
9234 "A route-map to match on\n")
9236 DEFUN (show_ip_bgp_cidr_only
,
9237 show_ip_bgp_cidr_only_cmd
,
9238 "show ip bgp cidr-only",
9242 "Display only routes with non-natural netmasks\n")
9244 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9245 bgp_show_type_cidr_only
, NULL
, 0);
9248 DEFUN (show_ip_bgp_flap_cidr_only
,
9249 show_ip_bgp_flap_cidr_only_cmd
,
9250 "show ip bgp flap-statistics cidr-only",
9254 "Display flap statistics of routes\n"
9255 "Display only routes with non-natural netmasks\n")
9257 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9258 bgp_show_type_flap_cidr_only
, NULL
, 0);
9261 ALIAS (show_ip_bgp_flap_cidr_only
,
9262 show_ip_bgp_damp_flap_cidr_only_cmd
,
9263 "show ip bgp dampening flap-statistics cidr-only",
9267 "Display detailed information about dampening\n"
9268 "Display flap statistics of routes\n"
9269 "Display only routes with non-natural netmasks\n")
9271 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9272 show_ip_bgp_ipv4_cidr_only_cmd
,
9273 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9278 "Address Family modifier\n"
9279 "Address Family modifier\n"
9280 "Display only routes with non-natural netmasks\n")
9282 if (strncmp (argv
[0], "m", 1) == 0)
9283 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9284 bgp_show_type_cidr_only
, NULL
, 0);
9286 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9287 bgp_show_type_cidr_only
, NULL
, 0);
9290 DEFUN (show_ip_bgp_community_all
,
9291 show_ip_bgp_community_all_cmd
,
9292 "show ip bgp community",
9296 "Display routes matching the communities\n")
9298 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9299 bgp_show_type_community_all
, NULL
, 0);
9302 DEFUN (show_ip_bgp_ipv4_community_all
,
9303 show_ip_bgp_ipv4_community_all_cmd
,
9304 "show ip bgp ipv4 (unicast|multicast) community",
9309 "Address Family modifier\n"
9310 "Address Family modifier\n"
9311 "Display routes matching the communities\n")
9313 if (strncmp (argv
[0], "m", 1) == 0)
9314 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9315 bgp_show_type_community_all
, NULL
, 0);
9317 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9318 bgp_show_type_community_all
, NULL
, 0);
9322 DEFUN (show_bgp_community_all
,
9323 show_bgp_community_all_cmd
,
9324 "show bgp community",
9327 "Display routes matching the communities\n")
9329 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9330 bgp_show_type_community_all
, NULL
, 0);
9333 ALIAS (show_bgp_community_all
,
9334 show_bgp_ipv6_community_all_cmd
,
9335 "show bgp ipv6 community",
9339 "Display routes matching the communities\n")
9342 DEFUN (show_ipv6_bgp_community_all
,
9343 show_ipv6_bgp_community_all_cmd
,
9344 "show ipv6 bgp community",
9348 "Display routes matching the communities\n")
9350 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9351 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9352 bgp_show_type_community_all
, NULL
, 0);
9356 DEFUN (show_ipv6_mbgp_community_all
,
9357 show_ipv6_mbgp_community_all_cmd
,
9358 "show ipv6 mbgp community",
9362 "Display routes matching the communities\n")
9364 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9365 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9366 bgp_show_type_community_all
, NULL
, 0);
9368 #endif /* HAVE_IPV6 */
9371 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9372 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9374 struct community
*com
;
9381 /* BGP structure lookup */
9384 bgp
= bgp_lookup_by_name (view_name
);
9387 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
9393 bgp
= bgp_get_default ();
9396 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9401 b
= buffer_new (1024);
9402 for (i
= 0; i
< argc
; i
++)
9405 buffer_putc (b
, ' ');
9408 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9413 buffer_putstr (b
, argv
[i
]);
9415 buffer_putc (b
, '\0');
9417 str
= buffer_getstr (b
);
9420 com
= community_str2com (str
);
9421 XFREE (MTYPE_TMP
, str
);
9424 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
9428 return bgp_show (vty
, bgp
, afi
, safi
,
9429 (exact
? bgp_show_type_community_exact
:
9430 bgp_show_type_community
), com
, 0);
9433 DEFUN (show_ip_bgp_community
,
9434 show_ip_bgp_community_cmd
,
9435 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9439 "Display routes matching the communities\n"
9441 "Do not send outside local AS (well-known community)\n"
9442 "Do not advertise to any peer (well-known community)\n"
9443 "Do not export to next AS (well-known community)\n")
9445 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9448 ALIAS (show_ip_bgp_community
,
9449 show_ip_bgp_community2_cmd
,
9450 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9454 "Display routes matching the communities\n"
9456 "Do not send outside local AS (well-known community)\n"
9457 "Do not advertise to any peer (well-known community)\n"
9458 "Do not export to next AS (well-known community)\n"
9460 "Do not send outside local AS (well-known community)\n"
9461 "Do not advertise to any peer (well-known community)\n"
9462 "Do not export to next AS (well-known community)\n")
9464 ALIAS (show_ip_bgp_community
,
9465 show_ip_bgp_community3_cmd
,
9466 "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)",
9470 "Display routes matching the communities\n"
9472 "Do not send outside local AS (well-known community)\n"
9473 "Do not advertise to any peer (well-known community)\n"
9474 "Do not export to next AS (well-known community)\n"
9476 "Do not send outside local AS (well-known community)\n"
9477 "Do not advertise to any peer (well-known community)\n"
9478 "Do not export to next AS (well-known community)\n"
9480 "Do not send outside local AS (well-known community)\n"
9481 "Do not advertise to any peer (well-known community)\n"
9482 "Do not export to next AS (well-known community)\n")
9484 ALIAS (show_ip_bgp_community
,
9485 show_ip_bgp_community4_cmd
,
9486 "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)",
9490 "Display routes matching the communities\n"
9492 "Do not send outside local AS (well-known community)\n"
9493 "Do not advertise to any peer (well-known community)\n"
9494 "Do not export to next AS (well-known community)\n"
9496 "Do not send outside local AS (well-known community)\n"
9497 "Do not advertise to any peer (well-known community)\n"
9498 "Do not export to next AS (well-known community)\n"
9500 "Do not send outside local AS (well-known community)\n"
9501 "Do not advertise to any peer (well-known community)\n"
9502 "Do not export to next AS (well-known community)\n"
9504 "Do not send outside local AS (well-known community)\n"
9505 "Do not advertise to any peer (well-known community)\n"
9506 "Do not export to next AS (well-known community)\n")
9508 DEFUN (show_ip_bgp_ipv4_community
,
9509 show_ip_bgp_ipv4_community_cmd
,
9510 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9515 "Address Family modifier\n"
9516 "Address Family modifier\n"
9517 "Display routes matching the communities\n"
9519 "Do not send outside local AS (well-known community)\n"
9520 "Do not advertise to any peer (well-known community)\n"
9521 "Do not export to next AS (well-known community)\n")
9523 if (strncmp (argv
[0], "m", 1) == 0)
9524 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
9526 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9529 ALIAS (show_ip_bgp_ipv4_community
,
9530 show_ip_bgp_ipv4_community2_cmd
,
9531 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9536 "Address Family modifier\n"
9537 "Address Family modifier\n"
9538 "Display routes matching the communities\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"
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_ip_bgp_ipv4_community
,
9549 show_ip_bgp_ipv4_community3_cmd
,
9550 "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)",
9555 "Address Family modifier\n"
9556 "Address Family modifier\n"
9557 "Display routes matching the communities\n"
9559 "Do not send outside local AS (well-known community)\n"
9560 "Do not advertise to any peer (well-known community)\n"
9561 "Do not export to next AS (well-known community)\n"
9563 "Do not send outside local AS (well-known community)\n"
9564 "Do not advertise to any peer (well-known community)\n"
9565 "Do not export to next AS (well-known community)\n"
9567 "Do not send outside local AS (well-known community)\n"
9568 "Do not advertise to any peer (well-known community)\n"
9569 "Do not export to next AS (well-known community)\n")
9571 ALIAS (show_ip_bgp_ipv4_community
,
9572 show_ip_bgp_ipv4_community4_cmd
,
9573 "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)",
9578 "Address Family modifier\n"
9579 "Address Family modifier\n"
9580 "Display routes matching the communities\n"
9582 "Do not send outside local AS (well-known community)\n"
9583 "Do not advertise to any peer (well-known community)\n"
9584 "Do not export to next AS (well-known community)\n"
9586 "Do not send outside local AS (well-known community)\n"
9587 "Do not advertise to any peer (well-known community)\n"
9588 "Do not export to next AS (well-known community)\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"
9594 "Do not send outside local AS (well-known community)\n"
9595 "Do not advertise to any peer (well-known community)\n"
9596 "Do not export to next AS (well-known community)\n")
9598 DEFUN (show_bgp_instance_afi_safi_community_all
,
9599 show_bgp_instance_afi_safi_community_all_cmd
,
9600 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
9603 BGP_INSTANCE_HELP_STR
9606 "Address Family modifier\n"
9607 "Address Family modifier\n"
9608 "Display routes matching the communities\n")
9614 /* BGP structure lookup. */
9615 bgp
= bgp_lookup_by_name (argv
[1]);
9618 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
9622 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9623 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9624 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
9627 DEFUN (show_bgp_instance_afi_safi_community
,
9628 show_bgp_instance_afi_safi_community_cmd
,
9629 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9632 BGP_INSTANCE_HELP_STR
9635 "Address family modifier\n"
9636 "Address family modifier\n"
9637 "Display routes matching the communities\n"
9639 "Do not send outside local AS (well-known community)\n"
9640 "Do not advertise to any peer (well-known community)\n"
9641 "Do not export to next AS (well-known community)\n")
9646 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9647 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9648 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
9651 ALIAS (show_bgp_instance_afi_safi_community
,
9652 show_bgp_instance_afi_safi_community2_cmd
,
9653 "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)",
9656 BGP_INSTANCE_HELP_STR
9659 "Address family modifier\n"
9660 "Address family modifier\n"
9661 "Display routes matching the communities\n"
9663 "Do not send outside local AS (well-known community)\n"
9664 "Do not advertise to any peer (well-known community)\n"
9665 "Do not export to next AS (well-known community)\n"
9667 "Do not send outside local AS (well-known community)\n"
9668 "Do not advertise to any peer (well-known community)\n"
9669 "Do not export to next AS (well-known community)\n")
9671 ALIAS (show_bgp_instance_afi_safi_community
,
9672 show_bgp_instance_afi_safi_community3_cmd
,
9673 "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)",
9676 BGP_INSTANCE_HELP_STR
9679 "Address family modifier\n"
9680 "Address family modifier\n"
9681 "Display routes matching the communities\n"
9683 "Do not send outside local AS (well-known community)\n"
9684 "Do not advertise to any peer (well-known community)\n"
9685 "Do not export to next AS (well-known community)\n"
9687 "Do not send outside local AS (well-known community)\n"
9688 "Do not advertise to any peer (well-known community)\n"
9689 "Do not export to next AS (well-known community)\n"
9691 "Do not send outside local AS (well-known community)\n"
9692 "Do not advertise to any peer (well-known community)\n"
9693 "Do not export to next AS (well-known community)\n")
9695 ALIAS (show_bgp_instance_afi_safi_community
,
9696 show_bgp_instance_afi_safi_community4_cmd
,
9697 "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)",
9700 BGP_INSTANCE_HELP_STR
9703 "Address family modifier\n"
9704 "Address family modifier\n"
9705 "Display routes matching the communities\n"
9707 "Do not send outside local AS (well-known community)\n"
9708 "Do not advertise to any peer (well-known community)\n"
9709 "Do not export to next AS (well-known community)\n"
9711 "Do not send outside local AS (well-known community)\n"
9712 "Do not advertise to any peer (well-known community)\n"
9713 "Do not export to next AS (well-known community)\n"
9715 "Do not send outside local AS (well-known community)\n"
9716 "Do not advertise to any peer (well-known community)\n"
9717 "Do not export to next AS (well-known community)\n"
9719 "Do not send outside local AS (well-known community)\n"
9720 "Do not advertise to any peer (well-known community)\n"
9721 "Do not export to next AS (well-known community)\n")
9723 DEFUN (show_ip_bgp_community_exact
,
9724 show_ip_bgp_community_exact_cmd
,
9725 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9729 "Display routes matching the communities\n"
9731 "Do not send outside local AS (well-known community)\n"
9732 "Do not advertise to any peer (well-known community)\n"
9733 "Do not export to next AS (well-known community)\n"
9734 "Exact match of the communities")
9736 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
9739 ALIAS (show_ip_bgp_community_exact
,
9740 show_ip_bgp_community2_exact_cmd
,
9741 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9745 "Display routes matching the communities\n"
9747 "Do not send outside local AS (well-known community)\n"
9748 "Do not advertise to any peer (well-known community)\n"
9749 "Do not export to next AS (well-known community)\n"
9751 "Do not send outside local AS (well-known community)\n"
9752 "Do not advertise to any peer (well-known community)\n"
9753 "Do not export to next AS (well-known community)\n"
9754 "Exact match of the communities")
9756 ALIAS (show_ip_bgp_community_exact
,
9757 show_ip_bgp_community3_exact_cmd
,
9758 "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",
9762 "Display routes matching the communities\n"
9764 "Do not send outside local AS (well-known community)\n"
9765 "Do not advertise to any peer (well-known community)\n"
9766 "Do not export to next AS (well-known community)\n"
9768 "Do not send outside local AS (well-known community)\n"
9769 "Do not advertise to any peer (well-known community)\n"
9770 "Do not export to next AS (well-known community)\n"
9772 "Do not send outside local AS (well-known community)\n"
9773 "Do not advertise to any peer (well-known community)\n"
9774 "Do not export to next AS (well-known community)\n"
9775 "Exact match of the communities")
9777 ALIAS (show_ip_bgp_community_exact
,
9778 show_ip_bgp_community4_exact_cmd
,
9779 "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",
9783 "Display routes matching the communities\n"
9785 "Do not send outside local AS (well-known community)\n"
9786 "Do not advertise to any peer (well-known community)\n"
9787 "Do not export to next AS (well-known community)\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"
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 "Do not send outside local AS (well-known community)\n"
9798 "Do not advertise to any peer (well-known community)\n"
9799 "Do not export to next AS (well-known community)\n"
9800 "Exact match of the communities")
9802 DEFUN (show_ip_bgp_ipv4_community_exact
,
9803 show_ip_bgp_ipv4_community_exact_cmd
,
9804 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9809 "Address Family modifier\n"
9810 "Address Family modifier\n"
9811 "Display routes matching the communities\n"
9813 "Do not send outside local AS (well-known community)\n"
9814 "Do not advertise to any peer (well-known community)\n"
9815 "Do not export to next AS (well-known community)\n"
9816 "Exact match of the communities")
9818 if (strncmp (argv
[0], "m", 1) == 0)
9819 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
9821 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
9824 ALIAS (show_ip_bgp_ipv4_community_exact
,
9825 show_ip_bgp_ipv4_community2_exact_cmd
,
9826 "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",
9831 "Address Family modifier\n"
9832 "Address Family modifier\n"
9833 "Display routes matching the communities\n"
9835 "Do not send outside local AS (well-known community)\n"
9836 "Do not advertise to any peer (well-known community)\n"
9837 "Do not export to next AS (well-known community)\n"
9839 "Do not send outside local AS (well-known community)\n"
9840 "Do not advertise to any peer (well-known community)\n"
9841 "Do not export to next AS (well-known community)\n"
9842 "Exact match of the communities")
9844 ALIAS (show_ip_bgp_ipv4_community_exact
,
9845 show_ip_bgp_ipv4_community3_exact_cmd
,
9846 "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",
9851 "Address Family modifier\n"
9852 "Address Family modifier\n"
9853 "Display routes matching the communities\n"
9855 "Do not send outside local AS (well-known community)\n"
9856 "Do not advertise to any peer (well-known community)\n"
9857 "Do not export to next AS (well-known community)\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"
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 "Exact match of the communities")
9868 ALIAS (show_ip_bgp_ipv4_community_exact
,
9869 show_ip_bgp_ipv4_community4_exact_cmd
,
9870 "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",
9875 "Address Family modifier\n"
9876 "Address Family modifier\n"
9877 "Display routes matching the communities\n"
9879 "Do not send outside local AS (well-known community)\n"
9880 "Do not advertise to any peer (well-known community)\n"
9881 "Do not export to next AS (well-known community)\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"
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"
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 "Exact match of the communities")
9897 DEFUN (show_bgp_community
,
9898 show_bgp_community_cmd
,
9899 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
9902 "Display routes matching the communities\n"
9904 "Do not send outside local AS (well-known community)\n"
9905 "Do not advertise to any peer (well-known community)\n"
9906 "Do not export to next AS (well-known community)\n")
9908 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
9911 ALIAS (show_bgp_community
,
9912 show_bgp_ipv6_community_cmd
,
9913 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
9917 "Display routes matching the communities\n"
9919 "Do not send outside local AS (well-known community)\n"
9920 "Do not advertise to any peer (well-known community)\n"
9921 "Do not export to next AS (well-known community)\n")
9923 ALIAS (show_bgp_community
,
9924 show_bgp_community2_cmd
,
9925 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9928 "Display routes matching the communities\n"
9930 "Do not send outside local AS (well-known community)\n"
9931 "Do not advertise to any peer (well-known community)\n"
9932 "Do not export to next AS (well-known community)\n"
9934 "Do not send outside local AS (well-known community)\n"
9935 "Do not advertise to any peer (well-known community)\n"
9936 "Do not export to next AS (well-known community)\n")
9938 ALIAS (show_bgp_community
,
9939 show_bgp_ipv6_community2_cmd
,
9940 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9944 "Display routes matching the communities\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"
9950 "Do not send outside local AS (well-known community)\n"
9951 "Do not advertise to any peer (well-known community)\n"
9952 "Do not export to next AS (well-known community)\n")
9954 ALIAS (show_bgp_community
,
9955 show_bgp_community3_cmd
,
9956 "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)",
9959 "Display routes matching the communities\n"
9961 "Do not send outside local AS (well-known community)\n"
9962 "Do not advertise to any peer (well-known community)\n"
9963 "Do not export to next AS (well-known community)\n"
9965 "Do not send outside local AS (well-known community)\n"
9966 "Do not advertise to any peer (well-known community)\n"
9967 "Do not export to next AS (well-known community)\n"
9969 "Do not send outside local AS (well-known community)\n"
9970 "Do not advertise to any peer (well-known community)\n"
9971 "Do not export to next AS (well-known community)\n")
9973 ALIAS (show_bgp_community
,
9974 show_bgp_ipv6_community3_cmd
,
9975 "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)",
9979 "Display routes matching the communities\n"
9981 "Do not send outside local AS (well-known community)\n"
9982 "Do not advertise to any peer (well-known community)\n"
9983 "Do not export to next AS (well-known community)\n"
9985 "Do not send outside local AS (well-known community)\n"
9986 "Do not advertise to any peer (well-known community)\n"
9987 "Do not export to next AS (well-known community)\n"
9989 "Do not send outside local AS (well-known community)\n"
9990 "Do not advertise to any peer (well-known community)\n"
9991 "Do not export to next AS (well-known community)\n")
9993 ALIAS (show_bgp_community
,
9994 show_bgp_community4_cmd
,
9995 "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)",
9998 "Display routes matching the communities\n"
10000 "Do not send outside local AS (well-known community)\n"
10001 "Do not advertise to any peer (well-known community)\n"
10002 "Do not export to next AS (well-known community)\n"
10004 "Do not send outside local AS (well-known community)\n"
10005 "Do not advertise to any peer (well-known community)\n"
10006 "Do not export to next AS (well-known community)\n"
10008 "Do not send outside local AS (well-known community)\n"
10009 "Do not advertise to any peer (well-known community)\n"
10010 "Do not export to next AS (well-known community)\n"
10012 "Do not send outside local AS (well-known community)\n"
10013 "Do not advertise to any peer (well-known community)\n"
10014 "Do not export to next AS (well-known community)\n")
10016 ALIAS (show_bgp_community
,
10017 show_bgp_ipv6_community4_cmd
,
10018 "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)",
10022 "Display routes matching the communities\n"
10024 "Do not send outside local AS (well-known community)\n"
10025 "Do not advertise to any peer (well-known community)\n"
10026 "Do not export to next AS (well-known community)\n"
10028 "Do not send outside local AS (well-known community)\n"
10029 "Do not advertise to any peer (well-known community)\n"
10030 "Do not export to next AS (well-known community)\n"
10032 "Do not send outside local AS (well-known community)\n"
10033 "Do not advertise to any peer (well-known community)\n"
10034 "Do not export to next AS (well-known community)\n"
10036 "Do not send outside local AS (well-known community)\n"
10037 "Do not advertise to any peer (well-known community)\n"
10038 "Do not export to next AS (well-known community)\n")
10041 DEFUN (show_ipv6_bgp_community
,
10042 show_ipv6_bgp_community_cmd
,
10043 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10047 "Display routes matching the communities\n"
10049 "Do not send outside local AS (well-known community)\n"
10050 "Do not advertise to any peer (well-known community)\n"
10051 "Do not export to next AS (well-known community)\n")
10053 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10054 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10058 ALIAS (show_ipv6_bgp_community
,
10059 show_ipv6_bgp_community2_cmd
,
10060 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10064 "Display routes matching the communities\n"
10066 "Do not send outside local AS (well-known community)\n"
10067 "Do not advertise to any peer (well-known community)\n"
10068 "Do not export to next AS (well-known community)\n"
10070 "Do not send outside local AS (well-known community)\n"
10071 "Do not advertise to any peer (well-known community)\n"
10072 "Do not export to next AS (well-known community)\n")
10075 ALIAS (show_ipv6_bgp_community
,
10076 show_ipv6_bgp_community3_cmd
,
10077 "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)",
10081 "Display routes matching the communities\n"
10083 "Do not send outside local AS (well-known community)\n"
10084 "Do not advertise to any peer (well-known community)\n"
10085 "Do not export to next AS (well-known community)\n"
10087 "Do not send outside local AS (well-known community)\n"
10088 "Do not advertise to any peer (well-known community)\n"
10089 "Do not export to next AS (well-known community)\n"
10091 "Do not send outside local AS (well-known community)\n"
10092 "Do not advertise to any peer (well-known community)\n"
10093 "Do not export to next AS (well-known community)\n")
10096 ALIAS (show_ipv6_bgp_community
,
10097 show_ipv6_bgp_community4_cmd
,
10098 "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)",
10102 "Display routes matching the communities\n"
10104 "Do not send outside local AS (well-known community)\n"
10105 "Do not advertise to any peer (well-known community)\n"
10106 "Do not export to next AS (well-known community)\n"
10108 "Do not send outside local AS (well-known community)\n"
10109 "Do not advertise to any peer (well-known community)\n"
10110 "Do not export to next AS (well-known community)\n"
10112 "Do not send outside local AS (well-known community)\n"
10113 "Do not advertise to any peer (well-known community)\n"
10114 "Do not export to next AS (well-known community)\n"
10116 "Do not send outside local AS (well-known community)\n"
10117 "Do not advertise to any peer (well-known community)\n"
10118 "Do not export to next AS (well-known community)\n")
10120 DEFUN (show_bgp_community_exact
,
10121 show_bgp_community_exact_cmd
,
10122 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10125 "Display routes matching the communities\n"
10127 "Do not send outside local AS (well-known community)\n"
10128 "Do not advertise to any peer (well-known community)\n"
10129 "Do not export to next AS (well-known community)\n"
10130 "Exact match of the communities")
10132 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10135 ALIAS (show_bgp_community_exact
,
10136 show_bgp_ipv6_community_exact_cmd
,
10137 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10141 "Display routes matching the communities\n"
10143 "Do not send outside local AS (well-known community)\n"
10144 "Do not advertise to any peer (well-known community)\n"
10145 "Do not export to next AS (well-known community)\n"
10146 "Exact match of the communities")
10148 ALIAS (show_bgp_community_exact
,
10149 show_bgp_community2_exact_cmd
,
10150 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10153 "Display routes matching the communities\n"
10155 "Do not send outside local AS (well-known community)\n"
10156 "Do not advertise to any peer (well-known community)\n"
10157 "Do not export to next AS (well-known community)\n"
10159 "Do not send outside local AS (well-known community)\n"
10160 "Do not advertise to any peer (well-known community)\n"
10161 "Do not export to next AS (well-known community)\n"
10162 "Exact match of the communities")
10164 ALIAS (show_bgp_community_exact
,
10165 show_bgp_ipv6_community2_exact_cmd
,
10166 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10170 "Display routes matching the communities\n"
10172 "Do not send outside local AS (well-known community)\n"
10173 "Do not advertise to any peer (well-known community)\n"
10174 "Do not export to next AS (well-known community)\n"
10176 "Do not send outside local AS (well-known community)\n"
10177 "Do not advertise to any peer (well-known community)\n"
10178 "Do not export to next AS (well-known community)\n"
10179 "Exact match of the communities")
10181 ALIAS (show_bgp_community_exact
,
10182 show_bgp_community3_exact_cmd
,
10183 "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",
10186 "Display routes matching the communities\n"
10188 "Do not send outside local AS (well-known community)\n"
10189 "Do not advertise to any peer (well-known community)\n"
10190 "Do not export to next AS (well-known community)\n"
10192 "Do not send outside local AS (well-known community)\n"
10193 "Do not advertise to any peer (well-known community)\n"
10194 "Do not export to next AS (well-known community)\n"
10196 "Do not send outside local AS (well-known community)\n"
10197 "Do not advertise to any peer (well-known community)\n"
10198 "Do not export to next AS (well-known community)\n"
10199 "Exact match of the communities")
10201 ALIAS (show_bgp_community_exact
,
10202 show_bgp_ipv6_community3_exact_cmd
,
10203 "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",
10207 "Display routes matching the communities\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"
10213 "Do not send outside local AS (well-known community)\n"
10214 "Do not advertise to any peer (well-known community)\n"
10215 "Do not export to next AS (well-known community)\n"
10217 "Do not send outside local AS (well-known community)\n"
10218 "Do not advertise to any peer (well-known community)\n"
10219 "Do not export to next AS (well-known community)\n"
10220 "Exact match of the communities")
10222 ALIAS (show_bgp_community_exact
,
10223 show_bgp_community4_exact_cmd
,
10224 "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",
10227 "Display routes matching the communities\n"
10229 "Do not send outside local AS (well-known community)\n"
10230 "Do not advertise to any peer (well-known community)\n"
10231 "Do not export to next AS (well-known community)\n"
10233 "Do not send outside local AS (well-known community)\n"
10234 "Do not advertise to any peer (well-known community)\n"
10235 "Do not export to next AS (well-known community)\n"
10237 "Do not send outside local AS (well-known community)\n"
10238 "Do not advertise to any peer (well-known community)\n"
10239 "Do not export to next AS (well-known community)\n"
10241 "Do not send outside local AS (well-known community)\n"
10242 "Do not advertise to any peer (well-known community)\n"
10243 "Do not export to next AS (well-known community)\n"
10244 "Exact match of the communities")
10246 ALIAS (show_bgp_community_exact
,
10247 show_bgp_ipv6_community4_exact_cmd
,
10248 "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",
10252 "Display routes matching the communities\n"
10254 "Do not send outside local AS (well-known community)\n"
10255 "Do not advertise to any peer (well-known community)\n"
10256 "Do not export to next AS (well-known community)\n"
10258 "Do not send outside local AS (well-known community)\n"
10259 "Do not advertise to any peer (well-known community)\n"
10260 "Do not export to next AS (well-known community)\n"
10262 "Do not send outside local AS (well-known community)\n"
10263 "Do not advertise to any peer (well-known community)\n"
10264 "Do not export to next AS (well-known community)\n"
10266 "Do not send outside local AS (well-known community)\n"
10267 "Do not advertise to any peer (well-known community)\n"
10268 "Do not export to next AS (well-known community)\n"
10269 "Exact match of the communities")
10272 DEFUN (show_ipv6_bgp_community_exact
,
10273 show_ipv6_bgp_community_exact_cmd
,
10274 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10278 "Display routes matching the communities\n"
10280 "Do not send outside local AS (well-known community)\n"
10281 "Do not advertise to any peer (well-known community)\n"
10282 "Do not export to next AS (well-known community)\n"
10283 "Exact match of the communities")
10285 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10286 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10290 ALIAS (show_ipv6_bgp_community_exact
,
10291 show_ipv6_bgp_community2_exact_cmd
,
10292 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10296 "Display routes matching the communities\n"
10298 "Do not send outside local AS (well-known community)\n"
10299 "Do not advertise to any peer (well-known community)\n"
10300 "Do not export to next AS (well-known community)\n"
10302 "Do not send outside local AS (well-known community)\n"
10303 "Do not advertise to any peer (well-known community)\n"
10304 "Do not export to next AS (well-known community)\n"
10305 "Exact match of the communities")
10308 ALIAS (show_ipv6_bgp_community_exact
,
10309 show_ipv6_bgp_community3_exact_cmd
,
10310 "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",
10314 "Display routes matching the communities\n"
10316 "Do not send outside local AS (well-known community)\n"
10317 "Do not advertise to any peer (well-known community)\n"
10318 "Do not export to next AS (well-known community)\n"
10320 "Do not send outside local AS (well-known community)\n"
10321 "Do not advertise to any peer (well-known community)\n"
10322 "Do not export to next AS (well-known community)\n"
10324 "Do not send outside local AS (well-known community)\n"
10325 "Do not advertise to any peer (well-known community)\n"
10326 "Do not export to next AS (well-known community)\n"
10327 "Exact match of the communities")
10330 ALIAS (show_ipv6_bgp_community_exact
,
10331 show_ipv6_bgp_community4_exact_cmd
,
10332 "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",
10336 "Display routes matching the communities\n"
10338 "Do not send outside local AS (well-known community)\n"
10339 "Do not advertise to any peer (well-known community)\n"
10340 "Do not export to next AS (well-known community)\n"
10342 "Do not send outside local AS (well-known community)\n"
10343 "Do not advertise to any peer (well-known community)\n"
10344 "Do not export to next AS (well-known community)\n"
10346 "Do not send outside local AS (well-known community)\n"
10347 "Do not advertise to any peer (well-known community)\n"
10348 "Do not export to next AS (well-known community)\n"
10350 "Do not send outside local AS (well-known community)\n"
10351 "Do not advertise to any peer (well-known community)\n"
10352 "Do not export to next AS (well-known community)\n"
10353 "Exact match of the communities")
10356 DEFUN (show_ipv6_mbgp_community
,
10357 show_ipv6_mbgp_community_cmd
,
10358 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10362 "Display routes matching the communities\n"
10364 "Do not send outside local AS (well-known community)\n"
10365 "Do not advertise to any peer (well-known community)\n"
10366 "Do not export to next AS (well-known community)\n")
10368 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10369 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10373 ALIAS (show_ipv6_mbgp_community
,
10374 show_ipv6_mbgp_community2_cmd
,
10375 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10379 "Display routes matching the communities\n"
10381 "Do not send outside local AS (well-known community)\n"
10382 "Do not advertise to any peer (well-known community)\n"
10383 "Do not export to next AS (well-known community)\n"
10385 "Do not send outside local AS (well-known community)\n"
10386 "Do not advertise to any peer (well-known community)\n"
10387 "Do not export to next AS (well-known community)\n")
10390 ALIAS (show_ipv6_mbgp_community
,
10391 show_ipv6_mbgp_community3_cmd
,
10392 "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)",
10396 "Display routes matching the communities\n"
10398 "Do not send outside local AS (well-known community)\n"
10399 "Do not advertise to any peer (well-known community)\n"
10400 "Do not export to next AS (well-known community)\n"
10402 "Do not send outside local AS (well-known community)\n"
10403 "Do not advertise to any peer (well-known community)\n"
10404 "Do not export to next AS (well-known community)\n"
10406 "Do not send outside local AS (well-known community)\n"
10407 "Do not advertise to any peer (well-known community)\n"
10408 "Do not export to next AS (well-known community)\n")
10411 ALIAS (show_ipv6_mbgp_community
,
10412 show_ipv6_mbgp_community4_cmd
,
10413 "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)",
10417 "Display routes matching the communities\n"
10419 "Do not send outside local AS (well-known community)\n"
10420 "Do not advertise to any peer (well-known community)\n"
10421 "Do not export to next AS (well-known community)\n"
10423 "Do not send outside local AS (well-known community)\n"
10424 "Do not advertise to any peer (well-known community)\n"
10425 "Do not export to next AS (well-known community)\n"
10427 "Do not send outside local AS (well-known community)\n"
10428 "Do not advertise to any peer (well-known community)\n"
10429 "Do not export to next AS (well-known community)\n"
10431 "Do not send outside local AS (well-known community)\n"
10432 "Do not advertise to any peer (well-known community)\n"
10433 "Do not export to next AS (well-known community)\n")
10436 DEFUN (show_ipv6_mbgp_community_exact
,
10437 show_ipv6_mbgp_community_exact_cmd
,
10438 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10442 "Display routes matching the communities\n"
10444 "Do not send outside local AS (well-known community)\n"
10445 "Do not advertise to any peer (well-known community)\n"
10446 "Do not export to next AS (well-known community)\n"
10447 "Exact match of the communities")
10449 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10450 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
10454 ALIAS (show_ipv6_mbgp_community_exact
,
10455 show_ipv6_mbgp_community2_exact_cmd
,
10456 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10460 "Display routes matching the communities\n"
10462 "Do not send outside local AS (well-known community)\n"
10463 "Do not advertise to any peer (well-known community)\n"
10464 "Do not export to next AS (well-known community)\n"
10466 "Do not send outside local AS (well-known community)\n"
10467 "Do not advertise to any peer (well-known community)\n"
10468 "Do not export to next AS (well-known community)\n"
10469 "Exact match of the communities")
10472 ALIAS (show_ipv6_mbgp_community_exact
,
10473 show_ipv6_mbgp_community3_exact_cmd
,
10474 "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",
10478 "Display routes matching the communities\n"
10480 "Do not send outside local AS (well-known community)\n"
10481 "Do not advertise to any peer (well-known community)\n"
10482 "Do not export to next AS (well-known community)\n"
10484 "Do not send outside local AS (well-known community)\n"
10485 "Do not advertise to any peer (well-known community)\n"
10486 "Do not export to next AS (well-known community)\n"
10488 "Do not send outside local AS (well-known community)\n"
10489 "Do not advertise to any peer (well-known community)\n"
10490 "Do not export to next AS (well-known community)\n"
10491 "Exact match of the communities")
10494 ALIAS (show_ipv6_mbgp_community_exact
,
10495 show_ipv6_mbgp_community4_exact_cmd
,
10496 "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",
10500 "Display routes matching the communities\n"
10502 "Do not send outside local AS (well-known community)\n"
10503 "Do not advertise to any peer (well-known community)\n"
10504 "Do not export to next AS (well-known community)\n"
10506 "Do not send outside local AS (well-known community)\n"
10507 "Do not advertise to any peer (well-known community)\n"
10508 "Do not export to next AS (well-known community)\n"
10510 "Do not send outside local AS (well-known community)\n"
10511 "Do not advertise to any peer (well-known community)\n"
10512 "Do not export to next AS (well-known community)\n"
10514 "Do not send outside local AS (well-known community)\n"
10515 "Do not advertise to any peer (well-known community)\n"
10516 "Do not export to next AS (well-known community)\n"
10517 "Exact match of the communities")
10518 #endif /* HAVE_IPV6 */
10521 bgp_show_community_list (struct vty
*vty
, const char *name
,
10522 const char *com
, int exact
,
10523 afi_t afi
, safi_t safi
)
10525 struct community_list
*list
;
10526 struct bgp
*bgp
= NULL
;
10528 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
10530 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
10531 return CMD_WARNING
;
10534 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
10537 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
10539 return CMD_WARNING
;
10542 return bgp_show (vty
, bgp
, afi
, safi
,
10543 (exact
? bgp_show_type_community_list_exact
:
10544 bgp_show_type_community_list
), list
, 0);
10547 DEFUN (show_ip_bgp_community_list
,
10548 show_ip_bgp_community_list_cmd
,
10549 "show ip bgp community-list (<1-500>|WORD)",
10553 "Display routes matching the community-list\n"
10554 "community-list number\n"
10555 "community-list name\n")
10557 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
10560 DEFUN (show_ip_bgp_instance_community_list
,
10561 show_ip_bgp_instance_community_list_cmd
,
10562 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
10566 BGP_INSTANCE_HELP_STR
10567 "Display routes matching the community-list\n"
10568 "community-list number\n"
10569 "community-list name\n")
10571 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
10574 DEFUN (show_ip_bgp_ipv4_community_list
,
10575 show_ip_bgp_ipv4_community_list_cmd
,
10576 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10581 "Address Family modifier\n"
10582 "Address Family modifier\n"
10583 "Display routes matching the community-list\n"
10584 "community-list number\n"
10585 "community-list name\n")
10587 if (strncmp (argv
[0], "m", 1) == 0)
10588 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
10590 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
10593 DEFUN (show_ip_bgp_community_list_exact
,
10594 show_ip_bgp_community_list_exact_cmd
,
10595 "show ip bgp community-list (<1-500>|WORD) exact-match",
10599 "Display routes matching the community-list\n"
10600 "community-list number\n"
10601 "community-list name\n"
10602 "Exact match of the communities\n")
10604 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
10607 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
10608 show_ip_bgp_ipv4_community_list_exact_cmd
,
10609 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10614 "Address Family modifier\n"
10615 "Address Family modifier\n"
10616 "Display routes matching the community-list\n"
10617 "community-list number\n"
10618 "community-list name\n"
10619 "Exact match of the communities\n")
10621 if (strncmp (argv
[0], "m", 1) == 0)
10622 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
10624 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
10628 DEFUN (show_bgp_community_list
,
10629 show_bgp_community_list_cmd
,
10630 "show bgp community-list (<1-500>|WORD)",
10633 "Display routes matching the community-list\n"
10634 "community-list number\n"
10635 "community-list name\n")
10637 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10640 ALIAS (show_bgp_community_list
,
10641 show_bgp_ipv6_community_list_cmd
,
10642 "show bgp ipv6 community-list (<1-500>|WORD)",
10646 "Display routes matching the community-list\n"
10647 "community-list number\n"
10648 "community-list name\n")
10651 DEFUN (show_ipv6_bgp_community_list
,
10652 show_ipv6_bgp_community_list_cmd
,
10653 "show ipv6 bgp community-list WORD",
10657 "Display routes matching the community-list\n"
10658 "community-list name\n")
10660 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10661 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10665 DEFUN (show_ipv6_mbgp_community_list
,
10666 show_ipv6_mbgp_community_list_cmd
,
10667 "show ipv6 mbgp community-list WORD",
10671 "Display routes matching the community-list\n"
10672 "community-list name\n")
10674 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10675 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
10678 DEFUN (show_bgp_community_list_exact
,
10679 show_bgp_community_list_exact_cmd
,
10680 "show bgp community-list (<1-500>|WORD) exact-match",
10683 "Display routes matching the community-list\n"
10684 "community-list number\n"
10685 "community-list name\n"
10686 "Exact match of the communities\n")
10688 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10691 ALIAS (show_bgp_community_list_exact
,
10692 show_bgp_ipv6_community_list_exact_cmd
,
10693 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10697 "Display routes matching the community-list\n"
10698 "community-list number\n"
10699 "community-list name\n"
10700 "Exact match of the communities\n")
10703 DEFUN (show_ipv6_bgp_community_list_exact
,
10704 show_ipv6_bgp_community_list_exact_cmd
,
10705 "show ipv6 bgp community-list WORD exact-match",
10709 "Display routes matching the community-list\n"
10710 "community-list name\n"
10711 "Exact match of the communities\n")
10713 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10714 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10718 DEFUN (show_ipv6_mbgp_community_list_exact
,
10719 show_ipv6_mbgp_community_list_exact_cmd
,
10720 "show ipv6 mbgp community-list WORD exact-match",
10724 "Display routes matching the community-list\n"
10725 "community-list name\n"
10726 "Exact match of the communities\n")
10728 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10729 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
10731 #endif /* HAVE_IPV6 */
10734 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
10735 const char *prefix
, afi_t afi
,
10736 safi_t safi
, enum bgp_show_type type
)
10740 struct bgp
*bgp
= NULL
;
10742 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
10744 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
10745 return CMD_WARNING
;
10750 ret
= str2prefix (prefix
, p
);
10753 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
10754 return CMD_WARNING
;
10757 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
10762 DEFUN (show_ip_bgp_prefix_longer
,
10763 show_ip_bgp_prefix_longer_cmd
,
10764 "show ip bgp A.B.C.D/M longer-prefixes",
10768 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10769 "Display route and more specific routes\n")
10771 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10772 bgp_show_type_prefix_longer
);
10775 DEFUN (show_ip_bgp_instance_prefix_longer
,
10776 show_ip_bgp_instance_prefix_longer_cmd
,
10777 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
10781 BGP_INSTANCE_HELP_STR
10782 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10783 "Display route and more specific routes\n")
10785 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
10786 bgp_show_type_prefix_longer
);
10789 DEFUN (show_ip_bgp_flap_prefix_longer
,
10790 show_ip_bgp_flap_prefix_longer_cmd
,
10791 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
10795 "Display flap statistics of routes\n"
10796 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10797 "Display route and more specific routes\n")
10799 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10800 bgp_show_type_flap_prefix_longer
);
10803 ALIAS (show_ip_bgp_flap_prefix_longer
,
10804 show_ip_bgp_damp_flap_prefix_longer_cmd
,
10805 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
10809 "Display detailed information about dampening\n"
10810 "Display flap statistics of routes\n"
10811 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10812 "Display route and more specific routes\n")
10814 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
10815 show_ip_bgp_ipv4_prefix_longer_cmd
,
10816 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
10821 "Address Family modifier\n"
10822 "Address Family modifier\n"
10823 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10824 "Display route and more specific routes\n")
10826 if (strncmp (argv
[0], "m", 1) == 0)
10827 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
10828 bgp_show_type_prefix_longer
);
10830 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
10831 bgp_show_type_prefix_longer
);
10834 DEFUN (show_ip_bgp_flap_address
,
10835 show_ip_bgp_flap_address_cmd
,
10836 "show ip bgp flap-statistics A.B.C.D",
10840 "Display flap statistics of routes\n"
10841 "Network in the BGP routing table to display\n")
10843 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10844 bgp_show_type_flap_address
);
10847 ALIAS (show_ip_bgp_flap_address
,
10848 show_ip_bgp_damp_flap_address_cmd
,
10849 "show ip bgp dampening flap-statistics A.B.C.D",
10853 "Display detailed information about dampening\n"
10854 "Display flap statistics of routes\n"
10855 "Network in the BGP routing table to display\n")
10857 DEFUN (show_ip_bgp_flap_prefix
,
10858 show_ip_bgp_flap_prefix_cmd
,
10859 "show ip bgp flap-statistics A.B.C.D/M",
10863 "Display flap statistics of routes\n"
10864 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10866 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10867 bgp_show_type_flap_prefix
);
10870 ALIAS (show_ip_bgp_flap_prefix
,
10871 show_ip_bgp_damp_flap_prefix_cmd
,
10872 "show ip bgp dampening flap-statistics A.B.C.D/M",
10876 "Display detailed information about dampening\n"
10877 "Display flap statistics of routes\n"
10878 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
10881 DEFUN (show_bgp_prefix_longer
,
10882 show_bgp_prefix_longer_cmd
,
10883 "show bgp X:X::X:X/M longer-prefixes",
10886 "IPv6 prefix <network>/<length>\n"
10887 "Display route and more specific routes\n")
10889 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
10890 bgp_show_type_prefix_longer
);
10893 ALIAS (show_bgp_prefix_longer
,
10894 show_bgp_ipv6_prefix_longer_cmd
,
10895 "show bgp ipv6 X:X::X:X/M longer-prefixes",
10899 "IPv6 prefix <network>/<length>\n"
10900 "Display route and more specific routes\n")
10903 DEFUN (show_ipv6_bgp_prefix_longer
,
10904 show_ipv6_bgp_prefix_longer_cmd
,
10905 "show ipv6 bgp X:X::X:X/M longer-prefixes",
10909 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
10910 "Display route and more specific routes\n")
10912 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10913 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
10914 bgp_show_type_prefix_longer
);
10918 DEFUN (show_ipv6_mbgp_prefix_longer
,
10919 show_ipv6_mbgp_prefix_longer_cmd
,
10920 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
10924 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
10925 "Display route and more specific routes\n")
10927 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10928 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
10929 bgp_show_type_prefix_longer
);
10931 #endif /* HAVE_IPV6 */
10933 static struct peer
*
10934 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
10935 const char *ip_str
, u_char use_json
)
10940 union sockunion su
;
10942 /* BGP structure lookup. */
10945 bgp
= bgp_lookup_by_name (view_name
);
10950 json_object
*json_no
= NULL
;
10951 json_no
= json_object_new_object();
10952 json_object_string_add(json_no
, "warning", "Can't find BGP view");
10953 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10954 json_object_free(json_no
);
10957 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
10963 bgp
= bgp_get_default ();
10968 json_object
*json_no
= NULL
;
10969 json_no
= json_object_new_object();
10970 json_object_string_add(json_no
, "warning", "No BGP process configured");
10971 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10972 json_object_free(json_no
);
10975 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10980 /* Get peer sockunion. */
10981 ret
= str2sockunion (ip_str
, &su
);
10984 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
10987 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
10993 json_object
*json_no
= NULL
;
10994 json_no
= json_object_new_object();
10995 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
10996 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
10997 json_object_free(json_no
);
11000 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11007 /* Peer structure lookup. */
11008 peer
= peer_lookup (bgp
, &su
);
11013 json_object
*json_no
= NULL
;
11014 json_no
= json_object_new_object();
11015 json_object_string_add(json_no
, "warning","No such neighbor");
11016 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11017 json_object_free(json_no
);
11020 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11029 BGP_STATS_MAXBITLEN
= 0,
11031 BGP_STATS_PREFIXES
,
11033 BGP_STATS_UNAGGREGATEABLE
,
11034 BGP_STATS_MAX_AGGREGATEABLE
,
11035 BGP_STATS_AGGREGATES
,
11037 BGP_STATS_ASPATH_COUNT
,
11038 BGP_STATS_ASPATH_MAXHOPS
,
11039 BGP_STATS_ASPATH_TOTHOPS
,
11040 BGP_STATS_ASPATH_MAXSIZE
,
11041 BGP_STATS_ASPATH_TOTSIZE
,
11042 BGP_STATS_ASN_HIGHEST
,
11046 static const char *table_stats_strs
[] =
11048 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11049 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11050 [BGP_STATS_RIB
] = "Total Advertisements",
11051 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11052 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11053 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11054 [BGP_STATS_SPACE
] = "Address space advertised",
11055 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11056 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11057 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11058 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11059 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11060 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11061 [BGP_STATS_MAX
] = NULL
,
11064 struct bgp_table_stats
11066 struct bgp_table
*table
;
11067 unsigned long long counts
[BGP_STATS_MAX
];
11071 #define TALLY_SIGFIG 100000
11072 static unsigned long
11073 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11075 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11076 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11077 unsigned long ret
= newtot
/ count
;
11079 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11087 bgp_table_stats_walker (struct thread
*t
)
11089 struct bgp_node
*rn
;
11090 struct bgp_node
*top
;
11091 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11092 unsigned int space
= 0;
11094 if (!(top
= bgp_table_top (ts
->table
)))
11097 switch (top
->p
.family
)
11100 space
= IPV4_MAX_BITLEN
;
11103 space
= IPV6_MAX_BITLEN
;
11107 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11109 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11111 struct bgp_info
*ri
;
11112 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11113 unsigned int rinum
= 0;
11121 ts
->counts
[BGP_STATS_PREFIXES
]++;
11122 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11125 ts
->counts
[BGP_STATS_AVGPLEN
]
11126 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11127 ts
->counts
[BGP_STATS_AVGPLEN
],
11131 /* check if the prefix is included by any other announcements */
11132 while (prn
&& !prn
->info
)
11133 prn
= bgp_node_parent_nolock (prn
);
11135 if (prn
== NULL
|| prn
== top
)
11137 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11138 /* announced address space */
11140 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11142 else if (prn
->info
)
11143 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11145 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11148 ts
->counts
[BGP_STATS_RIB
]++;
11151 (CHECK_FLAG (ri
->attr
->flag
,
11152 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11153 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11155 /* as-path stats */
11156 if (ri
->attr
&& ri
->attr
->aspath
)
11158 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11159 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11160 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11162 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11164 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11165 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11167 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11168 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11170 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11171 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11173 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11174 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11175 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11177 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11178 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11179 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11182 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11183 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11191 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11193 struct bgp_table_stats ts
;
11196 if (!bgp
->rib
[afi
][safi
])
11198 vty_out (vty
, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s",
11199 afi
, safi
, VTY_NEWLINE
);
11200 return CMD_WARNING
;
11203 memset (&ts
, 0, sizeof (ts
));
11204 ts
.table
= bgp
->rib
[afi
][safi
];
11205 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11207 vty_out (vty
, "BGP %s RIB statistics%s%s",
11208 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11210 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11212 if (!table_stats_strs
[i
])
11218 case BGP_STATS_ASPATH_AVGHOPS
:
11219 case BGP_STATS_ASPATH_AVGSIZE
:
11220 case BGP_STATS_AVGPLEN
:
11221 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11222 vty_out (vty
, "%12.2f",
11223 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11226 case BGP_STATS_ASPATH_TOTHOPS
:
11227 case BGP_STATS_ASPATH_TOTSIZE
:
11228 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11229 vty_out (vty
, "%12.2f",
11231 (float)ts
.counts
[i
] /
11232 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11235 case BGP_STATS_TOTPLEN
:
11236 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11237 vty_out (vty
, "%12.2f",
11239 (float)ts
.counts
[i
] /
11240 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11243 case BGP_STATS_SPACE
:
11244 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11245 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11246 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11248 vty_out (vty
, "%30s: ", "%% announced ");
11249 vty_out (vty
, "%12.2f%s",
11250 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11251 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11253 vty_out (vty
, "%30s: ", "/8 equivalent ");
11254 vty_out (vty
, "%12.2f%s",
11255 (float)ts
.counts
[BGP_STATS_SPACE
] /
11256 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11258 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11260 vty_out (vty
, "%30s: ", "/24 equivalent ");
11261 vty_out (vty
, "%12.2f",
11262 (float)ts
.counts
[BGP_STATS_SPACE
] /
11263 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11266 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11267 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11270 vty_out (vty
, "%s", VTY_NEWLINE
);
11272 return CMD_SUCCESS
;
11276 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11277 const char *afi_str
, const char *safi_str
)
11284 bgp
= bgp_lookup_by_name (name
);
11286 bgp
= bgp_get_default ();
11290 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
11291 return CMD_WARNING
;
11293 if (strncmp (afi_str
, "ipv", 3) == 0)
11295 if (strncmp (afi_str
, "ipv4", 4) == 0)
11297 else if (strncmp (afi_str
, "ipv6", 4) == 0)
11301 vty_out (vty
, "%% Invalid address family %s%s",
11302 afi_str
, VTY_NEWLINE
);
11303 return CMD_WARNING
;
11305 if (strncmp (safi_str
, "m", 1) == 0)
11306 safi
= SAFI_MULTICAST
;
11307 else if (strncmp (safi_str
, "u", 1) == 0)
11308 safi
= SAFI_UNICAST
;
11309 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
11310 safi
= SAFI_MPLS_VPN
;
11313 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11314 safi_str
, VTY_NEWLINE
);
11315 return CMD_WARNING
;
11320 vty_out (vty
, "%% Invalid address family %s%s",
11321 afi_str
, VTY_NEWLINE
);
11322 return CMD_WARNING
;
11325 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11328 DEFUN (show_bgp_statistics
,
11329 show_bgp_statistics_cmd
,
11330 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
11335 "Address Family modifier\n"
11336 "Address Family modifier\n"
11337 "BGP RIB advertisement statistics\n")
11339 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11342 ALIAS (show_bgp_statistics
,
11343 show_bgp_statistics_vpnv4_cmd
,
11344 "show bgp (ipv4) (vpnv4) statistics",
11348 "Address Family modifier\n"
11349 "BGP RIB advertisement statistics\n")
11351 DEFUN (show_bgp_statistics_view
,
11352 show_bgp_statistics_view_cmd
,
11353 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) statistics",
11356 BGP_INSTANCE_HELP_STR
11359 "Address Family modifier\n"
11360 "Address Family modifier\n"
11361 "BGP RIB advertisement statistics\n")
11363 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11366 ALIAS (show_bgp_statistics_view
,
11367 show_bgp_statistics_view_vpnv4_cmd
,
11368 "show bgp " BGP_INSTANCE_CMD
" (ipv4) (vpnv4) statistics",
11371 BGP_INSTANCE_HELP_STR
11373 "Address Family modifier\n"
11374 "BGP RIB advertisement statistics\n")
11386 PCOUNT_PFCNT
, /* the figure we display to users */
11390 static const char *pcount_strs
[] =
11392 [PCOUNT_ADJ_IN
] = "Adj-in",
11393 [PCOUNT_DAMPED
] = "Damped",
11394 [PCOUNT_REMOVED
] = "Removed",
11395 [PCOUNT_HISTORY
] = "History",
11396 [PCOUNT_STALE
] = "Stale",
11397 [PCOUNT_VALID
] = "Valid",
11398 [PCOUNT_ALL
] = "All RIB",
11399 [PCOUNT_COUNTED
] = "PfxCt counted",
11400 [PCOUNT_PFCNT
] = "Useable",
11401 [PCOUNT_MAX
] = NULL
,
11404 struct peer_pcounts
11406 unsigned int count
[PCOUNT_MAX
];
11407 const struct peer
*peer
;
11408 const struct bgp_table
*table
;
11412 bgp_peer_count_walker (struct thread
*t
)
11414 struct bgp_node
*rn
;
11415 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11416 const struct peer
*peer
= pc
->peer
;
11418 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11420 struct bgp_adj_in
*ain
;
11421 struct bgp_info
*ri
;
11423 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11424 if (ain
->peer
== peer
)
11425 pc
->count
[PCOUNT_ADJ_IN
]++;
11427 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11429 char buf
[SU_ADDRSTRLEN
];
11431 if (ri
->peer
!= peer
)
11434 pc
->count
[PCOUNT_ALL
]++;
11436 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11437 pc
->count
[PCOUNT_DAMPED
]++;
11438 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11439 pc
->count
[PCOUNT_HISTORY
]++;
11440 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
11441 pc
->count
[PCOUNT_REMOVED
]++;
11442 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
11443 pc
->count
[PCOUNT_STALE
]++;
11444 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
11445 pc
->count
[PCOUNT_VALID
]++;
11446 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11447 pc
->count
[PCOUNT_PFCNT
]++;
11449 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
11451 pc
->count
[PCOUNT_COUNTED
]++;
11452 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11453 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
11455 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11456 buf
, SU_ADDRSTRLEN
),
11462 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11463 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
11465 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11466 buf
, SU_ADDRSTRLEN
),
11476 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
11478 struct peer_pcounts pcounts
= { .peer
= peer
};
11480 json_object
*json
= NULL
;
11481 json_object
*json_loop
= NULL
;
11485 json
= json_object_new_object();
11486 json_loop
= json_object_new_object();
11489 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
11490 || !peer
->bgp
->rib
[afi
][safi
])
11494 json_object_string_add(json
, "warning", "No such neighbor or address family");
11495 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11496 json_object_free(json
);
11499 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11501 return CMD_WARNING
;
11504 memset (&pcounts
, 0, sizeof(pcounts
));
11505 pcounts
.peer
= peer
;
11506 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
11508 /* in-place call via thread subsystem so as to record execution time
11509 * * stats for the thread-walk (i.e. ensure this can't be blamed on
11510 * * on just vty_read()).
11512 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
11516 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
11517 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
11518 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
11520 for (i
= 0; i
< PCOUNT_MAX
; i
++)
11521 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
11523 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
11525 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
11527 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
11528 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
11530 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11531 json_object_free(json
);
11536 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
11538 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
11539 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
11544 vty_out (vty
, "Prefix counts for %s, %s%s",
11545 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
11548 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
11549 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
11550 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
11552 for (i
= 0; i
< PCOUNT_MAX
; i
++)
11553 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
11555 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
11557 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
11558 peer
->host
, VTY_NEWLINE
);
11559 vty_out (vty
, "Please report this bug, with the above command output%s",
11564 return CMD_SUCCESS
;
11567 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
11568 show_ip_bgp_neighbor_prefix_counts_cmd
,
11569 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11573 "Detailed information on TCP and BGP neighbor connections\n"
11574 "Neighbor to display information about\n"
11575 "Neighbor to display information about\n"
11576 "Neighbor on bgp configured interface\n"
11577 "Display detailed prefix count information\n"
11578 "JavaScript Object Notation\n")
11581 u_char uj
= use_json(argc
, argv
);
11583 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11585 return CMD_WARNING
;
11587 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11590 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
11591 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
11592 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11596 BGP_INSTANCE_HELP_STR
11597 "Detailed information on TCP and BGP neighbor connections\n"
11598 "Neighbor to display information about\n"
11599 "Neighbor to display information about\n"
11600 "Neighbor on bgp configured interface\n"
11601 "Display detailed prefix count information\n"
11602 "JavaScript Object Notation\n")
11605 u_char uj
= use_json(argc
, argv
);
11607 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11609 return CMD_WARNING
;
11611 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11614 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
11615 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
11616 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11620 "Detailed information on TCP and BGP neighbor connections\n"
11621 "Neighbor to display information about\n"
11622 "Neighbor to display information about\n"
11623 "Neighbor on bgp configured interface\n"
11624 "Display detailed prefix count information\n"
11625 "JavaScript Object Notation\n")
11628 u_char uj
= use_json(argc
, argv
);
11630 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11632 return CMD_WARNING
;
11634 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11637 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
11638 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
11639 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11642 BGP_INSTANCE_HELP_STR
11644 "Detailed information on TCP and BGP neighbor connections\n"
11645 "Neighbor to display information about\n"
11646 "Neighbor to display information about\n"
11647 "Neighbor on bgp configured interface\n"
11648 "Display detailed prefix count information\n"
11649 "JavaScript Object Notation\n")
11652 u_char uj
= use_json(argc
, argv
);
11654 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11656 return CMD_WARNING
;
11658 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11661 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
11662 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
11663 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11668 "Address Family modifier\n"
11669 "Address Family modifier\n"
11670 "Detailed information on TCP and BGP neighbor connections\n"
11671 "Neighbor to display information about\n"
11672 "Neighbor to display information about\n"
11673 "Neighbor on bgp configured interface\n"
11674 "Display detailed prefix count information\n"
11675 "JavaScript Object Notation\n")
11678 u_char uj
= use_json(argc
, argv
);
11680 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11682 return CMD_WARNING
;
11684 if (strncmp (argv
[0], "m", 1) == 0)
11685 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, uj
);
11687 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11690 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
11691 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
11692 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11697 "Address Family modifier\n"
11698 "Address Family modifier\n"
11699 "Detailed information on TCP and BGP neighbor connections\n"
11700 "Neighbor to display information about\n"
11701 "Neighbor to display information about\n"
11702 "Neighbor on bgp configured interface\n"
11703 "Display detailed prefix count information\n"
11704 "JavaScript Object Notation\n")
11707 u_char uj
= use_json(argc
, argv
);
11709 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11711 return CMD_WARNING
;
11713 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
, uj
);
11717 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
11718 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
11720 struct bgp_table
*table
;
11721 struct bgp_adj_in
*ain
;
11722 struct bgp_adj_out
*adj
;
11723 unsigned long output_count
;
11724 unsigned long filtered_count
;
11725 struct bgp_node
*rn
;
11730 struct attr_extra extra
;
11732 struct update_subgroup
*subgrp
;
11733 json_object
*json_scode
= NULL
;
11734 json_object
*json_ocode
= NULL
;
11735 json_object
*json_ar
= NULL
;
11736 struct peer_af
*paf
;
11740 json_scode
= json_object_new_object();
11741 json_ocode
= json_object_new_object();
11742 json_ar
= json_object_new_object();
11744 json_object_string_add(json_scode
, "suppressed", "s");
11745 json_object_string_add(json_scode
, "damped", "d");
11746 json_object_string_add(json_scode
, "history", "h");
11747 json_object_string_add(json_scode
, "valid", "*");
11748 json_object_string_add(json_scode
, "best", ">");
11749 json_object_string_add(json_scode
, "multipath", "=");
11750 json_object_string_add(json_scode
, "internal", "i");
11751 json_object_string_add(json_scode
, "ribFailure", "r");
11752 json_object_string_add(json_scode
, "stale", "S");
11753 json_object_string_add(json_scode
, "removed", "R");
11755 json_object_string_add(json_ocode
, "igp", "i");
11756 json_object_string_add(json_ocode
, "egp", "e");
11757 json_object_string_add(json_ocode
, "incomplete", "?");
11766 json_object_string_add(json
, "alert", "no BGP");
11767 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11768 json_object_free(json
);
11771 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
11775 table
= bgp
->rib
[afi
][safi
];
11777 output_count
= filtered_count
= 0;
11778 subgrp
= peer_subgroup(peer
, afi
, safi
);
11780 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11784 json_object_int_add(json
, "bgpTableVersion", table
->version
);
11785 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11786 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11787 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11788 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
11792 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11793 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11794 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11796 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
11797 VTY_NEWLINE
, VTY_NEWLINE
);
11802 attr
.extra
= &extra
;
11803 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
11807 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11809 if (ain
->peer
== peer
)
11815 json_object_int_add(json
, "bgpTableVersion", 0);
11816 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11817 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11818 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11822 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11823 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11824 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11831 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
11836 bgp_attr_dup(&attr
, ain
->attr
);
11837 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
11839 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
11850 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
11851 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
11852 if (paf
->peer
== peer
)
11858 json_object_int_add(json
, "bgpTableVersion", table
->version
);
11859 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11860 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11861 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11865 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
11866 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11867 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11868 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11876 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
11882 bgp_attr_dup(&attr
, adj
->attr
);
11883 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
11884 if (ret
!= RMAP_DENY
)
11886 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
11896 json_object_object_add(json
, "advertisedRoutes", json_ar
);
11898 if (output_count
!= 0)
11901 json_object_int_add(json
, "totalPrefixCounter", output_count
);
11903 vty_out (vty
, "%sTotal number of prefixes %ld%s",
11904 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
11908 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11909 json_object_free(json
);
11915 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
11916 int in
, const char *rmap_name
, u_char use_json
)
11918 json_object
*json
= NULL
;
11921 json
= json_object_new_object();
11923 if (!peer
|| !peer
->afc
[afi
][safi
])
11927 json_object_string_add(json
, "warning", "No such neighbor or address family");
11928 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11929 json_object_free(json
);
11932 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11934 return CMD_WARNING
;
11937 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11941 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
11942 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11943 json_object_free(json
);
11946 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
11948 return CMD_WARNING
;
11951 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
11953 return CMD_SUCCESS
;
11956 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
11957 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
11958 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11962 BGP_INSTANCE_HELP_STR
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 "Display the routes advertised to a BGP neighbor\n"
11967 "JavaScript Object Notation\n")
11970 u_char uj
= use_json(argc
, argv
);
11972 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
11973 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11975 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11978 return CMD_WARNING
;
11980 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
11983 DEFUN (show_ip_bgp_neighbor_advertised_route
,
11984 show_ip_bgp_neighbor_advertised_route_cmd
,
11985 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
11989 "Detailed information on TCP and BGP neighbor connections\n"
11990 "Neighbor to display information about\n"
11991 "Neighbor to display information about\n"
11992 "Neighbor on bgp configured interface\n"
11993 "Display the routes advertised to a BGP neighbor\n"
11994 "JavaScript Object Notation\n")
11998 const char *rmap_name
= NULL
;
11999 u_char uj
= use_json(argc
, argv
);
12001 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12004 return CMD_WARNING
;
12006 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12008 rmap_name
= argv
[1];
12010 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12013 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12014 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12015 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12019 "Detailed information on TCP and BGP neighbor connections\n"
12020 "Neighbor to display information about\n"
12021 "Neighbor to display information about\n"
12022 "Neighbor on bgp configured interface\n"
12023 "Display the routes advertised to a BGP neighbor\n"
12024 "JavaScript Object Notation\n")
12026 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12027 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12028 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12032 BGP_INSTANCE_HELP_STR
12033 "Detailed information on TCP and BGP neighbor connections\n"
12034 "Neighbor to display information about\n"
12035 "Neighbor to display information about\n"
12036 "Neighbor on bgp configured interface\n"
12037 "Display the routes advertised to a BGP neighbor\n"
12038 "JavaScript Object Notation\n")
12039 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12040 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12041 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12046 "Address Family modifier\n"
12047 "Address Family modifier\n"
12048 "Detailed information on TCP and BGP neighbor connections\n"
12049 "Neighbor to display information about\n"
12050 "Neighbor to display information about\n"
12051 "Neighbor on bgp configured interface\n"
12052 "Display the routes advertised to a BGP neighbor\n"
12053 "JavaScript Object Notation\n")
12056 const char *rmap_name
= NULL
;
12057 u_char uj
= use_json(argc
, argv
);
12059 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12061 return CMD_WARNING
;
12063 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12064 rmap_name
= argv
[2];
12066 if (strncmp (argv
[0], "m", 1) == 0)
12067 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0, rmap_name
, uj
);
12069 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12072 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12073 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12074 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12079 "Address Family modifier\n"
12080 "Address Family modifier\n"
12081 "Detailed information on TCP and BGP neighbor connections\n"
12082 "Neighbor to display information about\n"
12083 "Neighbor to display information about\n"
12084 "Neighbor on bgp configured interface\n"
12085 "Display the routes advertised to a BGP neighbor\n"
12086 "Route-map to control what is displayed\n"
12087 "JavaScript Object Notation\n")
12090 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12091 show_bgp_instance_neighbor_advertised_route_cmd
,
12092 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12095 BGP_INSTANCE_HELP_STR
12096 "Detailed information on TCP and BGP neighbor connections\n"
12097 "Neighbor to display information about\n"
12098 "Neighbor to display information about\n"
12099 "Neighbor on bgp configured interface\n"
12100 "Display the routes advertised to a BGP neighbor\n"
12101 "JavaScript Object Notation\n")
12104 u_char uj
= use_json(argc
, argv
);
12106 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12107 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12109 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12112 return CMD_WARNING
;
12114 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12117 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12118 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12119 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12122 BGP_INSTANCE_HELP_STR
12124 "Detailed information on TCP and BGP neighbor connections\n"
12125 "Neighbor to display information about\n"
12126 "Neighbor to display information about\n"
12127 "Neighbor on bgp configured interface\n"
12128 "Display the routes advertised to a BGP neighbor\n"
12129 "JavaScript Object Notation\n")
12131 DEFUN (show_bgp_neighbor_advertised_route
,
12132 show_bgp_neighbor_advertised_route_cmd
,
12133 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {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 routes advertised to a BGP neighbor\n"
12141 "JavaScript Object Notation\n")
12145 const char *rmap_name
= NULL
;
12146 u_char uj
= use_json(argc
, argv
);
12148 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12151 return CMD_WARNING
;
12153 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12154 rmap_name
= argv
[1];
12156 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12159 ALIAS (show_bgp_neighbor_advertised_route
,
12160 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12161 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12165 "Detailed information on TCP and BGP neighbor connections\n"
12166 "Neighbor to display information about\n"
12167 "Neighbor to display information about\n"
12168 "Neighbor on bgp configured interface\n"
12169 "Display the routes advertised to a BGP neighbor\n"
12170 "JavaScript Object Notation\n")
12173 ALIAS (show_bgp_neighbor_advertised_route
,
12174 ipv6_bgp_neighbor_advertised_route_cmd
,
12175 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12179 "Detailed information on TCP and BGP neighbor connections\n"
12180 "Neighbor to display information about\n"
12181 "Neighbor to display information about\n"
12182 "Neighbor on bgp configured interface\n"
12183 "Display the routes advertised to a BGP neighbor\n"
12184 "JavaScript Object Notation\n")
12187 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12188 ipv6_mbgp_neighbor_advertised_route_cmd
,
12189 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12193 "Detailed information on TCP and BGP neighbor connections\n"
12194 "Neighbor to display information about\n"
12195 "Neighbor to display information about\n"
12196 "Neighbor on bgp configured interface\n"
12197 "Neighbor on bgp configured interface\n"
12198 "Display the routes advertised to a BGP neighbor\n"
12199 "JavaScript Object Notation\n")
12202 u_char uj
= use_json(argc
, argv
);
12204 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12206 return CMD_WARNING
;
12208 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12209 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12211 #endif /* HAVE_IPV6 */
12213 DEFUN (show_bgp_instance_neighbor_received_routes
,
12214 show_bgp_instance_neighbor_received_routes_cmd
,
12215 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12218 BGP_INSTANCE_HELP_STR
12219 "Detailed information on TCP and BGP neighbor connections\n"
12220 "Neighbor to display information about\n"
12221 "Neighbor to display information about\n"
12222 "Neighbor on bgp configured interface\n"
12223 "Display the received routes from neighbor\n"
12224 "JavaScript Object Notation\n")
12227 u_char uj
= use_json(argc
, argv
);
12229 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12231 return CMD_WARNING
;
12233 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12236 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12237 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12238 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12242 BGP_INSTANCE_HELP_STR
12243 "Detailed information on TCP and BGP neighbor connections\n"
12244 "Neighbor to display information about\n"
12245 "Neighbor to display information about\n"
12246 "Neighbor on bgp configured interface\n"
12247 "Display the received routes from neighbor\n"
12248 "JavaScript Object Notation\n")
12251 u_char uj
= use_json(argc
, argv
);
12253 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12255 return CMD_WARNING
;
12257 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12260 ALIAS (show_bgp_instance_neighbor_received_routes
,
12261 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12262 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12265 BGP_INSTANCE_HELP_STR
12267 "Detailed information on TCP and BGP neighbor connections\n"
12268 "Neighbor to display information about\n"
12269 "Neighbor to display information about\n"
12270 "Neighbor on bgp configured interface\n"
12271 "Display the received routes from neighbor\n"
12272 "JavaScript Object Notation\n")
12274 DEFUN (show_ip_bgp_neighbor_received_routes
,
12275 show_ip_bgp_neighbor_received_routes_cmd
,
12276 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12280 "Detailed information on TCP and BGP neighbor connections\n"
12281 "Neighbor to display information about\n"
12282 "Neighbor to display information about\n"
12283 "Neighbor on bgp configured interface\n"
12284 "Display the received routes from neighbor\n"
12285 "JavaScript Object Notation\n")
12289 const char *rmap_name
= NULL
;
12290 u_char uj
= use_json(argc
, argv
);
12292 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12295 return CMD_WARNING
;
12297 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12298 rmap_name
= argv
[1];
12300 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12303 ALIAS (show_ip_bgp_neighbor_received_routes
,
12304 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12305 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12309 "Detailed information on TCP and BGP neighbor connections\n"
12310 "Neighbor to display information about\n"
12311 "Neighbor to display information about\n"
12312 "Neighbor on bgp configured interface\n"
12313 "Display the received routes from neighbor\n"
12314 "JavaScript Object Notation\n")
12316 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12317 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12318 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12322 BGP_INSTANCE_HELP_STR
12323 "Detailed information on TCP and BGP neighbor connections\n"
12324 "Neighbor to display information about\n"
12325 "Neighbor to display information about\n"
12326 "Neighbor on bgp configured interface\n"
12327 "Display the received routes from neighbor\n"
12328 "JavaScript Object Notation\n")
12330 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12331 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12332 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12337 "Address Family modifier\n"
12338 "Address Family modifier\n"
12339 "Detailed information on TCP and BGP neighbor connections\n"
12340 "Neighbor to display information about\n"
12341 "Neighbor to display information about\n"
12342 "Neighbor on bgp configured interface\n"
12343 "Display the received routes from neighbor\n"
12344 "JavaScript Object Notation\n")
12347 const char *rmap_name
= NULL
;
12348 u_char uj
= use_json(argc
, argv
);
12350 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12352 return CMD_WARNING
;
12354 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12355 rmap_name
= argv
[2];
12357 if (strncmp (argv
[0], "m", 1) == 0)
12358 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1, rmap_name
, uj
);
12360 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12363 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12364 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12365 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12370 "Address Family modifier\n"
12371 "Address Family modifier\n"
12372 "Detailed information on TCP and BGP neighbor connections\n"
12373 "Neighbor to display information about\n"
12374 "Neighbor to display information about\n"
12375 "Neighbor on bgp configured interface\n"
12376 "Display the received routes from neighbor\n"
12377 "JavaScript Object Notation\n")
12379 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12380 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12381 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12384 BGP_INSTANCE_HELP_STR
12387 "Address family modifier\n"
12388 "Address family modifier\n"
12389 "Detailed information on TCP and BGP neighbor connections\n"
12390 "Neighbor to display information about\n"
12391 "Neighbor to display information about\n"
12392 "Neighbor on bgp configured interface\n"
12393 "Display the advertised routes to neighbor\n"
12394 "Display the received routes from neighbor\n"
12395 "JavaScript Object Notation\n")
12401 u_char uj
= use_json(argc
, argv
);
12403 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12406 return CMD_WARNING
;
12408 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
12409 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
12410 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12412 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12415 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12416 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12417 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12421 "Detailed information on TCP and BGP neighbor connections\n"
12422 "Neighbor to display information about\n"
12423 "Neighbor to display information about\n"
12424 "Neighbor on bgp configured interface\n"
12425 "Display information received from a BGP neighbor\n"
12426 "Display the prefixlist filter\n"
12427 "JavaScript Object Notation\n")
12430 union sockunion su
;
12433 u_char uj
= use_json(argc
, argv
);
12435 ret
= str2sockunion (argv
[0], &su
);
12438 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12443 json_object
*json_no
= NULL
;
12444 json_object
*json_sub
= NULL
;
12445 json_no
= json_object_new_object();
12446 json_sub
= json_object_new_object();
12447 json_object_string_add(json_no
, "warning", "Malformed address or name");
12448 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12449 json_object_object_add(json_no
, "detail", json_sub
);
12450 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12451 json_object_free(json_no
);
12454 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12455 return CMD_WARNING
;
12460 peer
= peer_lookup (NULL
, &su
);
12465 json_object
*json_no
= NULL
;
12466 json_no
= json_object_new_object();
12467 json_object_string_add(json_no
, "warning", "Peer not found");
12468 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12469 json_object_free(json_no
);
12472 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12473 return CMD_WARNING
;
12477 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12478 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12482 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12483 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12489 json_object
*json_no
= NULL
;
12490 json_no
= json_object_new_object();
12491 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12492 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12493 json_object_free(json_no
);
12496 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12499 return CMD_SUCCESS
;
12502 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
12503 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
12504 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12509 "Address Family modifier\n"
12510 "Address Family modifier\n"
12511 "Detailed information on TCP and BGP neighbor connections\n"
12512 "Neighbor to display information about\n"
12513 "Neighbor to display information about\n"
12514 "Neighbor on bgp configured interface\n"
12515 "Display information received from a BGP neighbor\n"
12516 "Display the prefixlist filter\n"
12517 "JavaScript Object Notation\n")
12520 union sockunion su
;
12523 u_char uj
= use_json(argc
, argv
);
12525 ret
= str2sockunion (argv
[1], &su
);
12528 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
12533 json_object
*json_no
= NULL
;
12534 json_object
*json_sub
= NULL
;
12535 json_no
= json_object_new_object();
12536 json_sub
= json_object_new_object();
12537 json_object_string_add(json_no
, "warning", "Malformed address or name");
12538 json_object_string_add(json_sub
, "warningCause", argv
[1]);
12539 json_object_object_add(json_no
, "detail", json_sub
);
12540 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12541 json_object_free(json_no
);
12544 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
12545 return CMD_WARNING
;
12550 peer
= peer_lookup (NULL
, &su
);
12555 json_object
*json_no
= NULL
;
12556 json_no
= json_object_new_object();
12557 json_object_string_add(json_no
, "warning", "Peer not found");
12558 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12559 json_object_free(json_no
);
12562 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12563 return CMD_WARNING
;
12567 if (strncmp (argv
[0], "m", 1) == 0)
12569 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
12570 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12574 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
12575 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12581 json_object
*json_no
= NULL
;
12582 json_no
= json_object_new_object();
12583 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12584 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12585 json_object_free(json_no
);
12588 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12593 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12594 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12598 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12599 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12605 json_object
*json_no
= NULL
;
12606 json_no
= json_object_new_object();
12607 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12608 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12609 json_object_free(json_no
);
12612 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12616 return CMD_SUCCESS
;
12619 DEFUN (show_bgp_neighbor_received_routes
,
12620 show_bgp_neighbor_received_routes_cmd
,
12621 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12624 "Detailed information on TCP and BGP neighbor connections\n"
12625 "Neighbor to display information about\n"
12626 "Neighbor to display information about\n"
12627 "Neighbor on bgp configured interface\n"
12628 "Display the received routes from neighbor\n"
12629 "JavaScript Object Notation\n")
12632 const char *rmap_name
= NULL
;
12633 u_char uj
= use_json(argc
, argv
);
12635 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12638 return CMD_WARNING
;
12640 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12641 rmap_name
= argv
[1];
12643 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12646 ALIAS (show_bgp_neighbor_received_routes
,
12647 show_bgp_ipv6_neighbor_received_routes_cmd
,
12648 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12652 "Detailed information on TCP and BGP neighbor connections\n"
12653 "Neighbor to display information about\n"
12654 "Neighbor to display information about\n"
12655 "Neighbor on bgp configured interface\n"
12656 "Display the received routes from neighbor\n"
12657 "JavaScript Object Notation\n")
12659 DEFUN (show_bgp_neighbor_received_prefix_filter
,
12660 show_bgp_neighbor_received_prefix_filter_cmd
,
12661 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12664 "Detailed information on TCP and BGP neighbor connections\n"
12665 "Neighbor to display information about\n"
12666 "Neighbor to display information about\n"
12667 "Neighbor on bgp configured interface\n"
12668 "Display information received from a BGP neighbor\n"
12669 "Display the prefixlist filter\n"
12670 "JavaScript Object Notation\n")
12673 union sockunion su
;
12676 u_char uj
= use_json(argc
, argv
);
12678 ret
= str2sockunion (argv
[0], &su
);
12681 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12686 json_object
*json_no
= NULL
;
12687 json_object
*json_sub
= NULL
;
12688 json_no
= json_object_new_object();
12689 json_sub
= json_object_new_object();
12690 json_object_string_add(json_no
, "warning", "Malformed address or name");
12691 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12692 json_object_object_add(json_no
, "detail", json_sub
);
12693 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12694 json_object_free(json_no
);
12697 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12698 return CMD_WARNING
;
12703 peer
= peer_lookup (NULL
, &su
);
12708 json_object
*json_no
= NULL
;
12709 json_no
= json_object_new_object();
12710 json_object_string_add(json_no
, "warning", "No Peer");
12711 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12712 json_object_free(json_no
);
12715 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12716 return CMD_WARNING
;
12720 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
12721 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
12725 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
12726 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
12732 json_object
*json_no
= NULL
;
12733 json_no
= json_object_new_object();
12734 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12735 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12736 json_object_free(json_no
);
12739 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12742 return CMD_SUCCESS
;
12745 ALIAS (show_bgp_neighbor_received_prefix_filter
,
12746 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
12747 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12751 "Detailed information on TCP and BGP neighbor connections\n"
12752 "Neighbor to display information about\n"
12753 "Neighbor to display information about\n"
12754 "Neighbor on bgp configured interface\n"
12755 "Display information received from a BGP neighbor\n"
12756 "Display the prefixlist filter\n"
12757 "JavaScript Object Notation\n")
12760 ALIAS (show_bgp_neighbor_received_routes
,
12761 ipv6_bgp_neighbor_received_routes_cmd
,
12762 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12766 "Detailed information on TCP and BGP neighbor connections\n"
12767 "Neighbor to display information about\n"
12768 "Neighbor to display information about\n"
12769 "Neighbor on bgp configured interface\n"
12770 "Display the received routes from neighbor\n"
12771 "JavaScript Object Notation\n")
12774 DEFUN (ipv6_mbgp_neighbor_received_routes
,
12775 ipv6_mbgp_neighbor_received_routes_cmd
,
12776 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12780 "Detailed information on TCP and BGP neighbor connections\n"
12781 "Neighbor to display information about\n"
12782 "Neighbor to display information about\n"
12783 "Neighbor on bgp configured interface\n"
12784 "Display the received routes from neighbor\n"
12785 "JavaScript Object Notation\n")
12788 u_char uj
= use_json(argc
, argv
);
12790 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12792 return CMD_WARNING
;
12794 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12795 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
12798 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
12799 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
12800 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12803 BGP_INSTANCE_HELP_STR
12804 "Detailed information on TCP and BGP neighbor connections\n"
12805 "Neighbor to display information about\n"
12806 "Neighbor to display information about\n"
12807 "Neighbor on bgp configured interface\n"
12808 "Display information received from a BGP neighbor\n"
12809 "Display the prefixlist filter\n"
12810 "JavaScript Object Notation\n")
12813 union sockunion su
;
12817 u_char uj
= use_json(argc
, argv
);
12819 /* BGP structure lookup. */
12820 bgp
= bgp_lookup_by_name (argv
[1]);
12825 json_object
*json_no
= NULL
;
12826 json_no
= json_object_new_object();
12827 json_object_string_add(json_no
, "warning", "Can't find BGP view");
12828 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12829 json_object_free(json_no
);
12832 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
12833 return CMD_WARNING
;
12836 ret
= str2sockunion (argv
[2], &su
);
12839 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
12844 json_object
*json_no
= NULL
;
12845 json_object
*json_sub
= NULL
;
12846 json_no
= json_object_new_object();
12847 json_sub
= json_object_new_object();
12848 json_object_string_add(json_no
, "warning", "Malformed address or name");
12849 json_object_string_add(json_sub
, "warningCause", argv
[2]);
12850 json_object_object_add(json_no
, "detail", json_sub
);
12851 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12852 json_object_free(json_no
);
12855 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
12856 return CMD_WARNING
;
12861 peer
= peer_lookup (bgp
, &su
);
12866 json_object
*json_no
= NULL
;
12867 json_no
= json_object_new_object();
12868 json_object_boolean_true_add(json_no
, "noPeer");
12869 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12870 json_object_free(json_no
);
12873 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12874 return CMD_WARNING
;
12879 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
12880 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
12884 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
12885 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
12888 return CMD_SUCCESS
;
12890 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
12891 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
12892 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12895 BGP_INSTANCE_HELP_STR
12897 "Detailed information on TCP and BGP neighbor connections\n"
12898 "Neighbor to display information about\n"
12899 "Neighbor to display information about\n"
12900 "Neighbor on bgp configured interface\n"
12901 "Display information received from a BGP neighbor\n"
12902 "Display the prefixlist filter\n"
12903 "JavaScript Object NOtation\n")
12904 #endif /* HAVE_IPV6 */
12907 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
12908 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
12910 if (! peer
|| ! peer
->afc
[afi
][safi
])
12914 json_object
*json_no
= NULL
;
12915 json_no
= json_object_new_object();
12916 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
12917 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12918 json_object_free(json_no
);
12921 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12922 return CMD_WARNING
;
12925 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
12928 DEFUN (show_ip_bgp_neighbor_routes
,
12929 show_ip_bgp_neighbor_routes_cmd
,
12930 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
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 routes learned from neighbor\n"
12939 "JavaScript Object Notation\n")
12942 u_char uj
= use_json(argc
, argv
);
12944 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12946 return CMD_WARNING
;
12948 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12949 bgp_show_type_neighbor
, uj
);
12952 DEFUN (show_ip_bgp_instance_neighbor_routes
,
12953 show_ip_bgp_instance_neighbor_routes_cmd
,
12954 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
12958 BGP_INSTANCE_HELP_STR
12959 "Detailed information on TCP and BGP neighbor connections\n"
12960 "Neighbor to display information about\n"
12961 "Neighbor to display information about\n"
12962 "Neighbor on bgp configured interface\n"
12963 "Display routes learned from neighbor\n"
12964 "JavaScript Object Notation\n")
12967 u_char uj
= use_json(argc
, argv
);
12969 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12971 return CMD_WARNING
;
12973 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12974 bgp_show_type_neighbor
, uj
);
12977 DEFUN (show_ip_bgp_neighbor_flap
,
12978 show_ip_bgp_neighbor_flap_cmd
,
12979 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
12983 "Detailed information on TCP and BGP neighbor connections\n"
12984 "Neighbor to display information about\n"
12985 "Neighbor to display information about\n"
12986 "Neighbor on bgp configured interface\n"
12987 "Display flap statistics of the routes learned from neighbor\n"
12988 "JavaScript Object Notation\n")
12991 u_char uj
= use_json(argc
, argv
);
12993 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12995 return CMD_WARNING
;
12997 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
12998 bgp_show_type_flap_neighbor
, uj
);
13001 DEFUN (show_ip_bgp_neighbor_damp
,
13002 show_ip_bgp_neighbor_damp_cmd
,
13003 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
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 the dampened routes received from neighbor\n"
13012 "JavaScript Object Notation\n")
13015 u_char uj
= use_json(argc
, argv
);
13017 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13019 return CMD_WARNING
;
13021 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13022 bgp_show_type_damp_neighbor
, uj
);
13025 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13026 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13027 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13032 "Address Family modifier\n"
13033 "Address Family modifier\n"
13034 "Detailed information on TCP and BGP neighbor connections\n"
13035 "Neighbor to display information about\n"
13036 "Neighbor to display information about\n"
13037 "Neighbor on bgp configured interface\n"
13038 "Display routes learned from neighbor\n"
13039 "JavaScript Object Notation\n")
13042 u_char uj
= use_json(argc
, argv
);
13044 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13046 return CMD_WARNING
;
13048 if (strncmp (argv
[0], "m", 1) == 0)
13049 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
13050 bgp_show_type_neighbor
, uj
);
13052 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13053 bgp_show_type_neighbor
, uj
);
13057 DEFUN (show_bgp_instance_neighbor_routes
,
13058 show_bgp_instance_neighbor_routes_cmd
,
13059 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13062 BGP_INSTANCE_HELP_STR
13063 "Detailed information on TCP and BGP neighbor connections\n"
13064 "Neighbor to display information about\n"
13065 "Neighbor to display information about\n"
13066 "Neighbor on bgp configured interface\n"
13067 "Display routes learned from neighbor\n"
13068 "JavaScript Object Notation\n")
13071 u_char uj
= use_json(argc
, argv
);
13073 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13075 return CMD_WARNING
;
13077 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13078 bgp_show_type_neighbor
, uj
);
13081 ALIAS (show_bgp_instance_neighbor_routes
,
13082 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13083 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13086 BGP_INSTANCE_HELP_STR
13088 "Detailed information on TCP and BGP neighbor connections\n"
13089 "Neighbor to display information about\n"
13090 "Neighbor to display information about\n"
13091 "Neighbor on bgp configured interface\n"
13092 "Display routes learned from neighbor\n"
13093 "JavaScript Object Notation\n")
13095 DEFUN (show_bgp_instance_neighbor_damp
,
13096 show_bgp_instance_neighbor_damp_cmd
,
13097 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13100 BGP_INSTANCE_HELP_STR
13101 "Detailed information on TCP and BGP neighbor connections\n"
13102 "Neighbor to display information about\n"
13103 "Neighbor to display information about\n"
13104 "Neighbor on bgp configured interface\n"
13105 "Display the dampened routes received from neighbor\n"
13106 "JavaScript Object Notation\n")
13109 u_char uj
= use_json(argc
, argv
);
13111 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13112 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13113 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13115 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13118 return CMD_WARNING
;
13120 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13121 bgp_show_type_damp_neighbor
, uj
);
13124 ALIAS (show_bgp_instance_neighbor_damp
,
13125 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13126 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13129 BGP_INSTANCE_HELP_STR
13131 "Detailed information on TCP and BGP neighbor connections\n"
13132 "Neighbor to display information about\n"
13133 "Neighbor to display information about\n"
13134 "Neighbor on bgp configured interface\n"
13135 "Display the dampened routes received from neighbor\n"
13136 "JavaScript Object Notation\n")
13138 DEFUN (show_bgp_instance_neighbor_flap
,
13139 show_bgp_instance_neighbor_flap_cmd
,
13140 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13143 BGP_INSTANCE_HELP_STR
13144 "Detailed information on TCP and BGP neighbor connections\n"
13145 "Neighbor to display information about\n"
13146 "Neighbor to display information about\n"
13147 "Neighbor on bgp configured interface\n"
13148 "Display flap statistics of the routes learned from neighbor\n"
13149 "JavaScript Object Notation\n")
13152 u_char uj
= use_json(argc
, argv
);
13154 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13155 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13156 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13158 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13161 return CMD_WARNING
;
13163 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13164 bgp_show_type_flap_neighbor
, uj
);
13167 ALIAS (show_bgp_instance_neighbor_flap
,
13168 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13169 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13172 BGP_INSTANCE_HELP_STR
13174 "Detailed information on TCP and BGP neighbor connections\n"
13175 "Neighbor to display information about\n"
13176 "Neighbor to display information about\n"
13177 "Neighbor on bgp configured interface\n"
13178 "Display flap statistics of the routes learned from neighbor\n"
13179 "JavaScript Object Notation\n")
13181 DEFUN (show_bgp_neighbor_routes
,
13182 show_bgp_neighbor_routes_cmd
,
13183 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13186 "Detailed information on TCP and BGP neighbor connections\n"
13187 "Neighbor to display information about\n"
13188 "Neighbor to display information about\n"
13189 "Neighbor on bgp configured interface\n"
13190 "Display routes learned from neighbor\n"
13191 "JavaScript Object Notation\n")
13194 u_char uj
= use_json(argc
, argv
);
13196 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13198 return CMD_WARNING
;
13200 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13201 bgp_show_type_neighbor
, uj
);
13205 ALIAS (show_bgp_neighbor_routes
,
13206 show_bgp_ipv6_neighbor_routes_cmd
,
13207 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13211 "Detailed information on TCP and BGP neighbor connections\n"
13212 "Neighbor to display information about\n"
13213 "Neighbor to display information about\n"
13214 "Neighbor on bgp configured interface\n"
13215 "Display routes learned from neighbor\n"
13216 "JavaScript Object Notation\n")
13219 ALIAS (show_bgp_neighbor_routes
,
13220 ipv6_bgp_neighbor_routes_cmd
,
13221 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13225 "Detailed information on TCP and BGP neighbor connections\n"
13226 "Neighbor to display information about\n"
13227 "Neighbor to display information about\n"
13228 "Neighbor on bgp configured interface\n"
13229 "Display routes learned from neighbor\n"
13230 "JavaScript Object Notation\n")
13233 DEFUN (ipv6_mbgp_neighbor_routes
,
13234 ipv6_mbgp_neighbor_routes_cmd
,
13235 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13239 "Detailed information on TCP and BGP neighbor connections\n"
13240 "Neighbor to display information about\n"
13241 "Neighbor to display information about\n"
13242 "Neighbor on bgp configured interface\n"
13243 "Display routes learned from neighbor\n"
13244 "JavaScript Object Notation\n")
13247 u_char uj
= use_json(argc
, argv
);
13249 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13251 return CMD_WARNING
;
13253 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13254 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13255 bgp_show_type_neighbor
, uj
);
13258 ALIAS (show_bgp_instance_neighbor_flap
,
13259 show_bgp_neighbor_flap_cmd
,
13260 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13263 "Detailed information on TCP and BGP neighbor connections\n"
13264 "Neighbor to display information about\n"
13265 "Neighbor to display information about\n"
13266 "Neighbor on bgp configured interface\n"
13267 "Display flap statistics of the routes learned from neighbor\n"
13268 "JavaScript Object Notation\n")
13270 ALIAS (show_bgp_instance_neighbor_flap
,
13271 show_bgp_ipv6_neighbor_flap_cmd
,
13272 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13276 "Detailed information on TCP and BGP neighbor connections\n"
13277 "Neighbor to display information about\n"
13278 "Neighbor to display information about\n"
13279 "Neighbor on bgp configured interface\n"
13280 "Display flap statistics of the routes learned from neighbor\n"
13281 "JavaScript Object Notation\n")
13283 ALIAS (show_bgp_instance_neighbor_damp
,
13284 show_bgp_neighbor_damp_cmd
,
13285 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13288 "Detailed information on TCP and BGP neighbor connections\n"
13289 "Neighbor to display information about\n"
13290 "Neighbor to display information about\n"
13291 "Neighbor on bgp configured interface\n"
13292 "Display the dampened routes received from neighbor\n"
13293 "JavaScript Object Notation\n")
13295 ALIAS (show_bgp_instance_neighbor_damp
,
13296 show_bgp_ipv6_neighbor_damp_cmd
,
13297 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13301 "Detailed information on TCP and BGP neighbor connections\n"
13302 "Neighbor to display information about\n"
13303 "Neighbor to display information about\n"
13304 "Neighbor on bgp configured interface\n"
13305 "Display the dampened routes received from neighbor\n"
13306 "JavaScript Object Notation\n")
13308 #endif /* HAVE_IPV6 */
13310 struct bgp_table
*bgp_distance_table
;
13312 struct bgp_distance
13314 /* Distance value for the IP source prefix. */
13317 /* Name of the access-list to be matched. */
13321 static struct bgp_distance
*
13322 bgp_distance_new (void)
13324 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13328 bgp_distance_free (struct bgp_distance
*bdistance
)
13330 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13334 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13335 const char *ip_str
, const char *access_list_str
)
13338 struct prefix_ipv4 p
;
13340 struct bgp_node
*rn
;
13341 struct bgp_distance
*bdistance
;
13343 ret
= str2prefix_ipv4 (ip_str
, &p
);
13346 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13347 return CMD_WARNING
;
13350 distance
= atoi (distance_str
);
13352 /* Get BGP distance node. */
13353 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
13356 bdistance
= rn
->info
;
13357 bgp_unlock_node (rn
);
13361 bdistance
= bgp_distance_new ();
13362 rn
->info
= bdistance
;
13365 /* Set distance value. */
13366 bdistance
->distance
= distance
;
13368 /* Reset access-list configuration. */
13369 if (bdistance
->access_list
)
13371 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13372 bdistance
->access_list
= NULL
;
13374 if (access_list_str
)
13375 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13377 return CMD_SUCCESS
;
13381 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13382 const char *ip_str
, const char *access_list_str
)
13386 struct prefix_ipv4 p
;
13387 struct bgp_node
*rn
;
13388 struct bgp_distance
*bdistance
;
13390 ret
= str2prefix_ipv4 (ip_str
, &p
);
13393 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13394 return CMD_WARNING
;
13397 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
13400 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13401 return CMD_WARNING
;
13404 bdistance
= rn
->info
;
13405 distance
= atoi(distance_str
);
13407 if (bdistance
->distance
!= distance
)
13409 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13410 return CMD_WARNING
;
13413 if (bdistance
->access_list
)
13414 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13415 bgp_distance_free (bdistance
);
13418 bgp_unlock_node (rn
);
13419 bgp_unlock_node (rn
);
13421 return CMD_SUCCESS
;
13424 /* Apply BGP information to distance method. */
13426 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
13428 struct bgp_node
*rn
;
13429 struct prefix_ipv4 q
;
13431 struct bgp_distance
*bdistance
;
13432 struct access_list
*alist
;
13433 struct bgp_static
*bgp_static
;
13438 if (p
->family
!= AF_INET
)
13441 peer
= rinfo
->peer
;
13443 if (peer
->su
.sa
.sa_family
!= AF_INET
)
13446 memset (&q
, 0, sizeof (struct prefix_ipv4
));
13447 q
.family
= AF_INET
;
13448 q
.prefix
= peer
->su
.sin
.sin_addr
;
13449 q
.prefixlen
= IPV4_MAX_BITLEN
;
13451 /* Check source address. */
13452 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
13455 bdistance
= rn
->info
;
13456 bgp_unlock_node (rn
);
13458 if (bdistance
->access_list
)
13460 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
13461 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13462 return bdistance
->distance
;
13465 return bdistance
->distance
;
13468 /* Backdoor check. */
13469 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
13472 bgp_static
= rn
->info
;
13473 bgp_unlock_node (rn
);
13475 if (bgp_static
->backdoor
)
13477 if (bgp
->distance_local
)
13478 return bgp
->distance_local
;
13480 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13484 if (peer
->sort
== BGP_PEER_EBGP
)
13486 if (bgp
->distance_ebgp
)
13487 return bgp
->distance_ebgp
;
13488 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
13492 if (bgp
->distance_ibgp
)
13493 return bgp
->distance_ibgp
;
13494 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13498 DEFUN (bgp_distance
,
13500 "distance bgp <1-255> <1-255> <1-255>",
13501 "Define an administrative distance\n"
13503 "Distance for routes external to the AS\n"
13504 "Distance for routes internal to the AS\n"
13505 "Distance for local routes\n")
13511 bgp
->distance_ebgp
= atoi (argv
[0]);
13512 bgp
->distance_ibgp
= atoi (argv
[1]);
13513 bgp
->distance_local
= atoi (argv
[2]);
13514 return CMD_SUCCESS
;
13517 DEFUN (no_bgp_distance
,
13518 no_bgp_distance_cmd
,
13519 "no distance bgp <1-255> <1-255> <1-255>",
13521 "Define an administrative distance\n"
13523 "Distance for routes external to the AS\n"
13524 "Distance for routes internal to the AS\n"
13525 "Distance for local routes\n")
13531 bgp
->distance_ebgp
= 0;
13532 bgp
->distance_ibgp
= 0;
13533 bgp
->distance_local
= 0;
13534 return CMD_SUCCESS
;
13537 ALIAS (no_bgp_distance
,
13538 no_bgp_distance2_cmd
,
13541 "Define an administrative distance\n"
13544 DEFUN (bgp_distance_source
,
13545 bgp_distance_source_cmd
,
13546 "distance <1-255> A.B.C.D/M",
13547 "Define an administrative distance\n"
13548 "Administrative distance\n"
13549 "IP source prefix\n")
13551 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
13552 return CMD_SUCCESS
;
13555 DEFUN (no_bgp_distance_source
,
13556 no_bgp_distance_source_cmd
,
13557 "no distance <1-255> A.B.C.D/M",
13559 "Define an administrative distance\n"
13560 "Administrative distance\n"
13561 "IP source prefix\n")
13563 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
13564 return CMD_SUCCESS
;
13567 DEFUN (bgp_distance_source_access_list
,
13568 bgp_distance_source_access_list_cmd
,
13569 "distance <1-255> A.B.C.D/M WORD",
13570 "Define an administrative distance\n"
13571 "Administrative distance\n"
13572 "IP source prefix\n"
13573 "Access list name\n")
13575 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
13576 return CMD_SUCCESS
;
13579 DEFUN (no_bgp_distance_source_access_list
,
13580 no_bgp_distance_source_access_list_cmd
,
13581 "no distance <1-255> A.B.C.D/M WORD",
13583 "Define an administrative distance\n"
13584 "Administrative distance\n"
13585 "IP source prefix\n"
13586 "Access list name\n")
13588 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
13589 return CMD_SUCCESS
;
13592 DEFUN (bgp_damp_set
,
13594 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
13595 "BGP Specific commands\n"
13596 "Enable route-flap dampening\n"
13597 "Half-life time for the penalty\n"
13598 "Value to start reusing a route\n"
13599 "Value to start suppressing a route\n"
13600 "Maximum duration to suppress a stable route\n")
13603 int half
= DEFAULT_HALF_LIFE
* 60;
13604 int reuse
= DEFAULT_REUSE
;
13605 int suppress
= DEFAULT_SUPPRESS
;
13606 int max
= 4 * half
;
13610 half
= atoi (argv
[0]) * 60;
13611 reuse
= atoi (argv
[1]);
13612 suppress
= atoi (argv
[2]);
13613 max
= atoi (argv
[3]) * 60;
13615 else if (argc
== 1)
13617 half
= atoi (argv
[0]) * 60;
13623 if (suppress
< reuse
)
13625 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
13630 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
13631 half
, reuse
, suppress
, max
);
13634 ALIAS (bgp_damp_set
,
13636 "bgp dampening <1-45>",
13637 "BGP Specific commands\n"
13638 "Enable route-flap dampening\n"
13639 "Half-life time for the penalty\n")
13641 ALIAS (bgp_damp_set
,
13644 "BGP Specific commands\n"
13645 "Enable route-flap dampening\n")
13647 DEFUN (bgp_damp_unset
,
13648 bgp_damp_unset_cmd
,
13649 "no bgp dampening",
13651 "BGP Specific commands\n"
13652 "Enable route-flap dampening\n")
13657 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
13660 ALIAS (bgp_damp_unset
,
13661 bgp_damp_unset2_cmd
,
13662 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
13664 "BGP Specific commands\n"
13665 "Enable route-flap dampening\n"
13666 "Half-life time for the penalty\n"
13667 "Value to start reusing a route\n"
13668 "Value to start suppressing a route\n"
13669 "Maximum duration to suppress a stable route\n")
13671 ALIAS (bgp_damp_unset
,
13672 bgp_damp_unset3_cmd
,
13673 "no bgp dampening <1-45>",
13675 "BGP Specific commands\n"
13676 "Enable route-flap dampening\n"
13677 "Half-life time for the penalty\n")
13679 DEFUN (show_ip_bgp_dampened_paths
,
13680 show_ip_bgp_dampened_paths_cmd
,
13681 "show ip bgp dampened-paths",
13685 "Display paths suppressed due to dampening\n")
13687 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
13691 ALIAS (show_ip_bgp_dampened_paths
,
13692 show_ip_bgp_damp_dampened_paths_cmd
,
13693 "show ip bgp dampening dampened-paths",
13697 "Display detailed information about dampening\n"
13698 "Display paths suppressed due to dampening\n")
13700 DEFUN (show_ip_bgp_flap_statistics
,
13701 show_ip_bgp_flap_statistics_cmd
,
13702 "show ip bgp flap-statistics",
13706 "Display flap statistics of routes\n")
13708 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
13709 bgp_show_type_flap_statistics
, NULL
, 0);
13712 ALIAS (show_ip_bgp_flap_statistics
,
13713 show_ip_bgp_damp_flap_statistics_cmd
,
13714 "show ip bgp dampening flap-statistics",
13718 "Display detailed information about dampening\n"
13719 "Display flap statistics of routes\n")
13721 /* Display specified route of BGP table. */
13723 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
13724 const char *ip_str
, afi_t afi
, safi_t safi
,
13725 struct prefix_rd
*prd
, int prefix_check
)
13728 struct prefix match
;
13729 struct bgp_node
*rn
;
13730 struct bgp_node
*rm
;
13731 struct bgp_info
*ri
;
13732 struct bgp_info
*ri_temp
;
13734 struct bgp_table
*table
;
13736 /* BGP structure lookup. */
13739 bgp
= bgp_lookup_by_name (view_name
);
13742 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
13743 return CMD_WARNING
;
13748 bgp
= bgp_get_default ();
13751 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
13752 return CMD_WARNING
;
13756 /* Check IP address argument. */
13757 ret
= str2prefix (ip_str
, &match
);
13760 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
13761 return CMD_WARNING
;
13764 match
.family
= afi2family (afi
);
13766 if (safi
== SAFI_MPLS_VPN
)
13768 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
13770 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
13773 if ((table
= rn
->info
) != NULL
)
13774 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
13776 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
13781 if (ri
->extra
&& ri
->extra
->damp_info
)
13783 ri_temp
= ri
->next
;
13784 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
13792 bgp_unlock_node (rm
);
13798 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
13800 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
13805 if (ri
->extra
&& ri
->extra
->damp_info
)
13807 ri_temp
= ri
->next
;
13808 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
13816 bgp_unlock_node (rn
);
13820 return CMD_SUCCESS
;
13823 DEFUN (clear_ip_bgp_dampening
,
13824 clear_ip_bgp_dampening_cmd
,
13825 "clear ip bgp dampening",
13829 "Clear route flap dampening information\n")
13831 bgp_damp_info_clean ();
13832 return CMD_SUCCESS
;
13835 DEFUN (clear_ip_bgp_dampening_prefix
,
13836 clear_ip_bgp_dampening_prefix_cmd
,
13837 "clear ip bgp dampening A.B.C.D/M",
13841 "Clear route flap dampening information\n"
13842 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
13844 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
13845 SAFI_UNICAST
, NULL
, 1);
13848 DEFUN (clear_ip_bgp_dampening_address
,
13849 clear_ip_bgp_dampening_address_cmd
,
13850 "clear ip bgp dampening A.B.C.D",
13854 "Clear route flap dampening information\n"
13855 "Network to clear damping information\n")
13857 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
13858 SAFI_UNICAST
, NULL
, 0);
13861 DEFUN (clear_ip_bgp_dampening_address_mask
,
13862 clear_ip_bgp_dampening_address_mask_cmd
,
13863 "clear ip bgp dampening A.B.C.D A.B.C.D",
13867 "Clear route flap dampening information\n"
13868 "Network to clear damping information\n"
13872 char prefix_str
[BUFSIZ
];
13874 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
13877 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
13878 return CMD_WARNING
;
13881 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
13882 SAFI_UNICAST
, NULL
, 0);
13886 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
13887 afi_t afi
, safi_t safi
, int *write
)
13889 struct bgp_node
*prn
;
13890 struct bgp_node
*rn
;
13891 struct bgp_table
*table
;
13893 struct prefix_rd
*prd
;
13894 struct bgp_static
*bgp_static
;
13896 char buf
[SU_ADDRSTRLEN
];
13897 char rdbuf
[RD_ADDRSTRLEN
];
13899 /* Network configuration. */
13900 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
13901 if ((table
= prn
->info
) != NULL
)
13902 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
13903 if ((bgp_static
= rn
->info
) != NULL
)
13906 prd
= (struct prefix_rd
*) &prn
->p
;
13908 /* "address-family" display. */
13909 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13911 /* "network" configuration display. */
13912 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
13913 label
= decode_label (bgp_static
->tag
);
13915 vty_out (vty
, " network %s/%d rd %s tag %d",
13916 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13919 vty_out (vty
, "%s", VTY_NEWLINE
);
13924 /* Configuration of static route announcement and aggregate
13927 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
13928 afi_t afi
, safi_t safi
, int *write
)
13930 struct bgp_node
*rn
;
13932 struct bgp_static
*bgp_static
;
13933 struct bgp_aggregate
*bgp_aggregate
;
13934 char buf
[SU_ADDRSTRLEN
];
13936 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
13937 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
13939 /* Network configuration. */
13940 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
13941 if ((bgp_static
= rn
->info
) != NULL
)
13945 /* "address-family" display. */
13946 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13948 /* "network" configuration display. */
13949 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
13951 u_int32_t destination
;
13952 struct in_addr netmask
;
13954 destination
= ntohl (p
->u
.prefix4
.s_addr
);
13955 masklen2ip (p
->prefixlen
, &netmask
);
13956 vty_out (vty
, " network %s",
13957 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
13959 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
13960 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
13961 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
13962 || p
->u
.prefix4
.s_addr
== 0)
13964 /* Natural mask is not display. */
13967 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
13971 vty_out (vty
, " network %s/%d",
13972 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
13976 if (bgp_static
->rmap
.name
)
13977 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
13980 if (bgp_static
->backdoor
)
13981 vty_out (vty
, " backdoor");
13984 vty_out (vty
, "%s", VTY_NEWLINE
);
13987 /* Aggregate-address configuration. */
13988 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
13989 if ((bgp_aggregate
= rn
->info
) != NULL
)
13993 /* "address-family" display. */
13994 bgp_config_write_family_header (vty
, afi
, safi
, write
);
13996 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
13998 struct in_addr netmask
;
14000 masklen2ip (p
->prefixlen
, &netmask
);
14001 vty_out (vty
, " aggregate-address %s %s",
14002 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14003 inet_ntoa (netmask
));
14007 vty_out (vty
, " aggregate-address %s/%d",
14008 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14012 if (bgp_aggregate
->as_set
)
14013 vty_out (vty
, " as-set");
14015 if (bgp_aggregate
->summary_only
)
14016 vty_out (vty
, " summary-only");
14018 vty_out (vty
, "%s", VTY_NEWLINE
);
14025 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
14027 struct bgp_node
*rn
;
14028 struct bgp_distance
*bdistance
;
14030 /* Distance configuration. */
14031 if (bgp
->distance_ebgp
14032 && bgp
->distance_ibgp
14033 && bgp
->distance_local
14034 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
14035 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
14036 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
14037 vty_out (vty
, " distance bgp %d %d %d%s",
14038 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
14041 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
14042 if ((bdistance
= rn
->info
) != NULL
)
14044 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
14045 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
14046 bdistance
->access_list
? bdistance
->access_list
: "",
14053 /* Allocate routing table structure and install commands. */
14055 bgp_route_init (void)
14057 /* Init BGP distance table. */
14058 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
14060 /* IPv4 BGP commands. */
14061 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14062 install_element (BGP_NODE
, &bgp_network_cmd
);
14063 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14064 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14065 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14066 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14067 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14068 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14069 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14070 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14071 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14072 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14073 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14074 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14075 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14076 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14077 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14078 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14079 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14080 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14082 install_element (BGP_NODE
, &aggregate_address_cmd
);
14083 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14084 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14085 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14086 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14087 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14088 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14089 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14090 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14091 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14092 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14093 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14094 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14095 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14096 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14097 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14098 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14099 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14100 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14101 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14103 /* IPv4 unicast configuration. */
14104 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14105 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14106 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14107 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14108 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14109 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14110 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14111 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14112 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14113 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14114 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14115 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14116 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14117 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14119 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14120 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14121 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14122 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14123 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14124 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14125 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14126 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14127 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14128 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14129 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14130 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14131 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14132 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14133 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14134 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14135 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14136 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14137 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14138 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14140 /* IPv4 multicast configuration. */
14141 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14142 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14143 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14144 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14145 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14146 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14147 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14148 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14149 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14150 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14151 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14152 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14153 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14154 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14155 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14156 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14157 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14158 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14159 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14160 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14161 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14162 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14163 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14164 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14165 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14166 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14167 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14168 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14169 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14170 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14171 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14172 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14173 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14174 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14176 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14177 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14178 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14179 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14180 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14181 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14182 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14183 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14184 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14185 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14186 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14187 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14188 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14189 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14190 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14191 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14192 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14193 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14194 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14195 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14196 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14197 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14198 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14199 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14201 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14202 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14203 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14204 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14205 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14206 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14207 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14208 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14209 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14210 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14211 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14212 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14213 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14214 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14215 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14216 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14217 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14218 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14219 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14220 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14221 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14222 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14223 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14224 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14225 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14226 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14227 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14228 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14229 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14230 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14231 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14232 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14233 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14234 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14235 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14236 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14237 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14238 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14239 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14240 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14241 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14242 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14243 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14244 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14245 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14246 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14247 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14248 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14249 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14250 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14251 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14252 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14253 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14254 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14255 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14256 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14257 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14258 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14259 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14260 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14261 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14262 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14263 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14264 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14265 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14266 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14267 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14268 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14269 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14270 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14271 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14272 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14273 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14274 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14275 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14276 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14277 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14278 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14279 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14280 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14281 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14282 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14283 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14285 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
14286 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
14287 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14288 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14289 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14290 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14291 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14292 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14293 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14294 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
14295 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14296 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14297 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14298 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14299 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14300 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14301 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14302 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14303 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14304 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14305 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14306 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
14307 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
14308 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
14309 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
14310 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14311 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14312 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14313 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14314 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14315 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14316 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14317 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14318 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14319 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
14320 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
14321 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
14322 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
14323 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14324 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14325 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14326 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14328 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
14329 install_element (ENABLE_NODE
, &show_ip_bgp_instance_cmd
);
14330 install_element (ENABLE_NODE
, &show_ip_bgp_instance_all_cmd
);
14331 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
14332 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
14333 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
14334 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_cmd
);
14335 install_element (ENABLE_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14336 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14337 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14338 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14339 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14340 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14341 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14342 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
14343 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14344 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14345 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14346 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14347 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14348 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14349 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14350 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14351 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14353 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
14354 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14355 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
14356 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14357 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14358 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
14359 install_element (ENABLE_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14360 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14361 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
14362 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14363 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14364 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
14365 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14366 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
14367 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14368 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
14369 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
14370 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
14371 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
14372 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14373 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14374 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14375 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14376 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14377 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14378 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14379 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14380 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14381 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
14382 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
14383 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
14384 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
14385 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14386 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14387 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14388 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14389 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
14390 install_element (ENABLE_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14391 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14392 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14393 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14394 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14395 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14396 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14397 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14398 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14399 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14400 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14401 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14402 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14403 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14404 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14405 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14406 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14407 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14408 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14409 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14410 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14411 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14412 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14413 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14414 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14415 install_element (ENABLE_NODE
, &show_ip_bgp_dampening_params_cmd
);
14416 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14417 install_element (ENABLE_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14418 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14419 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14420 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
14421 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14422 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14423 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14424 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14425 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14426 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_regexp_cmd
);
14427 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14428 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14429 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14430 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14431 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14432 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14433 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14434 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14435 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14436 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14437 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14439 /* BGP dampening clear commands */
14440 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14441 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14442 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14443 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14446 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14447 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14448 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14449 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
14451 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14452 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14454 /* New config IPv6 BGP commands. */
14455 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14456 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14457 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14458 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14459 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14460 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14462 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14463 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14464 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14465 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14467 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14468 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14470 /* Old config IPv6 BGP commands. */
14471 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14472 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14474 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14475 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14476 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14477 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14479 install_element (VIEW_NODE
, &show_bgp_cmd
);
14480 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14481 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14482 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14483 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14484 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14485 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14486 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14487 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14488 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14489 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14490 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14491 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14492 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14493 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14494 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14495 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14496 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14497 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14498 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14499 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14500 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14501 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14502 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14503 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14504 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14505 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14506 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14507 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14508 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14509 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14510 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14511 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14512 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14513 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14514 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14515 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14516 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14517 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14518 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14519 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14520 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14521 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14522 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14523 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14524 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14525 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14526 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14527 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14528 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14529 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14530 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14531 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14532 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14533 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14534 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14535 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14536 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14537 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14538 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14539 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14540 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14541 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14542 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14543 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14544 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14545 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14546 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14547 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14548 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14549 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14550 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14551 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14552 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14553 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14554 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14555 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14556 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14557 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14558 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14559 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14560 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14561 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14562 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14563 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14564 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14565 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14566 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14567 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14568 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14569 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14570 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14573 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
14575 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
14576 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
14577 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14578 install_element (RESTRICTED_NODE
, &show_bgp_route_pathtype_cmd
);
14579 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14580 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14581 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
14582 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
14583 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14584 install_element (RESTRICTED_NODE
, &show_bgp_prefix_pathtype_cmd
);
14585 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14586 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14587 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
14588 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
14589 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
14590 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
14591 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
14592 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
14593 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
14594 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
14595 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
14596 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14597 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
14598 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14599 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
14600 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14601 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
14602 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14603 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_cmd
);
14604 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14605 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14606 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14607 install_element (RESTRICTED_NODE
, &show_bgp_instance_prefix_cmd
);
14608 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14609 install_element (RESTRICTED_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14610 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14612 install_element (ENABLE_NODE
, &show_bgp_cmd
);
14613 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
14614 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
14615 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
14616 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
14617 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14618 install_element (ENABLE_NODE
, &show_bgp_route_pathtype_cmd
);
14619 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14620 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14621 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
14622 install_element (ENABLE_NODE
, &show_bgp_prefix_pathtype_cmd
);
14623 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14624 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14625 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
14626 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14627 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
14628 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
14629 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
14630 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14631 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
14632 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14633 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
14634 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
14635 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
14636 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
14637 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
14638 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
14639 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
14640 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
14641 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
14642 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
14643 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
14644 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
14645 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
14646 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14647 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
14648 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14649 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
14650 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14651 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
14652 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14653 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
14654 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
14655 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
14656 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14657 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
14658 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14659 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14660 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14661 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14662 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14663 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
14664 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14665 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14666 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14667 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
14668 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14669 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
14670 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14671 install_element (ENABLE_NODE
, &show_bgp_instance_cmd
);
14672 install_element (ENABLE_NODE
, &show_bgp_instance_all_cmd
);
14673 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_cmd
);
14674 install_element (ENABLE_NODE
, &show_bgp_instance_route_cmd
);
14675 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14676 install_element (ENABLE_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14677 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14678 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_cmd
);
14679 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14680 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14681 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14682 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_list_cmd
);
14683 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14684 install_element (ENABLE_NODE
, &show_bgp_instance_filter_list_cmd
);
14685 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14686 install_element (ENABLE_NODE
, &show_bgp_instance_route_map_cmd
);
14687 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14688 install_element (ENABLE_NODE
, &show_bgp_instance_community_list_cmd
);
14689 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14690 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14691 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14692 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14693 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14694 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14695 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14696 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14697 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14698 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14699 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14700 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14701 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14702 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14703 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14706 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
14707 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
14708 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
14709 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
14712 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
14713 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
14714 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
14715 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
14716 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14717 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14718 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
14719 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
14720 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
14721 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
14722 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
14723 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14724 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14725 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14726 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14727 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
14728 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14729 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14730 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
14731 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
14732 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14733 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14734 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14735 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14736 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14737 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
14738 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
14739 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
14740 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
14741 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14742 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14743 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14744 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
14745 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
14746 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
14747 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14750 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
14751 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
14752 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
14753 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
14754 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14755 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14756 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
14757 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
14758 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
14759 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
14760 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
14761 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14762 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14763 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14764 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14765 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
14766 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14767 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14768 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
14769 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
14770 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14771 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14772 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14773 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14774 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14775 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
14776 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
14777 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
14778 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
14779 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14780 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14781 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14782 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
14783 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
14784 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
14785 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14788 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14789 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14790 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14791 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14794 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14795 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14796 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14797 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14800 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14801 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14802 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14803 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14804 #endif /* HAVE_IPV6 */
14806 install_element (BGP_NODE
, &bgp_distance_cmd
);
14807 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
14808 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
14809 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
14810 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
14811 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
14812 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
14814 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
14815 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
14816 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
14817 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
14818 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
14819 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
14820 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
14821 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
14822 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
14823 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
14824 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
14825 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
14829 bgp_route_finish (void)
14831 bgp_table_unlock (bgp_distance_table
);
14832 bgp_distance_table
= NULL
;