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.
2566 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2567 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2568 * the iteration over all RS clients.
2569 * Since we need to remove the entry from adj_in anyway, do that first and
2570 * if there was no entry, we don't need to do anything more.
2572 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2573 && peer
!= bgp
->peer_self
)
2574 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2576 if (bgp_debug_update (peer
, p
, NULL
, 1))
2577 zlog_debug ("%s withdrawing route %s/%d "
2578 "not in adj-in", peer
->host
,
2579 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2581 bgp_unlock_node (rn
);
2585 /* Lookup withdrawn route. */
2586 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2587 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2588 ri
->addpath_rx_id
== addpath_id
)
2592 if (bgp_debug_update(peer
, p
, NULL
, 1))
2594 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2595 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2597 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2598 p
->prefixlen
, buf2
);
2601 /* Withdraw specified route from routing table. */
2602 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2603 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
);
2604 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2605 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2606 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2609 /* Unlock bgp_node_get() lock. */
2610 bgp_unlock_node (rn
);
2616 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2618 struct update_subgroup
*subgrp
;
2619 subgrp
= peer_subgroup(peer
, afi
, safi
);
2620 subgroup_default_originate(subgrp
, withdraw
);
2625 * bgp_stop_announce_route_timer
2628 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2630 if (!paf
->t_announce_route
)
2633 THREAD_TIMER_OFF (paf
->t_announce_route
);
2637 * bgp_announce_route_timer_expired
2639 * Callback that is invoked when the route announcement timer for a
2643 bgp_announce_route_timer_expired (struct thread
*t
)
2645 struct peer_af
*paf
;
2649 paf
= THREAD_ARG (t
);
2652 assert (paf
->t_announce_route
);
2653 paf
->t_announce_route
= NULL
;
2655 if (peer
->status
!= Established
)
2658 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2661 peer_af_announce_route (paf
, 1);
2666 * bgp_announce_route
2668 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2671 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2673 struct peer_af
*paf
;
2674 struct update_subgroup
*subgrp
;
2676 paf
= peer_af_find (peer
, afi
, safi
);
2679 subgrp
= PAF_SUBGRP(paf
);
2682 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2683 * or a refresh has already been triggered.
2685 if (!subgrp
|| paf
->t_announce_route
)
2689 * Start a timer to stagger/delay the announce. This serves
2690 * two purposes - announcement can potentially be combined for
2691 * multiple peers and the announcement doesn't happen in the
2694 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2695 bgp_announce_route_timer_expired
, paf
,
2696 (subgrp
->peer_count
== 1) ?
2697 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2698 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2702 * Announce routes from all AF tables to a peer.
2704 * This should ONLY be called when there is a need to refresh the
2705 * routes to the peer based on a policy change for this peer alone
2706 * or a route refresh request received from the peer.
2707 * The operation will result in splitting the peer from its existing
2708 * subgroups and putting it in new subgroups.
2711 bgp_announce_route_all (struct peer
*peer
)
2716 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2717 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2718 bgp_announce_route (peer
, afi
, safi
);
2722 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2723 struct bgp_table
*table
, struct prefix_rd
*prd
)
2726 struct bgp_node
*rn
;
2727 struct bgp_adj_in
*ain
;
2730 table
= peer
->bgp
->rib
[afi
][safi
];
2732 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2733 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2735 if (ain
->peer
== peer
)
2737 struct bgp_info
*ri
= rn
->info
;
2738 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
2740 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
2741 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
2746 bgp_unlock_node (rn
);
2754 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
2756 struct bgp_node
*rn
;
2757 struct bgp_table
*table
;
2759 if (peer
->status
!= Established
)
2762 if (safi
!= SAFI_MPLS_VPN
)
2763 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
2765 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2766 rn
= bgp_route_next (rn
))
2767 if ((table
= rn
->info
) != NULL
)
2769 struct prefix_rd prd
;
2770 prd
.family
= AF_UNSPEC
;
2772 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
2774 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
2779 struct bgp_clear_node_queue
2781 struct bgp_node
*rn
;
2784 static wq_item_status
2785 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
2787 struct bgp_clear_node_queue
*cnq
= data
;
2788 struct bgp_node
*rn
= cnq
->rn
;
2789 struct peer
*peer
= wq
->spec
.data
;
2790 struct bgp_info
*ri
;
2791 afi_t afi
= bgp_node_table (rn
)->afi
;
2792 safi_t safi
= bgp_node_table (rn
)->safi
;
2794 assert (rn
&& peer
);
2796 /* It is possible that we have multiple paths for a prefix from a peer
2797 * if that peer is using AddPath.
2799 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2800 if (ri
->peer
== peer
)
2802 /* graceful restart STALE flag set. */
2803 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
2804 && peer
->nsf
[afi
][safi
]
2805 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
2806 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
2807 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
2809 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2815 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
2817 struct bgp_clear_node_queue
*cnq
= data
;
2818 struct bgp_node
*rn
= cnq
->rn
;
2819 struct bgp_table
*table
= bgp_node_table (rn
);
2821 bgp_unlock_node (rn
);
2822 bgp_table_unlock (table
);
2823 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
2827 bgp_clear_node_complete (struct work_queue
*wq
)
2829 struct peer
*peer
= wq
->spec
.data
;
2831 /* Tickle FSM to start moving again */
2832 BGP_EVENT_ADD (peer
, Clearing_Completed
);
2834 peer_unlock (peer
); /* bgp_clear_route */
2838 bgp_clear_node_queue_init (struct peer
*peer
)
2840 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
2842 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
2843 #undef CLEAR_QUEUE_NAME_LEN
2845 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
2847 zlog_err ("%s: Failed to allocate work queue", __func__
);
2850 peer
->clear_node_queue
->spec
.hold
= 10;
2851 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
2852 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
2853 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
2854 peer
->clear_node_queue
->spec
.max_retries
= 0;
2856 /* we only 'lock' this peer reference when the queue is actually active */
2857 peer
->clear_node_queue
->spec
.data
= peer
;
2861 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2862 struct bgp_table
*table
)
2864 struct bgp_node
*rn
;
2868 table
= peer
->bgp
->rib
[afi
][safi
];
2870 /* If still no table => afi/safi isn't configured at all or smth. */
2874 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2876 struct bgp_info
*ri
;
2877 struct bgp_adj_in
*ain
;
2878 struct bgp_adj_in
*ain_next
;
2880 /* XXX:TODO: This is suboptimal, every non-empty route_node is
2881 * queued for every clearing peer, regardless of whether it is
2882 * relevant to the peer at hand.
2884 * Overview: There are 3 different indices which need to be
2885 * scrubbed, potentially, when a peer is removed:
2887 * 1 peer's routes visible via the RIB (ie accepted routes)
2888 * 2 peer's routes visible by the (optional) peer's adj-in index
2889 * 3 other routes visible by the peer's adj-out index
2891 * 3 there is no hurry in scrubbing, once the struct peer is
2892 * removed from bgp->peer, we could just GC such deleted peer's
2893 * adj-outs at our leisure.
2895 * 1 and 2 must be 'scrubbed' in some way, at least made
2896 * invisible via RIB index before peer session is allowed to be
2897 * brought back up. So one needs to know when such a 'search' is
2902 * - there'd be a single global queue or a single RIB walker
2903 * - rather than tracking which route_nodes still need to be
2904 * examined on a peer basis, we'd track which peers still
2907 * Given that our per-peer prefix-counts now should be reliable,
2908 * this may actually be achievable. It doesn't seem to be a huge
2909 * problem at this time,
2911 * It is possible that we have multiple paths for a prefix from a peer
2912 * if that peer is using AddPath.
2917 ain_next
= ain
->next
;
2919 if (ain
->peer
== peer
)
2921 bgp_adj_in_remove (rn
, ain
);
2922 bgp_unlock_node (rn
);
2928 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2929 if (ri
->peer
== peer
)
2931 struct bgp_clear_node_queue
*cnq
;
2933 /* both unlocked in bgp_clear_node_queue_del */
2934 bgp_table_lock (bgp_node_table (rn
));
2936 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
2937 sizeof (struct bgp_clear_node_queue
));
2939 work_queue_add (peer
->clear_node_queue
, cnq
);
2947 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2949 struct bgp_node
*rn
;
2950 struct bgp_table
*table
;
2952 if (peer
->clear_node_queue
== NULL
)
2953 bgp_clear_node_queue_init (peer
);
2955 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
2956 * Idle until it receives a Clearing_Completed event. This protects
2957 * against peers which flap faster than we can we clear, which could
2960 * a) race with routes from the new session being installed before
2961 * clear_route_node visits the node (to delete the route of that
2963 * b) resource exhaustion, clear_route_node likely leads to an entry
2964 * on the process_main queue. Fast-flapping could cause that queue
2968 /* lock peer in assumption that clear-node-queue will get nodes; if so,
2969 * the unlock will happen upon work-queue completion; other wise, the
2970 * unlock happens at the end of this function.
2972 if (!peer
->clear_node_queue
->thread
)
2975 if (safi
!= SAFI_MPLS_VPN
)
2976 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
2978 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
2979 rn
= bgp_route_next (rn
))
2980 if ((table
= rn
->info
) != NULL
)
2981 bgp_clear_route_table (peer
, afi
, safi
, table
);
2983 /* unlock if no nodes got added to the clear-node-queue. */
2984 if (!peer
->clear_node_queue
->thread
)
2990 bgp_clear_route_all (struct peer
*peer
)
2995 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2996 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2997 bgp_clear_route (peer
, afi
, safi
);
3001 * Finish freeing things when exiting
3004 bgp_drain_workqueue_immediate (struct work_queue
*wq
)
3012 * no thread implies no queued items
3014 assert(!wq
->items
->count
);
3018 while (wq
->items
->count
)
3021 thread_cancel(wq
->thread
);
3022 work_queue_run(wq
->thread
);
3027 * Special function to process clear node queue when bgpd is exiting
3028 * and the thread scheduler is no longer running.
3031 bgp_peer_clear_node_queue_drain_immediate(struct peer
*peer
)
3036 bgp_drain_workqueue_immediate(peer
->clear_node_queue
);
3040 * The work queues are not specific to a BGP instance, but the
3041 * items in them refer to BGP instances, so this should be called
3042 * before each BGP instance is deleted.
3045 bgp_process_queues_drain_immediate(void)
3047 bgp_drain_workqueue_immediate(bm
->process_main_queue
);
3051 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3053 struct bgp_table
*table
;
3054 struct bgp_node
*rn
;
3055 struct bgp_adj_in
*ain
;
3056 struct bgp_adj_in
*ain_next
;
3058 table
= peer
->bgp
->rib
[afi
][safi
];
3060 /* It is possible that we have multiple paths for a prefix from a peer
3061 * if that peer is using AddPath.
3063 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3069 ain_next
= ain
->next
;
3071 if (ain
->peer
== peer
)
3073 bgp_adj_in_remove (rn
, ain
);
3074 bgp_unlock_node (rn
);
3083 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3085 struct bgp_node
*rn
;
3086 struct bgp_info
*ri
;
3087 struct bgp_table
*table
;
3089 table
= peer
->bgp
->rib
[afi
][safi
];
3091 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3093 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3094 if (ri
->peer
== peer
)
3096 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3097 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3104 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3106 struct bgp_node
*rn
;
3107 struct bgp_info
*ri
;
3108 struct bgp_info
*next
;
3110 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3111 for (ri
= rn
->info
; ri
; ri
= next
)
3114 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3115 && ri
->type
== ZEBRA_ROUTE_BGP
3116 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3117 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3118 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3122 /* Delete all kernel routes. */
3124 bgp_cleanup_routes (void)
3127 struct listnode
*node
, *nnode
;
3130 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
3132 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3134 struct bgp_node
*rn
;
3136 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3139 * VPN and ENCAP tables are two-level (RD is top level)
3141 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3142 rn
= bgp_route_next (rn
))
3145 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3146 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3148 bgp_unlock_node(rn
);
3158 bgp_zclient_reset ();
3159 access_list_reset ();
3160 prefix_list_reset ();
3164 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3166 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3167 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3170 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3173 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3182 int addpath_encoded
;
3183 u_int32_t addpath_id
;
3185 /* Check peer status. */
3186 if (peer
->status
!= Established
)
3190 lim
= pnt
+ packet
->length
;
3192 safi
= packet
->safi
;
3194 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3196 for (; pnt
< lim
; pnt
+= psize
)
3198 /* Clear prefix structure. */
3199 memset (&p
, 0, sizeof (struct prefix
));
3201 if (addpath_encoded
)
3204 /* When packet overflow occurs return immediately. */
3205 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3208 addpath_id
= ntohl(*((uint32_t*) pnt
));
3209 pnt
+= BGP_ADDPATH_ID_LEN
;
3212 /* Fetch prefix length. */
3213 p
.prefixlen
= *pnt
++;
3214 p
.family
= afi2family (afi
);
3216 /* Already checked in nlri_sanity_check(). We do double check
3218 if ((afi
== AFI_IP
&& p
.prefixlen
> 32)
3219 || (afi
== AFI_IP6
&& p
.prefixlen
> 128))
3222 /* Packet size overflow check. */
3223 psize
= PSIZE (p
.prefixlen
);
3225 /* When packet overflow occur return immediately. */
3226 if (pnt
+ psize
> lim
)
3229 /* Fetch prefix from NLRI packet. */
3230 memcpy (&p
.u
.prefix
, pnt
, psize
);
3232 /* Check address. */
3233 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3235 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3238 * From draft-ietf-idr-bgp4-22, Section 6.3:
3239 * If a BGP router receives an UPDATE message with a
3240 * semantically incorrect NLRI field, in which a prefix is
3241 * semantically incorrect (eg. an unexpected multicast IP
3242 * address), it should ignore the prefix.
3244 zlog_err ("IPv4 unicast NLRI is multicast address %s",
3245 inet_ntoa (p
.u
.prefix4
));
3252 /* Check address. */
3253 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3255 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3259 zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
3260 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3265 #endif /* HAVE_IPV6 */
3267 /* Normal process. */
3269 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3270 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3272 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3273 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3275 /* Address family configuration mismatch or maximum-prefix count
3281 /* Packet length consistency check. */
3288 /* NLRI encode syntax check routine. */
3290 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, safi_t safi
, u_char
*pnt
,
3291 bgp_size_t length
, int *numpfx
)
3296 int addpath_encoded
;
3300 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3302 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3303 syntactic validity. If the field is syntactically incorrect,
3304 then the Error Subcode is set to Invalid Network Field. */
3309 /* If the NLRI is encoded using addpath then the first 4 bytes are
3310 * the addpath ID. */
3311 if (addpath_encoded
)
3313 if (pnt
+ BGP_ADDPATH_ID_LEN
> end
)
3315 zlog_err ("%s [Error] Update packet error"
3316 " (prefix data addpath overflow)",
3318 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3319 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3322 pnt
+= BGP_ADDPATH_ID_LEN
;
3327 /* Prefix length check. */
3328 if ((afi
== AFI_IP
&& prefixlen
> 32)
3329 || (afi
== AFI_IP6
&& prefixlen
> 128))
3331 zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
3332 peer
->host
, prefixlen
);
3333 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3334 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3338 /* Packet size overflow check. */
3339 psize
= PSIZE (prefixlen
);
3341 if (pnt
+ psize
> end
)
3343 zlog_err ("%s [Error] Update packet error"
3344 " (prefix data overflow prefix size is %d)",
3346 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3347 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3355 /* Packet length consistency check. */
3358 zlog_err ("%s [Error] Update packet error"
3359 " (prefix length mismatch with total length)",
3361 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3362 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3368 static struct bgp_static
*
3369 bgp_static_new (void)
3371 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3375 bgp_static_free (struct bgp_static
*bgp_static
)
3377 if (bgp_static
->rmap
.name
)
3378 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3379 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3383 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3384 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3386 struct bgp_node
*rn
;
3387 struct bgp_info
*ri
;
3388 struct bgp_info
*new;
3389 struct bgp_info info
;
3391 struct attr
*attr_new
;
3394 assert (bgp_static
);
3398 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3400 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3402 attr
.nexthop
= bgp_static
->igpnexthop
;
3403 attr
.med
= bgp_static
->igpmetric
;
3404 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3406 if (bgp_static
->atomic
)
3407 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3409 /* Apply route-map. */
3410 if (bgp_static
->rmap
.name
)
3412 struct attr attr_tmp
= attr
;
3413 info
.peer
= bgp
->peer_self
;
3414 info
.attr
= &attr_tmp
;
3416 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3418 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3420 bgp
->peer_self
->rmap_type
= 0;
3422 if (ret
== RMAP_DENYMATCH
)
3424 /* Free uninterned attribute. */
3425 bgp_attr_flush (&attr_tmp
);
3427 /* Unintern original. */
3428 aspath_unintern (&attr
.aspath
);
3429 bgp_attr_extra_free (&attr
);
3430 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3433 attr_new
= bgp_attr_intern (&attr_tmp
);
3436 attr_new
= bgp_attr_intern (&attr
);
3438 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3439 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3440 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3445 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3446 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3447 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3449 bgp_unlock_node (rn
);
3450 bgp_attr_unintern (&attr_new
);
3451 aspath_unintern (&attr
.aspath
);
3452 bgp_attr_extra_free (&attr
);
3457 /* The attribute is changed. */
3458 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3460 /* Rewrite BGP route information. */
3461 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3462 bgp_info_restore(rn
, ri
);
3464 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3465 bgp_attr_unintern (&ri
->attr
);
3466 ri
->attr
= attr_new
;
3467 ri
->uptime
= bgp_clock ();
3469 /* Nexthop reachability check. */
3470 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3472 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3473 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3476 if (BGP_DEBUG(nht
, NHT
))
3478 char buf1
[INET6_ADDRSTRLEN
];
3479 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3481 zlog_debug("%s(%s): Route not in table, not advertising",
3482 __FUNCTION__
, buf1
);
3484 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3489 /* Delete the NHT structure if any, if we're toggling between
3490 * enabling/disabling import check. We deregister the route
3491 * from NHT to avoid overloading NHT and the process interaction
3493 bgp_unlink_nexthop(ri
);
3494 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3496 /* Process change. */
3497 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3498 bgp_process (bgp
, rn
, afi
, safi
);
3499 bgp_unlock_node (rn
);
3500 aspath_unintern (&attr
.aspath
);
3501 bgp_attr_extra_free (&attr
);
3506 /* Make new BGP info. */
3507 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3509 /* Nexthop reachability check. */
3510 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3512 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3513 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3516 if (BGP_DEBUG(nht
, NHT
))
3518 char buf1
[INET6_ADDRSTRLEN
];
3519 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3521 zlog_debug("%s(%s): Route not in table, not advertising",
3522 __FUNCTION__
, buf1
);
3524 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3529 /* Delete the NHT structure if any, if we're toggling between
3530 * enabling/disabling import check. We deregister the route
3531 * from NHT to avoid overloading NHT and the process interaction
3533 bgp_unlink_nexthop(new);
3535 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3538 /* Aggregate address increment. */
3539 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3541 /* Register new BGP information. */
3542 bgp_info_add (rn
, new);
3544 /* route_node_get lock */
3545 bgp_unlock_node (rn
);
3547 /* Process change. */
3548 bgp_process (bgp
, rn
, afi
, safi
);
3550 /* Unintern original. */
3551 aspath_unintern (&attr
.aspath
);
3552 bgp_attr_extra_free (&attr
);
3556 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3557 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3559 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3563 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3566 struct bgp_node
*rn
;
3567 struct bgp_info
*ri
;
3569 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3571 /* Check selected route and self inserted route. */
3572 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3573 if (ri
->peer
== bgp
->peer_self
3574 && ri
->type
== ZEBRA_ROUTE_BGP
3575 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3578 /* Withdraw static BGP route from routing table. */
3581 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3582 bgp_unlink_nexthop(ri
);
3583 bgp_info_delete (rn
, ri
);
3584 bgp_process (bgp
, rn
, afi
, safi
);
3587 /* Unlock bgp_node_lookup. */
3588 bgp_unlock_node (rn
);
3592 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3595 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3596 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3598 struct bgp_node
*rn
;
3599 struct bgp_info
*ri
;
3601 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3603 /* Check selected route and self inserted route. */
3604 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3605 if (ri
->peer
== bgp
->peer_self
3606 && ri
->type
== ZEBRA_ROUTE_BGP
3607 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3610 /* Withdraw static BGP route from routing table. */
3613 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3614 bgp_info_delete (rn
, ri
);
3615 bgp_process (bgp
, rn
, afi
, safi
);
3618 /* Unlock bgp_node_lookup. */
3619 bgp_unlock_node (rn
);
3623 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3624 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3626 struct bgp_node
*rn
;
3627 struct bgp_info
*new;
3628 struct attr
*attr_new
;
3629 struct attr attr
= { 0 };
3630 struct bgp_info
*ri
;
3632 assert (bgp_static
);
3634 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3636 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3638 attr
.nexthop
= bgp_static
->igpnexthop
;
3639 attr
.med
= bgp_static
->igpmetric
;
3640 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3642 /* Apply route-map. */
3643 if (bgp_static
->rmap
.name
)
3645 struct attr attr_tmp
= attr
;
3646 struct bgp_info info
;
3649 info
.peer
= bgp
->peer_self
;
3650 info
.attr
= &attr_tmp
;
3652 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3654 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3656 bgp
->peer_self
->rmap_type
= 0;
3658 if (ret
== RMAP_DENYMATCH
)
3660 /* Free uninterned attribute. */
3661 bgp_attr_flush (&attr_tmp
);
3663 /* Unintern original. */
3664 aspath_unintern (&attr
.aspath
);
3665 bgp_attr_extra_free (&attr
);
3666 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3671 attr_new
= bgp_attr_intern (&attr_tmp
);
3675 attr_new
= bgp_attr_intern (&attr
);
3678 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3679 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3680 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3685 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3686 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3688 bgp_unlock_node (rn
);
3689 bgp_attr_unintern (&attr_new
);
3690 aspath_unintern (&attr
.aspath
);
3691 bgp_attr_extra_free (&attr
);
3696 /* The attribute is changed. */
3697 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3699 /* Rewrite BGP route information. */
3700 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3701 bgp_info_restore(rn
, ri
);
3703 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3704 bgp_attr_unintern (&ri
->attr
);
3705 ri
->attr
= attr_new
;
3706 ri
->uptime
= bgp_clock ();
3708 /* Process change. */
3709 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3710 bgp_process (bgp
, rn
, afi
, safi
);
3711 bgp_unlock_node (rn
);
3712 aspath_unintern (&attr
.aspath
);
3713 bgp_attr_extra_free (&attr
);
3719 /* Make new BGP info. */
3720 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3722 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3723 new->extra
= bgp_info_extra_new();
3724 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
3726 /* Aggregate address increment. */
3727 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3729 /* Register new BGP information. */
3730 bgp_info_add (rn
, new);
3732 /* route_node_get lock */
3733 bgp_unlock_node (rn
);
3735 /* Process change. */
3736 bgp_process (bgp
, rn
, afi
, safi
);
3738 /* Unintern original. */
3739 aspath_unintern (&attr
.aspath
);
3740 bgp_attr_extra_free (&attr
);
3743 /* Configure static BGP network. When user don't run zebra, static
3744 route should be installed as valid. */
3746 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3747 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
3751 struct bgp_static
*bgp_static
;
3752 struct bgp_node
*rn
;
3753 u_char need_update
= 0;
3755 /* Convert IP prefix string to struct prefix. */
3756 ret
= str2prefix (ip_str
, &p
);
3759 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3763 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3765 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3769 #endif /* HAVE_IPV6 */
3773 /* Set BGP static route configuration. */
3774 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
3778 /* Configuration change. */
3779 bgp_static
= rn
->info
;
3781 /* Check previous routes are installed into BGP. */
3782 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
3785 bgp_static
->backdoor
= backdoor
;
3789 if (bgp_static
->rmap
.name
)
3790 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3791 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3792 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3796 if (bgp_static
->rmap
.name
)
3797 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3798 bgp_static
->rmap
.name
= NULL
;
3799 bgp_static
->rmap
.map
= NULL
;
3800 bgp_static
->valid
= 0;
3802 bgp_unlock_node (rn
);
3806 /* New configuration. */
3807 bgp_static
= bgp_static_new ();
3808 bgp_static
->backdoor
= backdoor
;
3809 bgp_static
->valid
= 0;
3810 bgp_static
->igpmetric
= 0;
3811 bgp_static
->igpnexthop
.s_addr
= 0;
3815 if (bgp_static
->rmap
.name
)
3816 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3817 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
3818 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
3820 rn
->info
= bgp_static
;
3823 bgp_static
->valid
= 1;
3825 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3827 if (! bgp_static
->backdoor
)
3828 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
3833 /* Configure static BGP network. */
3835 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3836 afi_t afi
, safi_t safi
)
3840 struct bgp_static
*bgp_static
;
3841 struct bgp_node
*rn
;
3843 /* Convert IP prefix string to struct prefix. */
3844 ret
= str2prefix (ip_str
, &p
);
3847 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
3851 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3853 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
3857 #endif /* HAVE_IPV6 */
3861 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
3864 vty_out (vty
, "%% Can't find specified static route configuration.%s",
3869 bgp_static
= rn
->info
;
3871 /* Update BGP RIB. */
3872 if (! bgp_static
->backdoor
)
3873 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
3875 /* Clear configuration. */
3876 bgp_static_free (bgp_static
);
3878 bgp_unlock_node (rn
);
3879 bgp_unlock_node (rn
);
3885 bgp_static_add (struct bgp
*bgp
)
3889 struct bgp_node
*rn
;
3890 struct bgp_node
*rm
;
3891 struct bgp_table
*table
;
3892 struct bgp_static
*bgp_static
;
3894 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3895 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3896 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3897 if (rn
->info
!= NULL
)
3899 if (safi
== SAFI_MPLS_VPN
)
3903 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3905 bgp_static
= rn
->info
;
3906 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
3911 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
3916 /* Called from bgp_delete(). Delete all static routes from the BGP
3919 bgp_static_delete (struct bgp
*bgp
)
3923 struct bgp_node
*rn
;
3924 struct bgp_node
*rm
;
3925 struct bgp_table
*table
;
3926 struct bgp_static
*bgp_static
;
3928 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3929 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3930 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3931 if (rn
->info
!= NULL
)
3933 if (safi
== SAFI_MPLS_VPN
)
3937 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
3939 bgp_static
= rn
->info
;
3940 bgp_static_withdraw_safi (bgp
, &rm
->p
,
3942 (struct prefix_rd
*)&rn
->p
,
3944 bgp_static_free (bgp_static
);
3946 bgp_unlock_node (rn
);
3951 bgp_static
= rn
->info
;
3952 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
3953 bgp_static_free (bgp_static
);
3955 bgp_unlock_node (rn
);
3961 bgp_static_redo_import_check (struct bgp
*bgp
)
3965 struct bgp_node
*rn
;
3966 struct bgp_static
*bgp_static
;
3968 /* Use this flag to force reprocessing of the route */
3969 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3970 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3971 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3972 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
3973 if (rn
->info
!= NULL
)
3975 bgp_static
= rn
->info
;
3976 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
3978 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
3982 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
3984 struct bgp_table
*table
;
3985 struct bgp_node
*rn
;
3986 struct bgp_info
*ri
;
3988 table
= bgp
->rib
[afi
][safi
];
3989 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3991 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3993 if (ri
->peer
== bgp
->peer_self
&&
3994 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
3995 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
3996 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
3997 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
3999 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4000 bgp_unlink_nexthop(ri
);
4001 bgp_info_delete (rn
, ri
);
4002 bgp_process (bgp
, rn
, afi
, safi
);
4009 * Purge all networks and redistributed routes from routing table.
4010 * Invoked upon the instance going down.
4013 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4018 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4019 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4020 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4025 * Currently this is used to set static routes for VPN and ENCAP.
4026 * I think it can probably be factored with bgp_static_set.
4029 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4030 const char *rd_str
, const char *tag_str
,
4031 const char *rmap_str
)
4035 struct prefix_rd prd
;
4037 struct bgp_node
*prn
;
4038 struct bgp_node
*rn
;
4039 struct bgp_table
*table
;
4040 struct bgp_static
*bgp_static
;
4045 ret
= str2prefix (ip_str
, &p
);
4048 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4053 ret
= str2prefix_rd (rd_str
, &prd
);
4056 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4060 ret
= str2tag (tag_str
, tag
);
4063 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4067 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4068 (struct prefix
*)&prd
);
4069 if (prn
->info
== NULL
)
4070 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4072 bgp_unlock_node (prn
);
4075 rn
= bgp_node_get (table
, &p
);
4079 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4080 bgp_unlock_node (rn
);
4084 /* New configuration. */
4085 bgp_static
= bgp_static_new ();
4086 bgp_static
->backdoor
= 0;
4087 bgp_static
->valid
= 0;
4088 bgp_static
->igpmetric
= 0;
4089 bgp_static
->igpnexthop
.s_addr
= 0;
4090 memcpy(bgp_static
->tag
, tag
, 3);
4091 bgp_static
->prd
= prd
;
4095 if (bgp_static
->rmap
.name
)
4096 free (bgp_static
->rmap
.name
);
4097 bgp_static
->rmap
.name
= strdup (rmap_str
);
4098 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4100 rn
->info
= bgp_static
;
4102 bgp_static
->valid
= 1;
4103 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4109 /* Configure static BGP network. */
4111 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4112 const char *rd_str
, const char *tag_str
)
4117 struct prefix_rd prd
;
4118 struct bgp_node
*prn
;
4119 struct bgp_node
*rn
;
4120 struct bgp_table
*table
;
4121 struct bgp_static
*bgp_static
;
4126 /* Convert IP prefix string to struct prefix. */
4127 ret
= str2prefix (ip_str
, &p
);
4130 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4135 ret
= str2prefix_rd (rd_str
, &prd
);
4138 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4142 ret
= str2tag (tag_str
, tag
);
4145 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4149 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4150 (struct prefix
*)&prd
);
4151 if (prn
->info
== NULL
)
4152 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4154 bgp_unlock_node (prn
);
4157 rn
= bgp_node_lookup (table
, &p
);
4161 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4163 bgp_static
= rn
->info
;
4164 bgp_static_free (bgp_static
);
4166 bgp_unlock_node (rn
);
4167 bgp_unlock_node (rn
);
4170 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4176 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4177 const char *rmap_name
)
4179 struct bgp_rmap
*rmap
;
4181 rmap
= &bgp
->table_map
[afi
][safi
];
4185 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4186 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4187 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4192 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4197 bgp_zebra_announce_table(bgp
, afi
, safi
);
4203 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4204 const char *rmap_name
)
4206 struct bgp_rmap
*rmap
;
4208 rmap
= &bgp
->table_map
[afi
][safi
];
4210 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4214 bgp_zebra_announce_table(bgp
, afi
, safi
);
4220 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4221 safi_t safi
, int *write
)
4223 if (bgp
->table_map
[afi
][safi
].name
)
4225 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4226 vty_out (vty
, " table-map %s%s",
4227 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4234 DEFUN (bgp_table_map
,
4237 "BGP table to RIB route download filter\n"
4238 "Name of the route map\n")
4240 return bgp_table_map_set (vty
, vty
->index
,
4241 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4243 DEFUN (no_bgp_table_map
,
4244 no_bgp_table_map_cmd
,
4245 "no table-map WORD",
4246 "BGP table to RIB route download filter\n"
4247 "Name of the route map\n")
4249 return bgp_table_map_unset (vty
, vty
->index
,
4250 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4255 "network A.B.C.D/M",
4256 "Specify a network to announce via BGP\n"
4257 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4259 return bgp_static_set (vty
, vty
->index
, argv
[0],
4260 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4263 DEFUN (bgp_network_route_map
,
4264 bgp_network_route_map_cmd
,
4265 "network A.B.C.D/M route-map WORD",
4266 "Specify a network to announce via BGP\n"
4267 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4268 "Route-map to modify the attributes\n"
4269 "Name of the route map\n")
4271 return bgp_static_set (vty
, vty
->index
, argv
[0],
4272 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4275 DEFUN (bgp_network_backdoor
,
4276 bgp_network_backdoor_cmd
,
4277 "network A.B.C.D/M backdoor",
4278 "Specify a network to announce via BGP\n"
4279 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4280 "Specify a BGP backdoor route\n")
4282 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4286 DEFUN (bgp_network_mask
,
4287 bgp_network_mask_cmd
,
4288 "network A.B.C.D mask A.B.C.D",
4289 "Specify a network to announce via BGP\n"
4295 char prefix_str
[BUFSIZ
];
4297 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4300 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4304 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4305 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4308 DEFUN (bgp_network_mask_route_map
,
4309 bgp_network_mask_route_map_cmd
,
4310 "network A.B.C.D mask A.B.C.D route-map WORD",
4311 "Specify a network to announce via BGP\n"
4315 "Route-map to modify the attributes\n"
4316 "Name of the route map\n")
4319 char prefix_str
[BUFSIZ
];
4321 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4324 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4328 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4329 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4332 DEFUN (bgp_network_mask_backdoor
,
4333 bgp_network_mask_backdoor_cmd
,
4334 "network A.B.C.D mask A.B.C.D backdoor",
4335 "Specify a network to announce via BGP\n"
4339 "Specify a BGP backdoor route\n")
4342 char prefix_str
[BUFSIZ
];
4344 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4347 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4351 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4355 DEFUN (bgp_network_mask_natural
,
4356 bgp_network_mask_natural_cmd
,
4358 "Specify a network to announce via BGP\n"
4362 char prefix_str
[BUFSIZ
];
4364 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4367 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4371 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4372 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4375 DEFUN (bgp_network_mask_natural_route_map
,
4376 bgp_network_mask_natural_route_map_cmd
,
4377 "network A.B.C.D route-map WORD",
4378 "Specify a network to announce via BGP\n"
4380 "Route-map to modify the attributes\n"
4381 "Name of the route map\n")
4384 char prefix_str
[BUFSIZ
];
4386 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4389 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4393 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4394 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4397 DEFUN (bgp_network_mask_natural_backdoor
,
4398 bgp_network_mask_natural_backdoor_cmd
,
4399 "network A.B.C.D backdoor",
4400 "Specify a network to announce via BGP\n"
4402 "Specify a BGP backdoor route\n")
4405 char prefix_str
[BUFSIZ
];
4407 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4410 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4414 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4418 DEFUN (no_bgp_network
,
4420 "no network A.B.C.D/M",
4422 "Specify a network to announce via BGP\n"
4423 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4425 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4426 bgp_node_safi (vty
));
4429 ALIAS (no_bgp_network
,
4430 no_bgp_network_route_map_cmd
,
4431 "no network A.B.C.D/M route-map WORD",
4433 "Specify a network to announce via BGP\n"
4434 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4435 "Route-map to modify the attributes\n"
4436 "Name of the route map\n")
4438 ALIAS (no_bgp_network
,
4439 no_bgp_network_backdoor_cmd
,
4440 "no network A.B.C.D/M backdoor",
4442 "Specify a network to announce via BGP\n"
4443 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4444 "Specify a BGP backdoor route\n")
4446 DEFUN (no_bgp_network_mask
,
4447 no_bgp_network_mask_cmd
,
4448 "no network A.B.C.D mask A.B.C.D",
4450 "Specify a network to announce via BGP\n"
4456 char prefix_str
[BUFSIZ
];
4458 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4461 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4465 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4466 bgp_node_safi (vty
));
4469 ALIAS (no_bgp_network_mask
,
4470 no_bgp_network_mask_route_map_cmd
,
4471 "no network A.B.C.D mask A.B.C.D route-map WORD",
4473 "Specify a network to announce via BGP\n"
4477 "Route-map to modify the attributes\n"
4478 "Name of the route map\n")
4480 ALIAS (no_bgp_network_mask
,
4481 no_bgp_network_mask_backdoor_cmd
,
4482 "no network A.B.C.D mask A.B.C.D backdoor",
4484 "Specify a network to announce via BGP\n"
4488 "Specify a BGP backdoor route\n")
4490 DEFUN (no_bgp_network_mask_natural
,
4491 no_bgp_network_mask_natural_cmd
,
4492 "no network A.B.C.D",
4494 "Specify a network to announce via BGP\n"
4498 char prefix_str
[BUFSIZ
];
4500 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4503 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4507 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4508 bgp_node_safi (vty
));
4511 ALIAS (no_bgp_network_mask_natural
,
4512 no_bgp_network_mask_natural_route_map_cmd
,
4513 "no network A.B.C.D route-map WORD",
4515 "Specify a network to announce via BGP\n"
4517 "Route-map to modify the attributes\n"
4518 "Name of the route map\n")
4520 ALIAS (no_bgp_network_mask_natural
,
4521 no_bgp_network_mask_natural_backdoor_cmd
,
4522 "no network A.B.C.D backdoor",
4524 "Specify a network to announce via BGP\n"
4526 "Specify a BGP backdoor route\n")
4529 DEFUN (ipv6_bgp_network
,
4530 ipv6_bgp_network_cmd
,
4531 "network X:X::X:X/M",
4532 "Specify a network to announce via BGP\n"
4533 "IPv6 prefix <network>/<length>\n")
4535 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4539 DEFUN (ipv6_bgp_network_route_map
,
4540 ipv6_bgp_network_route_map_cmd
,
4541 "network X:X::X:X/M route-map WORD",
4542 "Specify a network to announce via BGP\n"
4543 "IPv6 prefix <network>/<length>\n"
4544 "Route-map to modify the attributes\n"
4545 "Name of the route map\n")
4547 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4548 bgp_node_safi (vty
), argv
[1], 0);
4551 DEFUN (no_ipv6_bgp_network
,
4552 no_ipv6_bgp_network_cmd
,
4553 "no network X:X::X:X/M",
4555 "Specify a network to announce via BGP\n"
4556 "IPv6 prefix <network>/<length>\n")
4558 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4561 ALIAS (no_ipv6_bgp_network
,
4562 no_ipv6_bgp_network_route_map_cmd
,
4563 "no network X:X::X:X/M route-map WORD",
4565 "Specify a network to announce via BGP\n"
4566 "IPv6 prefix <network>/<length>\n"
4567 "Route-map to modify the attributes\n"
4568 "Name of the route map\n")
4570 ALIAS (ipv6_bgp_network
,
4571 old_ipv6_bgp_network_cmd
,
4572 "ipv6 bgp network X:X::X:X/M",
4575 "Specify a network to announce via BGP\n"
4576 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4578 ALIAS (no_ipv6_bgp_network
,
4579 old_no_ipv6_bgp_network_cmd
,
4580 "no ipv6 bgp network X:X::X:X/M",
4584 "Specify a network to announce via BGP\n"
4585 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4586 #endif /* HAVE_IPV6 */
4588 /* Aggreagete address:
4590 advertise-map Set condition to advertise attribute
4591 as-set Generate AS set path information
4592 attribute-map Set attributes of aggregate
4593 route-map Set parameters of aggregate
4594 summary-only Filter more specific routes from updates
4595 suppress-map Conditionally filter more specific routes from updates
4598 struct bgp_aggregate
4600 /* Summary-only flag. */
4601 u_char summary_only
;
4603 /* AS set generation. */
4606 /* Route-map for aggregated route. */
4607 struct route_map
*map
;
4609 /* Suppress-count. */
4610 unsigned long count
;
4612 /* SAFI configuration. */
4616 static struct bgp_aggregate
*
4617 bgp_aggregate_new (void)
4619 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4623 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4625 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4628 /* Update an aggregate as routes are added/removed from the BGP table */
4630 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4631 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4632 struct bgp_aggregate
*aggregate
)
4634 struct bgp_table
*table
;
4635 struct bgp_node
*top
;
4636 struct bgp_node
*rn
;
4638 struct aspath
*aspath
= NULL
;
4639 struct aspath
*asmerge
= NULL
;
4640 struct community
*community
= NULL
;
4641 struct community
*commerge
= NULL
;
4642 #if defined(AGGREGATE_NEXTHOP_CHECK)
4643 struct in_addr nexthop
;
4646 struct bgp_info
*ri
;
4647 struct bgp_info
*new;
4649 unsigned long match
= 0;
4650 u_char atomic_aggregate
= 0;
4652 /* Record adding route's nexthop and med. */
4655 #if defined(AGGREGATE_NEXTHOP_CHECK)
4656 nexthop
= rinew
->attr
->nexthop
;
4657 med
= rinew
->attr
->med
;
4661 /* ORIGIN attribute: If at least one route among routes that are
4662 aggregated has ORIGIN with the value INCOMPLETE, then the
4663 aggregated route must have the ORIGIN attribute with the value
4664 INCOMPLETE. Otherwise, if at least one route among routes that
4665 are aggregated has ORIGIN with the value EGP, then the aggregated
4666 route must have the origin attribute with the value EGP. In all
4667 other case the value of the ORIGIN attribute of the aggregated
4668 route is INTERNAL. */
4669 origin
= BGP_ORIGIN_IGP
;
4671 table
= bgp
->rib
[afi
][safi
];
4673 top
= bgp_node_get (table
, p
);
4674 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4675 if (rn
->p
.prefixlen
> p
->prefixlen
)
4679 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4681 if (BGP_INFO_HOLDDOWN (ri
))
4684 if (del
&& ri
== del
)
4687 if (! rinew
&& first
)
4689 #if defined(AGGREGATE_NEXTHOP_CHECK)
4690 nexthop
= ri
->attr
->nexthop
;
4691 med
= ri
->attr
->med
;
4696 #ifdef AGGREGATE_NEXTHOP_CHECK
4697 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4698 || ri
->attr
->med
!= med
)
4701 aspath_free (aspath
);
4703 community_free (community
);
4704 bgp_unlock_node (rn
);
4705 bgp_unlock_node (top
);
4708 #endif /* AGGREGATE_NEXTHOP_CHECK */
4710 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4711 atomic_aggregate
= 1;
4713 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4715 if (aggregate
->summary_only
)
4717 (bgp_info_extra_get (ri
))->suppress
++;
4718 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4724 if (origin
< ri
->attr
->origin
)
4725 origin
= ri
->attr
->origin
;
4727 if (aggregate
->as_set
)
4731 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4732 aspath_free (aspath
);
4736 aspath
= aspath_dup (ri
->attr
->aspath
);
4738 if (ri
->attr
->community
)
4742 commerge
= community_merge (community
,
4743 ri
->attr
->community
);
4744 community
= community_uniq_sort (commerge
);
4745 community_free (commerge
);
4748 community
= community_dup (ri
->attr
->community
);
4754 bgp_process (bgp
, rn
, afi
, safi
);
4756 bgp_unlock_node (top
);
4762 if (aggregate
->summary_only
)
4763 (bgp_info_extra_get (rinew
))->suppress
++;
4765 if (origin
< rinew
->attr
->origin
)
4766 origin
= rinew
->attr
->origin
;
4768 if (aggregate
->as_set
)
4772 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
4773 aspath_free (aspath
);
4777 aspath
= aspath_dup (rinew
->attr
->aspath
);
4779 if (rinew
->attr
->community
)
4783 commerge
= community_merge (community
,
4784 rinew
->attr
->community
);
4785 community
= community_uniq_sort (commerge
);
4786 community_free (commerge
);
4789 community
= community_dup (rinew
->attr
->community
);
4794 if (aggregate
->count
> 0)
4796 rn
= bgp_node_get (table
, p
);
4797 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4798 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4800 atomic_aggregate
), rn
);
4801 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4803 bgp_info_add (rn
, new);
4804 bgp_unlock_node (rn
);
4805 bgp_process (bgp
, rn
, afi
, safi
);
4810 aspath_free (aspath
);
4812 community_free (community
);
4816 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
4817 struct bgp_aggregate
*);
4820 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
4821 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
4823 struct bgp_node
*child
;
4824 struct bgp_node
*rn
;
4825 struct bgp_aggregate
*aggregate
;
4826 struct bgp_table
*table
;
4828 /* MPLS-VPN aggregation is not yet supported. */
4829 if (safi
== SAFI_MPLS_VPN
)
4832 table
= bgp
->aggregate
[afi
][safi
];
4834 /* No aggregates configured. */
4835 if (bgp_table_top_nolock (table
) == NULL
)
4838 if (p
->prefixlen
== 0)
4841 if (BGP_INFO_HOLDDOWN (ri
))
4844 child
= bgp_node_get (table
, p
);
4846 /* Aggregate address configuration check. */
4847 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4848 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4850 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4851 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
4853 bgp_unlock_node (child
);
4857 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
4858 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
4860 struct bgp_node
*child
;
4861 struct bgp_node
*rn
;
4862 struct bgp_aggregate
*aggregate
;
4863 struct bgp_table
*table
;
4865 /* MPLS-VPN aggregation is not yet supported. */
4866 if (safi
== SAFI_MPLS_VPN
)
4869 table
= bgp
->aggregate
[afi
][safi
];
4871 /* No aggregates configured. */
4872 if (bgp_table_top_nolock (table
) == NULL
)
4875 if (p
->prefixlen
== 0)
4878 child
= bgp_node_get (table
, p
);
4880 /* Aggregate address configuration check. */
4881 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
4882 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
4884 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
4885 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
4887 bgp_unlock_node (child
);
4890 /* Called via bgp_aggregate_set when the user configures aggregate-address */
4892 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
4893 struct bgp_aggregate
*aggregate
)
4895 struct bgp_table
*table
;
4896 struct bgp_node
*top
;
4897 struct bgp_node
*rn
;
4898 struct bgp_info
*new;
4899 struct bgp_info
*ri
;
4900 unsigned long match
;
4901 u_char origin
= BGP_ORIGIN_IGP
;
4902 struct aspath
*aspath
= NULL
;
4903 struct aspath
*asmerge
= NULL
;
4904 struct community
*community
= NULL
;
4905 struct community
*commerge
= NULL
;
4906 u_char atomic_aggregate
= 0;
4908 table
= bgp
->rib
[afi
][safi
];
4911 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
4913 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
4916 /* If routes exists below this node, generate aggregate routes. */
4917 top
= bgp_node_get (table
, p
);
4918 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4919 if (rn
->p
.prefixlen
> p
->prefixlen
)
4923 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4925 if (BGP_INFO_HOLDDOWN (ri
))
4928 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4929 atomic_aggregate
= 1;
4931 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4933 /* summary-only aggregate route suppress aggregated
4934 route announcement. */
4935 if (aggregate
->summary_only
)
4937 (bgp_info_extra_get (ri
))->suppress
++;
4938 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4942 /* If at least one route among routes that are aggregated has
4943 * ORIGIN with the value INCOMPLETE, then the aggregated route
4944 * MUST have the ORIGIN attribute with the value INCOMPLETE.
4945 * Otherwise, if at least one route among routes that are
4946 * aggregated has ORIGIN with the value EGP, then the aggregated
4947 * route MUST have the ORIGIN attribute with the value EGP.
4949 if (origin
< ri
->attr
->origin
)
4950 origin
= ri
->attr
->origin
;
4952 /* as-set aggregate route generate origin, as path,
4953 community aggregation. */
4954 if (aggregate
->as_set
)
4958 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4959 aspath_free (aspath
);
4963 aspath
= aspath_dup (ri
->attr
->aspath
);
4965 if (ri
->attr
->community
)
4969 commerge
= community_merge (community
,
4970 ri
->attr
->community
);
4971 community
= community_uniq_sort (commerge
);
4972 community_free (commerge
);
4975 community
= community_dup (ri
->attr
->community
);
4982 /* If this node is suppressed, process the change. */
4984 bgp_process (bgp
, rn
, afi
, safi
);
4986 bgp_unlock_node (top
);
4988 /* Add aggregate route to BGP table. */
4989 if (aggregate
->count
)
4991 rn
= bgp_node_get (table
, p
);
4992 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
4993 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
4995 atomic_aggregate
), rn
);
4996 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4998 bgp_info_add (rn
, new);
4999 bgp_unlock_node (rn
);
5001 /* Process change. */
5002 bgp_process (bgp
, rn
, afi
, safi
);
5007 aspath_free (aspath
);
5009 community_free (community
);
5014 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5015 safi_t safi
, struct bgp_aggregate
*aggregate
)
5017 struct bgp_table
*table
;
5018 struct bgp_node
*top
;
5019 struct bgp_node
*rn
;
5020 struct bgp_info
*ri
;
5021 unsigned long match
;
5023 table
= bgp
->rib
[afi
][safi
];
5025 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5027 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5030 /* If routes exists below this node, generate aggregate routes. */
5031 top
= bgp_node_get (table
, p
);
5032 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5033 if (rn
->p
.prefixlen
> p
->prefixlen
)
5037 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5039 if (BGP_INFO_HOLDDOWN (ri
))
5042 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5044 if (aggregate
->summary_only
&& ri
->extra
)
5046 ri
->extra
->suppress
--;
5048 if (ri
->extra
->suppress
== 0)
5050 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5058 /* If this node was suppressed, process the change. */
5060 bgp_process (bgp
, rn
, afi
, safi
);
5062 bgp_unlock_node (top
);
5064 /* Delete aggregate route from BGP table. */
5065 rn
= bgp_node_get (table
, p
);
5067 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5068 if (ri
->peer
== bgp
->peer_self
5069 && ri
->type
== ZEBRA_ROUTE_BGP
5070 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5073 /* Withdraw static BGP route from routing table. */
5076 bgp_info_delete (rn
, ri
);
5077 bgp_process (bgp
, rn
, afi
, safi
);
5080 /* Unlock bgp_node_lookup. */
5081 bgp_unlock_node (rn
);
5084 /* Aggregate route attribute. */
5085 #define AGGREGATE_SUMMARY_ONLY 1
5086 #define AGGREGATE_AS_SET 1
5089 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5090 afi_t afi
, safi_t safi
)
5094 struct bgp_node
*rn
;
5096 struct bgp_aggregate
*aggregate
;
5098 /* Convert string to prefix structure. */
5099 ret
= str2prefix (prefix_str
, &p
);
5102 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5107 /* Get BGP structure. */
5110 /* Old configuration check. */
5111 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5114 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5119 aggregate
= rn
->info
;
5120 if (aggregate
->safi
& SAFI_UNICAST
)
5121 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5122 if (aggregate
->safi
& SAFI_MULTICAST
)
5123 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5125 /* Unlock aggregate address configuration. */
5127 bgp_aggregate_free (aggregate
);
5128 bgp_unlock_node (rn
);
5129 bgp_unlock_node (rn
);
5135 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5136 afi_t afi
, safi_t safi
,
5137 u_char summary_only
, u_char as_set
)
5141 struct bgp_node
*rn
;
5143 struct bgp_aggregate
*aggregate
;
5145 /* Convert string to prefix structure. */
5146 ret
= str2prefix (prefix_str
, &p
);
5149 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5154 /* Get BGP structure. */
5157 /* Old configuration check. */
5158 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5162 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5163 /* try to remove the old entry */
5164 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5167 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5168 bgp_unlock_node (rn
);
5173 /* Make aggregate address structure. */
5174 aggregate
= bgp_aggregate_new ();
5175 aggregate
->summary_only
= summary_only
;
5176 aggregate
->as_set
= as_set
;
5177 aggregate
->safi
= safi
;
5178 rn
->info
= aggregate
;
5180 /* Aggregate address insert into BGP routing table. */
5181 if (safi
& SAFI_UNICAST
)
5182 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5183 if (safi
& SAFI_MULTICAST
)
5184 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5189 DEFUN (aggregate_address
,
5190 aggregate_address_cmd
,
5191 "aggregate-address A.B.C.D/M",
5192 "Configure BGP aggregate entries\n"
5193 "Aggregate prefix\n")
5195 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5198 DEFUN (aggregate_address_mask
,
5199 aggregate_address_mask_cmd
,
5200 "aggregate-address A.B.C.D A.B.C.D",
5201 "Configure BGP aggregate entries\n"
5202 "Aggregate address\n"
5206 char prefix_str
[BUFSIZ
];
5208 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5212 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5216 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5220 DEFUN (aggregate_address_summary_only
,
5221 aggregate_address_summary_only_cmd
,
5222 "aggregate-address A.B.C.D/M summary-only",
5223 "Configure BGP aggregate entries\n"
5224 "Aggregate prefix\n"
5225 "Filter more specific routes from updates\n")
5227 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5228 AGGREGATE_SUMMARY_ONLY
, 0);
5231 DEFUN (aggregate_address_mask_summary_only
,
5232 aggregate_address_mask_summary_only_cmd
,
5233 "aggregate-address A.B.C.D A.B.C.D summary-only",
5234 "Configure BGP aggregate entries\n"
5235 "Aggregate address\n"
5237 "Filter more specific routes from updates\n")
5240 char prefix_str
[BUFSIZ
];
5242 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5246 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5250 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5251 AGGREGATE_SUMMARY_ONLY
, 0);
5254 DEFUN (aggregate_address_as_set
,
5255 aggregate_address_as_set_cmd
,
5256 "aggregate-address A.B.C.D/M as-set",
5257 "Configure BGP aggregate entries\n"
5258 "Aggregate prefix\n"
5259 "Generate AS set path information\n")
5261 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5262 0, AGGREGATE_AS_SET
);
5265 DEFUN (aggregate_address_mask_as_set
,
5266 aggregate_address_mask_as_set_cmd
,
5267 "aggregate-address A.B.C.D A.B.C.D as-set",
5268 "Configure BGP aggregate entries\n"
5269 "Aggregate address\n"
5271 "Generate AS set path information\n")
5274 char prefix_str
[BUFSIZ
];
5276 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5280 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5284 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5285 0, AGGREGATE_AS_SET
);
5289 DEFUN (aggregate_address_as_set_summary
,
5290 aggregate_address_as_set_summary_cmd
,
5291 "aggregate-address A.B.C.D/M as-set summary-only",
5292 "Configure BGP aggregate entries\n"
5293 "Aggregate prefix\n"
5294 "Generate AS set path information\n"
5295 "Filter more specific routes from updates\n")
5297 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5298 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5301 ALIAS (aggregate_address_as_set_summary
,
5302 aggregate_address_summary_as_set_cmd
,
5303 "aggregate-address A.B.C.D/M summary-only as-set",
5304 "Configure BGP aggregate entries\n"
5305 "Aggregate prefix\n"
5306 "Filter more specific routes from updates\n"
5307 "Generate AS set path information\n")
5309 DEFUN (aggregate_address_mask_as_set_summary
,
5310 aggregate_address_mask_as_set_summary_cmd
,
5311 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5312 "Configure BGP aggregate entries\n"
5313 "Aggregate address\n"
5315 "Generate AS set path information\n"
5316 "Filter more specific routes from updates\n")
5319 char prefix_str
[BUFSIZ
];
5321 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5325 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5329 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5330 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5333 ALIAS (aggregate_address_mask_as_set_summary
,
5334 aggregate_address_mask_summary_as_set_cmd
,
5335 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5336 "Configure BGP aggregate entries\n"
5337 "Aggregate address\n"
5339 "Filter more specific routes from updates\n"
5340 "Generate AS set path information\n")
5342 DEFUN (no_aggregate_address
,
5343 no_aggregate_address_cmd
,
5344 "no aggregate-address A.B.C.D/M",
5346 "Configure BGP aggregate entries\n"
5347 "Aggregate prefix\n")
5349 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5352 ALIAS (no_aggregate_address
,
5353 no_aggregate_address_summary_only_cmd
,
5354 "no aggregate-address A.B.C.D/M summary-only",
5356 "Configure BGP aggregate entries\n"
5357 "Aggregate prefix\n"
5358 "Filter more specific routes from updates\n")
5360 ALIAS (no_aggregate_address
,
5361 no_aggregate_address_as_set_cmd
,
5362 "no aggregate-address A.B.C.D/M as-set",
5364 "Configure BGP aggregate entries\n"
5365 "Aggregate prefix\n"
5366 "Generate AS set path information\n")
5368 ALIAS (no_aggregate_address
,
5369 no_aggregate_address_as_set_summary_cmd
,
5370 "no aggregate-address A.B.C.D/M as-set summary-only",
5372 "Configure BGP aggregate entries\n"
5373 "Aggregate prefix\n"
5374 "Generate AS set path information\n"
5375 "Filter more specific routes from updates\n")
5377 ALIAS (no_aggregate_address
,
5378 no_aggregate_address_summary_as_set_cmd
,
5379 "no aggregate-address A.B.C.D/M summary-only as-set",
5381 "Configure BGP aggregate entries\n"
5382 "Aggregate prefix\n"
5383 "Filter more specific routes from updates\n"
5384 "Generate AS set path information\n")
5386 DEFUN (no_aggregate_address_mask
,
5387 no_aggregate_address_mask_cmd
,
5388 "no aggregate-address A.B.C.D A.B.C.D",
5390 "Configure BGP aggregate entries\n"
5391 "Aggregate address\n"
5395 char prefix_str
[BUFSIZ
];
5397 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5401 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5405 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5408 ALIAS (no_aggregate_address_mask
,
5409 no_aggregate_address_mask_summary_only_cmd
,
5410 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5412 "Configure BGP aggregate entries\n"
5413 "Aggregate address\n"
5415 "Filter more specific routes from updates\n")
5417 ALIAS (no_aggregate_address_mask
,
5418 no_aggregate_address_mask_as_set_cmd
,
5419 "no aggregate-address A.B.C.D A.B.C.D as-set",
5421 "Configure BGP aggregate entries\n"
5422 "Aggregate address\n"
5424 "Generate AS set path information\n")
5426 ALIAS (no_aggregate_address_mask
,
5427 no_aggregate_address_mask_as_set_summary_cmd
,
5428 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5430 "Configure BGP aggregate entries\n"
5431 "Aggregate address\n"
5433 "Generate AS set path information\n"
5434 "Filter more specific routes from updates\n")
5436 ALIAS (no_aggregate_address_mask
,
5437 no_aggregate_address_mask_summary_as_set_cmd
,
5438 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5440 "Configure BGP aggregate entries\n"
5441 "Aggregate address\n"
5443 "Filter more specific routes from updates\n"
5444 "Generate AS set path information\n")
5447 DEFUN (ipv6_aggregate_address
,
5448 ipv6_aggregate_address_cmd
,
5449 "aggregate-address X:X::X:X/M",
5450 "Configure BGP aggregate entries\n"
5451 "Aggregate prefix\n")
5453 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5456 DEFUN (ipv6_aggregate_address_summary_only
,
5457 ipv6_aggregate_address_summary_only_cmd
,
5458 "aggregate-address X:X::X:X/M summary-only",
5459 "Configure BGP aggregate entries\n"
5460 "Aggregate prefix\n"
5461 "Filter more specific routes from updates\n")
5463 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5464 AGGREGATE_SUMMARY_ONLY
, 0);
5467 DEFUN (no_ipv6_aggregate_address
,
5468 no_ipv6_aggregate_address_cmd
,
5469 "no aggregate-address X:X::X:X/M",
5471 "Configure BGP aggregate entries\n"
5472 "Aggregate prefix\n")
5474 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5477 DEFUN (no_ipv6_aggregate_address_summary_only
,
5478 no_ipv6_aggregate_address_summary_only_cmd
,
5479 "no aggregate-address X:X::X:X/M summary-only",
5481 "Configure BGP aggregate entries\n"
5482 "Aggregate prefix\n"
5483 "Filter more specific routes from updates\n")
5485 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5488 ALIAS (ipv6_aggregate_address
,
5489 old_ipv6_aggregate_address_cmd
,
5490 "ipv6 bgp aggregate-address X:X::X:X/M",
5493 "Configure BGP aggregate entries\n"
5494 "Aggregate prefix\n")
5496 ALIAS (ipv6_aggregate_address_summary_only
,
5497 old_ipv6_aggregate_address_summary_only_cmd
,
5498 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5501 "Configure BGP aggregate entries\n"
5502 "Aggregate prefix\n"
5503 "Filter more specific routes from updates\n")
5505 ALIAS (no_ipv6_aggregate_address
,
5506 old_no_ipv6_aggregate_address_cmd
,
5507 "no ipv6 bgp aggregate-address X:X::X:X/M",
5511 "Configure BGP aggregate entries\n"
5512 "Aggregate prefix\n")
5514 ALIAS (no_ipv6_aggregate_address_summary_only
,
5515 old_no_ipv6_aggregate_address_summary_only_cmd
,
5516 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5520 "Configure BGP aggregate entries\n"
5521 "Aggregate prefix\n"
5522 "Filter more specific routes from updates\n")
5523 #endif /* HAVE_IPV6 */
5525 /* Redistribute route treatment. */
5527 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5528 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5529 u_int32_t metric
, u_char type
, u_short instance
, u_short tag
)
5531 struct bgp_info
*new;
5532 struct bgp_info
*bi
;
5533 struct bgp_info info
;
5534 struct bgp_node
*bn
;
5536 struct attr
*new_attr
;
5539 struct bgp_redist
*red
;
5541 /* Make default attribute. */
5542 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5544 attr
.nexthop
= *nexthop
;
5545 attr
.nh_ifindex
= ifindex
;
5550 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5551 extra
->mp_nexthop_global
= *nexthop6
;
5552 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5557 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5558 attr
.extra
->tag
= tag
;
5560 afi
= family2afi (p
->family
);
5562 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5565 struct attr attr_new
;
5566 struct attr_extra extra_new
;
5568 /* Copy attribute for modification. */
5569 attr_new
.extra
= &extra_new
;
5570 bgp_attr_dup (&attr_new
, &attr
);
5572 if (red
->redist_metric_flag
)
5573 attr_new
.med
= red
->redist_metric
;
5575 /* Apply route-map. */
5578 info
.peer
= bgp
->peer_self
;
5579 info
.attr
= &attr_new
;
5581 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5583 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5585 bgp
->peer_self
->rmap_type
= 0;
5587 if (ret
== RMAP_DENYMATCH
)
5589 /* Free uninterned attribute. */
5590 bgp_attr_flush (&attr_new
);
5592 /* Unintern original. */
5593 aspath_unintern (&attr
.aspath
);
5594 bgp_attr_extra_free (&attr
);
5595 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5600 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5601 afi
, SAFI_UNICAST
, p
, NULL
);
5603 new_attr
= bgp_attr_intern (&attr_new
);
5605 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5606 if (bi
->peer
== bgp
->peer_self
5607 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5612 /* Ensure the (source route) type is updated. */
5614 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5615 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5617 bgp_attr_unintern (&new_attr
);
5618 aspath_unintern (&attr
.aspath
);
5619 bgp_attr_extra_free (&attr
);
5620 bgp_unlock_node (bn
);
5625 /* The attribute is changed. */
5626 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5628 /* Rewrite BGP route information. */
5629 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5630 bgp_info_restore(bn
, bi
);
5632 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5633 bgp_attr_unintern (&bi
->attr
);
5634 bi
->attr
= new_attr
;
5635 bi
->uptime
= bgp_clock ();
5637 /* Process change. */
5638 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5639 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5640 bgp_unlock_node (bn
);
5641 aspath_unintern (&attr
.aspath
);
5642 bgp_attr_extra_free (&attr
);
5647 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5649 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5651 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5652 bgp_info_add (bn
, new);
5653 bgp_unlock_node (bn
);
5654 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5657 /* Unintern original. */
5658 aspath_unintern (&attr
.aspath
);
5659 bgp_attr_extra_free (&attr
);
5663 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5666 struct bgp_node
*rn
;
5667 struct bgp_info
*ri
;
5668 struct bgp_redist
*red
;
5670 afi
= family2afi (p
->family
);
5672 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5675 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5677 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5678 if (ri
->peer
== bgp
->peer_self
5679 && ri
->type
== type
)
5684 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5685 bgp_info_delete (rn
, ri
);
5686 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5688 bgp_unlock_node (rn
);
5692 /* Withdraw specified route type's route. */
5694 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5696 struct bgp_node
*rn
;
5697 struct bgp_info
*ri
;
5698 struct bgp_table
*table
;
5700 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5702 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5704 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5705 if (ri
->peer
== bgp
->peer_self
5707 && ri
->instance
== instance
)
5712 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5713 bgp_info_delete (rn
, ri
);
5714 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5719 /* Static function to display route. */
5721 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5724 u_int32_t destination
;
5727 if (p
->family
== AF_INET
)
5729 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5730 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5732 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5733 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5734 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5735 || p
->u
.prefix4
.s_addr
== 0)
5737 /* When mask is natural, mask is not displayed. */
5740 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5743 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5748 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5750 vty_out (vty
, "%*s", len
, " ");
5753 enum bgp_display_type
5758 /* Print the short form route status for a bgp_info */
5760 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
5761 json_object
*json_path
)
5766 /* Route status display. */
5767 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5768 json_object_boolean_true_add(json_path
, "removed");
5770 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5771 json_object_boolean_true_add(json_path
, "stale");
5773 if (binfo
->extra
&& binfo
->extra
->suppress
)
5774 json_object_boolean_true_add(json_path
, "suppressed");
5776 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5777 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5778 json_object_boolean_true_add(json_path
, "valid");
5781 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5782 json_object_boolean_true_add(json_path
, "history");
5784 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5785 json_object_boolean_true_add(json_path
, "damped");
5787 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5788 json_object_boolean_true_add(json_path
, "bestpath");
5790 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5791 json_object_boolean_true_add(json_path
, "multipath");
5793 /* Internal route. */
5794 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5795 json_object_string_add(json_path
, "pathFrom", "internal");
5797 json_object_string_add(json_path
, "pathFrom", "external");
5802 /* Route status display. */
5803 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
5805 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
5807 else if (binfo
->extra
&& binfo
->extra
->suppress
)
5809 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
5810 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5816 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
5818 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
5820 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
5822 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
5827 /* Internal route. */
5828 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
5834 /* called from terminal list command */
5836 route_vty_out (struct vty
*vty
, struct prefix
*p
,
5837 struct bgp_info
*binfo
, int display
, safi_t safi
,
5838 json_object
*json_paths
)
5841 json_object
*json_path
= NULL
;
5842 json_object
*json_nexthops
= NULL
;
5843 json_object
*json_nexthop_global
= NULL
;
5844 json_object
*json_nexthop_ll
= NULL
;
5847 json_path
= json_object_new_object();
5849 /* short status lead text */
5850 route_vty_short_status_out (vty
, binfo
, json_path
);
5854 /* print prefix and mask */
5856 route_vty_out_route (p
, vty
);
5858 vty_out (vty
, "%*s", 17, " ");
5861 /* Print attribute */
5867 if (p
->family
== AF_INET
5868 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
5872 json_nexthop_global
= json_object_new_object();
5874 if (safi
== SAFI_MPLS_VPN
)
5875 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5877 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
5879 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
5880 json_object_boolean_true_add(json_nexthop_global
, "used");
5884 if (safi
== SAFI_MPLS_VPN
)
5885 vty_out (vty
, "%-16s",
5886 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
5888 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
5894 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
5901 json_nexthop_global
= json_object_new_object();
5902 json_object_string_add(json_nexthop_global
, "ip",
5903 inet_ntop (AF_INET6
,
5904 &attr
->extra
->mp_nexthop_global
,
5906 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
5907 json_object_string_add(json_nexthop_global
, "scope", "global");
5909 /* We display both LL & GL if both have been received */
5910 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5912 json_nexthop_ll
= json_object_new_object();
5913 json_object_string_add(json_nexthop_ll
, "ip",
5914 inet_ntop (AF_INET6
,
5915 &attr
->extra
->mp_nexthop_local
,
5917 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
5918 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
5920 if (IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
5921 &attr
->extra
->mp_nexthop_local
) != 0)
5922 json_object_boolean_true_add(json_nexthop_ll
, "used");
5924 json_object_boolean_true_add(json_nexthop_global
, "used");
5927 json_object_boolean_true_add(json_nexthop_global
, "used");
5931 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
5933 if (binfo
->peer
->conf_if
)
5935 len
= vty_out (vty
, "%s",
5936 binfo
->peer
->conf_if
);
5937 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
5940 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
5942 vty_out (vty
, "%*s", len
, " ");
5946 len
= vty_out (vty
, "%s",
5947 inet_ntop (AF_INET6
,
5948 &attr
->extra
->mp_nexthop_local
,
5953 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5955 vty_out (vty
, "%*s", len
, " ");
5960 len
= vty_out (vty
, "%s",
5961 inet_ntop (AF_INET6
,
5962 &attr
->extra
->mp_nexthop_global
,
5967 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
5969 vty_out (vty
, "%*s", len
, " ");
5973 #endif /* HAVE_IPV6 */
5976 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
5978 json_object_int_add(json_path
, "med", attr
->med
);
5980 vty_out (vty
, "%10u", attr
->med
);
5986 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
5988 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
5990 vty_out (vty
, "%7u", attr
->local_pref
);
5998 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6000 json_object_int_add(json_path
, "weight", 0);
6003 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6009 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6011 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6016 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6018 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6023 json_object_string_add(json_path
, "alert", "No attributes");
6025 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6030 if (json_nexthop_global
|| json_nexthop_ll
)
6032 json_nexthops
= json_object_new_array();
6034 if (json_nexthop_global
)
6035 json_object_array_add(json_nexthops
, json_nexthop_global
);
6037 if (json_nexthop_ll
)
6038 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6040 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6043 json_object_array_add(json_paths
, json_path
);
6046 vty_out (vty
, "%s", VTY_NEWLINE
);
6049 /* called from terminal list command */
6051 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6052 u_char use_json
, json_object
*json_ar
)
6054 json_object
*json_status
= NULL
;
6055 json_object
*json_net
= NULL
;
6057 /* Route status display. */
6060 json_status
= json_object_new_object();
6061 json_net
= json_object_new_object();
6070 /* print prefix and mask */
6072 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6074 route_vty_out_route (p
, vty
);
6076 /* Print attribute */
6081 if (p
->family
== AF_INET
&& (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6083 if (safi
== SAFI_MPLS_VPN
)
6084 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6086 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6089 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6093 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6096 #endif /* HAVE_IPV6 */
6098 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6099 json_object_int_add(json_net
, "metric", attr
->med
);
6101 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6102 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6105 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6107 json_object_int_add(json_net
, "weight", 0);
6111 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6114 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6118 if (p
->family
== AF_INET
&& (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6120 if (safi
== SAFI_MPLS_VPN
)
6121 vty_out (vty
, "%-16s",
6122 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6124 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6127 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6132 assert (attr
->extra
);
6134 len
= vty_out (vty
, "%s",
6135 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6139 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6141 vty_out (vty
, "%*s", len
, " ");
6143 #endif /* HAVE_IPV6 */
6144 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6145 vty_out (vty
, "%10u", attr
->med
);
6149 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6150 vty_out (vty
, "%7u", attr
->local_pref
);
6154 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6158 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6161 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6166 json_object_boolean_true_add(json_status
, "*");
6167 json_object_boolean_true_add(json_status
, ">");
6168 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6169 char buf_cut
[BUFSIZ
];
6170 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6173 vty_out (vty
, "%s", VTY_NEWLINE
);
6177 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6178 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6180 json_object
*json_out
= NULL
;
6182 u_int32_t label
= 0;
6188 json_out
= json_object_new_object();
6190 /* short status lead text */
6191 route_vty_short_status_out (vty
, binfo
, json_out
);
6193 /* print prefix and mask */
6197 route_vty_out_route (p
, vty
);
6199 vty_out (vty
, "%*s", 17, " ");
6202 /* Print attribute */
6206 if (p
->family
== AF_INET
6207 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6209 if (safi
== SAFI_MPLS_VPN
)
6212 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6214 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6219 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6221 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6225 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6227 assert (attr
->extra
);
6231 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6234 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6235 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6238 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6241 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6245 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6247 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6249 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6250 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6253 vty_out (vty
, "%s(%s)",
6254 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6256 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6261 #endif /* HAVE_IPV6 */
6264 label
= decode_label (binfo
->extra
->tag
);
6269 json_object_int_add(json_out
, "notag", label
);
6270 json_object_array_add(json
, json_out
);
6274 vty_out (vty
, "notag/%d", label
);
6275 vty_out (vty
, "%s", VTY_NEWLINE
);
6279 /* dampening route */
6281 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6282 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6286 char timebuf
[BGP_UPTIME_LEN
];
6288 /* short status lead text */
6289 route_vty_short_status_out (vty
, binfo
, json
);
6291 /* print prefix and mask */
6295 route_vty_out_route (p
, vty
);
6297 vty_out (vty
, "%*s", 17, " ");
6300 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6305 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6310 json_object_int_add(json
, "peerHost", len
);
6312 vty_out (vty
, "%*s", len
, " ");
6316 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6318 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6320 /* Print attribute */
6328 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6330 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6335 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6337 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6340 vty_out (vty
, "%s", VTY_NEWLINE
);
6345 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6346 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6349 struct bgp_damp_info
*bdi
;
6350 char timebuf
[BGP_UPTIME_LEN
];
6356 bdi
= binfo
->extra
->damp_info
;
6358 /* short status lead text */
6359 route_vty_short_status_out (vty
, binfo
, json
);
6361 /* print prefix and mask */
6365 route_vty_out_route (p
, vty
);
6367 vty_out (vty
, "%*s", 17, " ");
6370 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6375 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6380 json_object_int_add(json
, "peerHost", len
);
6382 vty_out (vty
, "%*s", len
, " ");
6385 len
= vty_out (vty
, "%d", bdi
->flap
);
6395 json_object_int_add(json
, "bdiFlap", len
);
6397 vty_out (vty
, "%*s", len
, " ");
6401 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6403 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6404 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6406 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6407 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6410 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6412 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6417 vty_out (vty
, "%*s ", 8, " ");
6420 /* Print attribute */
6428 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6430 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6435 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6437 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6440 vty_out (vty
, "%s", VTY_NEWLINE
);
6444 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6445 const char *header
, json_object
*json_adv_to
)
6447 char buf1
[INET6_ADDRSTRLEN
];
6448 json_object
*json_peer
= NULL
;
6452 /* 'advertised-to' is a dictionary of peers we have advertised this
6453 * prefix too. The key is the peer's IP or swpX, the value is the
6454 * hostname if we know it and "" if not.
6456 json_peer
= json_object_new_object();
6459 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6462 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6464 json_object_object_add(json_adv_to
,
6465 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6472 vty_out (vty
, "%s", header
);
6476 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6479 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6481 vty_out (vty
, " %s(%s)", peer
->hostname
,
6482 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6487 vty_out (vty
, " %s", peer
->conf_if
);
6489 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6495 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6496 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6497 json_object
*json_paths
)
6499 char buf
[INET6_ADDRSTRLEN
];
6502 int sockunion_vty_out (struct vty
*, union sockunion
*);
6503 #ifdef HAVE_CLOCK_MONOTONIC
6506 json_object
*json_bestpath
= NULL
;
6507 json_object
*json_cluster_list
= NULL
;
6508 json_object
*json_cluster_list_list
= NULL
;
6509 json_object
*json_ext_community
= NULL
;
6510 json_object
*json_last_update
= NULL
;
6511 json_object
*json_nexthop_global
= NULL
;
6512 json_object
*json_nexthop_ll
= NULL
;
6513 json_object
*json_nexthops
= NULL
;
6514 json_object
*json_path
= NULL
;
6515 json_object
*json_peer
= NULL
;
6516 json_object
*json_string
= NULL
;
6517 json_object
*json_adv_to
= NULL
;
6519 struct listnode
*node
, *nnode
;
6521 int addpath_capable
;
6527 json_path
= json_object_new_object();
6528 json_peer
= json_object_new_object();
6529 json_nexthop_global
= json_object_new_object();
6536 /* Line1 display AS-path, Aggregator */
6541 json_object_lock(attr
->aspath
->json
);
6542 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6546 if (attr
->aspath
->segments
)
6547 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6549 vty_out (vty
, " Local");
6553 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6556 json_object_boolean_true_add(json_path
, "removed");
6558 vty_out (vty
, ", (removed)");
6561 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6564 json_object_boolean_true_add(json_path
, "stale");
6566 vty_out (vty
, ", (stale)");
6569 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6573 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6574 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6578 vty_out (vty
, ", (aggregated by %u %s)",
6579 attr
->extra
->aggregator_as
,
6580 inet_ntoa (attr
->extra
->aggregator_addr
));
6584 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6587 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6589 vty_out (vty
, ", (Received from a RR-client)");
6592 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6595 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6597 vty_out (vty
, ", (Received from a RS-client)");
6600 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6603 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6605 vty_out (vty
, ", (history entry)");
6607 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6610 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6612 vty_out (vty
, ", (suppressed due to dampening)");
6616 vty_out (vty
, "%s", VTY_NEWLINE
);
6618 /* Line2 display Next-hop, Neighbor, Router-id */
6619 /* Display the nexthop */
6620 if (p
->family
== AF_INET
6621 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6623 if (safi
== SAFI_MPLS_VPN
)
6626 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6628 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6633 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6635 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6639 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6644 assert (attr
->extra
);
6647 json_object_string_add(json_nexthop_global
, "ip",
6648 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6649 buf
, INET6_ADDRSTRLEN
));
6650 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6651 json_object_string_add(json_nexthop_global
, "scope", "global");
6655 vty_out (vty
, " %s",
6656 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6657 buf
, INET6_ADDRSTRLEN
));
6660 #endif /* HAVE_IPV6 */
6663 /* Display the IGP cost or 'inaccessible' */
6664 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6667 json_object_boolean_false_add(json_nexthop_global
, "accessible");
6669 vty_out (vty
, " (inaccessible)");
6673 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6676 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
6678 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
6681 /* IGP cost is 0, display this only for json */
6685 json_object_int_add(json_nexthop_global
, "metric", 0);
6689 json_object_boolean_true_add(json_nexthop_global
, "accessible");
6692 /* Display peer "from" output */
6693 /* This path was originated locally */
6694 if (binfo
->peer
== bgp
->peer_self
)
6697 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6700 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
6702 vty_out (vty
, " from 0.0.0.0 ");
6707 json_object_string_add(json_peer
, "peerId", "::");
6709 vty_out (vty
, " from :: ");
6713 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
6715 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
6718 /* We RXed this path from one of our peers */
6724 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6725 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6727 if (binfo
->peer
->hostname
)
6728 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
6730 if (binfo
->peer
->domainname
)
6731 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
6733 if (binfo
->peer
->conf_if
)
6734 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
6738 if (binfo
->peer
->conf_if
)
6740 if (binfo
->peer
->hostname
&&
6741 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6742 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6743 binfo
->peer
->conf_if
);
6745 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
6749 if (binfo
->peer
->hostname
&&
6750 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6751 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
6754 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6757 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
6758 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
6760 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
6765 vty_out (vty
, "%s", VTY_NEWLINE
);
6768 /* display the link-local nexthop */
6769 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6773 json_nexthop_ll
= json_object_new_object();
6774 json_object_string_add(json_nexthop_ll
, "ip",
6775 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6776 buf
, INET6_ADDRSTRLEN
));
6777 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6778 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6780 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
6781 json_object_boolean_true_add(json_nexthop_ll
, "used");
6785 vty_out (vty
, " (%s) (used)%s",
6786 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6787 buf
, INET6_ADDRSTRLEN
),
6791 /* If we do not have a link-local nexthop then we must flag the global as "used" */
6795 json_object_boolean_true_add(json_nexthop_global
, "used");
6797 #endif /* HAVE_IPV6 */
6799 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
6801 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6803 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
6805 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
6808 json_object_int_add(json_path
, "med", attr
->med
);
6810 vty_out (vty
, ", metric %u", attr
->med
);
6813 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
6816 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6818 vty_out (vty
, ", localpref %u", attr
->local_pref
);
6823 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
6825 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
6828 if (attr
->extra
&& attr
->extra
->weight
!= 0)
6831 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6833 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
6836 if (attr
->extra
&& attr
->extra
->tag
!= 0)
6839 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
6841 vty_out (vty
, ", tag %d", attr
->extra
->tag
);
6844 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6847 json_object_boolean_false_add(json_path
, "valid");
6849 vty_out (vty
, ", invalid");
6851 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6854 json_object_boolean_true_add(json_path
, "valid");
6856 vty_out (vty
, ", valid");
6859 if (binfo
->peer
!= bgp
->peer_self
)
6861 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
6863 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
6866 json_object_string_add(json_peer
, "type", "confed-internal");
6868 vty_out (vty
, ", confed-internal");
6873 json_object_string_add(json_peer
, "type", "internal");
6875 vty_out (vty
, ", internal");
6880 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
6883 json_object_string_add(json_peer
, "type", "confed-external");
6885 vty_out (vty
, ", confed-external");
6890 json_object_string_add(json_peer
, "type", "external");
6892 vty_out (vty
, ", external");
6896 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
6900 json_object_boolean_true_add(json_path
, "aggregated");
6901 json_object_boolean_true_add(json_path
, "local");
6905 vty_out (vty
, ", aggregated, local");
6908 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
6911 json_object_boolean_true_add(json_path
, "sourced");
6913 vty_out (vty
, ", sourced");
6919 json_object_boolean_true_add(json_path
, "sourced");
6920 json_object_boolean_true_add(json_path
, "local");
6924 vty_out (vty
, ", sourced, local");
6928 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
6931 json_object_boolean_true_add(json_path
, "atomicAggregate");
6933 vty_out (vty
, ", atomic-aggregate");
6936 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
6937 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
6938 bgp_info_mpath_count (binfo
)))
6941 json_object_boolean_true_add(json_path
, "multipath");
6943 vty_out (vty
, ", multipath");
6946 // Mark the bestpath(s)
6947 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
6949 first_as
= aspath_get_firstas(attr
->aspath
);
6954 json_bestpath
= json_object_new_object();
6955 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
6960 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
6962 vty_out (vty
, ", bestpath-from-AS Local");
6966 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6971 json_bestpath
= json_object_new_object();
6972 json_object_boolean_true_add(json_bestpath
, "overall");
6975 vty_out (vty
, ", best");
6979 json_object_object_add(json_path
, "bestpath", json_bestpath
);
6982 vty_out (vty
, "%s", VTY_NEWLINE
);
6984 /* Line 4 display Community */
6985 if (attr
->community
)
6989 json_object_lock(attr
->community
->json
);
6990 json_object_object_add(json_path
, "community", attr
->community
->json
);
6994 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
6999 /* Line 5 display Extended-community */
7000 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7004 json_ext_community
= json_object_new_object();
7005 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7006 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7010 vty_out (vty
, " Extended Community: %s%s",
7011 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7015 /* Line 6 display Originator, Cluster-id */
7016 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7017 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7019 assert (attr
->extra
);
7020 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7023 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7025 vty_out (vty
, " Originator: %s",
7026 inet_ntoa (attr
->extra
->originator_id
));
7029 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7035 json_cluster_list
= json_object_new_object();
7036 json_cluster_list_list
= json_object_new_array();
7038 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7040 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7041 json_object_array_add(json_cluster_list_list
, json_string
);
7044 /* struct cluster_list does not have "str" variable like
7045 * aspath and community do. Add this someday if someone
7047 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7049 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7050 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7054 vty_out (vty
, ", Cluster list: ");
7056 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7058 vty_out (vty
, "%s ",
7059 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7065 vty_out (vty
, "%s", VTY_NEWLINE
);
7068 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7069 bgp_damp_info_vty (vty
, binfo
, json_path
);
7071 /* Line 7 display Addpath IDs */
7072 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7076 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7077 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7081 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7082 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7087 /* If we used addpath to TX a non-bestpath we need to display
7088 * "Advertised to" on a path-by-path basis */
7089 if (bgp
->addpath_tx_used
[afi
][safi
])
7093 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7095 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7096 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7098 if ((addpath_capable
&& has_adj
) ||
7099 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7101 if (json_path
&& !json_adv_to
)
7102 json_adv_to
= json_object_new_object();
7104 route_vty_out_advertised_to(vty
, peer
, &first
,
7114 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7121 vty_out (vty
, "%s", VTY_NEWLINE
);
7126 /* Line 8 display Uptime */
7127 #ifdef HAVE_CLOCK_MONOTONIC
7128 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7131 json_last_update
= json_object_new_object();
7132 json_object_int_add(json_last_update
, "epoch", tbuf
);
7133 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7134 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7137 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7141 json_last_update
= json_object_new_object();
7142 json_object_int_add(json_last_update
, "epoch", tbuf
);
7143 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7144 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7147 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7148 #endif /* HAVE_CLOCK_MONOTONIC */
7151 /* We've constructed the json object for this path, add it to the json
7156 if (json_nexthop_global
|| json_nexthop_ll
)
7158 json_nexthops
= json_object_new_array();
7160 if (json_nexthop_global
)
7161 json_object_array_add(json_nexthops
, json_nexthop_global
);
7163 if (json_nexthop_ll
)
7164 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7166 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7169 json_object_object_add(json_path
, "peer", json_peer
);
7170 json_object_array_add(json_paths
, json_path
);
7173 vty_out (vty
, "%s", VTY_NEWLINE
);
7176 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7177 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7178 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7182 bgp_show_type_normal
,
7183 bgp_show_type_regexp
,
7184 bgp_show_type_prefix_list
,
7185 bgp_show_type_filter_list
,
7186 bgp_show_type_route_map
,
7187 bgp_show_type_neighbor
,
7188 bgp_show_type_cidr_only
,
7189 bgp_show_type_prefix_longer
,
7190 bgp_show_type_community_all
,
7191 bgp_show_type_community
,
7192 bgp_show_type_community_exact
,
7193 bgp_show_type_community_list
,
7194 bgp_show_type_community_list_exact
,
7195 bgp_show_type_flap_statistics
,
7196 bgp_show_type_flap_address
,
7197 bgp_show_type_flap_prefix
,
7198 bgp_show_type_flap_cidr_only
,
7199 bgp_show_type_flap_regexp
,
7200 bgp_show_type_flap_filter_list
,
7201 bgp_show_type_flap_prefix_list
,
7202 bgp_show_type_flap_prefix_longer
,
7203 bgp_show_type_flap_route_map
,
7204 bgp_show_type_flap_neighbor
,
7205 bgp_show_type_dampend_paths
,
7206 bgp_show_type_damp_neighbor
7210 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7211 const char *prefix_list_str
, afi_t afi
,
7212 safi_t safi
, enum bgp_show_type type
);
7214 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7215 const char *filter
, afi_t afi
,
7216 safi_t safi
, enum bgp_show_type type
);
7218 bgp_show_route_map (struct vty
*vty
, const char *name
,
7219 const char *rmap_str
, afi_t afi
,
7220 safi_t safi
, enum bgp_show_type type
);
7222 bgp_show_community_list (struct vty
*vty
, const char *name
,
7223 const char *com
, int exact
,
7224 afi_t afi
, safi_t safi
);
7226 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7227 const char *prefix
, afi_t afi
,
7228 safi_t safi
, enum bgp_show_type type
);
7231 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
,
7232 struct in_addr
*router_id
, enum bgp_show_type type
,
7233 void *output_arg
, u_char use_json
, json_object
*json
)
7235 struct bgp_info
*ri
;
7236 struct bgp_node
*rn
;
7239 unsigned long output_count
;
7243 json_object
*json_paths
= NULL
;
7244 json_object
*json_routes
= NULL
;
7249 json
= json_object_new_object();
7251 json_object_int_add(json
, "tableVersion", table
->version
);
7252 json_object_string_add(json
, "routerId", inet_ntoa (*router_id
));
7253 json_routes
= json_object_new_object();
7256 /* This is first entry point, so reset total line. */
7259 /* Start processing of routes. */
7260 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7261 if (rn
->info
!= NULL
)
7266 json_paths
= json_object_new_array();
7270 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7272 if (type
== bgp_show_type_flap_statistics
7273 || type
== bgp_show_type_flap_address
7274 || type
== bgp_show_type_flap_prefix
7275 || type
== bgp_show_type_flap_cidr_only
7276 || type
== bgp_show_type_flap_regexp
7277 || type
== bgp_show_type_flap_filter_list
7278 || type
== bgp_show_type_flap_prefix_list
7279 || type
== bgp_show_type_flap_prefix_longer
7280 || type
== bgp_show_type_flap_route_map
7281 || type
== bgp_show_type_flap_neighbor
7282 || type
== bgp_show_type_dampend_paths
7283 || type
== bgp_show_type_damp_neighbor
)
7285 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7288 if (type
== bgp_show_type_regexp
7289 || type
== bgp_show_type_flap_regexp
)
7291 regex_t
*regex
= output_arg
;
7293 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7296 if (type
== bgp_show_type_prefix_list
7297 || type
== bgp_show_type_flap_prefix_list
)
7299 struct prefix_list
*plist
= output_arg
;
7301 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7304 if (type
== bgp_show_type_filter_list
7305 || type
== bgp_show_type_flap_filter_list
)
7307 struct as_list
*as_list
= output_arg
;
7309 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7312 if (type
== bgp_show_type_route_map
7313 || type
== bgp_show_type_flap_route_map
)
7315 struct route_map
*rmap
= output_arg
;
7316 struct bgp_info binfo
;
7317 struct attr dummy_attr
;
7318 struct attr_extra dummy_extra
;
7321 dummy_attr
.extra
= &dummy_extra
;
7322 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7324 binfo
.peer
= ri
->peer
;
7325 binfo
.attr
= &dummy_attr
;
7327 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7328 if (ret
== RMAP_DENYMATCH
)
7331 if (type
== bgp_show_type_neighbor
7332 || type
== bgp_show_type_flap_neighbor
7333 || type
== bgp_show_type_damp_neighbor
)
7335 union sockunion
*su
= output_arg
;
7337 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7340 if (type
== bgp_show_type_cidr_only
7341 || type
== bgp_show_type_flap_cidr_only
)
7343 u_int32_t destination
;
7345 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7346 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7348 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7350 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7353 if (type
== bgp_show_type_prefix_longer
7354 || type
== bgp_show_type_flap_prefix_longer
)
7356 struct prefix
*p
= output_arg
;
7358 if (! prefix_match (p
, &rn
->p
))
7361 if (type
== bgp_show_type_community_all
)
7363 if (! ri
->attr
->community
)
7366 if (type
== bgp_show_type_community
)
7368 struct community
*com
= output_arg
;
7370 if (! ri
->attr
->community
||
7371 ! community_match (ri
->attr
->community
, com
))
7374 if (type
== bgp_show_type_community_exact
)
7376 struct community
*com
= output_arg
;
7378 if (! ri
->attr
->community
||
7379 ! community_cmp (ri
->attr
->community
, com
))
7382 if (type
== bgp_show_type_community_list
)
7384 struct community_list
*list
= output_arg
;
7386 if (! community_list_match (ri
->attr
->community
, list
))
7389 if (type
== bgp_show_type_community_list_exact
)
7391 struct community_list
*list
= output_arg
;
7393 if (! community_list_exact_match (ri
->attr
->community
, list
))
7396 if (type
== bgp_show_type_flap_address
7397 || type
== bgp_show_type_flap_prefix
)
7399 struct prefix
*p
= output_arg
;
7401 if (! prefix_match (&rn
->p
, p
))
7404 if (type
== bgp_show_type_flap_prefix
)
7405 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7408 if (type
== bgp_show_type_dampend_paths
7409 || type
== bgp_show_type_damp_neighbor
)
7411 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7412 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7416 if (!use_json
&& header
)
7418 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (*router_id
), VTY_NEWLINE
);
7419 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7420 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7421 if (type
== bgp_show_type_dampend_paths
7422 || type
== bgp_show_type_damp_neighbor
)
7423 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7424 else if (type
== bgp_show_type_flap_statistics
7425 || type
== bgp_show_type_flap_address
7426 || type
== bgp_show_type_flap_prefix
7427 || type
== bgp_show_type_flap_cidr_only
7428 || type
== bgp_show_type_flap_regexp
7429 || type
== bgp_show_type_flap_filter_list
7430 || type
== bgp_show_type_flap_prefix_list
7431 || type
== bgp_show_type_flap_prefix_longer
7432 || type
== bgp_show_type_flap_route_map
7433 || type
== bgp_show_type_flap_neighbor
)
7434 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7436 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7440 if (type
== bgp_show_type_dampend_paths
7441 || type
== bgp_show_type_damp_neighbor
)
7442 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7443 else if (type
== bgp_show_type_flap_statistics
7444 || type
== bgp_show_type_flap_address
7445 || type
== bgp_show_type_flap_prefix
7446 || type
== bgp_show_type_flap_cidr_only
7447 || type
== bgp_show_type_flap_regexp
7448 || type
== bgp_show_type_flap_filter_list
7449 || type
== bgp_show_type_flap_prefix_list
7450 || type
== bgp_show_type_flap_prefix_longer
7451 || type
== bgp_show_type_flap_route_map
7452 || type
== bgp_show_type_flap_neighbor
)
7453 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7455 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7465 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7466 json_object_object_add(json_routes
, buf2
, json_paths
);
7473 json_object_object_add(json
, "routes", json_routes
);
7474 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7475 json_object_free(json
);
7479 /* No route is displayed */
7480 if (output_count
== 0)
7482 if (type
== bgp_show_type_normal
)
7483 vty_out (vty
, "No BGP network exists%s", VTY_NEWLINE
);
7486 vty_out (vty
, "%sTotal number of prefixes %ld%s",
7487 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
7494 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7495 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7497 struct bgp_table
*table
;
7501 bgp
= bgp_get_default ();
7507 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7511 table
= bgp
->rib
[afi
][safi
];
7513 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
,
7518 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7521 struct listnode
*node
, *nnode
;
7523 struct bgp_table
*table
;
7524 json_object
*json
= NULL
;
7528 vty_out (vty
, "{%s", VTY_NEWLINE
);
7530 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7534 if (!(json
= json_object_new_object()))
7536 zlog_err("Unable to allocate memory for JSON object");
7538 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
7542 json_object_int_add(json
, "vrfId",
7543 (bgp
->vrf_id
== VRF_UNKNOWN
)
7544 ? -1 : bgp
->vrf_id
);
7545 json_object_string_add(json
, "vrfName",
7546 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7547 ? "Default" : bgp
->name
);
7549 vty_out (vty
, ",%s", VTY_NEWLINE
);
7553 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7554 ? "Default" : bgp
->name
);
7558 vty_out (vty
, "%sInstance %s:%s",
7560 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7561 ? "Default" : bgp
->name
,
7564 table
= bgp
->rib
[afi
][safi
];
7565 bgp_show_table (vty
, table
, &bgp
->router_id
,
7566 bgp_show_type_normal
, NULL
, use_json
, json
);
7571 vty_out (vty
, "}%s", VTY_NEWLINE
);
7574 /* Header of detailed BGP route information */
7576 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7577 struct bgp_node
*rn
,
7578 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7581 struct bgp_info
*ri
;
7584 struct listnode
*node
, *nnode
;
7585 char buf1
[INET6_ADDRSTRLEN
];
7586 char buf2
[INET6_ADDRSTRLEN
];
7591 int no_advertise
= 0;
7594 json_object
*json_adv_to
= NULL
;
7600 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7601 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7605 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7606 (safi
== SAFI_MPLS_VPN
?
7607 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7608 safi
== SAFI_MPLS_VPN
? ":" : "",
7609 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7610 p
->prefixlen
, VTY_NEWLINE
);
7613 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7616 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7619 if (ri
->extra
&& ri
->extra
->suppress
)
7621 if (ri
->attr
->community
!= NULL
)
7623 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7625 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7627 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7635 vty_out (vty
, "Paths: (%d available", count
);
7638 vty_out (vty
, ", best #%d", best
);
7639 if (safi
== SAFI_UNICAST
)
7640 vty_out (vty
, ", table Default-IP-Routing-Table");
7643 vty_out (vty
, ", no best path");
7646 vty_out (vty
, ", not advertised to any peer");
7648 vty_out (vty
, ", not advertised to EBGP peer");
7650 vty_out (vty
, ", not advertised outside local AS");
7653 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7654 vty_out (vty
, ")%s", VTY_NEWLINE
);
7657 /* If we are not using addpath then we can display Advertised to and that will
7658 * show what peers we advertised the bestpath to. If we are using addpath
7659 * though then we must display Advertised to on a path-by-path basis. */
7660 if (!bgp
->addpath_tx_used
[afi
][safi
])
7662 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7664 if (bgp_adj_out_lookup (peer
, rn
, 0))
7666 if (json
&& !json_adv_to
)
7667 json_adv_to
= json_object_new_object();
7669 route_vty_out_advertised_to(vty
, peer
, &first
,
7670 " Advertised to non peer-group peers:\n ",
7679 json_object_object_add(json
, "advertisedTo", json_adv_to
);
7685 vty_out (vty
, " Not advertised to any peer");
7686 vty_out (vty
, "%s", VTY_NEWLINE
);
7691 /* Display specified route of BGP table. */
7693 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
7694 struct bgp_table
*rib
, const char *ip_str
,
7695 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7696 int prefix_check
, enum bgp_path_type pathtype
,
7702 struct prefix match
;
7703 struct bgp_node
*rn
;
7704 struct bgp_node
*rm
;
7705 struct bgp_info
*ri
;
7706 struct bgp_table
*table
;
7707 json_object
*json
= NULL
;
7708 json_object
*json_paths
= NULL
;
7710 /* Check IP address argument. */
7711 ret
= str2prefix (ip_str
, &match
);
7714 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
7718 match
.family
= afi2family (afi
);
7722 json
= json_object_new_object();
7723 json_paths
= json_object_new_array();
7726 if (safi
== SAFI_MPLS_VPN
)
7728 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
7730 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
7733 if ((table
= rn
->info
) != NULL
)
7737 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
7739 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
7741 bgp_unlock_node (rm
);
7745 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
7749 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
7750 AFI_IP
, SAFI_MPLS_VPN
, json
);
7756 if (pathtype
== BGP_PATH_ALL
||
7757 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7758 (pathtype
== BGP_PATH_MULTIPATH
&&
7759 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7760 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, SAFI_MPLS_VPN
, json_paths
);
7763 bgp_unlock_node (rm
);
7772 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
7774 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
7776 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7780 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
7785 if (pathtype
== BGP_PATH_ALL
||
7786 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
7787 (pathtype
== BGP_PATH_MULTIPATH
&&
7788 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
7789 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
7793 bgp_unlock_node (rn
);
7800 json_object_object_add(json
, "paths", json_paths
);
7802 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7803 json_object_free(json
);
7809 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
7817 /* Display specified route of Main RIB */
7819 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
7820 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7821 int prefix_check
, enum bgp_path_type pathtype
,
7826 /* BGP structure lookup. */
7829 bgp
= bgp_lookup_by_name (view_name
);
7832 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
7838 bgp
= bgp_get_default ();
7841 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7846 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
7847 afi
, safi
, prd
, prefix_check
, pathtype
,
7851 /* BGP route print out function. */
7854 "show ip bgp {json}",
7858 "JavaScript Object Notation\n")
7860 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
7863 DEFUN (show_ip_bgp_ipv4
,
7864 show_ip_bgp_ipv4_cmd
,
7865 "show ip bgp ipv4 (unicast|multicast) {json}",
7870 "Address Family modifier\n"
7871 "Address Family modifier\n"
7872 "JavaScript Object Notation\n")
7874 u_char uj
= use_json(argc
, argv
);
7876 if (strncmp (argv
[0], "m", 1) == 0)
7877 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
7880 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
7883 ALIAS (show_ip_bgp_ipv4
,
7884 show_bgp_ipv4_safi_cmd
,
7885 "show bgp ipv4 (unicast|multicast) {json}",
7889 "Address Family modifier\n"
7890 "Address Family modifier\n"
7891 "JavaScript Object Notation\n")
7893 DEFUN (show_ip_bgp_route
,
7894 show_ip_bgp_route_cmd
,
7895 "show ip bgp A.B.C.D {json}",
7899 "Network in the BGP routing table to display\n"
7900 "JavaScript Object Notation\n")
7902 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7905 DEFUN (show_ip_bgp_route_pathtype
,
7906 show_ip_bgp_route_pathtype_cmd
,
7907 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
7911 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7912 "Display only the bestpath\n"
7913 "Display only multipaths\n"
7914 "JavaScript Object Notation\n")
7916 u_char uj
= use_json(argc
, argv
);
7918 if (strncmp (argv
[1], "b", 1) == 0)
7919 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7921 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7924 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
7925 show_bgp_ipv4_safi_route_pathtype_cmd
,
7926 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
7930 "Address Family modifier\n"
7931 "Address Family modifier\n"
7932 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
7933 "Display only the bestpath\n"
7934 "Display only multipaths\n"
7935 "JavaScript Object Notation\n")
7937 u_char uj
= use_json(argc
, argv
);
7939 if (strncmp (argv
[0], "m", 1) == 0)
7940 if (strncmp (argv
[2], "b", 1) == 0)
7941 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7943 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7945 if (strncmp (argv
[2], "b", 1) == 0)
7946 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
7948 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
7951 DEFUN (show_ip_bgp_ipv4_route
,
7952 show_ip_bgp_ipv4_route_cmd
,
7953 "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
7958 "Address Family modifier\n"
7959 "Address Family modifier\n"
7960 "Network in the BGP routing table to display\n"
7961 "JavaScript Object Notation\n")
7963 u_char uj
= use_json(argc
, argv
);
7965 if (strncmp (argv
[0], "m", 1) == 0)
7966 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7968 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
7971 ALIAS (show_ip_bgp_ipv4_route
,
7972 show_bgp_ipv4_safi_route_cmd
,
7973 "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
7977 "Address Family modifier\n"
7978 "Address Family modifier\n"
7979 "Network in the BGP routing table to display\n"
7980 "JavaScript Object Notation\n")
7982 DEFUN (show_ip_bgp_vpnv4_all_route
,
7983 show_ip_bgp_vpnv4_all_route_cmd
,
7984 "show ip bgp vpnv4 all A.B.C.D {json}",
7988 "Display VPNv4 NLRI specific information\n"
7989 "Display information about all VPNv4 NLRIs\n"
7990 "Network in the BGP routing table to display\n"
7991 "JavaScript Object Notation\n")
7993 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
7997 DEFUN (show_ip_bgp_vpnv4_rd_route
,
7998 show_ip_bgp_vpnv4_rd_route_cmd
,
7999 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8003 "Display VPNv4 NLRI specific information\n"
8004 "Display information for a route distinguisher\n"
8005 "VPN Route Distinguisher\n"
8006 "Network in the BGP routing table to display\n"
8007 "JavaScript Object Notation\n")
8010 struct prefix_rd prd
;
8011 u_char uj
= use_json(argc
, argv
);
8013 ret
= str2prefix_rd (argv
[0], &prd
);
8016 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8019 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, uj
);
8022 DEFUN (show_ip_bgp_prefix
,
8023 show_ip_bgp_prefix_cmd
,
8024 "show ip bgp A.B.C.D/M {json}",
8028 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8029 "JavaScript Object Notation\n")
8031 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8034 DEFUN (show_ip_bgp_prefix_pathtype
,
8035 show_ip_bgp_prefix_pathtype_cmd
,
8036 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8040 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8041 "Display only the bestpath\n"
8042 "Display only multipaths\n"
8043 "JavaScript Object Notation\n")
8045 u_char uj
= use_json(argc
, argv
);
8046 if (strncmp (argv
[1], "b", 1) == 0)
8047 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8049 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8052 DEFUN (show_ip_bgp_ipv4_prefix
,
8053 show_ip_bgp_ipv4_prefix_cmd
,
8054 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8059 "Address Family modifier\n"
8060 "Address Family modifier\n"
8061 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8062 "JavaScript Object Notation\n")
8064 u_char uj
= use_json(argc
, argv
);
8066 if (strncmp (argv
[0], "m", 1) == 0)
8067 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8069 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8072 ALIAS (show_ip_bgp_ipv4_prefix
,
8073 show_bgp_ipv4_safi_prefix_cmd
,
8074 "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8078 "Address Family modifier\n"
8079 "Address Family modifier\n"
8080 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8081 "JavaScript Object Notation\n")
8083 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8084 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8085 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8090 "Address Family modifier\n"
8091 "Address Family modifier\n"
8092 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8093 "Display only the bestpath\n"
8094 "Display only multipaths\n"
8095 "JavaScript Object Notation\n")
8097 u_char uj
= use_json(argc
, argv
);
8099 if (strncmp (argv
[0], "m", 1) == 0)
8100 if (strncmp (argv
[2], "b", 1) == 0)
8101 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8103 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8105 if (strncmp (argv
[2], "b", 1) == 0)
8106 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8108 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8111 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8112 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8113 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8117 "Address Family modifier\n"
8118 "Address Family modifier\n"
8119 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8120 "Display only the bestpath\n"
8121 "Display only multipaths\n"
8122 "JavaScript Object Notation\n")
8124 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
8125 show_ip_bgp_vpnv4_all_prefix_cmd
,
8126 "show ip bgp vpnv4 all A.B.C.D/M {json}",
8130 "Display VPNv4 NLRI specific information\n"
8131 "Display information about all VPNv4 NLRIs\n"
8132 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8133 "JavaScript Object Notation\n")
8135 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8138 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
8139 show_ip_bgp_vpnv4_rd_prefix_cmd
,
8140 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8144 "Display VPNv4 NLRI specific information\n"
8145 "Display information for a route distinguisher\n"
8146 "VPN Route Distinguisher\n"
8147 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8148 "JavaScript Object Notation\n")
8151 struct prefix_rd prd
;
8153 ret
= str2prefix_rd (argv
[0], &prd
);
8156 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8159 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8162 DEFUN (show_ip_bgp_view
,
8163 show_ip_bgp_instance_cmd
,
8164 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8168 BGP_INSTANCE_HELP_STR
8169 "JavaScript Object Notation\n")
8173 /* BGP structure lookup. */
8174 bgp
= bgp_lookup_by_name (argv
[1]);
8177 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8181 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8184 DEFUN (show_ip_bgp_instance_all
,
8185 show_ip_bgp_instance_all_cmd
,
8186 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8190 BGP_INSTANCE_ALL_HELP_STR
8191 "JavaScript Object Notation\n")
8193 u_char uj
= use_json(argc
, argv
);
8195 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8199 DEFUN (show_ip_bgp_instance_route
,
8200 show_ip_bgp_instance_route_cmd
,
8201 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8205 BGP_INSTANCE_HELP_STR
8206 "Network in the BGP routing table to display\n"
8207 "JavaScript Object Notation\n")
8209 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8212 DEFUN (show_ip_bgp_instance_route_pathtype
,
8213 show_ip_bgp_instance_route_pathtype_cmd
,
8214 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8218 BGP_INSTANCE_HELP_STR
8219 "Network in the BGP routing table to display\n"
8220 "Display only the bestpath\n"
8221 "Display only multipaths\n"
8222 "JavaScript Object Notation\n")
8224 u_char uj
= use_json(argc
, argv
);
8226 if (strncmp (argv
[3], "b", 1) == 0)
8227 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8229 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8232 DEFUN (show_ip_bgp_instance_prefix
,
8233 show_ip_bgp_instance_prefix_cmd
,
8234 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8238 BGP_INSTANCE_HELP_STR
8239 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8240 "JavaScript Object Notation\n")
8242 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8245 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8246 show_ip_bgp_instance_prefix_pathtype_cmd
,
8247 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8251 BGP_INSTANCE_HELP_STR
8252 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8253 "Display only the bestpath\n"
8254 "Display only multipaths\n"
8255 "JavaScript Object Notation\n")
8257 u_char uj
= use_json(argc
, argv
);
8258 if (strncmp (argv
[3], "b", 1) == 0)
8259 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8261 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8270 "JavaScript Object Notation\n")
8272 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8273 NULL
, use_json(argc
, argv
));
8278 "show bgp ipv6 {json}",
8282 "JavaScript Object Notation\n")
8284 DEFUN (show_bgp_ipv6_safi
,
8285 show_bgp_ipv6_safi_cmd
,
8286 "show bgp ipv6 (unicast|multicast) {json}",
8290 "Address Family modifier\n"
8291 "Address Family modifier\n"
8292 "JavaScript Object Notation\n")
8294 u_char uj
= use_json(argc
, argv
);
8295 if (strncmp (argv
[0], "m", 1) == 0)
8296 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8299 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8303 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8305 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8306 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8307 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8311 DEFUN (show_ipv6_bgp
,
8313 "show ipv6 bgp {json}",
8317 "JavaScript Object Notation\n")
8319 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8320 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8321 NULL
, use_json(argc
, argv
));
8324 DEFUN (show_bgp_route
,
8326 "show bgp X:X::X:X {json}",
8329 "Network in the BGP routing table to display\n"
8330 "JavaScript Object Notation\n")
8332 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8335 ALIAS (show_bgp_route
,
8336 show_bgp_ipv6_route_cmd
,
8337 "show bgp ipv6 X:X::X:X {json}",
8341 "Network in the BGP routing table to display\n"
8342 "JavaScript Object Notation\n")
8344 DEFUN (show_bgp_ipv6_safi_route
,
8345 show_bgp_ipv6_safi_route_cmd
,
8346 "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
8350 "Address Family modifier\n"
8351 "Address Family modifier\n"
8352 "Network in the BGP routing table to display\n"
8353 "JavaScript Object Notation\n")
8355 u_char uj
= use_json(argc
, argv
);
8356 if (strncmp (argv
[0], "m", 1) == 0)
8357 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8359 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8362 DEFUN (show_bgp_route_pathtype
,
8363 show_bgp_route_pathtype_cmd
,
8364 "show bgp X:X::X:X (bestpath|multipath) {json}",
8367 "Network in the BGP routing table to display\n"
8368 "Display only the bestpath\n"
8369 "Display only multipaths\n"
8370 "JavaScript Object Notation\n")
8372 u_char uj
= use_json(argc
, argv
);
8373 if (strncmp (argv
[1], "b", 1) == 0)
8374 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8376 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8379 ALIAS (show_bgp_route_pathtype
,
8380 show_bgp_ipv6_route_pathtype_cmd
,
8381 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8385 "Network in the BGP routing table to display\n"
8386 "Display only the bestpath\n"
8387 "Display only multipaths\n"
8388 "JavaScript Object Notation\n")
8390 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8391 show_bgp_ipv6_safi_route_pathtype_cmd
,
8392 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
8396 "Address Family modifier\n"
8397 "Address Family modifier\n"
8398 "Network in the BGP routing table to display\n"
8399 "Display only the bestpath\n"
8400 "Display only multipaths\n"
8401 "JavaScript Object Notation\n")
8403 u_char uj
= use_json(argc
, argv
);
8404 if (strncmp (argv
[0], "m", 1) == 0)
8405 if (strncmp (argv
[2], "b", 1) == 0)
8406 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8408 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8410 if (strncmp (argv
[2], "b", 1) == 0)
8411 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8413 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8417 DEFUN (show_ipv6_bgp_route
,
8418 show_ipv6_bgp_route_cmd
,
8419 "show ipv6 bgp X:X::X:X {json}",
8423 "Network in the BGP routing table to display\n"
8424 "JavaScript Object Notation\n")
8426 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8427 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8430 DEFUN (show_bgp_prefix
,
8431 show_bgp_prefix_cmd
,
8432 "show bgp X:X::X:X/M {json}",
8435 "IPv6 prefix <network>/<length>\n"
8436 "JavaScript Object Notation\n")
8438 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8441 ALIAS (show_bgp_prefix
,
8442 show_bgp_ipv6_prefix_cmd
,
8443 "show bgp ipv6 X:X::X:X/M {json}",
8447 "IPv6 prefix <network>/<length>\n"
8448 "JavaScript Object Notation\n")
8450 DEFUN (show_bgp_ipv6_safi_prefix
,
8451 show_bgp_ipv6_safi_prefix_cmd
,
8452 "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
8456 "Address Family modifier\n"
8457 "Address Family modifier\n"
8458 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8459 "JavaScript Object Notation\n")
8461 u_char uj
= use_json(argc
, argv
);
8462 if (strncmp (argv
[0], "m", 1) == 0)
8463 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8465 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8468 DEFUN (show_bgp_prefix_pathtype
,
8469 show_bgp_prefix_pathtype_cmd
,
8470 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8473 "IPv6 prefix <network>/<length>\n"
8474 "Display only the bestpath\n"
8475 "Display only multipaths\n"
8476 "JavaScript Object Notation\n")
8478 u_char uj
= use_json(argc
, argv
);
8479 if (strncmp (argv
[1], "b", 1) == 0)
8480 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8482 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8485 ALIAS (show_bgp_prefix_pathtype
,
8486 show_bgp_ipv6_prefix_pathtype_cmd
,
8487 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8491 "IPv6 prefix <network>/<length>\n"
8492 "Display only the bestpath\n"
8493 "Display only multipaths\n"
8494 "JavaScript Object Notation\n")
8496 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8497 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8498 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
8502 "Address Family modifier\n"
8503 "Address Family modifier\n"
8504 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8505 "Display only the bestpath\n"
8506 "Display only multipaths\n"
8507 "JavaScript Object Notation\n")
8509 u_char uj
= use_json(argc
, argv
);
8510 if (strncmp (argv
[0], "m", 1) == 0)
8511 if (strncmp (argv
[2], "b", 1) == 0)
8512 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8514 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8516 if (strncmp (argv
[2], "b", 1) == 0)
8517 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8519 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8523 DEFUN (show_ipv6_bgp_prefix
,
8524 show_ipv6_bgp_prefix_cmd
,
8525 "show ipv6 bgp X:X::X:X/M {json}",
8529 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8530 "JavaScript Object Notation\n")
8532 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8533 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8536 DEFUN (show_bgp_view
,
8537 show_bgp_instance_cmd
,
8538 "show bgp " BGP_INSTANCE_CMD
" {json}",
8541 BGP_INSTANCE_HELP_STR
8542 "JavaScript Object Notation\n")
8546 /* BGP structure lookup. */
8547 bgp
= bgp_lookup_by_name (argv
[1]);
8550 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8554 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8557 DEFUN (show_bgp_instance_all
,
8558 show_bgp_instance_all_cmd
,
8559 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8562 BGP_INSTANCE_ALL_HELP_STR
8563 "JavaScript Object Notation\n")
8565 u_char uj
= use_json(argc
, argv
);
8567 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8571 ALIAS (show_bgp_view
,
8572 show_bgp_instance_ipv6_cmd
,
8573 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8576 BGP_INSTANCE_HELP_STR
8578 "JavaScript Object Notation\n")
8580 DEFUN (show_bgp_instance_route
,
8581 show_bgp_instance_route_cmd
,
8582 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8585 BGP_INSTANCE_HELP_STR
8586 "Network in the BGP routing table to display\n"
8587 "JavaScript Object Notation\n")
8589 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8592 ALIAS (show_bgp_instance_route
,
8593 show_bgp_instance_ipv6_route_cmd
,
8594 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8597 BGP_INSTANCE_HELP_STR
8599 "Network in the BGP routing table to display\n"
8600 "JavaScript Object Notation\n")
8602 DEFUN (show_bgp_instance_route_pathtype
,
8603 show_bgp_instance_route_pathtype_cmd
,
8604 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8607 BGP_INSTANCE_HELP_STR
8608 "Network in the BGP routing table to display\n"
8609 "Display only the bestpath\n"
8610 "Display only multipaths\n"
8611 "JavaScript Object Notation\n")
8613 u_char uj
= use_json(argc
, argv
);
8614 if (strncmp (argv
[3], "b", 1) == 0)
8615 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8617 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8620 ALIAS (show_bgp_instance_route_pathtype
,
8621 show_bgp_instance_ipv6_route_pathtype_cmd
,
8622 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
8625 BGP_INSTANCE_HELP_STR
8627 "Network in the BGP routing table to display\n"
8628 "Display only the bestpath\n"
8629 "Display only multipaths\n"
8630 "JavaScript Object Notation\n")
8632 DEFUN (show_bgp_instance_prefix
,
8633 show_bgp_instance_prefix_cmd
,
8634 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
8637 BGP_INSTANCE_HELP_STR
8638 "IPv6 prefix <network>/<length>\n"
8639 "JavaScript Object Notation\n")
8641 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8644 ALIAS (show_bgp_instance_prefix
,
8645 show_bgp_instance_ipv6_prefix_cmd
,
8646 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
8649 BGP_INSTANCE_HELP_STR
8651 "IPv6 prefix <network>/<length>\n"
8652 "JavaScript Object Notation\n")
8654 DEFUN (show_bgp_instance_prefix_pathtype
,
8655 show_bgp_instance_prefix_pathtype_cmd
,
8656 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
8659 BGP_INSTANCE_HELP_STR
8660 "IPv6 prefix <network>/<length>\n"
8661 "Display only the bestpath\n"
8662 "Display only multipaths\n"
8663 "JavaScript Object Notation\n")
8665 u_char uj
= use_json(argc
, argv
);
8666 if (strncmp (argv
[3], "b", 1) == 0)
8667 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8669 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8672 ALIAS (show_bgp_instance_prefix_pathtype
,
8673 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
8674 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8677 BGP_INSTANCE_HELP_STR
8679 "IPv6 prefix <network>/<length>\n"
8680 "Display only the bestpath\n"
8681 "Display only multipaths\n"
8682 "JavaScript Object Notation\n")
8684 DEFUN (show_bgp_instance_prefix_list
,
8685 show_bgp_instance_prefix_list_cmd
,
8686 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
8689 BGP_INSTANCE_HELP_STR
8690 "Display routes conforming to the prefix-list\n"
8691 "IPv6 prefix-list name\n")
8693 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8694 bgp_show_type_prefix_list
);
8697 ALIAS (show_bgp_instance_prefix_list
,
8698 show_bgp_instance_ipv6_prefix_list_cmd
,
8699 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
8702 BGP_INSTANCE_HELP_STR
8704 "Display routes conforming to the prefix-list\n"
8705 "IPv6 prefix-list name\n")
8707 DEFUN (show_bgp_instance_filter_list
,
8708 show_bgp_instance_filter_list_cmd
,
8709 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
8712 BGP_INSTANCE_HELP_STR
8713 "Display routes conforming to the filter-list\n"
8714 "Regular expression access list name\n")
8716 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8717 bgp_show_type_filter_list
);
8720 ALIAS (show_bgp_instance_filter_list
,
8721 show_bgp_instance_ipv6_filter_list_cmd
,
8722 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
8725 BGP_INSTANCE_HELP_STR
8727 "Display routes conforming to the filter-list\n"
8728 "Regular expression access list name\n")
8730 DEFUN (show_bgp_instance_route_map
,
8731 show_bgp_instance_route_map_cmd
,
8732 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
8735 BGP_INSTANCE_HELP_STR
8736 "Display routes matching the route-map\n"
8737 "A route-map to match on\n")
8739 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8740 bgp_show_type_route_map
);
8743 ALIAS (show_bgp_instance_route_map
,
8744 show_bgp_instance_ipv6_route_map_cmd
,
8745 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
8748 BGP_INSTANCE_HELP_STR
8750 "Display routes matching the route-map\n"
8751 "A route-map to match on\n")
8753 DEFUN (show_bgp_instance_community_list
,
8754 show_bgp_instance_community_list_cmd
,
8755 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
8758 BGP_INSTANCE_HELP_STR
8759 "Display routes matching the community-list\n"
8760 "community-list number\n"
8761 "community-list name\n")
8763 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
8766 ALIAS (show_bgp_instance_community_list
,
8767 show_bgp_instance_ipv6_community_list_cmd
,
8768 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
8771 BGP_INSTANCE_HELP_STR
8773 "Display routes matching the community-list\n"
8774 "community-list number\n"
8775 "community-list name\n")
8777 DEFUN (show_bgp_instance_prefix_longer
,
8778 show_bgp_instance_prefix_longer_cmd
,
8779 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
8782 BGP_INSTANCE_HELP_STR
8783 "IPv6 prefix <network>/<length>\n"
8784 "Display route and more specific routes\n")
8786 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
8787 bgp_show_type_prefix_longer
);
8790 ALIAS (show_bgp_instance_prefix_longer
,
8791 show_bgp_instance_ipv6_prefix_longer_cmd
,
8792 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
8795 BGP_INSTANCE_HELP_STR
8797 "IPv6 prefix <network>/<length>\n"
8798 "Display route and more specific routes\n")
8801 DEFUN (show_ipv6_mbgp
,
8803 "show ipv6 mbgp {json}",
8807 "JavaScript Object Notation\n")
8809 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8810 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8811 NULL
, use_json(argc
, argv
));
8815 DEFUN (show_ipv6_mbgp_route
,
8816 show_ipv6_mbgp_route_cmd
,
8817 "show ipv6 mbgp X:X::X:X {json}",
8821 "Network in the MBGP routing table to display\n"
8822 "JavaScript Object Notation\n")
8824 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8825 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8829 DEFUN (show_ipv6_mbgp_prefix
,
8830 show_ipv6_mbgp_prefix_cmd
,
8831 "show ipv6 mbgp X:X::X:X/M {json}",
8835 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8836 "JavaScript Object Notation\n")
8838 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8839 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8845 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
8846 safi_t safi
, enum bgp_show_type type
)
8856 b
= buffer_new (1024);
8857 for (i
= 0; i
< argc
; i
++)
8860 buffer_putc (b
, ' ');
8863 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
8868 buffer_putstr (b
, argv
[i
]);
8870 buffer_putc (b
, '\0');
8872 regstr
= buffer_getstr (b
);
8875 regex
= bgp_regcomp (regstr
);
8876 XFREE(MTYPE_TMP
, regstr
);
8879 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
8884 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
8885 bgp_regex_free (regex
);
8889 DEFUN (show_ip_bgp_regexp
,
8890 show_ip_bgp_regexp_cmd
,
8891 "show ip bgp regexp .LINE",
8895 "Display routes matching the AS path regular expression\n"
8896 "A regular-expression to match the BGP AS paths\n")
8898 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8899 bgp_show_type_regexp
);
8902 DEFUN (show_ip_bgp_flap_regexp
,
8903 show_ip_bgp_flap_regexp_cmd
,
8904 "show ip bgp flap-statistics regexp .LINE",
8908 "Display flap statistics of routes\n"
8909 "Display routes matching the AS path regular expression\n"
8910 "A regular-expression to match the BGP AS paths\n")
8912 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8913 bgp_show_type_flap_regexp
);
8916 ALIAS (show_ip_bgp_flap_regexp
,
8917 show_ip_bgp_damp_flap_regexp_cmd
,
8918 "show ip bgp dampening flap-statistics regexp .LINE",
8922 "Display detailed information about dampening\n"
8923 "Display flap statistics of routes\n"
8924 "Display routes matching the AS path regular expression\n"
8925 "A regular-expression to match the BGP AS paths\n")
8927 DEFUN (show_ip_bgp_ipv4_regexp
,
8928 show_ip_bgp_ipv4_regexp_cmd
,
8929 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
8934 "Address Family modifier\n"
8935 "Address Family modifier\n"
8936 "Display routes matching the AS path regular expression\n"
8937 "A regular-expression to match the BGP AS paths\n")
8939 if (strncmp (argv
[0], "m", 1) == 0)
8940 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
8941 bgp_show_type_regexp
);
8943 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
8944 bgp_show_type_regexp
);
8948 DEFUN (show_bgp_regexp
,
8949 show_bgp_regexp_cmd
,
8950 "show bgp regexp .LINE",
8953 "Display routes matching the AS path regular expression\n"
8954 "A regular-expression to match the BGP AS paths\n")
8956 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
8957 bgp_show_type_regexp
);
8960 ALIAS (show_bgp_regexp
,
8961 show_bgp_ipv6_regexp_cmd
,
8962 "show bgp ipv6 regexp .LINE",
8966 "Display routes matching the AS path regular expression\n"
8967 "A regular-expression to match the BGP AS paths\n")
8970 DEFUN (show_ipv6_bgp_regexp
,
8971 show_ipv6_bgp_regexp_cmd
,
8972 "show ipv6 bgp regexp .LINE",
8976 "Display routes matching the AS path regular expression\n"
8977 "A regular-expression to match the BGP AS paths\n")
8979 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8980 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
8981 bgp_show_type_regexp
);
8985 DEFUN (show_ipv6_mbgp_regexp
,
8986 show_ipv6_mbgp_regexp_cmd
,
8987 "show ipv6 mbgp regexp .LINE",
8991 "Display routes matching the AS path regular expression\n"
8992 "A regular-expression to match the MBGP AS paths\n")
8994 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8995 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
8996 bgp_show_type_regexp
);
8998 #endif /* HAVE_IPV6 */
9001 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9002 const char *prefix_list_str
, afi_t afi
,
9003 safi_t safi
, enum bgp_show_type type
)
9005 struct prefix_list
*plist
;
9006 struct bgp
*bgp
= NULL
;
9008 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9010 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9014 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9017 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9018 prefix_list_str
, VTY_NEWLINE
);
9022 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9025 DEFUN (show_ip_bgp_prefix_list
,
9026 show_ip_bgp_prefix_list_cmd
,
9027 "show ip bgp prefix-list WORD",
9031 "Display routes conforming to the prefix-list\n"
9032 "IP prefix-list name\n")
9034 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9035 bgp_show_type_prefix_list
);
9038 DEFUN (show_ip_bgp_instance_prefix_list
,
9039 show_ip_bgp_instance_prefix_list_cmd
,
9040 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9044 BGP_INSTANCE_HELP_STR
9045 "Display routes conforming to the prefix-list\n"
9046 "IP prefix-list name\n")
9048 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9049 bgp_show_type_prefix_list
);
9052 DEFUN (show_ip_bgp_flap_prefix_list
,
9053 show_ip_bgp_flap_prefix_list_cmd
,
9054 "show ip bgp flap-statistics prefix-list WORD",
9058 "Display flap statistics of routes\n"
9059 "Display routes conforming to the prefix-list\n"
9060 "IP prefix-list name\n")
9062 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9063 bgp_show_type_flap_prefix_list
);
9066 ALIAS (show_ip_bgp_flap_prefix_list
,
9067 show_ip_bgp_damp_flap_prefix_list_cmd
,
9068 "show ip bgp dampening flap-statistics prefix-list WORD",
9072 "Display detailed information about dampening\n"
9073 "Display flap statistics of routes\n"
9074 "Display routes conforming to the prefix-list\n"
9075 "IP prefix-list name\n")
9077 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9078 show_ip_bgp_ipv4_prefix_list_cmd
,
9079 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
9084 "Address Family modifier\n"
9085 "Address Family modifier\n"
9086 "Display routes conforming to the prefix-list\n"
9087 "IP prefix-list name\n")
9089 if (strncmp (argv
[0], "m", 1) == 0)
9090 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9091 bgp_show_type_prefix_list
);
9093 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9094 bgp_show_type_prefix_list
);
9098 DEFUN (show_bgp_prefix_list
,
9099 show_bgp_prefix_list_cmd
,
9100 "show bgp prefix-list WORD",
9103 "Display routes conforming to the prefix-list\n"
9104 "IPv6 prefix-list name\n")
9106 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9107 bgp_show_type_prefix_list
);
9110 ALIAS (show_bgp_prefix_list
,
9111 show_bgp_ipv6_prefix_list_cmd
,
9112 "show bgp ipv6 prefix-list WORD",
9116 "Display routes conforming to the prefix-list\n"
9117 "IPv6 prefix-list name\n")
9120 DEFUN (show_ipv6_bgp_prefix_list
,
9121 show_ipv6_bgp_prefix_list_cmd
,
9122 "show ipv6 bgp prefix-list WORD",
9126 "Display routes matching the prefix-list\n"
9127 "IPv6 prefix-list name\n")
9129 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9130 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9131 bgp_show_type_prefix_list
);
9135 DEFUN (show_ipv6_mbgp_prefix_list
,
9136 show_ipv6_mbgp_prefix_list_cmd
,
9137 "show ipv6 mbgp prefix-list WORD",
9141 "Display routes matching the prefix-list\n"
9142 "IPv6 prefix-list name\n")
9144 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9145 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9146 bgp_show_type_prefix_list
);
9148 #endif /* HAVE_IPV6 */
9151 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9152 const char *filter
, afi_t afi
,
9153 safi_t safi
, enum bgp_show_type type
)
9155 struct as_list
*as_list
;
9156 struct bgp
*bgp
= NULL
;
9158 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9160 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9164 as_list
= as_list_lookup (filter
);
9165 if (as_list
== NULL
)
9167 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9171 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9174 DEFUN (show_ip_bgp_filter_list
,
9175 show_ip_bgp_filter_list_cmd
,
9176 "show ip bgp filter-list WORD",
9180 "Display routes conforming to the filter-list\n"
9181 "Regular expression access list name\n")
9183 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9184 bgp_show_type_filter_list
);
9187 DEFUN (show_ip_bgp_instance_filter_list
,
9188 show_ip_bgp_instance_filter_list_cmd
,
9189 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9193 BGP_INSTANCE_HELP_STR
9194 "Display routes conforming to the filter-list\n"
9195 "Regular expression access list name\n")
9197 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9198 bgp_show_type_filter_list
);
9201 DEFUN (show_ip_bgp_flap_filter_list
,
9202 show_ip_bgp_flap_filter_list_cmd
,
9203 "show ip bgp flap-statistics filter-list WORD",
9207 "Display flap statistics of routes\n"
9208 "Display routes conforming to the filter-list\n"
9209 "Regular expression access list name\n")
9211 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9212 bgp_show_type_flap_filter_list
);
9215 ALIAS (show_ip_bgp_flap_filter_list
,
9216 show_ip_bgp_damp_flap_filter_list_cmd
,
9217 "show ip bgp dampening flap-statistics filter-list WORD",
9221 "Display detailed information about dampening\n"
9222 "Display flap statistics of routes\n"
9223 "Display routes conforming to the filter-list\n"
9224 "Regular expression access list name\n")
9226 DEFUN (show_ip_bgp_ipv4_filter_list
,
9227 show_ip_bgp_ipv4_filter_list_cmd
,
9228 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9233 "Address Family modifier\n"
9234 "Address Family modifier\n"
9235 "Display routes conforming to the filter-list\n"
9236 "Regular expression access list name\n")
9238 if (strncmp (argv
[0], "m", 1) == 0)
9239 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9240 bgp_show_type_filter_list
);
9242 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9243 bgp_show_type_filter_list
);
9247 DEFUN (show_bgp_filter_list
,
9248 show_bgp_filter_list_cmd
,
9249 "show bgp filter-list WORD",
9252 "Display routes conforming to the filter-list\n"
9253 "Regular expression access list name\n")
9255 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9256 bgp_show_type_filter_list
);
9259 ALIAS (show_bgp_filter_list
,
9260 show_bgp_ipv6_filter_list_cmd
,
9261 "show bgp ipv6 filter-list WORD",
9265 "Display routes conforming to the filter-list\n"
9266 "Regular expression access list name\n")
9269 DEFUN (show_ipv6_bgp_filter_list
,
9270 show_ipv6_bgp_filter_list_cmd
,
9271 "show ipv6 bgp filter-list WORD",
9275 "Display routes conforming to the filter-list\n"
9276 "Regular expression access list name\n")
9278 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9279 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9280 bgp_show_type_filter_list
);
9284 DEFUN (show_ipv6_mbgp_filter_list
,
9285 show_ipv6_mbgp_filter_list_cmd
,
9286 "show ipv6 mbgp filter-list WORD",
9290 "Display routes conforming to the filter-list\n"
9291 "Regular expression access list name\n")
9293 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9294 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9295 bgp_show_type_filter_list
);
9297 #endif /* HAVE_IPV6 */
9299 DEFUN (show_ip_bgp_dampening_info
,
9300 show_ip_bgp_dampening_params_cmd
,
9301 "show ip bgp dampening parameters",
9305 "Display detailed information about dampening\n"
9306 "Display detail of configured dampening parameters\n")
9308 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9312 bgp_show_route_map (struct vty
*vty
, const char *name
,
9313 const char *rmap_str
, afi_t afi
,
9314 safi_t safi
, enum bgp_show_type type
)
9316 struct route_map
*rmap
;
9317 struct bgp
*bgp
= NULL
;
9319 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9321 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9325 rmap
= route_map_lookup_by_name (rmap_str
);
9328 vty_out (vty
, "%% %s is not a valid route-map name%s",
9329 rmap_str
, VTY_NEWLINE
);
9333 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9336 DEFUN (show_ip_bgp_route_map
,
9337 show_ip_bgp_route_map_cmd
,
9338 "show ip bgp route-map WORD",
9342 "Display routes matching the route-map\n"
9343 "A route-map to match on\n")
9345 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9346 bgp_show_type_route_map
);
9349 DEFUN (show_ip_bgp_instance_route_map
,
9350 show_ip_bgp_instance_route_map_cmd
,
9351 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9355 BGP_INSTANCE_HELP_STR
9356 "Display routes matching the route-map\n"
9357 "A route-map to match on\n")
9359 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9360 bgp_show_type_route_map
);
9363 DEFUN (show_ip_bgp_flap_route_map
,
9364 show_ip_bgp_flap_route_map_cmd
,
9365 "show ip bgp flap-statistics route-map WORD",
9369 "Display flap statistics of routes\n"
9370 "Display routes matching the route-map\n"
9371 "A route-map to match on\n")
9373 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9374 bgp_show_type_flap_route_map
);
9377 ALIAS (show_ip_bgp_flap_route_map
,
9378 show_ip_bgp_damp_flap_route_map_cmd
,
9379 "show ip bgp dampening flap-statistics route-map WORD",
9383 "Display detailed information about dampening\n"
9384 "Display flap statistics of routes\n"
9385 "Display routes matching the route-map\n"
9386 "A route-map to match on\n")
9388 DEFUN (show_ip_bgp_ipv4_route_map
,
9389 show_ip_bgp_ipv4_route_map_cmd
,
9390 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9395 "Address Family modifier\n"
9396 "Address Family modifier\n"
9397 "Display routes matching the route-map\n"
9398 "A route-map to match on\n")
9400 if (strncmp (argv
[0], "m", 1) == 0)
9401 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9402 bgp_show_type_route_map
);
9404 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9405 bgp_show_type_route_map
);
9408 DEFUN (show_bgp_route_map
,
9409 show_bgp_route_map_cmd
,
9410 "show bgp route-map WORD",
9413 "Display routes matching the route-map\n"
9414 "A route-map to match on\n")
9416 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9417 bgp_show_type_route_map
);
9420 ALIAS (show_bgp_route_map
,
9421 show_bgp_ipv6_route_map_cmd
,
9422 "show bgp ipv6 route-map WORD",
9426 "Display routes matching the route-map\n"
9427 "A route-map to match on\n")
9429 DEFUN (show_ip_bgp_cidr_only
,
9430 show_ip_bgp_cidr_only_cmd
,
9431 "show ip bgp cidr-only",
9435 "Display only routes with non-natural netmasks\n")
9437 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9438 bgp_show_type_cidr_only
, NULL
, 0);
9441 DEFUN (show_ip_bgp_flap_cidr_only
,
9442 show_ip_bgp_flap_cidr_only_cmd
,
9443 "show ip bgp flap-statistics cidr-only",
9447 "Display flap statistics of routes\n"
9448 "Display only routes with non-natural netmasks\n")
9450 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9451 bgp_show_type_flap_cidr_only
, NULL
, 0);
9454 ALIAS (show_ip_bgp_flap_cidr_only
,
9455 show_ip_bgp_damp_flap_cidr_only_cmd
,
9456 "show ip bgp dampening flap-statistics cidr-only",
9460 "Display detailed information about dampening\n"
9461 "Display flap statistics of routes\n"
9462 "Display only routes with non-natural netmasks\n")
9464 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9465 show_ip_bgp_ipv4_cidr_only_cmd
,
9466 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9471 "Address Family modifier\n"
9472 "Address Family modifier\n"
9473 "Display only routes with non-natural netmasks\n")
9475 if (strncmp (argv
[0], "m", 1) == 0)
9476 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9477 bgp_show_type_cidr_only
, NULL
, 0);
9479 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9480 bgp_show_type_cidr_only
, NULL
, 0);
9483 DEFUN (show_ip_bgp_community_all
,
9484 show_ip_bgp_community_all_cmd
,
9485 "show ip bgp community",
9489 "Display routes matching the communities\n")
9491 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9492 bgp_show_type_community_all
, NULL
, 0);
9495 DEFUN (show_ip_bgp_ipv4_community_all
,
9496 show_ip_bgp_ipv4_community_all_cmd
,
9497 "show ip bgp ipv4 (unicast|multicast) community",
9502 "Address Family modifier\n"
9503 "Address Family modifier\n"
9504 "Display routes matching the communities\n")
9506 if (strncmp (argv
[0], "m", 1) == 0)
9507 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9508 bgp_show_type_community_all
, NULL
, 0);
9510 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9511 bgp_show_type_community_all
, NULL
, 0);
9515 DEFUN (show_bgp_community_all
,
9516 show_bgp_community_all_cmd
,
9517 "show bgp community",
9520 "Display routes matching the communities\n")
9522 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9523 bgp_show_type_community_all
, NULL
, 0);
9526 ALIAS (show_bgp_community_all
,
9527 show_bgp_ipv6_community_all_cmd
,
9528 "show bgp ipv6 community",
9532 "Display routes matching the communities\n")
9535 DEFUN (show_ipv6_bgp_community_all
,
9536 show_ipv6_bgp_community_all_cmd
,
9537 "show ipv6 bgp community",
9541 "Display routes matching the communities\n")
9543 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9544 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9545 bgp_show_type_community_all
, NULL
, 0);
9549 DEFUN (show_ipv6_mbgp_community_all
,
9550 show_ipv6_mbgp_community_all_cmd
,
9551 "show ipv6 mbgp community",
9555 "Display routes matching the communities\n")
9557 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9558 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9559 bgp_show_type_community_all
, NULL
, 0);
9561 #endif /* HAVE_IPV6 */
9564 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9565 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9567 struct community
*com
;
9574 /* BGP structure lookup */
9577 bgp
= bgp_lookup_by_name (view_name
);
9580 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
9586 bgp
= bgp_get_default ();
9589 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9594 b
= buffer_new (1024);
9595 for (i
= 0; i
< argc
; i
++)
9598 buffer_putc (b
, ' ');
9601 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9606 buffer_putstr (b
, argv
[i
]);
9608 buffer_putc (b
, '\0');
9610 str
= buffer_getstr (b
);
9613 com
= community_str2com (str
);
9614 XFREE (MTYPE_TMP
, str
);
9617 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
9621 return bgp_show (vty
, bgp
, afi
, safi
,
9622 (exact
? bgp_show_type_community_exact
:
9623 bgp_show_type_community
), com
, 0);
9626 DEFUN (show_ip_bgp_community
,
9627 show_ip_bgp_community_cmd
,
9628 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9632 "Display routes matching the communities\n"
9634 "Do not send outside local AS (well-known community)\n"
9635 "Do not advertise to any peer (well-known community)\n"
9636 "Do not export to next AS (well-known community)\n")
9638 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9641 ALIAS (show_ip_bgp_community
,
9642 show_ip_bgp_community2_cmd
,
9643 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9647 "Display routes matching the communities\n"
9649 "Do not send outside local AS (well-known community)\n"
9650 "Do not advertise to any peer (well-known community)\n"
9651 "Do not export to next AS (well-known community)\n"
9653 "Do not send outside local AS (well-known community)\n"
9654 "Do not advertise to any peer (well-known community)\n"
9655 "Do not export to next AS (well-known community)\n")
9657 ALIAS (show_ip_bgp_community
,
9658 show_ip_bgp_community3_cmd
,
9659 "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)",
9663 "Display routes matching the communities\n"
9665 "Do not send outside local AS (well-known community)\n"
9666 "Do not advertise to any peer (well-known community)\n"
9667 "Do not export to next AS (well-known community)\n"
9669 "Do not send outside local AS (well-known community)\n"
9670 "Do not advertise to any peer (well-known community)\n"
9671 "Do not export to next AS (well-known community)\n"
9673 "Do not send outside local AS (well-known community)\n"
9674 "Do not advertise to any peer (well-known community)\n"
9675 "Do not export to next AS (well-known community)\n")
9677 ALIAS (show_ip_bgp_community
,
9678 show_ip_bgp_community4_cmd
,
9679 "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)",
9683 "Display routes matching the communities\n"
9685 "Do not send outside local AS (well-known community)\n"
9686 "Do not advertise to any peer (well-known community)\n"
9687 "Do not export to next AS (well-known community)\n"
9689 "Do not send outside local AS (well-known community)\n"
9690 "Do not advertise to any peer (well-known community)\n"
9691 "Do not export to next AS (well-known community)\n"
9693 "Do not send outside local AS (well-known community)\n"
9694 "Do not advertise to any peer (well-known community)\n"
9695 "Do not export to next AS (well-known community)\n"
9697 "Do not send outside local AS (well-known community)\n"
9698 "Do not advertise to any peer (well-known community)\n"
9699 "Do not export to next AS (well-known community)\n")
9701 DEFUN (show_ip_bgp_ipv4_community
,
9702 show_ip_bgp_ipv4_community_cmd
,
9703 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9708 "Address Family modifier\n"
9709 "Address Family modifier\n"
9710 "Display routes matching the communities\n"
9712 "Do not send outside local AS (well-known community)\n"
9713 "Do not advertise to any peer (well-known community)\n"
9714 "Do not export to next AS (well-known community)\n")
9716 if (strncmp (argv
[0], "m", 1) == 0)
9717 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
9719 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9722 ALIAS (show_ip_bgp_ipv4_community
,
9723 show_ip_bgp_ipv4_community2_cmd
,
9724 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
9729 "Address Family modifier\n"
9730 "Address Family modifier\n"
9731 "Display routes matching the communities\n"
9733 "Do not send outside local AS (well-known community)\n"
9734 "Do not advertise to any peer (well-known community)\n"
9735 "Do not export to next AS (well-known community)\n"
9737 "Do not send outside local AS (well-known community)\n"
9738 "Do not advertise to any peer (well-known community)\n"
9739 "Do not export to next AS (well-known community)\n")
9741 ALIAS (show_ip_bgp_ipv4_community
,
9742 show_ip_bgp_ipv4_community3_cmd
,
9743 "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)",
9748 "Address Family modifier\n"
9749 "Address Family modifier\n"
9750 "Display routes matching the communities\n"
9752 "Do not send outside local AS (well-known community)\n"
9753 "Do not advertise to any peer (well-known community)\n"
9754 "Do not export to next AS (well-known community)\n"
9756 "Do not send outside local AS (well-known community)\n"
9757 "Do not advertise to any peer (well-known community)\n"
9758 "Do not export to next AS (well-known community)\n"
9760 "Do not send outside local AS (well-known community)\n"
9761 "Do not advertise to any peer (well-known community)\n"
9762 "Do not export to next AS (well-known community)\n")
9764 ALIAS (show_ip_bgp_ipv4_community
,
9765 show_ip_bgp_ipv4_community4_cmd
,
9766 "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)",
9771 "Address Family modifier\n"
9772 "Address Family modifier\n"
9773 "Display routes matching the communities\n"
9775 "Do not send outside local AS (well-known community)\n"
9776 "Do not advertise to any peer (well-known community)\n"
9777 "Do not export to next AS (well-known community)\n"
9779 "Do not send outside local AS (well-known community)\n"
9780 "Do not advertise to any peer (well-known community)\n"
9781 "Do not export to next AS (well-known community)\n"
9783 "Do not send outside local AS (well-known community)\n"
9784 "Do not advertise to any peer (well-known community)\n"
9785 "Do not export to next AS (well-known community)\n"
9787 "Do not send outside local AS (well-known community)\n"
9788 "Do not advertise to any peer (well-known community)\n"
9789 "Do not export to next AS (well-known community)\n")
9791 DEFUN (show_bgp_instance_afi_safi_community_all
,
9792 show_bgp_instance_afi_safi_community_all_cmd
,
9793 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
9796 BGP_INSTANCE_HELP_STR
9799 "Address Family modifier\n"
9800 "Address Family modifier\n"
9801 "Display routes matching the communities\n")
9807 /* BGP structure lookup. */
9808 bgp
= bgp_lookup_by_name (argv
[1]);
9811 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
9815 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9816 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9817 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
9820 DEFUN (show_bgp_instance_afi_safi_community
,
9821 show_bgp_instance_afi_safi_community_cmd
,
9822 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
9825 BGP_INSTANCE_HELP_STR
9828 "Address family modifier\n"
9829 "Address family modifier\n"
9830 "Display routes matching the communities\n"
9832 "Do not send outside local AS (well-known community)\n"
9833 "Do not advertise to any peer (well-known community)\n"
9834 "Do not export to next AS (well-known community)\n")
9839 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
9840 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
9841 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
9844 ALIAS (show_bgp_instance_afi_safi_community
,
9845 show_bgp_instance_afi_safi_community2_cmd
,
9846 "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)",
9849 BGP_INSTANCE_HELP_STR
9852 "Address family modifier\n"
9853 "Address family modifier\n"
9854 "Display routes matching the communities\n"
9856 "Do not send outside local AS (well-known community)\n"
9857 "Do not advertise to any peer (well-known community)\n"
9858 "Do not export to next AS (well-known community)\n"
9860 "Do not send outside local AS (well-known community)\n"
9861 "Do not advertise to any peer (well-known community)\n"
9862 "Do not export to next AS (well-known community)\n")
9864 ALIAS (show_bgp_instance_afi_safi_community
,
9865 show_bgp_instance_afi_safi_community3_cmd
,
9866 "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)",
9869 BGP_INSTANCE_HELP_STR
9872 "Address family modifier\n"
9873 "Address family modifier\n"
9874 "Display routes matching the communities\n"
9876 "Do not send outside local AS (well-known community)\n"
9877 "Do not advertise to any peer (well-known community)\n"
9878 "Do not export to next AS (well-known community)\n"
9880 "Do not send outside local AS (well-known community)\n"
9881 "Do not advertise to any peer (well-known community)\n"
9882 "Do not export to next AS (well-known community)\n"
9884 "Do not send outside local AS (well-known community)\n"
9885 "Do not advertise to any peer (well-known community)\n"
9886 "Do not export to next AS (well-known community)\n")
9888 ALIAS (show_bgp_instance_afi_safi_community
,
9889 show_bgp_instance_afi_safi_community4_cmd
,
9890 "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)",
9893 BGP_INSTANCE_HELP_STR
9896 "Address family modifier\n"
9897 "Address family modifier\n"
9898 "Display routes matching the communities\n"
9900 "Do not send outside local AS (well-known community)\n"
9901 "Do not advertise to any peer (well-known community)\n"
9902 "Do not export to next AS (well-known community)\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 "Do not send outside local AS (well-known community)\n"
9909 "Do not advertise to any peer (well-known community)\n"
9910 "Do not export to next AS (well-known community)\n"
9912 "Do not send outside local AS (well-known community)\n"
9913 "Do not advertise to any peer (well-known community)\n"
9914 "Do not export to next AS (well-known community)\n")
9916 DEFUN (show_ip_bgp_community_exact
,
9917 show_ip_bgp_community_exact_cmd
,
9918 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
9922 "Display routes matching the communities\n"
9924 "Do not send outside local AS (well-known community)\n"
9925 "Do not advertise to any peer (well-known community)\n"
9926 "Do not export to next AS (well-known community)\n"
9927 "Exact match of the communities")
9929 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
9932 ALIAS (show_ip_bgp_community_exact
,
9933 show_ip_bgp_community2_exact_cmd
,
9934 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
9938 "Display routes matching the communities\n"
9940 "Do not send outside local AS (well-known community)\n"
9941 "Do not advertise to any peer (well-known community)\n"
9942 "Do not export to next AS (well-known community)\n"
9944 "Do not send outside local AS (well-known community)\n"
9945 "Do not advertise to any peer (well-known community)\n"
9946 "Do not export to next AS (well-known community)\n"
9947 "Exact match of the communities")
9949 ALIAS (show_ip_bgp_community_exact
,
9950 show_ip_bgp_community3_exact_cmd
,
9951 "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",
9955 "Display routes matching the communities\n"
9957 "Do not send outside local AS (well-known community)\n"
9958 "Do not advertise to any peer (well-known community)\n"
9959 "Do not export to next AS (well-known community)\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"
9968 "Exact match of the communities")
9970 ALIAS (show_ip_bgp_community_exact
,
9971 show_ip_bgp_community4_exact_cmd
,
9972 "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",
9976 "Display routes matching the communities\n"
9978 "Do not send outside local AS (well-known community)\n"
9979 "Do not advertise to any peer (well-known community)\n"
9980 "Do not export to next AS (well-known community)\n"
9982 "Do not send outside local AS (well-known community)\n"
9983 "Do not advertise to any peer (well-known community)\n"
9984 "Do not export to next AS (well-known community)\n"
9986 "Do not send outside local AS (well-known community)\n"
9987 "Do not advertise to any peer (well-known community)\n"
9988 "Do not export to next AS (well-known community)\n"
9990 "Do not send outside local AS (well-known community)\n"
9991 "Do not advertise to any peer (well-known community)\n"
9992 "Do not export to next AS (well-known community)\n"
9993 "Exact match of the communities")
9995 DEFUN (show_ip_bgp_ipv4_community_exact
,
9996 show_ip_bgp_ipv4_community_exact_cmd
,
9997 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10002 "Address Family modifier\n"
10003 "Address Family modifier\n"
10004 "Display routes matching the communities\n"
10006 "Do not send outside local AS (well-known community)\n"
10007 "Do not advertise to any peer (well-known community)\n"
10008 "Do not export to next AS (well-known community)\n"
10009 "Exact match of the communities")
10011 if (strncmp (argv
[0], "m", 1) == 0)
10012 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
10014 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10017 ALIAS (show_ip_bgp_ipv4_community_exact
,
10018 show_ip_bgp_ipv4_community2_exact_cmd
,
10019 "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",
10024 "Address Family modifier\n"
10025 "Address Family modifier\n"
10026 "Display routes matching the communities\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"
10035 "Exact match of the communities")
10037 ALIAS (show_ip_bgp_ipv4_community_exact
,
10038 show_ip_bgp_ipv4_community3_exact_cmd
,
10039 "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",
10044 "Address Family modifier\n"
10045 "Address Family modifier\n"
10046 "Display routes matching the communities\n"
10048 "Do not send outside local AS (well-known community)\n"
10049 "Do not advertise to any peer (well-known community)\n"
10050 "Do not export to next AS (well-known community)\n"
10052 "Do not send outside local AS (well-known community)\n"
10053 "Do not advertise to any peer (well-known community)\n"
10054 "Do not export to next AS (well-known community)\n"
10056 "Do not send outside local AS (well-known community)\n"
10057 "Do not advertise to any peer (well-known community)\n"
10058 "Do not export to next AS (well-known community)\n"
10059 "Exact match of the communities")
10061 ALIAS (show_ip_bgp_ipv4_community_exact
,
10062 show_ip_bgp_ipv4_community4_exact_cmd
,
10063 "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",
10068 "Address Family modifier\n"
10069 "Address Family modifier\n"
10070 "Display routes matching the communities\n"
10072 "Do not send outside local AS (well-known community)\n"
10073 "Do not advertise to any peer (well-known community)\n"
10074 "Do not export to next AS (well-known community)\n"
10076 "Do not send outside local AS (well-known community)\n"
10077 "Do not advertise to any peer (well-known community)\n"
10078 "Do not export to next AS (well-known community)\n"
10080 "Do not send outside local AS (well-known community)\n"
10081 "Do not advertise to any peer (well-known community)\n"
10082 "Do not export to next AS (well-known community)\n"
10084 "Do not send outside local AS (well-known community)\n"
10085 "Do not advertise to any peer (well-known community)\n"
10086 "Do not export to next AS (well-known community)\n"
10087 "Exact match of the communities")
10090 DEFUN (show_bgp_community
,
10091 show_bgp_community_cmd
,
10092 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10095 "Display routes matching the communities\n"
10097 "Do not send outside local AS (well-known community)\n"
10098 "Do not advertise to any peer (well-known community)\n"
10099 "Do not export to next AS (well-known community)\n")
10101 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10104 ALIAS (show_bgp_community
,
10105 show_bgp_ipv6_community_cmd
,
10106 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10110 "Display routes matching the communities\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 ALIAS (show_bgp_community
,
10117 show_bgp_community2_cmd
,
10118 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10121 "Display routes matching the communities\n"
10123 "Do not send outside local AS (well-known community)\n"
10124 "Do not advertise to any peer (well-known community)\n"
10125 "Do not export to next AS (well-known community)\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")
10131 ALIAS (show_bgp_community
,
10132 show_bgp_ipv6_community2_cmd
,
10133 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10137 "Display routes matching the communities\n"
10139 "Do not send outside local AS (well-known community)\n"
10140 "Do not advertise to any peer (well-known community)\n"
10141 "Do not export to next AS (well-known community)\n"
10143 "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")
10147 ALIAS (show_bgp_community
,
10148 show_bgp_community3_cmd
,
10149 "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)",
10152 "Display routes matching the communities\n"
10154 "Do not send outside local AS (well-known community)\n"
10155 "Do not advertise to any peer (well-known community)\n"
10156 "Do not export to next AS (well-known community)\n"
10158 "Do not send outside local AS (well-known community)\n"
10159 "Do not advertise to any peer (well-known community)\n"
10160 "Do not export to next AS (well-known community)\n"
10162 "Do not send outside local AS (well-known community)\n"
10163 "Do not advertise to any peer (well-known community)\n"
10164 "Do not export to next AS (well-known community)\n")
10166 ALIAS (show_bgp_community
,
10167 show_bgp_ipv6_community3_cmd
,
10168 "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)",
10172 "Display routes matching the communities\n"
10174 "Do not send outside local AS (well-known community)\n"
10175 "Do not advertise to any peer (well-known community)\n"
10176 "Do not export to next AS (well-known community)\n"
10178 "Do not send outside local AS (well-known community)\n"
10179 "Do not advertise to any peer (well-known community)\n"
10180 "Do not export to next AS (well-known community)\n"
10182 "Do not send outside local AS (well-known community)\n"
10183 "Do not advertise to any peer (well-known community)\n"
10184 "Do not export to next AS (well-known community)\n")
10186 ALIAS (show_bgp_community
,
10187 show_bgp_community4_cmd
,
10188 "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)",
10191 "Display routes matching the communities\n"
10193 "Do not send outside local AS (well-known community)\n"
10194 "Do not advertise to any peer (well-known community)\n"
10195 "Do not export to next AS (well-known community)\n"
10197 "Do not send outside local AS (well-known community)\n"
10198 "Do not advertise to any peer (well-known community)\n"
10199 "Do not export to next AS (well-known community)\n"
10201 "Do not send outside local AS (well-known community)\n"
10202 "Do not advertise to any peer (well-known community)\n"
10203 "Do not export to next AS (well-known community)\n"
10205 "Do not send outside local AS (well-known community)\n"
10206 "Do not advertise to any peer (well-known community)\n"
10207 "Do not export to next AS (well-known community)\n")
10209 ALIAS (show_bgp_community
,
10210 show_bgp_ipv6_community4_cmd
,
10211 "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)",
10215 "Display routes matching the communities\n"
10217 "Do not send outside local AS (well-known community)\n"
10218 "Do not advertise to any peer (well-known community)\n"
10219 "Do not export to next AS (well-known community)\n"
10221 "Do not send outside local AS (well-known community)\n"
10222 "Do not advertise to any peer (well-known community)\n"
10223 "Do not export to next AS (well-known community)\n"
10225 "Do not send outside local AS (well-known community)\n"
10226 "Do not advertise to any peer (well-known community)\n"
10227 "Do not export to next AS (well-known community)\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")
10234 DEFUN (show_ipv6_bgp_community
,
10235 show_ipv6_bgp_community_cmd
,
10236 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10240 "Display routes matching the communities\n"
10242 "Do not send outside local AS (well-known community)\n"
10243 "Do not advertise to any peer (well-known community)\n"
10244 "Do not export to next AS (well-known community)\n")
10246 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10247 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10251 ALIAS (show_ipv6_bgp_community
,
10252 show_ipv6_bgp_community2_cmd
,
10253 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10257 "Display routes matching the communities\n"
10259 "Do not send outside local AS (well-known community)\n"
10260 "Do not advertise to any peer (well-known community)\n"
10261 "Do not export to next AS (well-known community)\n"
10263 "Do not send outside local AS (well-known community)\n"
10264 "Do not advertise to any peer (well-known community)\n"
10265 "Do not export to next AS (well-known community)\n")
10268 ALIAS (show_ipv6_bgp_community
,
10269 show_ipv6_bgp_community3_cmd
,
10270 "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)",
10274 "Display routes matching the communities\n"
10276 "Do not send outside local AS (well-known community)\n"
10277 "Do not advertise to any peer (well-known community)\n"
10278 "Do not export to next AS (well-known community)\n"
10280 "Do not send outside local AS (well-known community)\n"
10281 "Do not advertise to any peer (well-known community)\n"
10282 "Do not export to next AS (well-known community)\n"
10284 "Do not send outside local AS (well-known community)\n"
10285 "Do not advertise to any peer (well-known community)\n"
10286 "Do not export to next AS (well-known community)\n")
10289 ALIAS (show_ipv6_bgp_community
,
10290 show_ipv6_bgp_community4_cmd
,
10291 "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)",
10295 "Display routes matching the communities\n"
10297 "Do not send outside local AS (well-known community)\n"
10298 "Do not advertise to any peer (well-known community)\n"
10299 "Do not export to next AS (well-known community)\n"
10301 "Do not send outside local AS (well-known community)\n"
10302 "Do not advertise to any peer (well-known community)\n"
10303 "Do not export to next AS (well-known community)\n"
10305 "Do not send outside local AS (well-known community)\n"
10306 "Do not advertise to any peer (well-known community)\n"
10307 "Do not export to next AS (well-known community)\n"
10309 "Do not send outside local AS (well-known community)\n"
10310 "Do not advertise to any peer (well-known community)\n"
10311 "Do not export to next AS (well-known community)\n")
10313 DEFUN (show_bgp_community_exact
,
10314 show_bgp_community_exact_cmd
,
10315 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10318 "Display routes matching the communities\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"
10323 "Exact match of the communities")
10325 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10328 ALIAS (show_bgp_community_exact
,
10329 show_bgp_ipv6_community_exact_cmd
,
10330 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10334 "Display routes matching the communities\n"
10336 "Do not send outside local AS (well-known community)\n"
10337 "Do not advertise to any peer (well-known community)\n"
10338 "Do not export to next AS (well-known community)\n"
10339 "Exact match of the communities")
10341 ALIAS (show_bgp_community_exact
,
10342 show_bgp_community2_exact_cmd
,
10343 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10346 "Display routes matching the communities\n"
10348 "Do not send outside local AS (well-known community)\n"
10349 "Do not advertise to any peer (well-known community)\n"
10350 "Do not export to next AS (well-known community)\n"
10352 "Do not send outside local AS (well-known community)\n"
10353 "Do not advertise to any peer (well-known community)\n"
10354 "Do not export to next AS (well-known community)\n"
10355 "Exact match of the communities")
10357 ALIAS (show_bgp_community_exact
,
10358 show_bgp_ipv6_community2_exact_cmd
,
10359 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10363 "Display routes matching the communities\n"
10365 "Do not send outside local AS (well-known community)\n"
10366 "Do not advertise to any peer (well-known community)\n"
10367 "Do not export to next AS (well-known community)\n"
10369 "Do not send outside local AS (well-known community)\n"
10370 "Do not advertise to any peer (well-known community)\n"
10371 "Do not export to next AS (well-known community)\n"
10372 "Exact match of the communities")
10374 ALIAS (show_bgp_community_exact
,
10375 show_bgp_community3_exact_cmd
,
10376 "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",
10379 "Display routes matching the communities\n"
10381 "Do not send outside local AS (well-known community)\n"
10382 "Do not advertise to any peer (well-known community)\n"
10383 "Do not export to next AS (well-known community)\n"
10385 "Do not send outside local AS (well-known community)\n"
10386 "Do not advertise to any peer (well-known community)\n"
10387 "Do not export to next AS (well-known community)\n"
10389 "Do not send outside local AS (well-known community)\n"
10390 "Do not advertise to any peer (well-known community)\n"
10391 "Do not export to next AS (well-known community)\n"
10392 "Exact match of the communities")
10394 ALIAS (show_bgp_community_exact
,
10395 show_bgp_ipv6_community3_exact_cmd
,
10396 "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",
10400 "Display routes matching the communities\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"
10410 "Do not send outside local AS (well-known community)\n"
10411 "Do not advertise to any peer (well-known community)\n"
10412 "Do not export to next AS (well-known community)\n"
10413 "Exact match of the communities")
10415 ALIAS (show_bgp_community_exact
,
10416 show_bgp_community4_exact_cmd
,
10417 "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",
10420 "Display routes matching the communities\n"
10422 "Do not send outside local AS (well-known community)\n"
10423 "Do not advertise to any peer (well-known community)\n"
10424 "Do not export to next AS (well-known community)\n"
10426 "Do not send outside local AS (well-known community)\n"
10427 "Do not advertise to any peer (well-known community)\n"
10428 "Do not export to next AS (well-known community)\n"
10430 "Do not send outside local AS (well-known community)\n"
10431 "Do not advertise to any peer (well-known community)\n"
10432 "Do not export to next AS (well-known community)\n"
10434 "Do not send outside local AS (well-known community)\n"
10435 "Do not advertise to any peer (well-known community)\n"
10436 "Do not export to next AS (well-known community)\n"
10437 "Exact match of the communities")
10439 ALIAS (show_bgp_community_exact
,
10440 show_bgp_ipv6_community4_exact_cmd
,
10441 "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",
10445 "Display routes matching the communities\n"
10447 "Do not send outside local AS (well-known community)\n"
10448 "Do not advertise to any peer (well-known community)\n"
10449 "Do not export to next AS (well-known community)\n"
10451 "Do not send outside local AS (well-known community)\n"
10452 "Do not advertise to any peer (well-known community)\n"
10453 "Do not export to next AS (well-known community)\n"
10455 "Do not send outside local AS (well-known community)\n"
10456 "Do not advertise to any peer (well-known community)\n"
10457 "Do not export to next AS (well-known community)\n"
10459 "Do not send outside local AS (well-known community)\n"
10460 "Do not advertise to any peer (well-known community)\n"
10461 "Do not export to next AS (well-known community)\n"
10462 "Exact match of the communities")
10465 DEFUN (show_ipv6_bgp_community_exact
,
10466 show_ipv6_bgp_community_exact_cmd
,
10467 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10471 "Display routes matching the communities\n"
10473 "Do not send outside local AS (well-known community)\n"
10474 "Do not advertise to any peer (well-known community)\n"
10475 "Do not export to next AS (well-known community)\n"
10476 "Exact match of the communities")
10478 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10479 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10483 ALIAS (show_ipv6_bgp_community_exact
,
10484 show_ipv6_bgp_community2_exact_cmd
,
10485 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10489 "Display routes matching the communities\n"
10491 "Do not send outside local AS (well-known community)\n"
10492 "Do not advertise to any peer (well-known community)\n"
10493 "Do not export to next AS (well-known community)\n"
10495 "Do not send outside local AS (well-known community)\n"
10496 "Do not advertise to any peer (well-known community)\n"
10497 "Do not export to next AS (well-known community)\n"
10498 "Exact match of the communities")
10501 ALIAS (show_ipv6_bgp_community_exact
,
10502 show_ipv6_bgp_community3_exact_cmd
,
10503 "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",
10507 "Display routes matching the communities\n"
10509 "Do not send outside local AS (well-known community)\n"
10510 "Do not advertise to any peer (well-known community)\n"
10511 "Do not export to next AS (well-known community)\n"
10513 "Do not send outside local AS (well-known community)\n"
10514 "Do not advertise to any peer (well-known community)\n"
10515 "Do not export to next AS (well-known community)\n"
10517 "Do not send outside local AS (well-known community)\n"
10518 "Do not advertise to any peer (well-known community)\n"
10519 "Do not export to next AS (well-known community)\n"
10520 "Exact match of the communities")
10523 ALIAS (show_ipv6_bgp_community_exact
,
10524 show_ipv6_bgp_community4_exact_cmd
,
10525 "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",
10529 "Display routes matching the communities\n"
10531 "Do not send outside local AS (well-known community)\n"
10532 "Do not advertise to any peer (well-known community)\n"
10533 "Do not export to next AS (well-known community)\n"
10535 "Do not send outside local AS (well-known community)\n"
10536 "Do not advertise to any peer (well-known community)\n"
10537 "Do not export to next AS (well-known community)\n"
10539 "Do not send outside local AS (well-known community)\n"
10540 "Do not advertise to any peer (well-known community)\n"
10541 "Do not export to next AS (well-known community)\n"
10543 "Do not send outside local AS (well-known community)\n"
10544 "Do not advertise to any peer (well-known community)\n"
10545 "Do not export to next AS (well-known community)\n"
10546 "Exact match of the communities")
10549 DEFUN (show_ipv6_mbgp_community
,
10550 show_ipv6_mbgp_community_cmd
,
10551 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10555 "Display routes matching the communities\n"
10557 "Do not send outside local AS (well-known community)\n"
10558 "Do not advertise to any peer (well-known community)\n"
10559 "Do not export to next AS (well-known community)\n")
10561 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10562 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10566 ALIAS (show_ipv6_mbgp_community
,
10567 show_ipv6_mbgp_community2_cmd
,
10568 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10572 "Display routes matching the communities\n"
10574 "Do not send outside local AS (well-known community)\n"
10575 "Do not advertise to any peer (well-known community)\n"
10576 "Do not export to next AS (well-known community)\n"
10578 "Do not send outside local AS (well-known community)\n"
10579 "Do not advertise to any peer (well-known community)\n"
10580 "Do not export to next AS (well-known community)\n")
10583 ALIAS (show_ipv6_mbgp_community
,
10584 show_ipv6_mbgp_community3_cmd
,
10585 "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)",
10589 "Display routes matching the communities\n"
10591 "Do not send outside local AS (well-known community)\n"
10592 "Do not advertise to any peer (well-known community)\n"
10593 "Do not export to next AS (well-known community)\n"
10595 "Do not send outside local AS (well-known community)\n"
10596 "Do not advertise to any peer (well-known community)\n"
10597 "Do not export to next AS (well-known community)\n"
10599 "Do not send outside local AS (well-known community)\n"
10600 "Do not advertise to any peer (well-known community)\n"
10601 "Do not export to next AS (well-known community)\n")
10604 ALIAS (show_ipv6_mbgp_community
,
10605 show_ipv6_mbgp_community4_cmd
,
10606 "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)",
10610 "Display routes matching the communities\n"
10612 "Do not send outside local AS (well-known community)\n"
10613 "Do not advertise to any peer (well-known community)\n"
10614 "Do not export to next AS (well-known community)\n"
10616 "Do not send outside local AS (well-known community)\n"
10617 "Do not advertise to any peer (well-known community)\n"
10618 "Do not export to next AS (well-known community)\n"
10620 "Do not send outside local AS (well-known community)\n"
10621 "Do not advertise to any peer (well-known community)\n"
10622 "Do not export to next AS (well-known community)\n"
10624 "Do not send outside local AS (well-known community)\n"
10625 "Do not advertise to any peer (well-known community)\n"
10626 "Do not export to next AS (well-known community)\n")
10629 DEFUN (show_ipv6_mbgp_community_exact
,
10630 show_ipv6_mbgp_community_exact_cmd
,
10631 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10635 "Display routes matching the communities\n"
10637 "Do not send outside local AS (well-known community)\n"
10638 "Do not advertise to any peer (well-known community)\n"
10639 "Do not export to next AS (well-known community)\n"
10640 "Exact match of the communities")
10642 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10643 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
10647 ALIAS (show_ipv6_mbgp_community_exact
,
10648 show_ipv6_mbgp_community2_exact_cmd
,
10649 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10653 "Display routes matching the communities\n"
10655 "Do not send outside local AS (well-known community)\n"
10656 "Do not advertise to any peer (well-known community)\n"
10657 "Do not export to next AS (well-known community)\n"
10659 "Do not send outside local AS (well-known community)\n"
10660 "Do not advertise to any peer (well-known community)\n"
10661 "Do not export to next AS (well-known community)\n"
10662 "Exact match of the communities")
10665 ALIAS (show_ipv6_mbgp_community_exact
,
10666 show_ipv6_mbgp_community3_exact_cmd
,
10667 "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",
10671 "Display routes matching the communities\n"
10673 "Do not send outside local AS (well-known community)\n"
10674 "Do not advertise to any peer (well-known community)\n"
10675 "Do not export to next AS (well-known community)\n"
10677 "Do not send outside local AS (well-known community)\n"
10678 "Do not advertise to any peer (well-known community)\n"
10679 "Do not export to next AS (well-known community)\n"
10681 "Do not send outside local AS (well-known community)\n"
10682 "Do not advertise to any peer (well-known community)\n"
10683 "Do not export to next AS (well-known community)\n"
10684 "Exact match of the communities")
10687 ALIAS (show_ipv6_mbgp_community_exact
,
10688 show_ipv6_mbgp_community4_exact_cmd
,
10689 "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",
10693 "Display routes matching the communities\n"
10695 "Do not send outside local AS (well-known community)\n"
10696 "Do not advertise to any peer (well-known community)\n"
10697 "Do not export to next AS (well-known community)\n"
10699 "Do not send outside local AS (well-known community)\n"
10700 "Do not advertise to any peer (well-known community)\n"
10701 "Do not export to next AS (well-known community)\n"
10703 "Do not send outside local AS (well-known community)\n"
10704 "Do not advertise to any peer (well-known community)\n"
10705 "Do not export to next AS (well-known community)\n"
10707 "Do not send outside local AS (well-known community)\n"
10708 "Do not advertise to any peer (well-known community)\n"
10709 "Do not export to next AS (well-known community)\n"
10710 "Exact match of the communities")
10711 #endif /* HAVE_IPV6 */
10714 bgp_show_community_list (struct vty
*vty
, const char *name
,
10715 const char *com
, int exact
,
10716 afi_t afi
, safi_t safi
)
10718 struct community_list
*list
;
10719 struct bgp
*bgp
= NULL
;
10721 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
10723 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
10724 return CMD_WARNING
;
10727 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
10730 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
10732 return CMD_WARNING
;
10735 return bgp_show (vty
, bgp
, afi
, safi
,
10736 (exact
? bgp_show_type_community_list_exact
:
10737 bgp_show_type_community_list
), list
, 0);
10740 DEFUN (show_ip_bgp_community_list
,
10741 show_ip_bgp_community_list_cmd
,
10742 "show ip bgp community-list (<1-500>|WORD)",
10746 "Display routes matching the community-list\n"
10747 "community-list number\n"
10748 "community-list name\n")
10750 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
10753 DEFUN (show_ip_bgp_instance_community_list
,
10754 show_ip_bgp_instance_community_list_cmd
,
10755 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
10759 BGP_INSTANCE_HELP_STR
10760 "Display routes matching the community-list\n"
10761 "community-list number\n"
10762 "community-list name\n")
10764 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
10767 DEFUN (show_ip_bgp_ipv4_community_list
,
10768 show_ip_bgp_ipv4_community_list_cmd
,
10769 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
10774 "Address Family modifier\n"
10775 "Address Family modifier\n"
10776 "Display routes matching the community-list\n"
10777 "community-list number\n"
10778 "community-list name\n")
10780 if (strncmp (argv
[0], "m", 1) == 0)
10781 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
10783 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
10786 DEFUN (show_ip_bgp_community_list_exact
,
10787 show_ip_bgp_community_list_exact_cmd
,
10788 "show ip bgp community-list (<1-500>|WORD) exact-match",
10792 "Display routes matching the community-list\n"
10793 "community-list number\n"
10794 "community-list name\n"
10795 "Exact match of the communities\n")
10797 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
10800 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
10801 show_ip_bgp_ipv4_community_list_exact_cmd
,
10802 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
10807 "Address Family modifier\n"
10808 "Address Family modifier\n"
10809 "Display routes matching the community-list\n"
10810 "community-list number\n"
10811 "community-list name\n"
10812 "Exact match of the communities\n")
10814 if (strncmp (argv
[0], "m", 1) == 0)
10815 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
10817 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
10821 DEFUN (show_bgp_community_list
,
10822 show_bgp_community_list_cmd
,
10823 "show bgp community-list (<1-500>|WORD)",
10826 "Display routes matching the community-list\n"
10827 "community-list number\n"
10828 "community-list name\n")
10830 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10833 ALIAS (show_bgp_community_list
,
10834 show_bgp_ipv6_community_list_cmd
,
10835 "show bgp ipv6 community-list (<1-500>|WORD)",
10839 "Display routes matching the community-list\n"
10840 "community-list number\n"
10841 "community-list name\n")
10844 DEFUN (show_ipv6_bgp_community_list
,
10845 show_ipv6_bgp_community_list_cmd
,
10846 "show ipv6 bgp community-list WORD",
10850 "Display routes matching the community-list\n"
10851 "community-list name\n")
10853 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10854 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
10858 DEFUN (show_ipv6_mbgp_community_list
,
10859 show_ipv6_mbgp_community_list_cmd
,
10860 "show ipv6 mbgp community-list WORD",
10864 "Display routes matching the community-list\n"
10865 "community-list name\n")
10867 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10868 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
10871 DEFUN (show_bgp_community_list_exact
,
10872 show_bgp_community_list_exact_cmd
,
10873 "show bgp community-list (<1-500>|WORD) exact-match",
10876 "Display routes matching the community-list\n"
10877 "community-list number\n"
10878 "community-list name\n"
10879 "Exact match of the communities\n")
10881 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10884 ALIAS (show_bgp_community_list_exact
,
10885 show_bgp_ipv6_community_list_exact_cmd
,
10886 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
10890 "Display routes matching the community-list\n"
10891 "community-list number\n"
10892 "community-list name\n"
10893 "Exact match of the communities\n")
10896 DEFUN (show_ipv6_bgp_community_list_exact
,
10897 show_ipv6_bgp_community_list_exact_cmd
,
10898 "show ipv6 bgp community-list WORD exact-match",
10902 "Display routes matching the community-list\n"
10903 "community-list name\n"
10904 "Exact match of the communities\n")
10906 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10907 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
10911 DEFUN (show_ipv6_mbgp_community_list_exact
,
10912 show_ipv6_mbgp_community_list_exact_cmd
,
10913 "show ipv6 mbgp community-list WORD exact-match",
10917 "Display routes matching the community-list\n"
10918 "community-list name\n"
10919 "Exact match of the communities\n")
10921 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10922 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
10924 #endif /* HAVE_IPV6 */
10927 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
10928 const char *prefix
, afi_t afi
,
10929 safi_t safi
, enum bgp_show_type type
)
10933 struct bgp
*bgp
= NULL
;
10935 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
10937 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
10938 return CMD_WARNING
;
10943 ret
= str2prefix (prefix
, p
);
10946 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
10947 return CMD_WARNING
;
10950 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
10955 DEFUN (show_ip_bgp_prefix_longer
,
10956 show_ip_bgp_prefix_longer_cmd
,
10957 "show ip bgp A.B.C.D/M longer-prefixes",
10961 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10962 "Display route and more specific routes\n")
10964 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10965 bgp_show_type_prefix_longer
);
10968 DEFUN (show_ip_bgp_instance_prefix_longer
,
10969 show_ip_bgp_instance_prefix_longer_cmd
,
10970 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
10974 BGP_INSTANCE_HELP_STR
10975 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10976 "Display route and more specific routes\n")
10978 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
10979 bgp_show_type_prefix_longer
);
10982 DEFUN (show_ip_bgp_flap_prefix_longer
,
10983 show_ip_bgp_flap_prefix_longer_cmd
,
10984 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
10988 "Display flap statistics of routes\n"
10989 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
10990 "Display route and more specific routes\n")
10992 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
10993 bgp_show_type_flap_prefix_longer
);
10996 ALIAS (show_ip_bgp_flap_prefix_longer
,
10997 show_ip_bgp_damp_flap_prefix_longer_cmd
,
10998 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11002 "Display detailed information about dampening\n"
11003 "Display flap statistics of routes\n"
11004 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11005 "Display route and more specific routes\n")
11007 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11008 show_ip_bgp_ipv4_prefix_longer_cmd
,
11009 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11014 "Address Family modifier\n"
11015 "Address Family modifier\n"
11016 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11017 "Display route and more specific routes\n")
11019 if (strncmp (argv
[0], "m", 1) == 0)
11020 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
11021 bgp_show_type_prefix_longer
);
11023 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
11024 bgp_show_type_prefix_longer
);
11027 DEFUN (show_ip_bgp_flap_address
,
11028 show_ip_bgp_flap_address_cmd
,
11029 "show ip bgp flap-statistics A.B.C.D",
11033 "Display flap statistics of routes\n"
11034 "Network in the BGP routing table to display\n")
11036 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11037 bgp_show_type_flap_address
);
11040 ALIAS (show_ip_bgp_flap_address
,
11041 show_ip_bgp_damp_flap_address_cmd
,
11042 "show ip bgp dampening flap-statistics A.B.C.D",
11046 "Display detailed information about dampening\n"
11047 "Display flap statistics of routes\n"
11048 "Network in the BGP routing table to display\n")
11050 DEFUN (show_ip_bgp_flap_prefix
,
11051 show_ip_bgp_flap_prefix_cmd
,
11052 "show ip bgp flap-statistics A.B.C.D/M",
11056 "Display flap statistics of routes\n"
11057 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11059 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11060 bgp_show_type_flap_prefix
);
11063 ALIAS (show_ip_bgp_flap_prefix
,
11064 show_ip_bgp_damp_flap_prefix_cmd
,
11065 "show ip bgp dampening flap-statistics A.B.C.D/M",
11069 "Display detailed information about dampening\n"
11070 "Display flap statistics of routes\n"
11071 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11074 DEFUN (show_bgp_prefix_longer
,
11075 show_bgp_prefix_longer_cmd
,
11076 "show bgp X:X::X:X/M longer-prefixes",
11079 "IPv6 prefix <network>/<length>\n"
11080 "Display route and more specific routes\n")
11082 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11083 bgp_show_type_prefix_longer
);
11086 ALIAS (show_bgp_prefix_longer
,
11087 show_bgp_ipv6_prefix_longer_cmd
,
11088 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11092 "IPv6 prefix <network>/<length>\n"
11093 "Display route and more specific routes\n")
11096 DEFUN (show_ipv6_bgp_prefix_longer
,
11097 show_ipv6_bgp_prefix_longer_cmd
,
11098 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11102 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11103 "Display route and more specific routes\n")
11105 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11106 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11107 bgp_show_type_prefix_longer
);
11111 DEFUN (show_ipv6_mbgp_prefix_longer
,
11112 show_ipv6_mbgp_prefix_longer_cmd
,
11113 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11117 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11118 "Display route and more specific routes\n")
11120 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11121 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11122 bgp_show_type_prefix_longer
);
11124 #endif /* HAVE_IPV6 */
11126 static struct peer
*
11127 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11128 const char *ip_str
, u_char use_json
)
11133 union sockunion su
;
11135 /* BGP structure lookup. */
11138 bgp
= bgp_lookup_by_name (view_name
);
11143 json_object
*json_no
= NULL
;
11144 json_no
= json_object_new_object();
11145 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11146 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11147 json_object_free(json_no
);
11150 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11156 bgp
= bgp_get_default ();
11161 json_object
*json_no
= NULL
;
11162 json_no
= json_object_new_object();
11163 json_object_string_add(json_no
, "warning", "No BGP process configured");
11164 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11165 json_object_free(json_no
);
11168 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11173 /* Get peer sockunion. */
11174 ret
= str2sockunion (ip_str
, &su
);
11177 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11180 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11186 json_object
*json_no
= NULL
;
11187 json_no
= json_object_new_object();
11188 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11189 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11190 json_object_free(json_no
);
11193 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11200 /* Peer structure lookup. */
11201 peer
= peer_lookup (bgp
, &su
);
11206 json_object
*json_no
= NULL
;
11207 json_no
= json_object_new_object();
11208 json_object_string_add(json_no
, "warning","No such neighbor");
11209 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11210 json_object_free(json_no
);
11213 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11222 BGP_STATS_MAXBITLEN
= 0,
11224 BGP_STATS_PREFIXES
,
11226 BGP_STATS_UNAGGREGATEABLE
,
11227 BGP_STATS_MAX_AGGREGATEABLE
,
11228 BGP_STATS_AGGREGATES
,
11230 BGP_STATS_ASPATH_COUNT
,
11231 BGP_STATS_ASPATH_MAXHOPS
,
11232 BGP_STATS_ASPATH_TOTHOPS
,
11233 BGP_STATS_ASPATH_MAXSIZE
,
11234 BGP_STATS_ASPATH_TOTSIZE
,
11235 BGP_STATS_ASN_HIGHEST
,
11239 static const char *table_stats_strs
[] =
11241 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11242 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11243 [BGP_STATS_RIB
] = "Total Advertisements",
11244 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11245 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11246 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11247 [BGP_STATS_SPACE
] = "Address space advertised",
11248 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11249 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11250 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11251 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11252 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11253 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11254 [BGP_STATS_MAX
] = NULL
,
11257 struct bgp_table_stats
11259 struct bgp_table
*table
;
11260 unsigned long long counts
[BGP_STATS_MAX
];
11264 #define TALLY_SIGFIG 100000
11265 static unsigned long
11266 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11268 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11269 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11270 unsigned long ret
= newtot
/ count
;
11272 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11280 bgp_table_stats_walker (struct thread
*t
)
11282 struct bgp_node
*rn
;
11283 struct bgp_node
*top
;
11284 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11285 unsigned int space
= 0;
11287 if (!(top
= bgp_table_top (ts
->table
)))
11290 switch (top
->p
.family
)
11293 space
= IPV4_MAX_BITLEN
;
11296 space
= IPV6_MAX_BITLEN
;
11300 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11302 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11304 struct bgp_info
*ri
;
11305 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11306 unsigned int rinum
= 0;
11314 ts
->counts
[BGP_STATS_PREFIXES
]++;
11315 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11318 ts
->counts
[BGP_STATS_AVGPLEN
]
11319 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11320 ts
->counts
[BGP_STATS_AVGPLEN
],
11324 /* check if the prefix is included by any other announcements */
11325 while (prn
&& !prn
->info
)
11326 prn
= bgp_node_parent_nolock (prn
);
11328 if (prn
== NULL
|| prn
== top
)
11330 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11331 /* announced address space */
11333 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11335 else if (prn
->info
)
11336 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11338 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11341 ts
->counts
[BGP_STATS_RIB
]++;
11344 (CHECK_FLAG (ri
->attr
->flag
,
11345 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11346 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11348 /* as-path stats */
11349 if (ri
->attr
&& ri
->attr
->aspath
)
11351 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11352 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11353 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11355 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11357 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11358 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11360 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11361 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11363 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11364 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11366 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11367 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11368 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11370 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11371 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11372 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11375 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11376 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11384 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11386 struct bgp_table_stats ts
;
11389 if (!bgp
->rib
[afi
][safi
])
11391 vty_out (vty
, "%% No RIB exist's for the AFI(%d)/SAFI(%d)%s",
11392 afi
, safi
, VTY_NEWLINE
);
11393 return CMD_WARNING
;
11396 memset (&ts
, 0, sizeof (ts
));
11397 ts
.table
= bgp
->rib
[afi
][safi
];
11398 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11400 vty_out (vty
, "BGP %s RIB statistics%s%s",
11401 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11403 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11405 if (!table_stats_strs
[i
])
11411 case BGP_STATS_ASPATH_AVGHOPS
:
11412 case BGP_STATS_ASPATH_AVGSIZE
:
11413 case BGP_STATS_AVGPLEN
:
11414 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11415 vty_out (vty
, "%12.2f",
11416 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11419 case BGP_STATS_ASPATH_TOTHOPS
:
11420 case BGP_STATS_ASPATH_TOTSIZE
:
11421 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11422 vty_out (vty
, "%12.2f",
11424 (float)ts
.counts
[i
] /
11425 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11428 case BGP_STATS_TOTPLEN
:
11429 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11430 vty_out (vty
, "%12.2f",
11432 (float)ts
.counts
[i
] /
11433 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11436 case BGP_STATS_SPACE
:
11437 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11438 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11439 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11441 vty_out (vty
, "%30s: ", "%% announced ");
11442 vty_out (vty
, "%12.2f%s",
11443 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11444 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11446 vty_out (vty
, "%30s: ", "/8 equivalent ");
11447 vty_out (vty
, "%12.2f%s",
11448 (float)ts
.counts
[BGP_STATS_SPACE
] /
11449 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11451 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11453 vty_out (vty
, "%30s: ", "/24 equivalent ");
11454 vty_out (vty
, "%12.2f",
11455 (float)ts
.counts
[BGP_STATS_SPACE
] /
11456 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11459 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11460 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11463 vty_out (vty
, "%s", VTY_NEWLINE
);
11465 return CMD_SUCCESS
;
11469 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11470 const char *afi_str
, const char *safi_str
)
11477 bgp
= bgp_lookup_by_name (name
);
11479 bgp
= bgp_get_default ();
11483 vty_out (vty
, "%% No such BGP instance exist%s", VTY_NEWLINE
);
11484 return CMD_WARNING
;
11486 if (strncmp (afi_str
, "ipv", 3) == 0)
11488 if (strncmp (afi_str
, "ipv4", 4) == 0)
11490 else if (strncmp (afi_str
, "ipv6", 4) == 0)
11494 vty_out (vty
, "%% Invalid address family %s%s",
11495 afi_str
, VTY_NEWLINE
);
11496 return CMD_WARNING
;
11498 if (strncmp (safi_str
, "m", 1) == 0)
11499 safi
= SAFI_MULTICAST
;
11500 else if (strncmp (safi_str
, "u", 1) == 0)
11501 safi
= SAFI_UNICAST
;
11502 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
11503 safi
= SAFI_MPLS_VPN
;
11506 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11507 safi_str
, VTY_NEWLINE
);
11508 return CMD_WARNING
;
11513 vty_out (vty
, "%% Invalid address family %s%s",
11514 afi_str
, VTY_NEWLINE
);
11515 return CMD_WARNING
;
11518 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11521 DEFUN (show_bgp_statistics
,
11522 show_bgp_statistics_cmd
,
11523 "show bgp (ipv4|ipv6) (unicast|multicast) statistics",
11528 "Address Family modifier\n"
11529 "Address Family modifier\n"
11530 "BGP RIB advertisement statistics\n")
11532 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11535 ALIAS (show_bgp_statistics
,
11536 show_bgp_statistics_vpnv4_cmd
,
11537 "show bgp (ipv4) (vpnv4) statistics",
11541 "Address Family modifier\n"
11542 "BGP RIB advertisement statistics\n")
11544 DEFUN (show_bgp_statistics_view
,
11545 show_bgp_statistics_view_cmd
,
11546 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) statistics",
11549 BGP_INSTANCE_HELP_STR
11552 "Address Family modifier\n"
11553 "Address Family modifier\n"
11554 "BGP RIB advertisement statistics\n")
11556 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11559 ALIAS (show_bgp_statistics_view
,
11560 show_bgp_statistics_view_vpnv4_cmd
,
11561 "show bgp " BGP_INSTANCE_CMD
" (ipv4) (vpnv4) statistics",
11564 BGP_INSTANCE_HELP_STR
11566 "Address Family modifier\n"
11567 "BGP RIB advertisement statistics\n")
11579 PCOUNT_PFCNT
, /* the figure we display to users */
11583 static const char *pcount_strs
[] =
11585 [PCOUNT_ADJ_IN
] = "Adj-in",
11586 [PCOUNT_DAMPED
] = "Damped",
11587 [PCOUNT_REMOVED
] = "Removed",
11588 [PCOUNT_HISTORY
] = "History",
11589 [PCOUNT_STALE
] = "Stale",
11590 [PCOUNT_VALID
] = "Valid",
11591 [PCOUNT_ALL
] = "All RIB",
11592 [PCOUNT_COUNTED
] = "PfxCt counted",
11593 [PCOUNT_PFCNT
] = "Useable",
11594 [PCOUNT_MAX
] = NULL
,
11597 struct peer_pcounts
11599 unsigned int count
[PCOUNT_MAX
];
11600 const struct peer
*peer
;
11601 const struct bgp_table
*table
;
11605 bgp_peer_count_walker (struct thread
*t
)
11607 struct bgp_node
*rn
;
11608 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11609 const struct peer
*peer
= pc
->peer
;
11611 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11613 struct bgp_adj_in
*ain
;
11614 struct bgp_info
*ri
;
11616 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11617 if (ain
->peer
== peer
)
11618 pc
->count
[PCOUNT_ADJ_IN
]++;
11620 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11622 char buf
[SU_ADDRSTRLEN
];
11624 if (ri
->peer
!= peer
)
11627 pc
->count
[PCOUNT_ALL
]++;
11629 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11630 pc
->count
[PCOUNT_DAMPED
]++;
11631 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11632 pc
->count
[PCOUNT_HISTORY
]++;
11633 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
11634 pc
->count
[PCOUNT_REMOVED
]++;
11635 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
11636 pc
->count
[PCOUNT_STALE
]++;
11637 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
11638 pc
->count
[PCOUNT_VALID
]++;
11639 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11640 pc
->count
[PCOUNT_PFCNT
]++;
11642 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
11644 pc
->count
[PCOUNT_COUNTED
]++;
11645 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11646 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
11648 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11649 buf
, SU_ADDRSTRLEN
),
11655 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11656 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
11658 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11659 buf
, SU_ADDRSTRLEN
),
11669 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
11671 struct peer_pcounts pcounts
= { .peer
= peer
};
11673 json_object
*json
= NULL
;
11674 json_object
*json_loop
= NULL
;
11678 json
= json_object_new_object();
11679 json_loop
= json_object_new_object();
11682 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
11683 || !peer
->bgp
->rib
[afi
][safi
])
11687 json_object_string_add(json
, "warning", "No such neighbor or address family");
11688 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11689 json_object_free(json
);
11692 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11694 return CMD_WARNING
;
11697 memset (&pcounts
, 0, sizeof(pcounts
));
11698 pcounts
.peer
= peer
;
11699 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
11701 /* in-place call via thread subsystem so as to record execution time
11702 * * stats for the thread-walk (i.e. ensure this can't be blamed on
11703 * * on just vty_read()).
11705 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
11709 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
11710 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
11711 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
11713 for (i
= 0; i
< PCOUNT_MAX
; i
++)
11714 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
11716 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
11718 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
11720 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
11721 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
11723 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11724 json_object_free(json
);
11729 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
11731 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
11732 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
11737 vty_out (vty
, "Prefix counts for %s, %s%s",
11738 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
11741 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
11742 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
11743 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
11745 for (i
= 0; i
< PCOUNT_MAX
; i
++)
11746 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
11748 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
11750 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
11751 peer
->host
, VTY_NEWLINE
);
11752 vty_out (vty
, "Please report this bug, with the above command output%s",
11757 return CMD_SUCCESS
;
11760 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
11761 show_ip_bgp_neighbor_prefix_counts_cmd
,
11762 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11766 "Detailed information on TCP and BGP neighbor connections\n"
11767 "Neighbor to display information about\n"
11768 "Neighbor to display information about\n"
11769 "Neighbor on bgp configured interface\n"
11770 "Display detailed prefix count information\n"
11771 "JavaScript Object Notation\n")
11774 u_char uj
= use_json(argc
, argv
);
11776 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11778 return CMD_WARNING
;
11780 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11783 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
11784 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
11785 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11789 BGP_INSTANCE_HELP_STR
11790 "Detailed information on TCP and BGP neighbor connections\n"
11791 "Neighbor to display information about\n"
11792 "Neighbor to display information about\n"
11793 "Neighbor on bgp configured interface\n"
11794 "Display detailed prefix count information\n"
11795 "JavaScript Object Notation\n")
11798 u_char uj
= use_json(argc
, argv
);
11800 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11802 return CMD_WARNING
;
11804 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11807 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
11808 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
11809 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11813 "Detailed information on TCP and BGP neighbor connections\n"
11814 "Neighbor to display information about\n"
11815 "Neighbor to display information about\n"
11816 "Neighbor on bgp configured interface\n"
11817 "Display detailed prefix count information\n"
11818 "JavaScript Object Notation\n")
11821 u_char uj
= use_json(argc
, argv
);
11823 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11825 return CMD_WARNING
;
11827 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11830 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
11831 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
11832 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11835 BGP_INSTANCE_HELP_STR
11837 "Detailed information on TCP and BGP neighbor connections\n"
11838 "Neighbor to display information about\n"
11839 "Neighbor to display information about\n"
11840 "Neighbor on bgp configured interface\n"
11841 "Display detailed prefix count information\n"
11842 "JavaScript Object Notation\n")
11845 u_char uj
= use_json(argc
, argv
);
11847 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
11849 return CMD_WARNING
;
11851 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
11854 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
11855 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
11856 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11861 "Address Family modifier\n"
11862 "Address Family modifier\n"
11863 "Detailed information on TCP and BGP neighbor connections\n"
11864 "Neighbor to display information about\n"
11865 "Neighbor to display information about\n"
11866 "Neighbor on bgp configured interface\n"
11867 "Display detailed prefix count information\n"
11868 "JavaScript Object Notation\n")
11871 u_char uj
= use_json(argc
, argv
);
11873 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
11875 return CMD_WARNING
;
11877 if (strncmp (argv
[0], "m", 1) == 0)
11878 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, uj
);
11880 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
11883 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
11884 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
11885 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
11890 "Address Family modifier\n"
11891 "Address Family modifier\n"
11892 "Detailed information on TCP and BGP neighbor connections\n"
11893 "Neighbor to display information about\n"
11894 "Neighbor to display information about\n"
11895 "Neighbor on bgp configured interface\n"
11896 "Display detailed prefix count information\n"
11897 "JavaScript Object Notation\n")
11900 u_char uj
= use_json(argc
, argv
);
11902 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
11904 return CMD_WARNING
;
11906 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
, uj
);
11910 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
11911 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
11913 struct bgp_table
*table
;
11914 struct bgp_adj_in
*ain
;
11915 struct bgp_adj_out
*adj
;
11916 unsigned long output_count
;
11917 unsigned long filtered_count
;
11918 struct bgp_node
*rn
;
11923 struct attr_extra extra
;
11925 struct update_subgroup
*subgrp
;
11926 json_object
*json_scode
= NULL
;
11927 json_object
*json_ocode
= NULL
;
11928 json_object
*json_ar
= NULL
;
11929 struct peer_af
*paf
;
11933 json_scode
= json_object_new_object();
11934 json_ocode
= json_object_new_object();
11935 json_ar
= json_object_new_object();
11937 json_object_string_add(json_scode
, "suppressed", "s");
11938 json_object_string_add(json_scode
, "damped", "d");
11939 json_object_string_add(json_scode
, "history", "h");
11940 json_object_string_add(json_scode
, "valid", "*");
11941 json_object_string_add(json_scode
, "best", ">");
11942 json_object_string_add(json_scode
, "multipath", "=");
11943 json_object_string_add(json_scode
, "internal", "i");
11944 json_object_string_add(json_scode
, "ribFailure", "r");
11945 json_object_string_add(json_scode
, "stale", "S");
11946 json_object_string_add(json_scode
, "removed", "R");
11948 json_object_string_add(json_ocode
, "igp", "i");
11949 json_object_string_add(json_ocode
, "egp", "e");
11950 json_object_string_add(json_ocode
, "incomplete", "?");
11959 json_object_string_add(json
, "alert", "no BGP");
11960 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
11961 json_object_free(json
);
11964 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
11968 table
= bgp
->rib
[afi
][safi
];
11970 output_count
= filtered_count
= 0;
11971 subgrp
= peer_subgroup(peer
, afi
, safi
);
11973 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11977 json_object_int_add(json
, "bgpTableVersion", table
->version
);
11978 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
11979 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
11980 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
11981 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
11985 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
11986 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11987 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
11989 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
11990 VTY_NEWLINE
, VTY_NEWLINE
);
11995 attr
.extra
= &extra
;
11996 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12000 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12002 if (ain
->peer
== peer
)
12008 json_object_int_add(json
, "bgpTableVersion", 0);
12009 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12010 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12011 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12015 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12016 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12017 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12024 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12029 bgp_attr_dup(&attr
, ain
->attr
);
12030 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12032 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12043 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12044 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12045 if (paf
->peer
== peer
)
12051 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12052 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12053 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12054 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12058 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12059 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12060 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12061 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12069 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12075 bgp_attr_dup(&attr
, adj
->attr
);
12076 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12077 if (ret
!= RMAP_DENY
)
12079 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12089 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12091 if (output_count
!= 0)
12094 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12096 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12097 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12101 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12102 json_object_free(json
);
12108 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12109 int in
, const char *rmap_name
, u_char use_json
)
12111 json_object
*json
= NULL
;
12114 json
= json_object_new_object();
12116 if (!peer
|| !peer
->afc
[afi
][safi
])
12120 json_object_string_add(json
, "warning", "No such neighbor or address family");
12121 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12122 json_object_free(json
);
12125 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12127 return CMD_WARNING
;
12130 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12134 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12135 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
12136 json_object_free(json
);
12139 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12141 return CMD_WARNING
;
12144 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12146 return CMD_SUCCESS
;
12149 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12150 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12151 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12155 BGP_INSTANCE_HELP_STR
12156 "Detailed information on TCP and BGP neighbor connections\n"
12157 "Neighbor to display information about\n"
12158 "Neighbor to display information about\n"
12159 "Display the routes advertised to a BGP neighbor\n"
12160 "JavaScript Object Notation\n")
12163 u_char uj
= use_json(argc
, argv
);
12165 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12166 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12168 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12171 return CMD_WARNING
;
12173 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12176 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12177 show_ip_bgp_neighbor_advertised_route_cmd
,
12178 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12182 "Detailed information on TCP and BGP neighbor connections\n"
12183 "Neighbor to display information about\n"
12184 "Neighbor to display information about\n"
12185 "Neighbor on bgp configured interface\n"
12186 "Display the routes advertised to a BGP neighbor\n"
12187 "JavaScript Object Notation\n")
12191 const char *rmap_name
= NULL
;
12192 u_char uj
= use_json(argc
, argv
);
12194 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12197 return CMD_WARNING
;
12199 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12201 rmap_name
= argv
[1];
12203 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12206 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12207 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12208 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12212 "Detailed information on TCP and BGP neighbor connections\n"
12213 "Neighbor to display information about\n"
12214 "Neighbor to display information about\n"
12215 "Neighbor on bgp configured interface\n"
12216 "Display the routes advertised to a BGP neighbor\n"
12217 "JavaScript Object Notation\n")
12219 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12220 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12221 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12225 BGP_INSTANCE_HELP_STR
12226 "Detailed information on TCP and BGP neighbor connections\n"
12227 "Neighbor to display information about\n"
12228 "Neighbor to display information about\n"
12229 "Neighbor on bgp configured interface\n"
12230 "Display the routes advertised to a BGP neighbor\n"
12231 "JavaScript Object Notation\n")
12232 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12233 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12234 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12239 "Address Family modifier\n"
12240 "Address Family modifier\n"
12241 "Detailed information on TCP and BGP neighbor connections\n"
12242 "Neighbor to display information about\n"
12243 "Neighbor to display information about\n"
12244 "Neighbor on bgp configured interface\n"
12245 "Display the routes advertised to a BGP neighbor\n"
12246 "JavaScript Object Notation\n")
12249 const char *rmap_name
= NULL
;
12250 u_char uj
= use_json(argc
, argv
);
12252 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12254 return CMD_WARNING
;
12256 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12257 rmap_name
= argv
[2];
12259 if (strncmp (argv
[0], "m", 1) == 0)
12260 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0, rmap_name
, uj
);
12262 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12265 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12266 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12267 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12272 "Address Family modifier\n"
12273 "Address Family modifier\n"
12274 "Detailed information on TCP and BGP neighbor connections\n"
12275 "Neighbor to display information about\n"
12276 "Neighbor to display information about\n"
12277 "Neighbor on bgp configured interface\n"
12278 "Display the routes advertised to a BGP neighbor\n"
12279 "Route-map to control what is displayed\n"
12280 "JavaScript Object Notation\n")
12283 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12284 show_bgp_instance_neighbor_advertised_route_cmd
,
12285 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12288 BGP_INSTANCE_HELP_STR
12289 "Detailed information on TCP and BGP neighbor connections\n"
12290 "Neighbor to display information about\n"
12291 "Neighbor to display information about\n"
12292 "Neighbor on bgp configured interface\n"
12293 "Display the routes advertised to a BGP neighbor\n"
12294 "JavaScript Object Notation\n")
12297 u_char uj
= use_json(argc
, argv
);
12299 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12300 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12302 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12305 return CMD_WARNING
;
12307 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12310 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12311 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12312 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12315 BGP_INSTANCE_HELP_STR
12317 "Detailed information on TCP and BGP neighbor connections\n"
12318 "Neighbor to display information about\n"
12319 "Neighbor to display information about\n"
12320 "Neighbor on bgp configured interface\n"
12321 "Display the routes advertised to a BGP neighbor\n"
12322 "JavaScript Object Notation\n")
12324 DEFUN (show_bgp_neighbor_advertised_route
,
12325 show_bgp_neighbor_advertised_route_cmd
,
12326 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12329 "Detailed information on TCP and BGP neighbor connections\n"
12330 "Neighbor to display information about\n"
12331 "Neighbor to display information about\n"
12332 "Neighbor on bgp configured interface\n"
12333 "Display the routes advertised to a BGP neighbor\n"
12334 "JavaScript Object Notation\n")
12338 const char *rmap_name
= NULL
;
12339 u_char uj
= use_json(argc
, argv
);
12341 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12344 return CMD_WARNING
;
12346 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12347 rmap_name
= argv
[1];
12349 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12352 ALIAS (show_bgp_neighbor_advertised_route
,
12353 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12354 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12358 "Detailed information on TCP and BGP neighbor connections\n"
12359 "Neighbor to display information about\n"
12360 "Neighbor to display information about\n"
12361 "Neighbor on bgp configured interface\n"
12362 "Display the routes advertised to a BGP neighbor\n"
12363 "JavaScript Object Notation\n")
12366 ALIAS (show_bgp_neighbor_advertised_route
,
12367 ipv6_bgp_neighbor_advertised_route_cmd
,
12368 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
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 routes advertised to a BGP neighbor\n"
12377 "JavaScript Object Notation\n")
12380 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12381 ipv6_mbgp_neighbor_advertised_route_cmd
,
12382 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12386 "Detailed information on TCP and BGP neighbor connections\n"
12387 "Neighbor to display information about\n"
12388 "Neighbor to display information about\n"
12389 "Neighbor on bgp configured interface\n"
12390 "Neighbor on bgp configured interface\n"
12391 "Display the routes advertised to a BGP neighbor\n"
12392 "JavaScript Object Notation\n")
12395 u_char uj
= use_json(argc
, argv
);
12397 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12399 return CMD_WARNING
;
12401 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12402 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12404 #endif /* HAVE_IPV6 */
12406 DEFUN (show_bgp_instance_neighbor_received_routes
,
12407 show_bgp_instance_neighbor_received_routes_cmd
,
12408 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12411 BGP_INSTANCE_HELP_STR
12412 "Detailed information on TCP and BGP neighbor connections\n"
12413 "Neighbor to display information about\n"
12414 "Neighbor to display information about\n"
12415 "Neighbor on bgp configured interface\n"
12416 "Display the received routes from neighbor\n"
12417 "JavaScript Object Notation\n")
12420 u_char uj
= use_json(argc
, argv
);
12422 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12424 return CMD_WARNING
;
12426 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12429 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12430 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12431 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12435 BGP_INSTANCE_HELP_STR
12436 "Detailed information on TCP and BGP neighbor connections\n"
12437 "Neighbor to display information about\n"
12438 "Neighbor to display information about\n"
12439 "Neighbor on bgp configured interface\n"
12440 "Display the received routes from neighbor\n"
12441 "JavaScript Object Notation\n")
12444 u_char uj
= use_json(argc
, argv
);
12446 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12448 return CMD_WARNING
;
12450 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12453 ALIAS (show_bgp_instance_neighbor_received_routes
,
12454 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12455 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12458 BGP_INSTANCE_HELP_STR
12460 "Detailed information on TCP and BGP neighbor connections\n"
12461 "Neighbor to display information about\n"
12462 "Neighbor to display information about\n"
12463 "Neighbor on bgp configured interface\n"
12464 "Display the received routes from neighbor\n"
12465 "JavaScript Object Notation\n")
12467 DEFUN (show_ip_bgp_neighbor_received_routes
,
12468 show_ip_bgp_neighbor_received_routes_cmd
,
12469 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12473 "Detailed information on TCP and BGP neighbor connections\n"
12474 "Neighbor to display information about\n"
12475 "Neighbor to display information about\n"
12476 "Neighbor on bgp configured interface\n"
12477 "Display the received routes from neighbor\n"
12478 "JavaScript Object Notation\n")
12482 const char *rmap_name
= NULL
;
12483 u_char uj
= use_json(argc
, argv
);
12485 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12488 return CMD_WARNING
;
12490 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12491 rmap_name
= argv
[1];
12493 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12496 ALIAS (show_ip_bgp_neighbor_received_routes
,
12497 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12498 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12502 "Detailed information on TCP and BGP neighbor connections\n"
12503 "Neighbor to display information about\n"
12504 "Neighbor to display information about\n"
12505 "Neighbor on bgp configured interface\n"
12506 "Display the received routes from neighbor\n"
12507 "JavaScript Object Notation\n")
12509 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12510 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12511 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12515 BGP_INSTANCE_HELP_STR
12516 "Detailed information on TCP and BGP neighbor connections\n"
12517 "Neighbor to display information about\n"
12518 "Neighbor to display information about\n"
12519 "Neighbor on bgp configured interface\n"
12520 "Display the received routes from neighbor\n"
12521 "JavaScript Object Notation\n")
12523 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12524 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12525 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12530 "Address Family modifier\n"
12531 "Address Family modifier\n"
12532 "Detailed information on TCP and BGP neighbor connections\n"
12533 "Neighbor to display information about\n"
12534 "Neighbor to display information about\n"
12535 "Neighbor on bgp configured interface\n"
12536 "Display the received routes from neighbor\n"
12537 "JavaScript Object Notation\n")
12540 const char *rmap_name
= NULL
;
12541 u_char uj
= use_json(argc
, argv
);
12543 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12545 return CMD_WARNING
;
12547 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12548 rmap_name
= argv
[2];
12550 if (strncmp (argv
[0], "m", 1) == 0)
12551 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1, rmap_name
, uj
);
12553 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12556 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12557 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12558 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12563 "Address Family modifier\n"
12564 "Address Family modifier\n"
12565 "Detailed information on TCP and BGP neighbor connections\n"
12566 "Neighbor to display information about\n"
12567 "Neighbor to display information about\n"
12568 "Neighbor on bgp configured interface\n"
12569 "Display the received routes from neighbor\n"
12570 "JavaScript Object Notation\n")
12572 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12573 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12574 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12577 BGP_INSTANCE_HELP_STR
12580 "Address family modifier\n"
12581 "Address family modifier\n"
12582 "Detailed information on TCP and BGP neighbor connections\n"
12583 "Neighbor to display information about\n"
12584 "Neighbor to display information about\n"
12585 "Neighbor on bgp configured interface\n"
12586 "Display the advertised routes to neighbor\n"
12587 "Display the received routes from neighbor\n"
12588 "JavaScript Object Notation\n")
12594 u_char uj
= use_json(argc
, argv
);
12596 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12599 return CMD_WARNING
;
12601 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
12602 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
12603 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12605 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12608 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12609 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12610 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12614 "Detailed information on TCP and BGP neighbor connections\n"
12615 "Neighbor to display information about\n"
12616 "Neighbor to display information about\n"
12617 "Neighbor on bgp configured interface\n"
12618 "Display information received from a BGP neighbor\n"
12619 "Display the prefixlist filter\n"
12620 "JavaScript Object Notation\n")
12623 union sockunion su
;
12626 u_char uj
= use_json(argc
, argv
);
12628 ret
= str2sockunion (argv
[0], &su
);
12631 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12636 json_object
*json_no
= NULL
;
12637 json_object
*json_sub
= NULL
;
12638 json_no
= json_object_new_object();
12639 json_sub
= json_object_new_object();
12640 json_object_string_add(json_no
, "warning", "Malformed address or name");
12641 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12642 json_object_object_add(json_no
, "detail", json_sub
);
12643 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12644 json_object_free(json_no
);
12647 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12648 return CMD_WARNING
;
12653 peer
= peer_lookup (NULL
, &su
);
12658 json_object
*json_no
= NULL
;
12659 json_no
= json_object_new_object();
12660 json_object_string_add(json_no
, "warning", "Peer not found");
12661 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12662 json_object_free(json_no
);
12665 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12666 return CMD_WARNING
;
12670 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12671 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12675 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12676 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12682 json_object
*json_no
= NULL
;
12683 json_no
= json_object_new_object();
12684 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12685 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12686 json_object_free(json_no
);
12689 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12692 return CMD_SUCCESS
;
12695 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
12696 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
12697 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12702 "Address Family modifier\n"
12703 "Address Family modifier\n"
12704 "Detailed information on TCP and BGP neighbor connections\n"
12705 "Neighbor to display information about\n"
12706 "Neighbor to display information about\n"
12707 "Neighbor on bgp configured interface\n"
12708 "Display information received from a BGP neighbor\n"
12709 "Display the prefixlist filter\n"
12710 "JavaScript Object Notation\n")
12713 union sockunion su
;
12716 u_char uj
= use_json(argc
, argv
);
12718 ret
= str2sockunion (argv
[1], &su
);
12721 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
12726 json_object
*json_no
= NULL
;
12727 json_object
*json_sub
= NULL
;
12728 json_no
= json_object_new_object();
12729 json_sub
= json_object_new_object();
12730 json_object_string_add(json_no
, "warning", "Malformed address or name");
12731 json_object_string_add(json_sub
, "warningCause", argv
[1]);
12732 json_object_object_add(json_no
, "detail", json_sub
);
12733 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12734 json_object_free(json_no
);
12737 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
12738 return CMD_WARNING
;
12743 peer
= peer_lookup (NULL
, &su
);
12748 json_object
*json_no
= NULL
;
12749 json_no
= json_object_new_object();
12750 json_object_string_add(json_no
, "warning", "Peer not found");
12751 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12752 json_object_free(json_no
);
12755 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12756 return CMD_WARNING
;
12760 if (strncmp (argv
[0], "m", 1) == 0)
12762 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
12763 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12767 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
12768 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12774 json_object
*json_no
= NULL
;
12775 json_no
= json_object_new_object();
12776 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12777 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12778 json_object_free(json_no
);
12781 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12786 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12787 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12791 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12792 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12798 json_object
*json_no
= NULL
;
12799 json_no
= json_object_new_object();
12800 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12801 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12802 json_object_free(json_no
);
12805 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12809 return CMD_SUCCESS
;
12812 DEFUN (show_bgp_neighbor_received_routes
,
12813 show_bgp_neighbor_received_routes_cmd
,
12814 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12817 "Detailed information on TCP and BGP neighbor connections\n"
12818 "Neighbor to display information about\n"
12819 "Neighbor to display information about\n"
12820 "Neighbor on bgp configured interface\n"
12821 "Display the received routes from neighbor\n"
12822 "JavaScript Object Notation\n")
12825 const char *rmap_name
= NULL
;
12826 u_char uj
= use_json(argc
, argv
);
12828 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12831 return CMD_WARNING
;
12833 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12834 rmap_name
= argv
[1];
12836 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12839 ALIAS (show_bgp_neighbor_received_routes
,
12840 show_bgp_ipv6_neighbor_received_routes_cmd
,
12841 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12845 "Detailed information on TCP and BGP neighbor connections\n"
12846 "Neighbor to display information about\n"
12847 "Neighbor to display information about\n"
12848 "Neighbor on bgp configured interface\n"
12849 "Display the received routes from neighbor\n"
12850 "JavaScript Object Notation\n")
12852 DEFUN (show_bgp_neighbor_received_prefix_filter
,
12853 show_bgp_neighbor_received_prefix_filter_cmd
,
12854 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12857 "Detailed information on TCP and BGP neighbor connections\n"
12858 "Neighbor to display information about\n"
12859 "Neighbor to display information about\n"
12860 "Neighbor on bgp configured interface\n"
12861 "Display information received from a BGP neighbor\n"
12862 "Display the prefixlist filter\n"
12863 "JavaScript Object Notation\n")
12866 union sockunion su
;
12869 u_char uj
= use_json(argc
, argv
);
12871 ret
= str2sockunion (argv
[0], &su
);
12874 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12879 json_object
*json_no
= NULL
;
12880 json_object
*json_sub
= NULL
;
12881 json_no
= json_object_new_object();
12882 json_sub
= json_object_new_object();
12883 json_object_string_add(json_no
, "warning", "Malformed address or name");
12884 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12885 json_object_object_add(json_no
, "detail", json_sub
);
12886 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12887 json_object_free(json_no
);
12890 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12891 return CMD_WARNING
;
12896 peer
= peer_lookup (NULL
, &su
);
12901 json_object
*json_no
= NULL
;
12902 json_no
= json_object_new_object();
12903 json_object_string_add(json_no
, "warning", "No Peer");
12904 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12905 json_object_free(json_no
);
12908 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12909 return CMD_WARNING
;
12913 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
12914 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
12918 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
12919 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
12925 json_object
*json_no
= NULL
;
12926 json_no
= json_object_new_object();
12927 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12928 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12929 json_object_free(json_no
);
12932 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12935 return CMD_SUCCESS
;
12938 ALIAS (show_bgp_neighbor_received_prefix_filter
,
12939 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
12940 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12944 "Detailed information on TCP and BGP neighbor connections\n"
12945 "Neighbor to display information about\n"
12946 "Neighbor to display information about\n"
12947 "Neighbor on bgp configured interface\n"
12948 "Display information received from a BGP neighbor\n"
12949 "Display the prefixlist filter\n"
12950 "JavaScript Object Notation\n")
12953 ALIAS (show_bgp_neighbor_received_routes
,
12954 ipv6_bgp_neighbor_received_routes_cmd
,
12955 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
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 the received routes from neighbor\n"
12964 "JavaScript Object Notation\n")
12967 DEFUN (ipv6_mbgp_neighbor_received_routes
,
12968 ipv6_mbgp_neighbor_received_routes_cmd
,
12969 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12973 "Detailed information on TCP and BGP neighbor connections\n"
12974 "Neighbor to display information about\n"
12975 "Neighbor to display information about\n"
12976 "Neighbor on bgp configured interface\n"
12977 "Display the received routes from neighbor\n"
12978 "JavaScript Object Notation\n")
12981 u_char uj
= use_json(argc
, argv
);
12983 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12985 return CMD_WARNING
;
12987 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12988 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
12991 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
12992 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
12993 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12996 BGP_INSTANCE_HELP_STR
12997 "Detailed information on TCP and BGP neighbor connections\n"
12998 "Neighbor to display information about\n"
12999 "Neighbor to display information about\n"
13000 "Neighbor on bgp configured interface\n"
13001 "Display information received from a BGP neighbor\n"
13002 "Display the prefixlist filter\n"
13003 "JavaScript Object Notation\n")
13006 union sockunion su
;
13010 u_char uj
= use_json(argc
, argv
);
13012 /* BGP structure lookup. */
13013 bgp
= bgp_lookup_by_name (argv
[1]);
13018 json_object
*json_no
= NULL
;
13019 json_no
= json_object_new_object();
13020 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13021 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13022 json_object_free(json_no
);
13025 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13026 return CMD_WARNING
;
13029 ret
= str2sockunion (argv
[2], &su
);
13032 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13037 json_object
*json_no
= NULL
;
13038 json_object
*json_sub
= NULL
;
13039 json_no
= json_object_new_object();
13040 json_sub
= json_object_new_object();
13041 json_object_string_add(json_no
, "warning", "Malformed address or name");
13042 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13043 json_object_object_add(json_no
, "detail", json_sub
);
13044 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13045 json_object_free(json_no
);
13048 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13049 return CMD_WARNING
;
13054 peer
= peer_lookup (bgp
, &su
);
13059 json_object
*json_no
= NULL
;
13060 json_no
= json_object_new_object();
13061 json_object_boolean_true_add(json_no
, "noPeer");
13062 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13063 json_object_free(json_no
);
13066 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13067 return CMD_WARNING
;
13072 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13073 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13077 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13078 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13081 return CMD_SUCCESS
;
13083 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13084 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13085 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13088 BGP_INSTANCE_HELP_STR
13090 "Detailed information on TCP and BGP neighbor connections\n"
13091 "Neighbor to display information about\n"
13092 "Neighbor to display information about\n"
13093 "Neighbor on bgp configured interface\n"
13094 "Display information received from a BGP neighbor\n"
13095 "Display the prefixlist filter\n"
13096 "JavaScript Object NOtation\n")
13097 #endif /* HAVE_IPV6 */
13100 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13101 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13103 if (! peer
|| ! peer
->afc
[afi
][safi
])
13107 json_object
*json_no
= NULL
;
13108 json_no
= json_object_new_object();
13109 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13110 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13111 json_object_free(json_no
);
13114 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13115 return CMD_WARNING
;
13118 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13121 DEFUN (show_ip_bgp_neighbor_routes
,
13122 show_ip_bgp_neighbor_routes_cmd
,
13123 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13127 "Detailed information on TCP and BGP neighbor connections\n"
13128 "Neighbor to display information about\n"
13129 "Neighbor to display information about\n"
13130 "Neighbor on bgp configured interface\n"
13131 "Display routes learned from neighbor\n"
13132 "JavaScript Object Notation\n")
13135 u_char uj
= use_json(argc
, argv
);
13137 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13139 return CMD_WARNING
;
13141 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13142 bgp_show_type_neighbor
, uj
);
13145 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13146 show_ip_bgp_instance_neighbor_routes_cmd
,
13147 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13151 BGP_INSTANCE_HELP_STR
13152 "Detailed information on TCP and BGP neighbor connections\n"
13153 "Neighbor to display information about\n"
13154 "Neighbor to display information about\n"
13155 "Neighbor on bgp configured interface\n"
13156 "Display routes learned from neighbor\n"
13157 "JavaScript Object Notation\n")
13160 u_char uj
= use_json(argc
, argv
);
13162 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13164 return CMD_WARNING
;
13166 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13167 bgp_show_type_neighbor
, uj
);
13170 DEFUN (show_ip_bgp_neighbor_flap
,
13171 show_ip_bgp_neighbor_flap_cmd
,
13172 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13176 "Detailed information on TCP and BGP neighbor connections\n"
13177 "Neighbor to display information about\n"
13178 "Neighbor to display information about\n"
13179 "Neighbor on bgp configured interface\n"
13180 "Display flap statistics of the routes learned from neighbor\n"
13181 "JavaScript Object Notation\n")
13184 u_char uj
= use_json(argc
, argv
);
13186 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13188 return CMD_WARNING
;
13190 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13191 bgp_show_type_flap_neighbor
, uj
);
13194 DEFUN (show_ip_bgp_neighbor_damp
,
13195 show_ip_bgp_neighbor_damp_cmd
,
13196 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13200 "Detailed information on TCP and BGP neighbor connections\n"
13201 "Neighbor to display information about\n"
13202 "Neighbor to display information about\n"
13203 "Neighbor on bgp configured interface\n"
13204 "Display the dampened routes received from neighbor\n"
13205 "JavaScript Object Notation\n")
13208 u_char uj
= use_json(argc
, argv
);
13210 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13212 return CMD_WARNING
;
13214 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13215 bgp_show_type_damp_neighbor
, uj
);
13218 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13219 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13220 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13225 "Address Family modifier\n"
13226 "Address Family modifier\n"
13227 "Detailed information on TCP and BGP neighbor connections\n"
13228 "Neighbor to display information about\n"
13229 "Neighbor to display information about\n"
13230 "Neighbor on bgp configured interface\n"
13231 "Display routes learned from neighbor\n"
13232 "JavaScript Object Notation\n")
13235 u_char uj
= use_json(argc
, argv
);
13237 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13239 return CMD_WARNING
;
13241 if (strncmp (argv
[0], "m", 1) == 0)
13242 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
13243 bgp_show_type_neighbor
, uj
);
13245 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13246 bgp_show_type_neighbor
, uj
);
13250 DEFUN (show_bgp_instance_neighbor_routes
,
13251 show_bgp_instance_neighbor_routes_cmd
,
13252 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13255 BGP_INSTANCE_HELP_STR
13256 "Detailed information on TCP and BGP neighbor connections\n"
13257 "Neighbor to display information about\n"
13258 "Neighbor to display information about\n"
13259 "Neighbor on bgp configured interface\n"
13260 "Display routes learned from neighbor\n"
13261 "JavaScript Object Notation\n")
13264 u_char uj
= use_json(argc
, argv
);
13266 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13268 return CMD_WARNING
;
13270 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13271 bgp_show_type_neighbor
, uj
);
13274 ALIAS (show_bgp_instance_neighbor_routes
,
13275 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13276 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13279 BGP_INSTANCE_HELP_STR
13281 "Detailed information on TCP and BGP neighbor connections\n"
13282 "Neighbor to display information about\n"
13283 "Neighbor to display information about\n"
13284 "Neighbor on bgp configured interface\n"
13285 "Display routes learned from neighbor\n"
13286 "JavaScript Object Notation\n")
13288 DEFUN (show_bgp_instance_neighbor_damp
,
13289 show_bgp_instance_neighbor_damp_cmd
,
13290 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13293 BGP_INSTANCE_HELP_STR
13294 "Detailed information on TCP and BGP neighbor connections\n"
13295 "Neighbor to display information about\n"
13296 "Neighbor to display information about\n"
13297 "Neighbor on bgp configured interface\n"
13298 "Display the dampened routes received from neighbor\n"
13299 "JavaScript Object Notation\n")
13302 u_char uj
= use_json(argc
, argv
);
13304 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13305 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13306 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13308 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13311 return CMD_WARNING
;
13313 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13314 bgp_show_type_damp_neighbor
, uj
);
13317 ALIAS (show_bgp_instance_neighbor_damp
,
13318 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13319 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13322 BGP_INSTANCE_HELP_STR
13324 "Detailed information on TCP and BGP neighbor connections\n"
13325 "Neighbor to display information about\n"
13326 "Neighbor to display information about\n"
13327 "Neighbor on bgp configured interface\n"
13328 "Display the dampened routes received from neighbor\n"
13329 "JavaScript Object Notation\n")
13331 DEFUN (show_bgp_instance_neighbor_flap
,
13332 show_bgp_instance_neighbor_flap_cmd
,
13333 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13336 BGP_INSTANCE_HELP_STR
13337 "Detailed information on TCP and BGP neighbor connections\n"
13338 "Neighbor to display information about\n"
13339 "Neighbor to display information about\n"
13340 "Neighbor on bgp configured interface\n"
13341 "Display flap statistics of the routes learned from neighbor\n"
13342 "JavaScript Object Notation\n")
13345 u_char uj
= use_json(argc
, argv
);
13347 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13348 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13349 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13351 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13354 return CMD_WARNING
;
13356 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13357 bgp_show_type_flap_neighbor
, uj
);
13360 ALIAS (show_bgp_instance_neighbor_flap
,
13361 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13362 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13365 BGP_INSTANCE_HELP_STR
13367 "Detailed information on TCP and BGP neighbor connections\n"
13368 "Neighbor to display information about\n"
13369 "Neighbor to display information about\n"
13370 "Neighbor on bgp configured interface\n"
13371 "Display flap statistics of the routes learned from neighbor\n"
13372 "JavaScript Object Notation\n")
13374 DEFUN (show_bgp_neighbor_routes
,
13375 show_bgp_neighbor_routes_cmd
,
13376 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13379 "Detailed information on TCP and BGP neighbor connections\n"
13380 "Neighbor to display information about\n"
13381 "Neighbor to display information about\n"
13382 "Neighbor on bgp configured interface\n"
13383 "Display routes learned from neighbor\n"
13384 "JavaScript Object Notation\n")
13387 u_char uj
= use_json(argc
, argv
);
13389 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13391 return CMD_WARNING
;
13393 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13394 bgp_show_type_neighbor
, uj
);
13398 ALIAS (show_bgp_neighbor_routes
,
13399 show_bgp_ipv6_neighbor_routes_cmd
,
13400 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13404 "Detailed information on TCP and BGP neighbor connections\n"
13405 "Neighbor to display information about\n"
13406 "Neighbor to display information about\n"
13407 "Neighbor on bgp configured interface\n"
13408 "Display routes learned from neighbor\n"
13409 "JavaScript Object Notation\n")
13412 ALIAS (show_bgp_neighbor_routes
,
13413 ipv6_bgp_neighbor_routes_cmd
,
13414 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13418 "Detailed information on TCP and BGP neighbor connections\n"
13419 "Neighbor to display information about\n"
13420 "Neighbor to display information about\n"
13421 "Neighbor on bgp configured interface\n"
13422 "Display routes learned from neighbor\n"
13423 "JavaScript Object Notation\n")
13426 DEFUN (ipv6_mbgp_neighbor_routes
,
13427 ipv6_mbgp_neighbor_routes_cmd
,
13428 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13432 "Detailed information on TCP and BGP neighbor connections\n"
13433 "Neighbor to display information about\n"
13434 "Neighbor to display information about\n"
13435 "Neighbor on bgp configured interface\n"
13436 "Display routes learned from neighbor\n"
13437 "JavaScript Object Notation\n")
13440 u_char uj
= use_json(argc
, argv
);
13442 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13444 return CMD_WARNING
;
13446 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13447 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13448 bgp_show_type_neighbor
, uj
);
13451 ALIAS (show_bgp_instance_neighbor_flap
,
13452 show_bgp_neighbor_flap_cmd
,
13453 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13456 "Detailed information on TCP and BGP neighbor connections\n"
13457 "Neighbor to display information about\n"
13458 "Neighbor to display information about\n"
13459 "Neighbor on bgp configured interface\n"
13460 "Display flap statistics of the routes learned from neighbor\n"
13461 "JavaScript Object Notation\n")
13463 ALIAS (show_bgp_instance_neighbor_flap
,
13464 show_bgp_ipv6_neighbor_flap_cmd
,
13465 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13469 "Detailed information on TCP and BGP neighbor connections\n"
13470 "Neighbor to display information about\n"
13471 "Neighbor to display information about\n"
13472 "Neighbor on bgp configured interface\n"
13473 "Display flap statistics of the routes learned from neighbor\n"
13474 "JavaScript Object Notation\n")
13476 ALIAS (show_bgp_instance_neighbor_damp
,
13477 show_bgp_neighbor_damp_cmd
,
13478 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13481 "Detailed information on TCP and BGP neighbor connections\n"
13482 "Neighbor to display information about\n"
13483 "Neighbor to display information about\n"
13484 "Neighbor on bgp configured interface\n"
13485 "Display the dampened routes received from neighbor\n"
13486 "JavaScript Object Notation\n")
13488 ALIAS (show_bgp_instance_neighbor_damp
,
13489 show_bgp_ipv6_neighbor_damp_cmd
,
13490 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13494 "Detailed information on TCP and BGP neighbor connections\n"
13495 "Neighbor to display information about\n"
13496 "Neighbor to display information about\n"
13497 "Neighbor on bgp configured interface\n"
13498 "Display the dampened routes received from neighbor\n"
13499 "JavaScript Object Notation\n")
13501 #endif /* HAVE_IPV6 */
13503 struct bgp_table
*bgp_distance_table
;
13505 struct bgp_distance
13507 /* Distance value for the IP source prefix. */
13510 /* Name of the access-list to be matched. */
13514 static struct bgp_distance
*
13515 bgp_distance_new (void)
13517 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13521 bgp_distance_free (struct bgp_distance
*bdistance
)
13523 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13527 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13528 const char *ip_str
, const char *access_list_str
)
13531 struct prefix_ipv4 p
;
13533 struct bgp_node
*rn
;
13534 struct bgp_distance
*bdistance
;
13536 ret
= str2prefix_ipv4 (ip_str
, &p
);
13539 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13540 return CMD_WARNING
;
13543 distance
= atoi (distance_str
);
13545 /* Get BGP distance node. */
13546 rn
= bgp_node_get (bgp_distance_table
, (struct prefix
*) &p
);
13549 bdistance
= rn
->info
;
13550 bgp_unlock_node (rn
);
13554 bdistance
= bgp_distance_new ();
13555 rn
->info
= bdistance
;
13558 /* Set distance value. */
13559 bdistance
->distance
= distance
;
13561 /* Reset access-list configuration. */
13562 if (bdistance
->access_list
)
13564 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13565 bdistance
->access_list
= NULL
;
13567 if (access_list_str
)
13568 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13570 return CMD_SUCCESS
;
13574 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13575 const char *ip_str
, const char *access_list_str
)
13579 struct prefix_ipv4 p
;
13580 struct bgp_node
*rn
;
13581 struct bgp_distance
*bdistance
;
13583 ret
= str2prefix_ipv4 (ip_str
, &p
);
13586 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13587 return CMD_WARNING
;
13590 rn
= bgp_node_lookup (bgp_distance_table
, (struct prefix
*)&p
);
13593 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13594 return CMD_WARNING
;
13597 bdistance
= rn
->info
;
13598 distance
= atoi(distance_str
);
13600 if (bdistance
->distance
!= distance
)
13602 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13603 return CMD_WARNING
;
13606 if (bdistance
->access_list
)
13607 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13608 bgp_distance_free (bdistance
);
13611 bgp_unlock_node (rn
);
13612 bgp_unlock_node (rn
);
13614 return CMD_SUCCESS
;
13617 /* Apply BGP information to distance method. */
13619 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, struct bgp
*bgp
)
13621 struct bgp_node
*rn
;
13622 struct prefix_ipv4 q
;
13624 struct bgp_distance
*bdistance
;
13625 struct access_list
*alist
;
13626 struct bgp_static
*bgp_static
;
13631 if (p
->family
!= AF_INET
)
13634 peer
= rinfo
->peer
;
13636 if (peer
->su
.sa
.sa_family
!= AF_INET
)
13639 memset (&q
, 0, sizeof (struct prefix_ipv4
));
13640 q
.family
= AF_INET
;
13641 q
.prefix
= peer
->su
.sin
.sin_addr
;
13642 q
.prefixlen
= IPV4_MAX_BITLEN
;
13644 /* Check source address. */
13645 rn
= bgp_node_match (bgp_distance_table
, (struct prefix
*) &q
);
13648 bdistance
= rn
->info
;
13649 bgp_unlock_node (rn
);
13651 if (bdistance
->access_list
)
13653 alist
= access_list_lookup (AFI_IP
, bdistance
->access_list
);
13654 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13655 return bdistance
->distance
;
13658 return bdistance
->distance
;
13661 /* Backdoor check. */
13662 rn
= bgp_node_lookup (bgp
->route
[AFI_IP
][SAFI_UNICAST
], p
);
13665 bgp_static
= rn
->info
;
13666 bgp_unlock_node (rn
);
13668 if (bgp_static
->backdoor
)
13670 if (bgp
->distance_local
)
13671 return bgp
->distance_local
;
13673 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13677 if (peer
->sort
== BGP_PEER_EBGP
)
13679 if (bgp
->distance_ebgp
)
13680 return bgp
->distance_ebgp
;
13681 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
13685 if (bgp
->distance_ibgp
)
13686 return bgp
->distance_ibgp
;
13687 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13691 DEFUN (bgp_distance
,
13693 "distance bgp <1-255> <1-255> <1-255>",
13694 "Define an administrative distance\n"
13696 "Distance for routes external to the AS\n"
13697 "Distance for routes internal to the AS\n"
13698 "Distance for local routes\n")
13704 bgp
->distance_ebgp
= atoi (argv
[0]);
13705 bgp
->distance_ibgp
= atoi (argv
[1]);
13706 bgp
->distance_local
= atoi (argv
[2]);
13707 return CMD_SUCCESS
;
13710 DEFUN (no_bgp_distance
,
13711 no_bgp_distance_cmd
,
13712 "no distance bgp <1-255> <1-255> <1-255>",
13714 "Define an administrative distance\n"
13716 "Distance for routes external to the AS\n"
13717 "Distance for routes internal to the AS\n"
13718 "Distance for local routes\n")
13724 bgp
->distance_ebgp
= 0;
13725 bgp
->distance_ibgp
= 0;
13726 bgp
->distance_local
= 0;
13727 return CMD_SUCCESS
;
13730 ALIAS (no_bgp_distance
,
13731 no_bgp_distance2_cmd
,
13734 "Define an administrative distance\n"
13737 DEFUN (bgp_distance_source
,
13738 bgp_distance_source_cmd
,
13739 "distance <1-255> A.B.C.D/M",
13740 "Define an administrative distance\n"
13741 "Administrative distance\n"
13742 "IP source prefix\n")
13744 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
13745 return CMD_SUCCESS
;
13748 DEFUN (no_bgp_distance_source
,
13749 no_bgp_distance_source_cmd
,
13750 "no distance <1-255> A.B.C.D/M",
13752 "Define an administrative distance\n"
13753 "Administrative distance\n"
13754 "IP source prefix\n")
13756 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
13757 return CMD_SUCCESS
;
13760 DEFUN (bgp_distance_source_access_list
,
13761 bgp_distance_source_access_list_cmd
,
13762 "distance <1-255> A.B.C.D/M WORD",
13763 "Define an administrative distance\n"
13764 "Administrative distance\n"
13765 "IP source prefix\n"
13766 "Access list name\n")
13768 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
13769 return CMD_SUCCESS
;
13772 DEFUN (no_bgp_distance_source_access_list
,
13773 no_bgp_distance_source_access_list_cmd
,
13774 "no distance <1-255> A.B.C.D/M WORD",
13776 "Define an administrative distance\n"
13777 "Administrative distance\n"
13778 "IP source prefix\n"
13779 "Access list name\n")
13781 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
13782 return CMD_SUCCESS
;
13785 DEFUN (bgp_damp_set
,
13787 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
13788 "BGP Specific commands\n"
13789 "Enable route-flap dampening\n"
13790 "Half-life time for the penalty\n"
13791 "Value to start reusing a route\n"
13792 "Value to start suppressing a route\n"
13793 "Maximum duration to suppress a stable route\n")
13796 int half
= DEFAULT_HALF_LIFE
* 60;
13797 int reuse
= DEFAULT_REUSE
;
13798 int suppress
= DEFAULT_SUPPRESS
;
13799 int max
= 4 * half
;
13803 half
= atoi (argv
[0]) * 60;
13804 reuse
= atoi (argv
[1]);
13805 suppress
= atoi (argv
[2]);
13806 max
= atoi (argv
[3]) * 60;
13808 else if (argc
== 1)
13810 half
= atoi (argv
[0]) * 60;
13816 if (suppress
< reuse
)
13818 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
13823 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
13824 half
, reuse
, suppress
, max
);
13827 ALIAS (bgp_damp_set
,
13829 "bgp dampening <1-45>",
13830 "BGP Specific commands\n"
13831 "Enable route-flap dampening\n"
13832 "Half-life time for the penalty\n")
13834 ALIAS (bgp_damp_set
,
13837 "BGP Specific commands\n"
13838 "Enable route-flap dampening\n")
13840 DEFUN (bgp_damp_unset
,
13841 bgp_damp_unset_cmd
,
13842 "no bgp dampening",
13844 "BGP Specific commands\n"
13845 "Enable route-flap dampening\n")
13850 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
13853 ALIAS (bgp_damp_unset
,
13854 bgp_damp_unset2_cmd
,
13855 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
13857 "BGP Specific commands\n"
13858 "Enable route-flap dampening\n"
13859 "Half-life time for the penalty\n"
13860 "Value to start reusing a route\n"
13861 "Value to start suppressing a route\n"
13862 "Maximum duration to suppress a stable route\n")
13864 ALIAS (bgp_damp_unset
,
13865 bgp_damp_unset3_cmd
,
13866 "no bgp dampening <1-45>",
13868 "BGP Specific commands\n"
13869 "Enable route-flap dampening\n"
13870 "Half-life time for the penalty\n")
13872 DEFUN (show_ip_bgp_dampened_paths
,
13873 show_ip_bgp_dampened_paths_cmd
,
13874 "show ip bgp dampened-paths",
13878 "Display paths suppressed due to dampening\n")
13880 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
13884 ALIAS (show_ip_bgp_dampened_paths
,
13885 show_ip_bgp_damp_dampened_paths_cmd
,
13886 "show ip bgp dampening dampened-paths",
13890 "Display detailed information about dampening\n"
13891 "Display paths suppressed due to dampening\n")
13893 DEFUN (show_ip_bgp_flap_statistics
,
13894 show_ip_bgp_flap_statistics_cmd
,
13895 "show ip bgp flap-statistics",
13899 "Display flap statistics of routes\n")
13901 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
13902 bgp_show_type_flap_statistics
, NULL
, 0);
13905 ALIAS (show_ip_bgp_flap_statistics
,
13906 show_ip_bgp_damp_flap_statistics_cmd
,
13907 "show ip bgp dampening flap-statistics",
13911 "Display detailed information about dampening\n"
13912 "Display flap statistics of routes\n")
13914 /* Display specified route of BGP table. */
13916 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
13917 const char *ip_str
, afi_t afi
, safi_t safi
,
13918 struct prefix_rd
*prd
, int prefix_check
)
13921 struct prefix match
;
13922 struct bgp_node
*rn
;
13923 struct bgp_node
*rm
;
13924 struct bgp_info
*ri
;
13925 struct bgp_info
*ri_temp
;
13927 struct bgp_table
*table
;
13929 /* BGP structure lookup. */
13932 bgp
= bgp_lookup_by_name (view_name
);
13935 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
13936 return CMD_WARNING
;
13941 bgp
= bgp_get_default ();
13944 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
13945 return CMD_WARNING
;
13949 /* Check IP address argument. */
13950 ret
= str2prefix (ip_str
, &match
);
13953 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
13954 return CMD_WARNING
;
13957 match
.family
= afi2family (afi
);
13959 if (safi
== SAFI_MPLS_VPN
)
13961 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][SAFI_MPLS_VPN
]); rn
; rn
= bgp_route_next (rn
))
13963 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
13966 if ((table
= rn
->info
) != NULL
)
13967 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
13969 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
13974 if (ri
->extra
&& ri
->extra
->damp_info
)
13976 ri_temp
= ri
->next
;
13977 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
13985 bgp_unlock_node (rm
);
13991 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
13993 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
13998 if (ri
->extra
&& ri
->extra
->damp_info
)
14000 ri_temp
= ri
->next
;
14001 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14009 bgp_unlock_node (rn
);
14013 return CMD_SUCCESS
;
14016 DEFUN (clear_ip_bgp_dampening
,
14017 clear_ip_bgp_dampening_cmd
,
14018 "clear ip bgp dampening",
14022 "Clear route flap dampening information\n")
14024 bgp_damp_info_clean ();
14025 return CMD_SUCCESS
;
14028 DEFUN (clear_ip_bgp_dampening_prefix
,
14029 clear_ip_bgp_dampening_prefix_cmd
,
14030 "clear ip bgp dampening A.B.C.D/M",
14034 "Clear route flap dampening information\n"
14035 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14037 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14038 SAFI_UNICAST
, NULL
, 1);
14041 DEFUN (clear_ip_bgp_dampening_address
,
14042 clear_ip_bgp_dampening_address_cmd
,
14043 "clear ip bgp dampening A.B.C.D",
14047 "Clear route flap dampening information\n"
14048 "Network to clear damping information\n")
14050 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14051 SAFI_UNICAST
, NULL
, 0);
14054 DEFUN (clear_ip_bgp_dampening_address_mask
,
14055 clear_ip_bgp_dampening_address_mask_cmd
,
14056 "clear ip bgp dampening A.B.C.D A.B.C.D",
14060 "Clear route flap dampening information\n"
14061 "Network to clear damping information\n"
14065 char prefix_str
[BUFSIZ
];
14067 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14070 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14071 return CMD_WARNING
;
14074 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14075 SAFI_UNICAST
, NULL
, 0);
14079 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14080 afi_t afi
, safi_t safi
, int *write
)
14082 struct bgp_node
*prn
;
14083 struct bgp_node
*rn
;
14084 struct bgp_table
*table
;
14086 struct prefix_rd
*prd
;
14087 struct bgp_static
*bgp_static
;
14089 char buf
[SU_ADDRSTRLEN
];
14090 char rdbuf
[RD_ADDRSTRLEN
];
14092 /* Network configuration. */
14093 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14094 if ((table
= prn
->info
) != NULL
)
14095 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14096 if ((bgp_static
= rn
->info
) != NULL
)
14099 prd
= (struct prefix_rd
*) &prn
->p
;
14101 /* "address-family" display. */
14102 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14104 /* "network" configuration display. */
14105 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14106 label
= decode_label (bgp_static
->tag
);
14108 vty_out (vty
, " network %s/%d rd %s tag %d",
14109 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14112 vty_out (vty
, "%s", VTY_NEWLINE
);
14117 /* Configuration of static route announcement and aggregate
14120 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14121 afi_t afi
, safi_t safi
, int *write
)
14123 struct bgp_node
*rn
;
14125 struct bgp_static
*bgp_static
;
14126 struct bgp_aggregate
*bgp_aggregate
;
14127 char buf
[SU_ADDRSTRLEN
];
14129 if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
14130 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14132 /* Network configuration. */
14133 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14134 if ((bgp_static
= rn
->info
) != NULL
)
14138 /* "address-family" display. */
14139 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14141 /* "network" configuration display. */
14142 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14144 u_int32_t destination
;
14145 struct in_addr netmask
;
14147 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14148 masklen2ip (p
->prefixlen
, &netmask
);
14149 vty_out (vty
, " network %s",
14150 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14152 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14153 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14154 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14155 || p
->u
.prefix4
.s_addr
== 0)
14157 /* Natural mask is not display. */
14160 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14164 vty_out (vty
, " network %s/%d",
14165 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14169 if (bgp_static
->rmap
.name
)
14170 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14173 if (bgp_static
->backdoor
)
14174 vty_out (vty
, " backdoor");
14177 vty_out (vty
, "%s", VTY_NEWLINE
);
14180 /* Aggregate-address configuration. */
14181 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14182 if ((bgp_aggregate
= rn
->info
) != NULL
)
14186 /* "address-family" display. */
14187 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14189 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14191 struct in_addr netmask
;
14193 masklen2ip (p
->prefixlen
, &netmask
);
14194 vty_out (vty
, " aggregate-address %s %s",
14195 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14196 inet_ntoa (netmask
));
14200 vty_out (vty
, " aggregate-address %s/%d",
14201 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14205 if (bgp_aggregate
->as_set
)
14206 vty_out (vty
, " as-set");
14208 if (bgp_aggregate
->summary_only
)
14209 vty_out (vty
, " summary-only");
14211 vty_out (vty
, "%s", VTY_NEWLINE
);
14218 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
)
14220 struct bgp_node
*rn
;
14221 struct bgp_distance
*bdistance
;
14223 /* Distance configuration. */
14224 if (bgp
->distance_ebgp
14225 && bgp
->distance_ibgp
14226 && bgp
->distance_local
14227 && (bgp
->distance_ebgp
!= ZEBRA_EBGP_DISTANCE_DEFAULT
14228 || bgp
->distance_ibgp
!= ZEBRA_IBGP_DISTANCE_DEFAULT
14229 || bgp
->distance_local
!= ZEBRA_IBGP_DISTANCE_DEFAULT
))
14230 vty_out (vty
, " distance bgp %d %d %d%s",
14231 bgp
->distance_ebgp
, bgp
->distance_ibgp
, bgp
->distance_local
,
14234 for (rn
= bgp_table_top (bgp_distance_table
); rn
; rn
= bgp_route_next (rn
))
14235 if ((bdistance
= rn
->info
) != NULL
)
14237 vty_out (vty
, " distance %d %s/%d %s%s", bdistance
->distance
,
14238 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
14239 bdistance
->access_list
? bdistance
->access_list
: "",
14246 /* Allocate routing table structure and install commands. */
14248 bgp_route_init (void)
14250 /* Init BGP distance table. */
14251 bgp_distance_table
= bgp_table_init (AFI_IP
, SAFI_UNICAST
);
14253 /* IPv4 BGP commands. */
14254 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14255 install_element (BGP_NODE
, &bgp_network_cmd
);
14256 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14257 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14258 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14259 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14260 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14261 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14262 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14263 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14264 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14265 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14266 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14267 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14268 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14269 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14270 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14271 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14272 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14273 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14275 install_element (BGP_NODE
, &aggregate_address_cmd
);
14276 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14277 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14278 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14279 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14280 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14281 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14282 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14283 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14284 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14285 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14286 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14287 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14288 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14289 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14290 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14291 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14292 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14293 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14294 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14296 /* IPv4 unicast configuration. */
14297 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14298 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14299 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14300 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14301 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14302 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14303 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14304 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14305 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14306 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14307 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14308 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14309 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14310 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14312 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14313 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14314 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14315 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14316 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14317 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14318 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14319 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14320 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14321 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14322 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14323 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14324 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14325 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14326 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14327 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14328 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14329 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14330 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14331 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14333 /* IPv4 multicast configuration. */
14334 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14335 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14336 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14337 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14338 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14339 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14340 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14341 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14342 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14343 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14344 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14345 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14346 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14347 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14348 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14349 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14350 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14351 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14352 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14353 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14354 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14355 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14356 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14357 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14358 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14359 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14360 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14361 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14362 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14363 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14364 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14365 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14366 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14367 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14369 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14370 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14371 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14372 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14373 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14374 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14375 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14376 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14377 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14378 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14379 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14380 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14381 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14382 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14383 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14384 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14385 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14386 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14387 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14388 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14389 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14390 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14391 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14392 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14394 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14395 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14396 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14397 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14398 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14399 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14400 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14401 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14402 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14403 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14404 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14405 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14406 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14407 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14408 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14409 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14410 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14411 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14412 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14413 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14414 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14415 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14416 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14417 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14418 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14419 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14420 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14421 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14422 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14423 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14424 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14425 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14426 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14427 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14428 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14429 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14430 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14431 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14432 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14433 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14434 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14435 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14436 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14437 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14438 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14439 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14440 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14441 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14442 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14443 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14444 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14445 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14446 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14447 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14448 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14449 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14450 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14451 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14452 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14453 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14454 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14455 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14456 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14457 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14458 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14459 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14460 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14461 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14462 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14463 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14464 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14465 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14466 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14467 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14468 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14469 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14470 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14471 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14472 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14473 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14474 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14475 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14476 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14478 /* Restricted node: VIEW_NODE - (set of dangerous commands) */
14479 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_cmd
);
14480 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14481 install_element (RESTRICTED_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14482 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14483 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14484 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14485 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14486 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14487 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_cmd
);
14488 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14489 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14490 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14491 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14492 install_element (RESTRICTED_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14493 install_element (RESTRICTED_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14494 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14495 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14496 install_element (RESTRICTED_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14497 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_route_cmd
);
14498 install_element (RESTRICTED_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14499 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_cmd
);
14500 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_cmd
);
14501 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_cmd
);
14502 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_cmd
);
14503 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14504 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14505 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14506 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14507 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14508 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14509 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14510 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14511 install_element (RESTRICTED_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14512 install_element (RESTRICTED_NODE
, &show_ip_bgp_community_exact_cmd
);
14513 install_element (RESTRICTED_NODE
, &show_ip_bgp_community2_exact_cmd
);
14514 install_element (RESTRICTED_NODE
, &show_ip_bgp_community3_exact_cmd
);
14515 install_element (RESTRICTED_NODE
, &show_ip_bgp_community4_exact_cmd
);
14516 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14517 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14518 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14519 install_element (RESTRICTED_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14521 install_element (ENABLE_NODE
, &show_ip_bgp_cmd
);
14522 install_element (ENABLE_NODE
, &show_ip_bgp_instance_cmd
);
14523 install_element (ENABLE_NODE
, &show_ip_bgp_instance_all_cmd
);
14524 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cmd
);
14525 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_cmd
);
14526 install_element (ENABLE_NODE
, &show_ip_bgp_route_cmd
);
14527 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_cmd
);
14528 install_element (ENABLE_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14529 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14530 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14531 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14532 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14533 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14534 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14535 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_cmd
);
14536 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14537 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14538 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14539 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14540 install_element (ENABLE_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14541 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14542 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14543 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14544 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14546 install_element (ENABLE_NODE
, &show_ip_bgp_regexp_cmd
);
14547 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14548 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_list_cmd
);
14549 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14550 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14551 install_element (ENABLE_NODE
, &show_ip_bgp_filter_list_cmd
);
14552 install_element (ENABLE_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14553 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14554 install_element (ENABLE_NODE
, &show_ip_bgp_route_map_cmd
);
14555 install_element (ENABLE_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14556 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14557 install_element (ENABLE_NODE
, &show_ip_bgp_cidr_only_cmd
);
14558 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14559 install_element (ENABLE_NODE
, &show_ip_bgp_community_all_cmd
);
14560 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14561 install_element (ENABLE_NODE
, &show_ip_bgp_community_cmd
);
14562 install_element (ENABLE_NODE
, &show_ip_bgp_community2_cmd
);
14563 install_element (ENABLE_NODE
, &show_ip_bgp_community3_cmd
);
14564 install_element (ENABLE_NODE
, &show_ip_bgp_community4_cmd
);
14565 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14566 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14567 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14568 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14569 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14570 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14571 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14572 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14573 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14574 install_element (ENABLE_NODE
, &show_ip_bgp_community_exact_cmd
);
14575 install_element (ENABLE_NODE
, &show_ip_bgp_community2_exact_cmd
);
14576 install_element (ENABLE_NODE
, &show_ip_bgp_community3_exact_cmd
);
14577 install_element (ENABLE_NODE
, &show_ip_bgp_community4_exact_cmd
);
14578 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14579 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14580 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14581 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14582 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_cmd
);
14583 install_element (ENABLE_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14584 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14585 install_element (ENABLE_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14586 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14587 install_element (ENABLE_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14588 install_element (ENABLE_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14589 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14590 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14591 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14592 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14593 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14594 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14595 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14596 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14597 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14598 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14599 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14600 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14601 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14602 install_element (ENABLE_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14603 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14604 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14605 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14606 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14607 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14608 install_element (ENABLE_NODE
, &show_ip_bgp_dampening_params_cmd
);
14609 install_element (ENABLE_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14610 install_element (ENABLE_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14611 install_element (ENABLE_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14612 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14613 install_element (ENABLE_NODE
, &show_ip_bgp_flap_address_cmd
);
14614 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14615 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14616 install_element (ENABLE_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14617 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14618 install_element (ENABLE_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14619 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_regexp_cmd
);
14620 install_element (ENABLE_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14621 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14622 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14623 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14624 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14625 install_element (ENABLE_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14626 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14627 install_element (ENABLE_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14628 install_element (ENABLE_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14629 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14630 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14632 /* BGP dampening clear commands */
14633 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14634 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14635 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14636 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14639 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14640 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14641 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14642 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
14644 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14645 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14647 /* New config IPv6 BGP commands. */
14648 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14649 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14650 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14651 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14652 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14653 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14655 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14656 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14657 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14658 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14660 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14661 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14663 /* Old config IPv6 BGP commands. */
14664 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14665 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14667 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14668 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14669 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14670 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14672 install_element (VIEW_NODE
, &show_bgp_cmd
);
14673 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14674 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14675 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14676 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14677 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14678 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14679 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14680 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14681 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14682 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14683 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14684 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14685 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14686 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14687 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14688 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14689 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14690 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14691 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14692 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14693 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14694 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14695 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14696 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14697 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14698 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14699 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14700 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14701 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14702 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14703 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14704 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14705 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14706 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14707 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14708 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14709 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14710 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14711 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14712 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14713 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14714 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14715 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14716 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14717 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14718 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14719 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14720 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14721 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14722 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14723 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14724 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14725 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14726 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14727 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14728 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14729 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14730 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14731 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14732 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14733 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14734 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14735 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14736 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14737 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14738 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14739 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14740 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14741 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14742 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14743 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14744 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14745 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14746 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14747 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14748 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14749 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14750 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14751 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14752 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14753 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14754 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14755 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14756 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14757 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14758 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14759 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14760 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14761 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14762 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14763 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14766 * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
14768 install_element (RESTRICTED_NODE
, &show_bgp_route_cmd
);
14769 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_cmd
);
14770 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14771 install_element (RESTRICTED_NODE
, &show_bgp_route_pathtype_cmd
);
14772 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14773 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14774 install_element (RESTRICTED_NODE
, &show_bgp_prefix_cmd
);
14775 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_cmd
);
14776 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14777 install_element (RESTRICTED_NODE
, &show_bgp_prefix_pathtype_cmd
);
14778 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14779 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14780 install_element (RESTRICTED_NODE
, &show_bgp_community_cmd
);
14781 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_cmd
);
14782 install_element (RESTRICTED_NODE
, &show_bgp_community2_cmd
);
14783 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_cmd
);
14784 install_element (RESTRICTED_NODE
, &show_bgp_community3_cmd
);
14785 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_cmd
);
14786 install_element (RESTRICTED_NODE
, &show_bgp_community4_cmd
);
14787 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_cmd
);
14788 install_element (RESTRICTED_NODE
, &show_bgp_community_exact_cmd
);
14789 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14790 install_element (RESTRICTED_NODE
, &show_bgp_community2_exact_cmd
);
14791 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14792 install_element (RESTRICTED_NODE
, &show_bgp_community3_exact_cmd
);
14793 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14794 install_element (RESTRICTED_NODE
, &show_bgp_community4_exact_cmd
);
14795 install_element (RESTRICTED_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14796 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_cmd
);
14797 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14798 install_element (RESTRICTED_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14799 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14800 install_element (RESTRICTED_NODE
, &show_bgp_instance_prefix_cmd
);
14801 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14802 install_element (RESTRICTED_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14803 install_element (RESTRICTED_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14805 install_element (ENABLE_NODE
, &show_bgp_cmd
);
14806 install_element (ENABLE_NODE
, &show_bgp_ipv6_cmd
);
14807 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_cmd
);
14808 install_element (ENABLE_NODE
, &show_bgp_route_cmd
);
14809 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_cmd
);
14810 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14811 install_element (ENABLE_NODE
, &show_bgp_route_pathtype_cmd
);
14812 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14813 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14814 install_element (ENABLE_NODE
, &show_bgp_prefix_cmd
);
14815 install_element (ENABLE_NODE
, &show_bgp_prefix_pathtype_cmd
);
14816 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14817 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14818 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_cmd
);
14819 install_element (ENABLE_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14820 install_element (ENABLE_NODE
, &show_bgp_regexp_cmd
);
14821 install_element (ENABLE_NODE
, &show_bgp_ipv6_regexp_cmd
);
14822 install_element (ENABLE_NODE
, &show_bgp_prefix_list_cmd
);
14823 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14824 install_element (ENABLE_NODE
, &show_bgp_filter_list_cmd
);
14825 install_element (ENABLE_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14826 install_element (ENABLE_NODE
, &show_bgp_route_map_cmd
);
14827 install_element (ENABLE_NODE
, &show_bgp_ipv6_route_map_cmd
);
14828 install_element (ENABLE_NODE
, &show_bgp_community_all_cmd
);
14829 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_all_cmd
);
14830 install_element (ENABLE_NODE
, &show_bgp_community_cmd
);
14831 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_cmd
);
14832 install_element (ENABLE_NODE
, &show_bgp_community2_cmd
);
14833 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_cmd
);
14834 install_element (ENABLE_NODE
, &show_bgp_community3_cmd
);
14835 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_cmd
);
14836 install_element (ENABLE_NODE
, &show_bgp_community4_cmd
);
14837 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_cmd
);
14838 install_element (ENABLE_NODE
, &show_bgp_community_exact_cmd
);
14839 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14840 install_element (ENABLE_NODE
, &show_bgp_community2_exact_cmd
);
14841 install_element (ENABLE_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14842 install_element (ENABLE_NODE
, &show_bgp_community3_exact_cmd
);
14843 install_element (ENABLE_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14844 install_element (ENABLE_NODE
, &show_bgp_community4_exact_cmd
);
14845 install_element (ENABLE_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14846 install_element (ENABLE_NODE
, &show_bgp_community_list_cmd
);
14847 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_cmd
);
14848 install_element (ENABLE_NODE
, &show_bgp_community_list_exact_cmd
);
14849 install_element (ENABLE_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14850 install_element (ENABLE_NODE
, &show_bgp_prefix_longer_cmd
);
14851 install_element (ENABLE_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14852 install_element (ENABLE_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14853 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14854 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14855 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14856 install_element (ENABLE_NODE
, &show_bgp_neighbor_routes_cmd
);
14857 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14858 install_element (ENABLE_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14859 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14860 install_element (ENABLE_NODE
, &show_bgp_neighbor_flap_cmd
);
14861 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14862 install_element (ENABLE_NODE
, &show_bgp_neighbor_damp_cmd
);
14863 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14864 install_element (ENABLE_NODE
, &show_bgp_instance_cmd
);
14865 install_element (ENABLE_NODE
, &show_bgp_instance_all_cmd
);
14866 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_cmd
);
14867 install_element (ENABLE_NODE
, &show_bgp_instance_route_cmd
);
14868 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14869 install_element (ENABLE_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14870 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14871 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_cmd
);
14872 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14873 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14874 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14875 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_list_cmd
);
14876 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14877 install_element (ENABLE_NODE
, &show_bgp_instance_filter_list_cmd
);
14878 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14879 install_element (ENABLE_NODE
, &show_bgp_instance_route_map_cmd
);
14880 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14881 install_element (ENABLE_NODE
, &show_bgp_instance_community_list_cmd
);
14882 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14883 install_element (ENABLE_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14884 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14885 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14886 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14887 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14888 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14889 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14890 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14891 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14892 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14893 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14894 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14895 install_element (ENABLE_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14896 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14899 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
14900 install_element (ENABLE_NODE
, &show_bgp_statistics_vpnv4_cmd
);
14901 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
14902 install_element (ENABLE_NODE
, &show_bgp_statistics_view_vpnv4_cmd
);
14905 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
14906 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
14907 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
14908 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
14909 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14910 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14911 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
14912 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
14913 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
14914 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
14915 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
14916 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14917 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14918 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14919 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14920 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
14921 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14922 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14923 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
14924 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
14925 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14926 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14927 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14928 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14929 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14930 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
14931 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
14932 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
14933 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
14934 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14935 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14936 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14937 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
14938 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
14939 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
14940 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14943 install_element (ENABLE_NODE
, &show_ipv6_bgp_cmd
);
14944 install_element (ENABLE_NODE
, &show_ipv6_bgp_route_cmd
);
14945 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_cmd
);
14946 install_element (ENABLE_NODE
, &show_ipv6_bgp_regexp_cmd
);
14947 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14948 install_element (ENABLE_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14949 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_all_cmd
);
14950 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_cmd
);
14951 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_cmd
);
14952 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_cmd
);
14953 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_cmd
);
14954 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14955 install_element (ENABLE_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14956 install_element (ENABLE_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14957 install_element (ENABLE_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14958 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_cmd
);
14959 install_element (ENABLE_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14960 install_element (ENABLE_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14961 install_element (ENABLE_NODE
, &show_ipv6_mbgp_cmd
);
14962 install_element (ENABLE_NODE
, &show_ipv6_mbgp_route_cmd
);
14963 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14964 install_element (ENABLE_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14965 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14966 install_element (ENABLE_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14967 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14968 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_cmd
);
14969 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_cmd
);
14970 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_cmd
);
14971 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_cmd
);
14972 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14973 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14974 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14975 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
14976 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_cmd
);
14977 install_element (ENABLE_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
14978 install_element (ENABLE_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14981 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14982 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14983 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14984 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14987 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14988 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14989 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14990 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14993 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14994 install_element (ENABLE_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14995 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14996 install_element (ENABLE_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14997 #endif /* HAVE_IPV6 */
14999 install_element (BGP_NODE
, &bgp_distance_cmd
);
15000 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
15001 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
15002 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
15003 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
15004 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
15005 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
15007 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15008 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15009 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15010 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15011 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15012 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15013 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15014 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15015 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15016 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15017 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15018 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15022 bgp_route_finish (void)
15024 bgp_table_unlock (bgp_distance_table
);
15025 bgp_distance_table
= NULL
;