1 /* BGP routing information
2 Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
34 #include "sockunion.h"
37 #include "workqueue.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_table.h"
43 #include "bgpd/bgp_route.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_debug.h"
46 #include "bgpd/bgp_aspath.h"
47 #include "bgpd/bgp_regex.h"
48 #include "bgpd/bgp_community.h"
49 #include "bgpd/bgp_ecommunity.h"
50 #include "bgpd/bgp_clist.h"
51 #include "bgpd/bgp_packet.h"
52 #include "bgpd/bgp_filter.h"
53 #include "bgpd/bgp_fsm.h"
54 #include "bgpd/bgp_mplsvpn.h"
55 #include "bgpd/bgp_nexthop.h"
56 #include "bgpd/bgp_damp.h"
57 #include "bgpd/bgp_advertise.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_vty.h"
60 #include "bgpd/bgp_mpath.h"
61 #include "bgpd/bgp_nht.h"
62 #include "bgpd/bgp_updgrp.h"
63 #include "bgpd/bgp_vty.h"
66 #include "bgpd/rfapi/rfapi_backend.h"
67 #include "bgpd/rfapi/vnc_import_bgp.h"
68 #include "bgpd/rfapi/vnc_export_bgp.h"
71 /* Extern from bgp_dump.c */
72 extern const char *bgp_origin_str
[];
73 extern const char *bgp_origin_long_str
[];
76 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
77 struct prefix_rd
*prd
)
80 struct bgp_node
*prn
= NULL
;
86 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
88 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
90 if (prn
->info
== NULL
)
91 prn
->info
= bgp_table_init (afi
, safi
);
93 bgp_unlock_node (prn
);
97 rn
= bgp_node_get (table
, p
);
99 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
105 /* Allocate bgp_info_extra */
106 static struct bgp_info_extra
*
107 bgp_info_extra_new (void)
109 struct bgp_info_extra
*new;
110 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
115 bgp_info_extra_free (struct bgp_info_extra
**extra
)
119 if ((*extra
)->damp_info
)
120 bgp_damp_info_free ((*extra
)->damp_info
, 0);
122 (*extra
)->damp_info
= NULL
;
124 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
130 /* Get bgp_info extra information for the given bgp_info, lazy allocated
133 struct bgp_info_extra
*
134 bgp_info_extra_get (struct bgp_info
*ri
)
137 ri
->extra
= bgp_info_extra_new();
141 /* Allocate new bgp info structure. */
145 return XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
148 /* Free bgp route information. */
150 bgp_info_free (struct bgp_info
*binfo
)
153 bgp_attr_unintern (&binfo
->attr
);
155 bgp_unlink_nexthop(binfo
);
156 bgp_info_extra_free (&binfo
->extra
);
157 bgp_info_mpath_free (&binfo
->mpath
);
159 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
161 XFREE (MTYPE_BGP_ROUTE
, binfo
);
165 bgp_info_lock (struct bgp_info
*binfo
)
172 bgp_info_unlock (struct bgp_info
*binfo
)
174 assert (binfo
&& binfo
->lock
> 0);
177 if (binfo
->lock
== 0)
180 zlog_debug ("%s: unlocked and freeing", __func__
);
181 zlog_backtrace (LOG_DEBUG
);
183 bgp_info_free (binfo
);
188 if (binfo
->lock
== 1)
190 zlog_debug ("%s: unlocked to 1", __func__
);
191 zlog_backtrace (LOG_DEBUG
);
199 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
201 struct bgp_info
*top
;
213 peer_lock (ri
->peer
); /* bgp_info peer reference */
216 /* Do the actual removal of info from RIB, for use by bgp_process
217 completion callback *only* */
219 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
222 ri
->next
->prev
= ri
->prev
;
224 ri
->prev
->next
= ri
->next
;
228 bgp_info_mpath_dequeue (ri
);
229 bgp_info_unlock (ri
);
230 bgp_unlock_node (rn
);
234 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
236 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
237 /* set of previous already took care of pcount */
238 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
241 /* undo the effects of a previous call to bgp_info_delete; typically
242 called when a route is deleted and then quickly re-added before the
243 deletion has been processed */
245 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
247 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
248 /* unset of previous already took care of pcount */
249 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
252 /* Adjust pcount as required */
254 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
256 struct bgp_table
*table
;
258 assert (rn
&& bgp_node_table (rn
));
259 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
261 table
= bgp_node_table (rn
);
263 if (ri
->peer
== ri
->peer
->bgp
->peer_self
)
266 if (!BGP_INFO_COUNTABLE (ri
)
267 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
270 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
272 /* slight hack, but more robust against errors. */
273 if (ri
->peer
->pcount
[table
->afi
][table
->safi
])
274 ri
->peer
->pcount
[table
->afi
][table
->safi
]--;
277 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
278 __func__
, ri
->peer
->host
);
279 zlog_backtrace (LOG_WARNING
);
280 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
283 else if (BGP_INFO_COUNTABLE (ri
)
284 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
286 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
287 ri
->peer
->pcount
[table
->afi
][table
->safi
]++;
292 /* Set/unset bgp_info flags, adjusting any other state as needed.
293 * This is here primarily to keep prefix-count in check.
296 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
298 SET_FLAG (ri
->flags
, flag
);
300 /* early bath if we know it's not a flag that changes countability state */
301 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
304 bgp_pcount_adjust (rn
, ri
);
308 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
310 UNSET_FLAG (ri
->flags
, flag
);
312 /* early bath if we know it's not a flag that changes countability state */
313 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
316 bgp_pcount_adjust (rn
, ri
);
319 /* Get MED value. If MED value is missing and "bgp bestpath
320 missing-as-worst" is specified, treat it as the worst value. */
322 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
324 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
328 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
336 bgp_info_path_with_addpath_rx_str (struct bgp_info
*ri
, char *buf
)
338 if (ri
->addpath_rx_id
)
339 sprintf(buf
, "path %s (addpath rxid %d)", ri
->peer
->host
, ri
->addpath_rx_id
);
341 sprintf(buf
, "path %s", ri
->peer
->host
);
344 /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */
346 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
347 int *paths_eq
, struct bgp_maxpaths_cfg
*mpath_cfg
, int debug
,
350 struct attr
*newattr
, *existattr
;
351 struct attr_extra
*newattre
, *existattre
;
352 bgp_peer_sort_t new_sort
;
353 bgp_peer_sort_t exist_sort
;
355 u_int32_t exist_pref
;
358 u_int32_t new_weight
;
359 u_int32_t exist_weight
;
360 uint32_t newm
, existm
;
361 struct in_addr new_id
;
362 struct in_addr exist_id
;
365 int internal_as_route
;
368 char new_buf
[PATH_ADDPATH_STR_BUFFER
];
369 char exist_buf
[PATH_ADDPATH_STR_BUFFER
];
377 zlog_debug("%s: new is NULL", pfx_buf
);
382 bgp_info_path_with_addpath_rx_str (new, new_buf
);
387 zlog_debug("%s: %s is the initial bestpath", pfx_buf
, new_buf
);
393 bgp_info_path_with_addpath_rx_str (exist
, exist_buf
);
394 zlog_debug("%s: Comparing %s flags 0x%x with %s flags 0x%x",
395 pfx_buf
, new_buf
, new->flags
, exist_buf
, exist
->flags
);
399 existattr
= exist
->attr
;
400 newattre
= newattr
->extra
;
401 existattre
= existattr
->extra
;
403 /* 1. Weight check. */
404 new_weight
= exist_weight
= 0;
407 new_weight
= newattre
->weight
;
409 exist_weight
= existattre
->weight
;
411 if (new_weight
> exist_weight
)
414 zlog_debug("%s: %s wins over %s due to weight %d > %d",
415 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
419 if (new_weight
< exist_weight
)
422 zlog_debug("%s: %s loses to %s due to weight %d < %d",
423 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
427 /* 2. Local preference check. */
428 new_pref
= exist_pref
= bgp
->default_local_pref
;
430 if (newattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
431 new_pref
= newattr
->local_pref
;
432 if (existattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
433 exist_pref
= existattr
->local_pref
;
435 if (new_pref
> exist_pref
)
438 zlog_debug("%s: %s wins over %s due to localpref %d > %d",
439 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
443 if (new_pref
< exist_pref
)
446 zlog_debug("%s: %s loses to %s due to localpref %d < %d",
447 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
451 /* 3. Local route check. We prefer:
453 * - BGP_ROUTE_AGGREGATE
454 * - BGP_ROUTE_REDISTRIBUTE
456 if (! (new->sub_type
== BGP_ROUTE_NORMAL
))
459 zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type",
460 pfx_buf
, new_buf
, exist_buf
);
464 if (! (exist
->sub_type
== BGP_ROUTE_NORMAL
))
467 zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type",
468 pfx_buf
, new_buf
, exist_buf
);
472 /* 4. AS path length check. */
473 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
475 int exist_hops
= aspath_count_hops (existattr
->aspath
);
476 int exist_confeds
= aspath_count_confeds (existattr
->aspath
);
478 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
482 aspath_hops
= aspath_count_hops (newattr
->aspath
);
483 aspath_hops
+= aspath_count_confeds (newattr
->aspath
);
485 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
488 zlog_debug("%s: %s wins over %s due to aspath (with confeds) hopcount %d < %d",
489 pfx_buf
, new_buf
, exist_buf
,
490 aspath_hops
, (exist_hops
+ exist_confeds
));
494 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
497 zlog_debug("%s: %s loses to %s due to aspath (with confeds) hopcount %d > %d",
498 pfx_buf
, new_buf
, exist_buf
,
499 aspath_hops
, (exist_hops
+ exist_confeds
));
505 int newhops
= aspath_count_hops (newattr
->aspath
);
507 if (newhops
< exist_hops
)
510 zlog_debug("%s: %s wins over %s due to aspath hopcount %d < %d",
511 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
515 if (newhops
> exist_hops
)
518 zlog_debug("%s: %s loses to %s due to aspath hopcount %d > %d",
519 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
525 /* 5. Origin check. */
526 if (newattr
->origin
< existattr
->origin
)
529 zlog_debug("%s: %s wins over %s due to ORIGIN %s < %s",
530 pfx_buf
, new_buf
, exist_buf
,
531 bgp_origin_long_str
[newattr
->origin
],
532 bgp_origin_long_str
[existattr
->origin
]);
536 if (newattr
->origin
> existattr
->origin
)
539 zlog_debug("%s: %s loses to %s due to ORIGIN %s > %s",
540 pfx_buf
, new_buf
, exist_buf
,
541 bgp_origin_long_str
[newattr
->origin
],
542 bgp_origin_long_str
[existattr
->origin
]);
547 internal_as_route
= (aspath_count_hops (newattr
->aspath
) == 0
548 && aspath_count_hops (existattr
->aspath
) == 0);
549 confed_as_route
= (aspath_count_confeds (newattr
->aspath
) > 0
550 && aspath_count_confeds (existattr
->aspath
) > 0
551 && aspath_count_hops (newattr
->aspath
) == 0
552 && aspath_count_hops (existattr
->aspath
) == 0);
554 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
555 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
557 || aspath_cmp_left (newattr
->aspath
, existattr
->aspath
)
558 || aspath_cmp_left_confed (newattr
->aspath
, existattr
->aspath
)
559 || internal_as_route
)
561 new_med
= bgp_med_value (new->attr
, bgp
);
562 exist_med
= bgp_med_value (exist
->attr
, bgp
);
564 if (new_med
< exist_med
)
567 zlog_debug("%s: %s wins over %s due to MED %d < %d",
568 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
572 if (new_med
> exist_med
)
575 zlog_debug("%s: %s loses to %s due to MED %d > %d",
576 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
581 /* 7. Peer type check. */
582 new_sort
= new->peer
->sort
;
583 exist_sort
= exist
->peer
->sort
;
585 if (new_sort
== BGP_PEER_EBGP
586 && (exist_sort
== BGP_PEER_IBGP
|| exist_sort
== BGP_PEER_CONFED
))
589 zlog_debug("%s: %s wins over %s due to eBGP peer > iBGP peer",
590 pfx_buf
, new_buf
, exist_buf
);
594 if (exist_sort
== BGP_PEER_EBGP
595 && (new_sort
== BGP_PEER_IBGP
|| new_sort
== BGP_PEER_CONFED
))
598 zlog_debug("%s: %s loses to %s due to iBGP peer < eBGP peer",
599 pfx_buf
, new_buf
, exist_buf
);
603 /* 8. IGP metric check. */
607 newm
= new->extra
->igpmetric
;
609 existm
= exist
->extra
->igpmetric
;
614 zlog_debug("%s: %s wins over %s due to IGP metric %d < %d",
615 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
622 zlog_debug("%s: %s loses to %s due to IGP metric %d > %d",
623 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
627 /* 9. Same IGP metric. Compare the cluster list length as
628 representative of IGP hops metric. Rewrite the metric value
629 pair (newm, existm) with the cluster list length. Prefer the
630 path with smaller cluster list length. */
633 if (peer_sort (new->peer
) == BGP_PEER_IBGP
634 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
635 && CHECK_FLAG (mpath_cfg
->ibgp_flags
,
636 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
638 newm
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
639 existm
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
644 zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
645 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
652 zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
653 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
659 /* 10. confed-external vs. confed-internal */
660 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
662 if (new_sort
== BGP_PEER_CONFED
&& exist_sort
== BGP_PEER_IBGP
)
665 zlog_debug("%s: %s wins over %s due to confed-external peer > confed-internal peer",
666 pfx_buf
, new_buf
, exist_buf
);
670 if (exist_sort
== BGP_PEER_CONFED
&& new_sort
== BGP_PEER_IBGP
)
673 zlog_debug("%s: %s loses to %s due to confed-internal peer < confed-external peer",
674 pfx_buf
, new_buf
, exist_buf
);
679 /* 11. Maximum path check. */
682 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
))
686 * For the two paths, all comparison steps till IGP metric
687 * have succeeded - including AS_PATH hop count. Since 'bgp
688 * bestpath as-path multipath-relax' knob is on, we don't need
689 * an exact match of AS_PATH. Thus, mark the paths are equal.
690 * That will trigger both these paths to get into the multipath
696 zlog_debug("%s: %s and %s are equal via multipath-relax",
697 pfx_buf
, new_buf
, exist_buf
);
699 else if (new->peer
->sort
== BGP_PEER_IBGP
)
701 if (aspath_cmp (new->attr
->aspath
, exist
->attr
->aspath
))
706 zlog_debug("%s: %s and %s are equal via matching aspaths",
707 pfx_buf
, new_buf
, exist_buf
);
710 else if (new->peer
->as
== exist
->peer
->as
)
715 zlog_debug("%s: %s and %s are equal via same remote-as",
716 pfx_buf
, new_buf
, exist_buf
);
722 * TODO: If unequal cost ibgp multipath is enabled we can
723 * mark the paths as equal here instead of returning
728 zlog_debug("%s: %s wins over %s after IGP metric comparison",
729 pfx_buf
, new_buf
, exist_buf
);
731 zlog_debug("%s: %s loses to %s after IGP metric comparison",
732 pfx_buf
, new_buf
, exist_buf
);
737 /* 12. If both paths are external, prefer the path that was received
738 first (the oldest one). This step minimizes route-flap, since a
739 newer path won't displace an older one, even if it was the
740 preferred route based on the additional decision criteria below. */
741 if (! bgp_flag_check (bgp
, BGP_FLAG_COMPARE_ROUTER_ID
)
742 && new_sort
== BGP_PEER_EBGP
743 && exist_sort
== BGP_PEER_EBGP
)
745 if (CHECK_FLAG (new->flags
, BGP_INFO_SELECTED
))
748 zlog_debug("%s: %s wins over %s due to oldest external",
749 pfx_buf
, new_buf
, exist_buf
);
753 if (CHECK_FLAG (exist
->flags
, BGP_INFO_SELECTED
))
756 zlog_debug("%s: %s loses to %s due to oldest external",
757 pfx_buf
, new_buf
, exist_buf
);
762 /* 13. Router-ID comparision. */
763 /* If one of the paths is "stale", the corresponding peer router-id will
764 * be 0 and would always win over the other path. If originator id is
765 * used for the comparision, it will decide which path is better.
767 if (newattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
768 new_id
.s_addr
= newattre
->originator_id
.s_addr
;
770 new_id
.s_addr
= new->peer
->remote_id
.s_addr
;
771 if (existattr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
772 exist_id
.s_addr
= existattre
->originator_id
.s_addr
;
774 exist_id
.s_addr
= exist
->peer
->remote_id
.s_addr
;
776 if (ntohl (new_id
.s_addr
) < ntohl (exist_id
.s_addr
))
779 zlog_debug("%s: %s wins over %s due to Router-ID comparison",
780 pfx_buf
, new_buf
, exist_buf
);
784 if (ntohl (new_id
.s_addr
) > ntohl (exist_id
.s_addr
))
787 zlog_debug("%s: %s loses to %s due to Router-ID comparison",
788 pfx_buf
, new_buf
, exist_buf
);
792 /* 14. Cluster length comparision. */
793 new_cluster
= BGP_CLUSTER_LIST_LENGTH(new->attr
);
794 exist_cluster
= BGP_CLUSTER_LIST_LENGTH(exist
->attr
);
796 if (new_cluster
< exist_cluster
)
799 zlog_debug("%s: %s wins over %s due to CLUSTER_LIST length %d < %d",
800 pfx_buf
, new_buf
, exist_buf
, new_cluster
, exist_cluster
);
804 if (new_cluster
> exist_cluster
)
807 zlog_debug("%s: %s loses to %s due to CLUSTER_LIST length %d > %d",
808 pfx_buf
, new_buf
, exist_buf
, new_cluster
, exist_cluster
);
812 /* 15. Neighbor address comparision. */
813 /* Do this only if neither path is "stale" as stale paths do not have
814 * valid peer information (as the connection may or may not be up).
816 if (CHECK_FLAG (exist
->flags
, BGP_INFO_STALE
))
819 zlog_debug("%s: %s wins over %s due to latter path being STALE",
820 pfx_buf
, new_buf
, exist_buf
);
824 if (CHECK_FLAG (new->flags
, BGP_INFO_STALE
))
827 zlog_debug("%s: %s loses to %s due to former path being STALE",
828 pfx_buf
, new_buf
, exist_buf
);
832 /* locally configured routes to advertise do not have su_remote */
833 if (new->peer
->su_remote
== NULL
)
835 if (exist
->peer
->su_remote
== NULL
)
838 ret
= sockunion_cmp (new->peer
->su_remote
, exist
->peer
->su_remote
);
843 zlog_debug("%s: %s loses to %s due to Neighor IP comparison",
844 pfx_buf
, new_buf
, exist_buf
);
851 zlog_debug("%s: %s wins over %s due to Neighor IP comparison",
852 pfx_buf
, new_buf
, exist_buf
);
857 zlog_debug("%s: %s wins over %s due to nothing left to compare",
858 pfx_buf
, new_buf
, exist_buf
);
863 /* Compare two bgp route entity. Return -1 if new is preferred, 1 if exist
864 * is preferred, or 0 if they are the same (usually will only occur if
865 * multipath is enabled
866 * This version is compatible with */
868 bgp_info_cmp_compatible (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
869 afi_t afi
, safi_t safi
)
872 struct bgp_maxpaths_cfg mpath_cfg
;
874 ret
= bgp_info_cmp (bgp
, new, exist
, &paths_eq
, &mpath_cfg
, 0, __func__
);
888 static enum filter_type
889 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
890 afi_t afi
, safi_t safi
)
892 struct bgp_filter
*filter
;
894 filter
= &peer
->filter
[afi
][safi
];
896 #define FILTER_EXIST_WARN(F,f,filter) \
897 if (BGP_DEBUG (update, UPDATE_IN) \
898 && !(F ## _IN (filter))) \
899 zlog_warn ("%s: Could not find configured input %s-list %s!", \
900 peer->host, #f, F ## _IN_NAME(filter));
902 if (DISTRIBUTE_IN_NAME (filter
)) {
903 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
905 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
909 if (PREFIX_LIST_IN_NAME (filter
)) {
910 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
912 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
916 if (FILTER_LIST_IN_NAME (filter
)) {
917 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
919 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
923 return FILTER_PERMIT
;
924 #undef FILTER_EXIST_WARN
927 static enum filter_type
928 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
929 afi_t afi
, safi_t safi
)
931 struct bgp_filter
*filter
;
933 filter
= &peer
->filter
[afi
][safi
];
935 #define FILTER_EXIST_WARN(F,f,filter) \
936 if (BGP_DEBUG (update, UPDATE_OUT) \
937 && !(F ## _OUT (filter))) \
938 zlog_warn ("%s: Could not find configured output %s-list %s!", \
939 peer->host, #f, F ## _OUT_NAME(filter));
941 if (DISTRIBUTE_OUT_NAME (filter
)) {
942 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
944 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
948 if (PREFIX_LIST_OUT_NAME (filter
)) {
949 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
951 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
955 if (FILTER_LIST_OUT_NAME (filter
)) {
956 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
958 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
962 return FILTER_PERMIT
;
963 #undef FILTER_EXIST_WARN
966 /* If community attribute includes no_export then return 1. */
968 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
972 /* NO_ADVERTISE check. */
973 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
976 /* NO_EXPORT check. */
977 if (peer
->sort
== BGP_PEER_EBGP
&&
978 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
981 /* NO_EXPORT_SUBCONFED check. */
982 if (peer
->sort
== BGP_PEER_EBGP
983 || peer
->sort
== BGP_PEER_CONFED
)
984 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
990 /* Route reflection loop check. */
992 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
994 struct in_addr cluster_id
;
996 if (attr
->extra
&& attr
->extra
->cluster
)
998 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
999 cluster_id
= peer
->bgp
->cluster_id
;
1001 cluster_id
= peer
->bgp
->router_id
;
1003 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
1010 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1011 afi_t afi
, safi_t safi
, const char *rmap_name
)
1013 struct bgp_filter
*filter
;
1014 struct bgp_info info
;
1015 route_map_result_t ret
;
1016 struct route_map
*rmap
= NULL
;
1018 filter
= &peer
->filter
[afi
][safi
];
1020 /* Apply default weight value. */
1021 if (peer
->weight
[afi
][safi
])
1022 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
[afi
][safi
];
1026 rmap
= route_map_lookup_by_name(rmap_name
);
1033 if (ROUTE_MAP_IN_NAME(filter
))
1035 rmap
= ROUTE_MAP_IN (filter
);
1042 /* Route map apply. */
1045 /* Duplicate current value to new strucutre for modification. */
1049 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
1051 /* Apply BGP route map to the attribute. */
1052 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1054 peer
->rmap_type
= 0;
1056 if (ret
== RMAP_DENYMATCH
)
1058 /* Free newly generated AS path and community by route-map. */
1059 bgp_attr_flush (attr
);
1067 bgp_output_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1068 afi_t afi
, safi_t safi
, const char *rmap_name
)
1070 struct bgp_filter
*filter
;
1071 struct bgp_info info
;
1072 route_map_result_t ret
;
1073 struct route_map
*rmap
= NULL
;
1075 filter
= &peer
->filter
[afi
][safi
];
1077 /* Apply default weight value. */
1078 if (peer
->weight
[afi
][safi
])
1079 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
[afi
][safi
];
1083 rmap
= route_map_lookup_by_name(rmap_name
);
1090 if (ROUTE_MAP_OUT_NAME(filter
))
1092 rmap
= ROUTE_MAP_OUT (filter
);
1099 /* Route map apply. */
1102 /* Duplicate current value to new strucutre for modification. */
1106 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1108 /* Apply BGP route map to the attribute. */
1109 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1111 peer
->rmap_type
= 0;
1113 if (ret
== RMAP_DENYMATCH
)
1114 /* caller has multiple error paths with bgp_attr_flush() */
1120 /* If this is an EBGP peer with remove-private-AS */
1122 bgp_peer_remove_private_as(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1123 struct peer
*peer
, struct attr
*attr
)
1125 if (peer
->sort
== BGP_PEER_EBGP
&&
1126 (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1127 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
) ||
1128 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
) ||
1129 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)))
1131 // Take action on the entire aspath
1132 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1133 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
1135 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
1136 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1138 // The entire aspath consists of private ASNs so create an empty aspath
1139 else if (aspath_private_as_check (attr
->aspath
))
1140 attr
->aspath
= aspath_empty_get ();
1142 // There are some public and some private ASNs, remove the private ASNs
1144 attr
->aspath
= aspath_remove_private_asns (attr
->aspath
);
1147 // 'all' was not specified so the entire aspath must be private ASNs
1148 // for us to do anything
1149 else if (aspath_private_as_check (attr
->aspath
))
1151 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
1152 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1154 attr
->aspath
= aspath_empty_get ();
1159 /* If this is an EBGP peer with as-override */
1161 bgp_peer_as_override(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1162 struct peer
*peer
, struct attr
*attr
)
1164 if (peer
->sort
== BGP_PEER_EBGP
&&
1165 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
))
1167 if (aspath_single_asn_check (attr
->aspath
, peer
->as
))
1168 attr
->aspath
= aspath_replace_specific_asn (attr
->aspath
, peer
->as
, bgp
->as
);
1173 subgroup_announce_reset_nhop (u_char family
, struct attr
*attr
)
1175 if (family
== AF_INET
)
1176 attr
->nexthop
.s_addr
= 0;
1178 if (family
== AF_INET6
)
1179 memset (&attr
->extra
->mp_nexthop_global
, 0, IPV6_MAX_BYTELEN
);
1184 subgroup_announce_check (struct bgp_info
*ri
, struct update_subgroup
*subgrp
,
1185 struct prefix
*p
, struct attr
*attr
)
1187 struct bgp_filter
*filter
;
1190 struct peer
*onlypeer
;
1192 struct attr
*riattr
;
1193 struct peer_af
*paf
;
1194 char buf
[SU_ADDRSTRLEN
];
1200 int samepeer_safe
= 0; /* for synthetic mplsvpns routes */
1202 if (DISABLE_BGP_ANNOUNCE
)
1205 afi
= SUBGRP_AFI(subgrp
);
1206 safi
= SUBGRP_SAFI(subgrp
);
1207 peer
= SUBGRP_PEER(subgrp
);
1209 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_LONESOUL
))
1210 onlypeer
= SUBGRP_PFIRST(subgrp
)->peer
;
1213 filter
= &peer
->filter
[afi
][safi
];
1214 bgp
= SUBGRP_INST(subgrp
);
1215 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
1218 if (((afi
== AFI_IP
) || (afi
== AFI_IP6
)) && (safi
== SAFI_MPLS_VPN
) &&
1219 ((ri
->type
== ZEBRA_ROUTE_BGP_DIRECT
) ||
1220 (ri
->type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
))) {
1223 * direct and direct_ext type routes originate internally even
1224 * though they can have peer pointers that reference other systems
1227 prefix2str(p
, buf
, BUFSIZ
);
1228 zlog_debug("%s: pfx %s bgp_direct->vpn route peer safe", __func__
, buf
);
1233 /* With addpath we may be asked to TX all kinds of paths so make sure
1235 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
) ||
1236 CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
) ||
1237 CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
1242 /* If this is not the bestpath then check to see if there is an enabled addpath
1243 * feature that requires us to advertise it */
1244 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1246 if (! bgp_addpath_tx_path(peer
, afi
, safi
, ri
))
1252 /* Aggregate-address suppress check. */
1253 if (ri
->extra
&& ri
->extra
->suppress
)
1254 if (! UNSUPPRESS_MAP_NAME (filter
))
1259 /* Do not send back route to sender. */
1260 if (onlypeer
&& from
== onlypeer
)
1265 /* Do not send the default route in the BGP table if the neighbor is
1266 * configured for default-originate */
1267 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
1269 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1272 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1274 #endif /* HAVE_IPV6 */
1277 /* Transparency check. */
1278 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
1279 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
1284 /* If community is not disabled check the no-export and local. */
1285 if (! transparent
&& bgp_community_filter (peer
, riattr
))
1287 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1288 zlog_debug ("subgrpannouncecheck: community filter check fail");
1292 /* If the attribute has originator-id and it is same as remote
1295 riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
) &&
1296 (IPV4_ADDR_SAME (&onlypeer
->remote_id
, &riattr
->extra
->originator_id
)))
1298 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1299 zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as "
1302 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1307 /* ORF prefix-list filter check */
1308 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1309 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1310 || CHECK_FLAG (peer
->af_cap
[afi
][safi
],
1311 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1312 if (peer
->orf_plist
[afi
][safi
])
1314 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1316 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1317 zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF",
1319 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1325 /* Output filter check. */
1326 if (bgp_output_filter (peer
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
1328 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1329 zlog_debug ("%s [Update:SEND] %s/%d is filtered",
1331 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1336 #ifdef BGP_SEND_ASPATH_CHECK
1337 /* AS path loop check. */
1338 if (onlypeer
&& aspath_loop_check (riattr
->aspath
, onlypeer
->as
))
1340 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1341 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u "
1342 "that is part of AS path.",
1343 onlypeer
->host
, onlypeer
->as
);
1346 #endif /* BGP_SEND_ASPATH_CHECK */
1348 /* If we're a CONFED we need to loop check the CONFED ID too */
1349 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
1351 if (aspath_loop_check(riattr
->aspath
, bgp
->confed_id
))
1353 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1354 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u"
1362 /* Route-Reflect check. */
1363 if (from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1368 /* IBGP reflection check. */
1369 if (reflect
&& !samepeer_safe
)
1371 /* A route from a Client peer. */
1372 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
1374 /* Reflect to all the Non-Client peers and also to the
1375 Client peers other than the originator. Originator check
1376 is already done. So there is noting to do. */
1377 /* no bgp client-to-client reflection check. */
1378 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
1379 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1380 PEER_FLAG_REFLECTOR_CLIENT
))
1385 /* A route from a Non-client peer. Reflect to all other
1387 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1388 PEER_FLAG_REFLECTOR_CLIENT
))
1393 /* For modify attribute, copy it to temporary structure. */
1394 bgp_attr_dup (attr
, riattr
);
1396 /* If local-preference is not set. */
1397 if ((peer
->sort
== BGP_PEER_IBGP
1398 || peer
->sort
== BGP_PEER_CONFED
)
1399 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
1401 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1402 attr
->local_pref
= bgp
->default_local_pref
;
1405 /* If originator-id is not set and the route is to be reflected,
1406 set the originator id */
1407 if (reflect
&& (!(attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))))
1409 attr
->extra
= bgp_attr_extra_get(attr
);
1410 IPV4_ADDR_COPY(&(attr
->extra
->originator_id
), &(from
->remote_id
));
1411 SET_FLAG(attr
->flag
, BGP_ATTR_ORIGINATOR_ID
);
1414 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
1415 if (peer
->sort
== BGP_PEER_EBGP
1416 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
1418 if (from
!= bgp
->peer_self
&& ! transparent
1419 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
1420 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
1423 /* Since the nexthop attribute can vary per peer, it is not explicitly set
1424 * in announce check, only certain flags and length (or number of nexthops
1425 * -- for IPv6/MP_REACH) are set here in order to guide the update formation
1426 * code in setting the nexthop(s) on a per peer basis in reformat_peer().
1427 * Typically, the source nexthop in the attribute is preserved but in the
1428 * scenarios where we know it will always be overwritten, we reset the
1429 * nexthop to "0" in an attempt to achieve better Update packing. An
1430 * example of this is when a prefix from each of 2 IBGP peers needs to be
1431 * announced to an EBGP peer (and they have the same attributes barring
1435 SET_FLAG(attr
->rmap_change_flags
, BATTR_REFLECTED
);
1438 #define NEXTHOP_IS_V6 (\
1439 (safi != SAFI_ENCAP && \
1440 (p->family == AF_INET6 || peer_cap_enhe(peer))) || \
1441 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
1443 /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
1444 * the peer (group) is configured to receive link-local nexthop unchanged
1445 * and it is available in the prefix OR we're not reflecting the route and
1446 * the peer (group) to whom we're going to announce is on a shared network
1447 * and this is either a self-originated route or the peer is EBGP.
1451 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
1452 if ((CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1453 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) &&
1454 IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
)) ||
1455 (!reflect
&& peer
->shared_network
&&
1456 (from
== bgp
->peer_self
|| peer
->sort
== BGP_PEER_EBGP
)))
1458 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
1461 /* Clear off link-local nexthop in source, whenever it is not needed to
1462 * ensure more prefixes share the same attribute for announcement.
1464 if (!(CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1465 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)))
1466 memset (&attr
->extra
->mp_nexthop_local
, 0, IPV6_MAX_BYTELEN
);
1468 #endif /* HAVE_IPV6 */
1470 bgp_peer_remove_private_as(bgp
, afi
, safi
, peer
, attr
);
1471 bgp_peer_as_override(bgp
, afi
, safi
, peer
, attr
);
1473 /* Route map & unsuppress-map apply. */
1474 if (ROUTE_MAP_OUT_NAME (filter
)
1475 || (ri
->extra
&& ri
->extra
->suppress
) )
1477 struct bgp_info info
;
1478 struct attr dummy_attr
;
1479 struct attr_extra dummy_extra
;
1481 dummy_attr
.extra
= &dummy_extra
;
1485 /* don't confuse inbound and outbound setting */
1486 RESET_FLAG(attr
->rmap_change_flags
);
1489 * The route reflector is not allowed to modify the attributes
1490 * of the reflected IBGP routes unless explicitly allowed.
1492 if ((from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1493 && !bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
))
1495 bgp_attr_dup (&dummy_attr
, attr
);
1496 info
.attr
= &dummy_attr
;
1499 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1501 if (ri
->extra
&& ri
->extra
->suppress
)
1502 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1504 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1506 peer
->rmap_type
= 0;
1508 if (ret
== RMAP_DENYMATCH
)
1510 bgp_attr_flush (attr
);
1515 /* After route-map has been applied, we check to see if the nexthop to
1516 * be carried in the attribute (that is used for the announcement) can
1517 * be cleared off or not. We do this in all cases where we would be
1518 * setting the nexthop to "ourselves". For IPv6, we only need to consider
1519 * the global nexthop here; the link-local nexthop would have been cleared
1520 * already, and if not, it is required by the update formation code.
1521 * Also see earlier comments in this function.
1524 * If route-map has performed some operation on the nexthop or the peer
1525 * configuration says to pass it unchanged, we cannot reset the nexthop
1526 * here, so only attempt to do it if these aren't true. Note that the
1527 * route-map handler itself might have cleared the nexthop, if for example,
1528 * it is configured as 'peer-address'.
1530 if (!bgp_rmap_nhop_changed(attr
->rmap_change_flags
,
1531 riattr
->rmap_change_flags
) &&
1533 !CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
))
1535 /* We can reset the nexthop, if setting (or forcing) it to 'self' */
1536 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
) ||
1537 CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_FORCE_NEXTHOP_SELF
))
1540 CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1541 PEER_FLAG_FORCE_NEXTHOP_SELF
))
1542 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ?
1543 AF_INET6
: p
->family
), attr
);
1545 else if (peer
->sort
== BGP_PEER_EBGP
)
1547 /* Can also reset the nexthop if announcing to EBGP, but only if
1548 * no peer in the subgroup is on a shared subnet.
1549 * Note: 3rd party nexthop currently implemented for IPv4 only.
1551 SUBGRP_FOREACH_PEER (subgrp
, paf
)
1553 if (bgp_multiaccess_check_v4 (riattr
->nexthop
, paf
->peer
))
1557 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ? AF_INET6
: p
->family
), attr
);
1559 /* If IPv6/MP and nexthop does not have any override and happens to
1560 * be a link-local address, reset it so that we don't pass along the
1561 * source's link-local IPv6 address to recipients who may not be on
1562 * the same interface.
1564 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1566 if (IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_global
))
1567 subgroup_announce_reset_nhop (AF_INET6
, attr
);
1574 struct bgp_info_pair
1576 struct bgp_info
*old
;
1577 struct bgp_info
*new;
1581 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
,
1582 struct bgp_maxpaths_cfg
*mpath_cfg
,
1583 struct bgp_info_pair
*result
)
1585 struct bgp_info
*new_select
;
1586 struct bgp_info
*old_select
;
1587 struct bgp_info
*ri
;
1588 struct bgp_info
*ri1
;
1589 struct bgp_info
*ri2
;
1590 struct bgp_info
*nextri
= NULL
;
1591 int paths_eq
, do_mpath
, debug
;
1592 struct list mp_list
;
1593 char pfx_buf
[PREFIX2STR_BUFFER
];
1594 char path_buf
[PATH_ADDPATH_STR_BUFFER
];
1596 bgp_mp_list_init (&mp_list
);
1597 do_mpath
= (mpath_cfg
->maxpaths_ebgp
> 1 || mpath_cfg
->maxpaths_ibgp
> 1);
1599 debug
= bgp_debug_bestpath(&rn
->p
);
1602 prefix2str (&rn
->p
, pfx_buf
, sizeof (pfx_buf
));
1604 /* bgp deterministic-med */
1606 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1609 /* Clear BGP_INFO_DMED_SELECTED for all paths */
1610 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1611 bgp_info_unset_flag (rn
, ri1
, BGP_INFO_DMED_SELECTED
);
1613 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1615 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1617 if (BGP_INFO_HOLDDOWN (ri1
))
1619 if (ri1
->peer
&& ri1
->peer
!= bgp
->peer_self
)
1620 if (ri1
->peer
->status
!= Established
)
1626 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1628 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1630 if (BGP_INFO_HOLDDOWN (ri2
))
1633 ri2
->peer
!= bgp
->peer_self
&&
1634 !CHECK_FLAG (ri2
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1635 if (ri2
->peer
->status
!= Established
)
1638 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1639 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1642 if (bgp_info_cmp (bgp
, ri2
, new_select
, &paths_eq
,
1643 mpath_cfg
, debug
, pfx_buf
))
1645 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1649 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1653 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1654 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1658 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1659 zlog_debug("%s: %s is the bestpath from AS %d",
1660 pfx_buf
, path_buf
, aspath_get_first_as(new_select
->attr
->aspath
));
1665 /* Check old selected route and new selected route. */
1668 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1670 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1673 if (BGP_INFO_HOLDDOWN (ri
))
1675 /* reap REMOVED routes, if needs be
1676 * selected route must stay for a while longer though
1678 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1679 && (ri
!= old_select
))
1680 bgp_info_reap (rn
, ri
);
1686 ri
->peer
!= bgp
->peer_self
&&
1687 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1688 if (ri
->peer
->status
!= Established
)
1691 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1692 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1694 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1698 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1700 if (bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
))
1706 /* Now that we know which path is the bestpath see if any of the other paths
1707 * qualify as multipaths
1712 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1714 sprintf (path_buf
, "NONE");
1715 zlog_debug("%s: After path selection, newbest is %s oldbest was %s",
1717 old_select
? old_select
->peer
->host
: "NONE");
1720 if (do_mpath
&& new_select
)
1722 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1726 bgp_info_path_with_addpath_rx_str (ri
, path_buf
);
1728 if (ri
== new_select
)
1731 zlog_debug("%s: %s is the bestpath, add to the multipath list",
1733 bgp_mp_list_add (&mp_list
, ri
);
1737 if (BGP_INFO_HOLDDOWN (ri
))
1741 ri
->peer
!= bgp
->peer_self
&&
1742 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1743 if (ri
->peer
->status
!= Established
)
1746 if (!bgp_info_nexthop_cmp (ri
, new_select
))
1749 zlog_debug("%s: %s has the same nexthop as the bestpath, skip it",
1754 bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
);
1759 zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list",
1761 bgp_mp_list_add (&mp_list
, ri
);
1766 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1767 bgp_info_mpath_aggregate_update (new_select
, old_select
);
1768 bgp_mp_list_clear (&mp_list
);
1770 result
->old
= old_select
;
1771 result
->new = new_select
;
1777 * A new route/change in bestpath of an existing route. Evaluate the path
1778 * for advertisement to the subgroup.
1781 subgroup_process_announce_selected (struct update_subgroup
*subgrp
,
1782 struct bgp_info
*selected
,
1783 struct bgp_node
*rn
,
1784 u_int32_t addpath_tx_id
)
1787 struct peer
*onlypeer
;
1789 struct attr_extra extra
;
1794 afi
= SUBGRP_AFI(subgrp
);
1795 safi
= SUBGRP_SAFI(subgrp
);
1796 onlypeer
= ((SUBGRP_PCOUNT(subgrp
) == 1) ?
1797 (SUBGRP_PFIRST(subgrp
))->peer
: NULL
);
1799 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1800 if (onlypeer
&& CHECK_FLAG (onlypeer
->af_sflags
[afi
][safi
],
1801 PEER_STATUS_ORF_WAIT_REFRESH
))
1804 /* It's initialized in bgp_announce_check() */
1805 attr
.extra
= &extra
;
1807 /* Announcement to the subgroup. If the route is filtered withdraw it. */
1810 if (subgroup_announce_check(selected
, subgrp
, p
, &attr
))
1811 bgp_adj_out_set_subgroup(rn
, subgrp
, &attr
, selected
);
1813 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, selected
->addpath_tx_id
);
1816 /* If selected is NULL we must withdraw the path using addpath_tx_id */
1819 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, addpath_tx_id
);
1826 * Clear IGP changed flag and attribute changed flag for a route (all paths).
1827 * This is called at the end of route processing.
1830 bgp_zebra_clear_route_change_flags (struct bgp_node
*rn
)
1832 struct bgp_info
*ri
;
1834 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1836 if (BGP_INFO_HOLDDOWN (ri
))
1838 UNSET_FLAG (ri
->flags
, BGP_INFO_IGP_CHANGED
);
1839 UNSET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
1844 * Has the route changed from the RIB's perspective? This is invoked only
1845 * if the route selection returns the same best route as earlier - to
1846 * determine if we need to update zebra or not.
1849 bgp_zebra_has_route_changed (struct bgp_node
*rn
, struct bgp_info
*selected
)
1851 struct bgp_info
*mpinfo
;
1853 /* If this is multipath, check all selected paths for any nexthop change or
1854 * attribute change. Some attribute changes (e.g., community) aren't of
1855 * relevance to the RIB, but we'll update zebra to ensure we handle the
1856 * case of BGP nexthop change. This is the behavior when the best path has
1857 * an attribute change anyway.
1859 if (CHECK_FLAG (selected
->flags
, BGP_INFO_IGP_CHANGED
) ||
1860 CHECK_FLAG (selected
->flags
, BGP_INFO_MULTIPATH_CHG
))
1863 /* If this is multipath, check all selected paths for any nexthop change */
1864 for (mpinfo
= bgp_info_mpath_first (selected
); mpinfo
;
1865 mpinfo
= bgp_info_mpath_next (mpinfo
))
1867 if (CHECK_FLAG (mpinfo
->flags
, BGP_INFO_IGP_CHANGED
)
1868 || CHECK_FLAG (mpinfo
->flags
, BGP_INFO_ATTR_CHANGED
))
1872 /* Nothing has changed from the RIB's perspective. */
1876 struct bgp_process_queue
1879 struct bgp_node
*rn
;
1884 static wq_item_status
1885 bgp_process_main (struct work_queue
*wq
, void *data
)
1887 struct bgp_process_queue
*pq
= data
;
1888 struct bgp
*bgp
= pq
->bgp
;
1889 struct bgp_node
*rn
= pq
->rn
;
1890 afi_t afi
= pq
->afi
;
1891 safi_t safi
= pq
->safi
;
1892 struct prefix
*p
= &rn
->p
;
1893 struct bgp_info
*new_select
;
1894 struct bgp_info
*old_select
;
1895 struct bgp_info_pair old_and_new
;
1897 /* Is it end of initial update? (after startup) */
1900 quagga_timestamp(3, bgp
->update_delay_zebra_resume_time
,
1901 sizeof(bgp
->update_delay_zebra_resume_time
));
1903 bgp
->main_zebra_update_hold
= 0;
1904 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1905 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1907 bgp_zebra_announce_table(bgp
, afi
, safi
);
1909 bgp
->main_peers_update_hold
= 0;
1911 bgp_start_routeadv(bgp
);
1915 /* Best path selection. */
1916 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1917 old_select
= old_and_new
.old
;
1918 new_select
= old_and_new
.new;
1920 /* Nothing to do. */
1921 if (old_select
&& old_select
== new_select
&&
1922 !CHECK_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
) &&
1923 !CHECK_FLAG(old_select
->flags
, BGP_INFO_ATTR_CHANGED
) &&
1924 !bgp
->addpath_tx_used
[afi
][safi
])
1926 if (bgp_zebra_has_route_changed (rn
, old_select
))
1929 vnc_import_bgp_add_route(bgp
, p
, old_select
);
1930 vnc_import_bgp_exterior_add_route(bgp
, p
, old_select
);
1932 bgp_zebra_announce (p
, old_select
, bgp
, afi
, safi
);
1934 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1935 bgp_zebra_clear_route_change_flags (rn
);
1936 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1940 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1941 UNSET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
1943 /* bestpath has changed; bump version */
1944 if (old_select
|| new_select
)
1946 bgp_bump_version(rn
);
1948 if (!bgp
->t_rmap_def_originate_eval
)
1951 THREAD_TIMER_ON(bm
->master
, bgp
->t_rmap_def_originate_eval
,
1952 update_group_refresh_default_originate_route_map
,
1953 bgp
, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER
);
1958 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1961 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1962 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1963 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1967 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
1968 if (old_select
!= new_select
) {
1970 vnc_import_bgp_exterior_del_route(bgp
, p
, old_select
);
1971 vnc_import_bgp_del_route(bgp
, p
, old_select
);
1974 vnc_import_bgp_exterior_add_route(bgp
, p
, new_select
);
1975 vnc_import_bgp_add_route(bgp
, p
, new_select
);
1981 group_announce_route(bgp
, afi
, safi
, rn
, new_select
);
1984 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) &&
1985 (bgp
->inst_type
!= BGP_INSTANCE_TYPE_VIEW
) &&
1986 !bgp_option_check (BGP_OPT_NO_FIB
))
1989 && new_select
->type
== ZEBRA_ROUTE_BGP
1990 && (new_select
->sub_type
== BGP_ROUTE_NORMAL
||
1991 new_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1992 bgp_zebra_announce (p
, new_select
, bgp
, afi
, safi
);
1995 /* Withdraw the route from the kernel. */
1997 && old_select
->type
== ZEBRA_ROUTE_BGP
1998 && (old_select
->sub_type
== BGP_ROUTE_NORMAL
||
1999 old_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
2000 bgp_zebra_withdraw (p
, old_select
, safi
);
2004 /* Clear any route change flags. */
2005 bgp_zebra_clear_route_change_flags (rn
);
2007 /* Reap old select bgp_info, if it has been removed */
2008 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
2009 bgp_info_reap (rn
, old_select
);
2011 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2016 bgp_processq_del (struct work_queue
*wq
, void *data
)
2018 struct bgp_process_queue
*pq
= data
;
2019 struct bgp_table
*table
;
2021 bgp_unlock (pq
->bgp
);
2024 table
= bgp_node_table (pq
->rn
);
2025 bgp_unlock_node (pq
->rn
);
2026 bgp_table_unlock (table
);
2028 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
2032 bgp_process_queue_init (void)
2034 if (!bm
->process_main_queue
)
2036 bm
->process_main_queue
2037 = work_queue_new (bm
->master
, "process_main_queue");
2039 if ( !bm
->process_main_queue
)
2041 zlog_err ("%s: Failed to allocate work queue", __func__
);
2046 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
2047 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
2048 bm
->process_main_queue
->spec
.max_retries
= 0;
2049 bm
->process_main_queue
->spec
.hold
= 50;
2050 /* Use a higher yield value of 50ms for main queue processing */
2051 bm
->process_main_queue
->spec
.yield
= 50 * 1000L;
2055 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
2057 struct bgp_process_queue
*pqnode
;
2059 /* already scheduled for processing? */
2060 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
2063 if (bm
->process_main_queue
== NULL
)
2064 bgp_process_queue_init ();
2066 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2067 sizeof (struct bgp_process_queue
));
2071 /* all unlocked in bgp_processq_del */
2072 bgp_table_lock (bgp_node_table (rn
));
2073 pqnode
->rn
= bgp_lock_node (rn
);
2077 pqnode
->safi
= safi
;
2078 work_queue_add (bm
->process_main_queue
, pqnode
);
2079 SET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2084 bgp_add_eoiu_mark (struct bgp
*bgp
)
2086 struct bgp_process_queue
*pqnode
;
2088 if (bm
->process_main_queue
== NULL
)
2089 bgp_process_queue_init ();
2091 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2092 sizeof (struct bgp_process_queue
));
2099 work_queue_add (bm
->process_main_queue
, pqnode
);
2103 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
2107 peer
= THREAD_ARG (thread
);
2108 peer
->t_pmax_restart
= NULL
;
2110 if (bgp_debug_neighbor_events(peer
))
2111 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
2114 peer_clear (peer
, NULL
);
2120 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
2121 safi_t safi
, int always
)
2123 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
2126 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
2128 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
2132 zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
2133 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
2134 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
2135 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2137 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
2143 if (safi
== SAFI_MPLS_VPN
)
2144 safi
= SAFI_MPLS_LABELED_VPN
;
2146 ndata
[0] = (afi
>> 8);
2149 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
2150 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
2151 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
2152 ndata
[6] = (peer
->pmax
[afi
][safi
]);
2154 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
2155 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
2156 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
2159 /* Dynamic peers will just close their connection. */
2160 if (peer_dynamic_neighbor (peer
))
2163 /* restart timer start */
2164 if (peer
->pmax_restart
[afi
][safi
])
2166 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
2168 if (bgp_debug_neighbor_events(peer
))
2169 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
2170 peer
->host
, peer
->v_pmax_restart
);
2172 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
2173 peer
->v_pmax_restart
);
2179 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2181 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
2183 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
2187 zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
2188 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
2189 peer
->pmax
[afi
][safi
]);
2190 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2193 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2197 /* Unconditionally remove the route from the RIB, without taking
2198 * damping into consideration (eg, because the session went down)
2201 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2202 afi_t afi
, safi_t safi
)
2204 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2206 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2207 bgp_info_delete (rn
, ri
); /* keep historical info */
2209 bgp_process (peer
->bgp
, rn
, afi
, safi
);
2213 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2214 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
)
2216 int status
= BGP_DAMP_NONE
;
2218 /* apply dampening, if result is suppressed, we'll be retaining
2219 * the bgp_info in the RIB for historical reference.
2221 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2222 && peer
->sort
== BGP_PEER_EBGP
)
2223 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
2224 == BGP_DAMP_SUPPRESSED
)
2226 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2231 if (safi
== SAFI_MPLS_VPN
) {
2232 struct bgp_node
*prn
= NULL
;
2233 struct bgp_table
*table
= NULL
;
2235 prn
= bgp_node_get(peer
->bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2237 table
= (struct bgp_table
*)(prn
->info
);
2239 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2246 bgp_unlock_node(prn
);
2248 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2249 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2251 vnc_import_bgp_del_route(peer
->bgp
, &rn
->p
, ri
);
2252 vnc_import_bgp_exterior_del_route(peer
->bgp
, &rn
->p
, ri
);
2256 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2259 static struct bgp_info
*
2260 info_make (int type
, int sub_type
, u_short instance
, struct peer
*peer
, struct attr
*attr
,
2261 struct bgp_node
*rn
)
2263 struct bgp_info
*new;
2265 /* Make new BGP info. */
2266 new = XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
2268 new->instance
= instance
;
2269 new->sub_type
= sub_type
;
2272 new->uptime
= bgp_clock ();
2274 new->addpath_tx_id
= ++peer
->bgp
->addpath_tx_id
;
2279 bgp_info_addpath_rx_str(u_int32_t addpath_id
, char *buf
)
2282 sprintf(buf
, " with addpath ID %d", addpath_id
);
2286 /* Check if received nexthop is valid or not. */
2288 bgp_update_martian_nexthop (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct attr
*attr
)
2290 struct attr_extra
*attre
= attr
->extra
;
2293 /* Only validated for unicast and multicast currently. */
2294 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2297 /* If NEXT_HOP is present, validate it. */
2298 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2300 if (attr
->nexthop
.s_addr
== 0 ||
2301 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2302 bgp_nexthop_self (bgp
, attr
))
2306 /* If MP_NEXTHOP is present, validate it. */
2307 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2308 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2309 * it is not an IPv6 link-local address.
2311 if (attre
&& attre
->mp_nexthop_len
)
2313 switch (attre
->mp_nexthop_len
)
2315 case BGP_ATTR_NHLEN_IPV4
:
2316 case BGP_ATTR_NHLEN_VPNV4
:
2317 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2318 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2322 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2323 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2324 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2325 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2326 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2328 #endif /* HAVE_IPV6 */
2340 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2341 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2342 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2346 int aspath_loop_count
= 0;
2347 struct bgp_node
*rn
;
2349 struct attr new_attr
;
2350 struct attr_extra new_extra
;
2351 struct attr
*attr_new
;
2352 struct bgp_info
*ri
;
2353 struct bgp_info
*new;
2355 char buf
[SU_ADDRSTRLEN
];
2358 int do_loop_check
= 1;
2360 int vnc_implicit_withdraw
= 0;
2363 memset (&new_attr
, 0, sizeof(struct attr
));
2364 memset (&new_extra
, 0, sizeof(struct attr_extra
));
2367 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2369 /* When peer's soft reconfiguration enabled. Record input packet in
2371 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2372 && peer
!= bgp
->peer_self
)
2373 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2375 /* Check previously received route. */
2376 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2377 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2378 ri
->addpath_rx_id
== addpath_id
)
2381 /* AS path local-as loop check. */
2382 if (peer
->change_local_as
)
2384 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2385 aspath_loop_count
= 1;
2387 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2389 reason
= "as-path contains our own AS;";
2394 /* If the peer is configured for "allowas-in origin" and the last ASN in the
2395 * as-path is our ASN then we do not need to call aspath_loop_check
2397 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN_ORIGIN
))
2398 if (aspath_get_last_as(attr
->aspath
) == bgp
->as
)
2401 /* AS path loop check. */
2404 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2405 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2406 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
) > peer
->allowas_in
[afi
][safi
]))
2408 reason
= "as-path contains our own AS;";
2413 /* Route reflector originator ID check. */
2414 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2415 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2417 reason
= "originator is us;";
2421 /* Route reflector cluster ID check. */
2422 if (bgp_cluster_filter (peer
, attr
))
2424 reason
= "reflected from the same cluster;";
2428 /* Apply incoming filter. */
2429 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2435 new_attr
.extra
= &new_extra
;
2436 bgp_attr_dup (&new_attr
, attr
);
2438 /* Apply incoming route-map.
2439 * NB: new_attr may now contain newly allocated values from route-map "set"
2440 * commands, so we need bgp_attr_flush in the error paths, until we intern
2441 * the attr (which takes over the memory references) */
2442 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2444 reason
= "route-map;";
2445 bgp_attr_flush (&new_attr
);
2449 /* next hop check. */
2450 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2452 reason
= "martian or self next-hop;";
2453 bgp_attr_flush (&new_attr
);
2457 attr_new
= bgp_attr_intern (&new_attr
);
2459 /* If the update is implicit withdraw. */
2462 ri
->uptime
= bgp_clock ();
2464 /* Same attribute comes in. */
2465 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2466 && attrhash_cmp (ri
->attr
, attr_new
))
2468 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2469 && peer
->sort
== BGP_PEER_EBGP
2470 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2472 if (bgp_debug_update(peer
, p
, NULL
, 1))
2474 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2475 zlog_debug ("%s rcvd %s/%d%s",
2477 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2478 p
->prefixlen
, buf2
);
2481 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2483 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2484 bgp_process (bgp
, rn
, afi
, safi
);
2487 else /* Duplicate - odd */
2489 if (bgp_debug_update(peer
, p
, NULL
, 1))
2491 if (!peer
->rcvd_attr_printed
)
2493 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2494 peer
->rcvd_attr_printed
= 1;
2497 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2498 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2500 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2501 p
->prefixlen
, buf2
);
2504 /* graceful restart STALE flag unset. */
2505 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2507 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2508 bgp_process (bgp
, rn
, afi
, safi
);
2512 bgp_unlock_node (rn
);
2513 bgp_attr_unintern (&attr_new
);
2518 /* Withdraw/Announce before we fully processed the withdraw */
2519 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2521 if (bgp_debug_update(peer
, p
, NULL
, 1))
2523 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2524 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2526 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2527 p
->prefixlen
, buf2
);
2529 bgp_info_restore (rn
, ri
);
2532 /* Received Logging. */
2533 if (bgp_debug_update(peer
, p
, NULL
, 1))
2535 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2536 zlog_debug ("%s rcvd %s/%d%s",
2538 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2539 p
->prefixlen
, buf2
);
2542 /* graceful restart STALE flag unset. */
2543 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2544 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2546 /* The attribute is changed. */
2547 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2549 /* implicit withdraw, decrement aggregate and pcount here.
2550 * only if update is accepted, they'll increment below.
2552 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2554 /* Update bgp route dampening information. */
2555 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2556 && peer
->sort
== BGP_PEER_EBGP
)
2558 /* This is implicit withdraw so we should update dampening
2560 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2561 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2564 if (safi
== SAFI_MPLS_VPN
) {
2565 struct bgp_node
*prn
= NULL
;
2566 struct bgp_table
*table
= NULL
;
2568 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2570 table
= (struct bgp_table
*)(prn
->info
);
2572 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2579 bgp_unlock_node(prn
);
2581 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2582 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2584 * Implicit withdraw case.
2586 ++vnc_implicit_withdraw
;
2587 vnc_import_bgp_del_route(bgp
, p
, ri
);
2588 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
2593 /* Update to new attribute. */
2594 bgp_attr_unintern (&ri
->attr
);
2595 ri
->attr
= attr_new
;
2597 /* Update MPLS tag. */
2598 if (safi
== SAFI_MPLS_VPN
)
2599 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2602 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
2604 if (vnc_implicit_withdraw
)
2607 * Add back the route with its new attributes (e.g., nexthop).
2608 * The route is still selected, until the route selection
2609 * queued by bgp_process actually runs. We have to make this
2610 * update to the VNC side immediately to avoid racing against
2611 * configuration changes (e.g., route-map changes) which
2612 * trigger re-importation of the entire RIB.
2614 vnc_import_bgp_add_route(bgp
, p
, ri
);
2615 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
2620 /* Update bgp route dampening information. */
2621 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2622 && peer
->sort
== BGP_PEER_EBGP
)
2624 /* Now we do normal update dampening. */
2625 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2626 if (ret
== BGP_DAMP_SUPPRESSED
)
2628 bgp_unlock_node (rn
);
2633 /* Nexthop reachability check. */
2634 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2636 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2637 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2638 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2643 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2644 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2647 if (BGP_DEBUG(nht
, NHT
))
2649 char buf1
[INET6_ADDRSTRLEN
];
2650 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2651 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2653 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2657 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2660 if (safi
== SAFI_MPLS_VPN
)
2662 struct bgp_node
*prn
= NULL
;
2663 struct bgp_table
*table
= NULL
;
2665 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2668 table
= (struct bgp_table
*)(prn
->info
);
2670 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2677 bgp_unlock_node(prn
);
2681 /* Process change. */
2682 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2684 bgp_process (bgp
, rn
, afi
, safi
);
2685 bgp_unlock_node (rn
);
2688 } // End of implicit withdraw
2690 /* Received Logging. */
2691 if (bgp_debug_update(peer
, p
, NULL
, 1))
2693 if (!peer
->rcvd_attr_printed
)
2695 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2696 peer
->rcvd_attr_printed
= 1;
2699 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2700 zlog_debug ("%s rcvd %s/%d%s",
2702 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2703 p
->prefixlen
, buf2
);
2706 /* Make new BGP info. */
2707 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2709 /* Update MPLS tag. */
2710 if (safi
== SAFI_MPLS_VPN
)
2711 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2713 /* Nexthop reachability check. */
2714 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2716 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2717 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2718 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2723 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2724 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2727 if (BGP_DEBUG(nht
, NHT
))
2729 char buf1
[INET6_ADDRSTRLEN
];
2730 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2731 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2733 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2737 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2740 new->addpath_rx_id
= addpath_id
;
2742 /* Increment prefix */
2743 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2745 /* Register new BGP information. */
2746 bgp_info_add (rn
, new);
2748 /* route_node_get lock */
2749 bgp_unlock_node (rn
);
2752 if (safi
== SAFI_MPLS_VPN
)
2754 struct bgp_node
*prn
= NULL
;
2755 struct bgp_table
*table
= NULL
;
2757 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2760 table
= (struct bgp_table
*)(prn
->info
);
2762 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2769 bgp_unlock_node(prn
);
2773 /* If maximum prefix count is configured and current prefix
2775 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2778 /* Process change. */
2779 bgp_process (bgp
, rn
, afi
, safi
);
2783 /* This BGP update is filtered. Log the reason then update BGP
2786 if (bgp_debug_update(peer
, p
, NULL
, 1))
2788 if (!peer
->rcvd_attr_printed
)
2790 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2791 peer
->rcvd_attr_printed
= 1;
2794 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2795 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2797 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2798 p
->prefixlen
, buf2
, reason
);
2802 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2804 bgp_unlock_node (rn
);
2810 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2811 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2812 struct prefix_rd
*prd
, u_char
*tag
)
2815 char buf
[SU_ADDRSTRLEN
];
2817 struct bgp_node
*rn
;
2818 struct bgp_info
*ri
;
2823 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2825 /* If peer is soft reconfiguration enabled. Record input packet for
2826 * further calculation.
2828 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2829 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2830 * the iteration over all RS clients.
2831 * Since we need to remove the entry from adj_in anyway, do that first and
2832 * if there was no entry, we don't need to do anything more.
2834 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2835 && peer
!= bgp
->peer_self
)
2836 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2838 if (bgp_debug_update (peer
, p
, NULL
, 1))
2839 zlog_debug ("%s withdrawing route %s/%d "
2840 "not in adj-in", peer
->host
,
2841 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2843 bgp_unlock_node (rn
);
2847 /* Lookup withdrawn route. */
2848 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2849 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2850 ri
->addpath_rx_id
== addpath_id
)
2854 if (bgp_debug_update(peer
, p
, NULL
, 1))
2856 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2857 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2859 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2860 p
->prefixlen
, buf2
);
2863 /* Withdraw specified route from routing table. */
2864 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2865 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
, prd
);
2866 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2867 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2868 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2871 /* Unlock bgp_node_get() lock. */
2872 bgp_unlock_node (rn
);
2878 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2880 struct update_subgroup
*subgrp
;
2881 subgrp
= peer_subgroup(peer
, afi
, safi
);
2882 subgroup_default_originate(subgrp
, withdraw
);
2887 * bgp_stop_announce_route_timer
2890 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2892 if (!paf
->t_announce_route
)
2895 THREAD_TIMER_OFF (paf
->t_announce_route
);
2899 * bgp_announce_route_timer_expired
2901 * Callback that is invoked when the route announcement timer for a
2905 bgp_announce_route_timer_expired (struct thread
*t
)
2907 struct peer_af
*paf
;
2910 paf
= THREAD_ARG (t
);
2913 assert (paf
->t_announce_route
);
2914 paf
->t_announce_route
= NULL
;
2916 if (peer
->status
!= Established
)
2919 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2922 peer_af_announce_route (paf
, 1);
2927 * bgp_announce_route
2929 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2932 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2934 struct peer_af
*paf
;
2935 struct update_subgroup
*subgrp
;
2937 paf
= peer_af_find (peer
, afi
, safi
);
2940 subgrp
= PAF_SUBGRP(paf
);
2943 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2944 * or a refresh has already been triggered.
2946 if (!subgrp
|| paf
->t_announce_route
)
2950 * Start a timer to stagger/delay the announce. This serves
2951 * two purposes - announcement can potentially be combined for
2952 * multiple peers and the announcement doesn't happen in the
2955 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2956 bgp_announce_route_timer_expired
, paf
,
2957 (subgrp
->peer_count
== 1) ?
2958 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2959 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2963 * Announce routes from all AF tables to a peer.
2965 * This should ONLY be called when there is a need to refresh the
2966 * routes to the peer based on a policy change for this peer alone
2967 * or a route refresh request received from the peer.
2968 * The operation will result in splitting the peer from its existing
2969 * subgroups and putting it in new subgroups.
2972 bgp_announce_route_all (struct peer
*peer
)
2977 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2978 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2979 bgp_announce_route (peer
, afi
, safi
);
2983 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2984 struct bgp_table
*table
, struct prefix_rd
*prd
)
2987 struct bgp_node
*rn
;
2988 struct bgp_adj_in
*ain
;
2991 table
= peer
->bgp
->rib
[afi
][safi
];
2993 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2994 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2996 if (ain
->peer
== peer
)
2998 struct bgp_info
*ri
= rn
->info
;
2999 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
3001 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
3002 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
3007 bgp_unlock_node (rn
);
3015 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3017 struct bgp_node
*rn
;
3018 struct bgp_table
*table
;
3020 if (peer
->status
!= Established
)
3023 if ((safi
!= SAFI_MPLS_VPN
) && (safi
!= SAFI_ENCAP
))
3024 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
3026 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3027 rn
= bgp_route_next (rn
))
3028 if ((table
= rn
->info
) != NULL
)
3030 struct prefix_rd prd
;
3031 prd
.family
= AF_UNSPEC
;
3033 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
3035 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
3040 struct bgp_clear_node_queue
3042 struct bgp_node
*rn
;
3045 static wq_item_status
3046 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
3048 struct bgp_clear_node_queue
*cnq
= data
;
3049 struct bgp_node
*rn
= cnq
->rn
;
3050 struct peer
*peer
= wq
->spec
.data
;
3051 struct bgp_info
*ri
;
3052 afi_t afi
= bgp_node_table (rn
)->afi
;
3053 safi_t safi
= bgp_node_table (rn
)->safi
;
3055 assert (rn
&& peer
);
3057 /* It is possible that we have multiple paths for a prefix from a peer
3058 * if that peer is using AddPath.
3060 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3061 if (ri
->peer
== peer
)
3063 /* graceful restart STALE flag set. */
3064 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
3065 && peer
->nsf
[afi
][safi
]
3066 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
3067 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
3068 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
3070 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3076 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
3078 struct bgp_clear_node_queue
*cnq
= data
;
3079 struct bgp_node
*rn
= cnq
->rn
;
3080 struct bgp_table
*table
= bgp_node_table (rn
);
3082 bgp_unlock_node (rn
);
3083 bgp_table_unlock (table
);
3084 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
3088 bgp_clear_node_complete (struct work_queue
*wq
)
3090 struct peer
*peer
= wq
->spec
.data
;
3092 /* Tickle FSM to start moving again */
3093 BGP_EVENT_ADD (peer
, Clearing_Completed
);
3095 peer_unlock (peer
); /* bgp_clear_route */
3099 bgp_clear_node_queue_init (struct peer
*peer
)
3101 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
3103 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
3104 #undef CLEAR_QUEUE_NAME_LEN
3106 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
3108 zlog_err ("%s: Failed to allocate work queue", __func__
);
3111 peer
->clear_node_queue
->spec
.hold
= 10;
3112 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
3113 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
3114 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
3115 peer
->clear_node_queue
->spec
.max_retries
= 0;
3117 /* we only 'lock' this peer reference when the queue is actually active */
3118 peer
->clear_node_queue
->spec
.data
= peer
;
3122 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3123 struct bgp_table
*table
)
3125 struct bgp_node
*rn
;
3129 table
= peer
->bgp
->rib
[afi
][safi
];
3131 /* If still no table => afi/safi isn't configured at all or smth. */
3135 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3137 struct bgp_info
*ri
;
3138 struct bgp_adj_in
*ain
;
3139 struct bgp_adj_in
*ain_next
;
3141 /* XXX:TODO: This is suboptimal, every non-empty route_node is
3142 * queued for every clearing peer, regardless of whether it is
3143 * relevant to the peer at hand.
3145 * Overview: There are 3 different indices which need to be
3146 * scrubbed, potentially, when a peer is removed:
3148 * 1 peer's routes visible via the RIB (ie accepted routes)
3149 * 2 peer's routes visible by the (optional) peer's adj-in index
3150 * 3 other routes visible by the peer's adj-out index
3152 * 3 there is no hurry in scrubbing, once the struct peer is
3153 * removed from bgp->peer, we could just GC such deleted peer's
3154 * adj-outs at our leisure.
3156 * 1 and 2 must be 'scrubbed' in some way, at least made
3157 * invisible via RIB index before peer session is allowed to be
3158 * brought back up. So one needs to know when such a 'search' is
3163 * - there'd be a single global queue or a single RIB walker
3164 * - rather than tracking which route_nodes still need to be
3165 * examined on a peer basis, we'd track which peers still
3168 * Given that our per-peer prefix-counts now should be reliable,
3169 * this may actually be achievable. It doesn't seem to be a huge
3170 * problem at this time,
3172 * It is possible that we have multiple paths for a prefix from a peer
3173 * if that peer is using AddPath.
3178 ain_next
= ain
->next
;
3180 if (ain
->peer
== peer
)
3182 bgp_adj_in_remove (rn
, ain
);
3183 bgp_unlock_node (rn
);
3189 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3190 if (ri
->peer
== peer
)
3192 struct bgp_clear_node_queue
*cnq
;
3194 /* both unlocked in bgp_clear_node_queue_del */
3195 bgp_table_lock (bgp_node_table (rn
));
3197 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
3198 sizeof (struct bgp_clear_node_queue
));
3200 work_queue_add (peer
->clear_node_queue
, cnq
);
3208 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3210 struct bgp_node
*rn
;
3211 struct bgp_table
*table
;
3213 if (peer
->clear_node_queue
== NULL
)
3214 bgp_clear_node_queue_init (peer
);
3216 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3217 * Idle until it receives a Clearing_Completed event. This protects
3218 * against peers which flap faster than we can we clear, which could
3221 * a) race with routes from the new session being installed before
3222 * clear_route_node visits the node (to delete the route of that
3224 * b) resource exhaustion, clear_route_node likely leads to an entry
3225 * on the process_main queue. Fast-flapping could cause that queue
3229 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3230 * the unlock will happen upon work-queue completion; other wise, the
3231 * unlock happens at the end of this function.
3233 if (!peer
->clear_node_queue
->thread
)
3236 if (safi
!= SAFI_MPLS_VPN
&& safi
!= SAFI_ENCAP
)
3237 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
3239 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3240 rn
= bgp_route_next (rn
))
3241 if ((table
= rn
->info
) != NULL
)
3242 bgp_clear_route_table (peer
, afi
, safi
, table
);
3244 /* unlock if no nodes got added to the clear-node-queue. */
3245 if (!peer
->clear_node_queue
->thread
)
3251 bgp_clear_route_all (struct peer
*peer
)
3256 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3257 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3258 bgp_clear_route (peer
, afi
, safi
);
3261 rfapiProcessPeerDown(peer
);
3266 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3268 struct bgp_table
*table
;
3269 struct bgp_node
*rn
;
3270 struct bgp_adj_in
*ain
;
3271 struct bgp_adj_in
*ain_next
;
3273 table
= peer
->bgp
->rib
[afi
][safi
];
3275 /* It is possible that we have multiple paths for a prefix from a peer
3276 * if that peer is using AddPath.
3278 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3284 ain_next
= ain
->next
;
3286 if (ain
->peer
== peer
)
3288 bgp_adj_in_remove (rn
, ain
);
3289 bgp_unlock_node (rn
);
3298 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3300 struct bgp_node
*rn
;
3301 struct bgp_info
*ri
;
3302 struct bgp_table
*table
;
3304 table
= peer
->bgp
->rib
[afi
][safi
];
3306 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3308 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3309 if (ri
->peer
== peer
)
3311 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3312 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3319 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3321 struct bgp_node
*rn
;
3322 struct bgp_info
*ri
;
3323 struct bgp_info
*next
;
3325 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3326 for (ri
= rn
->info
; ri
; ri
= next
)
3329 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3330 && ri
->type
== ZEBRA_ROUTE_BGP
3331 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3332 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3335 if (table
->owner
&& table
->owner
->bgp
)
3336 vnc_import_bgp_del_route(table
->owner
->bgp
, &rn
->p
, ri
);
3338 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3343 /* Delete all kernel routes. */
3345 bgp_cleanup_routes (void)
3348 struct listnode
*node
, *nnode
;
3351 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
3353 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3355 struct bgp_node
*rn
;
3357 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3360 * VPN and ENCAP tables are two-level (RD is top level)
3362 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3363 rn
= bgp_route_next (rn
))
3367 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3368 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3370 bgp_unlock_node(rn
);
3374 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_ENCAP
]); rn
;
3375 rn
= bgp_route_next (rn
))
3379 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_ENCAP
);
3380 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3382 bgp_unlock_node(rn
);
3393 bgp_zclient_reset ();
3394 access_list_reset ();
3395 prefix_list_reset ();
3399 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3401 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3402 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3405 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3408 bgp_nlri_parse (struct peer
*peer
, struct attr
*attr
, struct bgp_nlri
*packet
)
3417 int addpath_encoded
;
3418 u_int32_t addpath_id
;
3420 /* Check peer status. */
3421 if (peer
->status
!= Established
)
3425 lim
= pnt
+ packet
->length
;
3427 safi
= packet
->safi
;
3429 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3431 for (; pnt
< lim
; pnt
+= psize
)
3433 /* Clear prefix structure. */
3434 memset (&p
, 0, sizeof (struct prefix
));
3436 if (addpath_encoded
)
3439 /* When packet overflow occurs return immediately. */
3440 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3443 addpath_id
= ntohl(*((uint32_t*) pnt
));
3444 pnt
+= BGP_ADDPATH_ID_LEN
;
3447 /* Fetch prefix length. */
3448 p
.prefixlen
= *pnt
++;
3449 p
.family
= afi2family (afi
);
3451 /* Already checked in nlri_sanity_check(). We do double check
3453 if ((afi
== AFI_IP
&& p
.prefixlen
> 32)
3454 || (afi
== AFI_IP6
&& p
.prefixlen
> 128))
3457 /* Packet size overflow check. */
3458 psize
= PSIZE (p
.prefixlen
);
3460 /* When packet overflow occur return immediately. */
3461 if (pnt
+ psize
> lim
)
3464 /* Fetch prefix from NLRI packet. */
3465 memcpy (&p
.u
.prefix
, pnt
, psize
);
3467 /* Check address. */
3468 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3470 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3473 * From draft-ietf-idr-bgp4-22, Section 6.3:
3474 * If a BGP router receives an UPDATE message with a
3475 * semantically incorrect NLRI field, in which a prefix is
3476 * semantically incorrect (eg. an unexpected multicast IP
3477 * address), it should ignore the prefix.
3479 zlog_err ("IPv4 unicast NLRI is multicast address %s",
3480 inet_ntoa (p
.u
.prefix4
));
3487 /* Check address. */
3488 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3490 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3494 zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
3495 inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3500 #endif /* HAVE_IPV6 */
3502 /* Normal process. */
3504 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3505 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3507 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3508 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3510 /* Address family configuration mismatch or maximum-prefix count
3516 /* Packet length consistency check. */
3523 /* NLRI encode syntax check routine. */
3525 bgp_nlri_sanity_check (struct peer
*peer
, int afi
, safi_t safi
, u_char
*pnt
,
3526 bgp_size_t length
, int *numpfx
)
3531 int addpath_encoded
;
3535 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3537 /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
3538 syntactic validity. If the field is syntactically incorrect,
3539 then the Error Subcode is set to Invalid Network Field. */
3545 /* If the NLRI is encoded using addpath then the first 4 bytes are
3546 * the addpath ID. */
3547 if (addpath_encoded
)
3549 if (pnt
+ BGP_ADDPATH_ID_LEN
> end
)
3551 zlog_err ("%s [Error] Update packet error"
3552 " (prefix data addpath overflow)",
3554 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3555 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3558 pnt
+= BGP_ADDPATH_ID_LEN
;
3563 /* Prefix length check. */
3565 if (safi
== SAFI_ENCAP
) {
3566 if (prefixlen
> 128)
3569 if ((afi
== AFI_IP
&& prefixlen
> 32) ||
3570 (afi
== AFI_IP6
&& prefixlen
> 128)) {
3577 zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
3578 peer
->host
, prefixlen
);
3579 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3580 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3584 /* Packet size overflow check. */
3585 psize
= PSIZE (prefixlen
);
3587 if (pnt
+ psize
> end
)
3589 zlog_err ("%s [Error] Update packet error"
3590 " (prefix data overflow prefix size is %d)",
3592 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3593 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3601 /* Packet length consistency check. */
3604 zlog_err ("%s [Error] Update packet error"
3605 " (prefix length mismatch with total length)",
3607 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
3608 BGP_NOTIFY_UPDATE_INVAL_NETWORK
);
3614 static struct bgp_static
*
3615 bgp_static_new (void)
3617 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3621 bgp_static_free (struct bgp_static
*bgp_static
)
3623 if (bgp_static
->rmap
.name
)
3624 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3625 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3629 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3630 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3632 struct bgp_node
*rn
;
3633 struct bgp_info
*ri
;
3634 struct bgp_info
*new;
3635 struct bgp_info info
;
3637 struct attr
*attr_new
;
3640 int vnc_implicit_withdraw
= 0;
3643 assert (bgp_static
);
3647 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3649 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3651 attr
.nexthop
= bgp_static
->igpnexthop
;
3652 attr
.med
= bgp_static
->igpmetric
;
3653 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3655 if (bgp_static
->atomic
)
3656 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3658 /* Apply route-map. */
3659 if (bgp_static
->rmap
.name
)
3661 struct attr attr_tmp
= attr
;
3662 info
.peer
= bgp
->peer_self
;
3663 info
.attr
= &attr_tmp
;
3665 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3667 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3669 bgp
->peer_self
->rmap_type
= 0;
3671 if (ret
== RMAP_DENYMATCH
)
3673 /* Free uninterned attribute. */
3674 bgp_attr_flush (&attr_tmp
);
3676 /* Unintern original. */
3677 aspath_unintern (&attr
.aspath
);
3678 bgp_attr_extra_free (&attr
);
3679 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3682 attr_new
= bgp_attr_intern (&attr_tmp
);
3685 attr_new
= bgp_attr_intern (&attr
);
3687 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3688 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3689 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3694 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3695 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3696 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3698 bgp_unlock_node (rn
);
3699 bgp_attr_unintern (&attr_new
);
3700 aspath_unintern (&attr
.aspath
);
3701 bgp_attr_extra_free (&attr
);
3706 /* The attribute is changed. */
3707 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3709 /* Rewrite BGP route information. */
3710 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3711 bgp_info_restore(rn
, ri
);
3713 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3715 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3717 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
3720 * Implicit withdraw case.
3721 * We have to do this before ri is changed
3723 ++vnc_implicit_withdraw
;
3724 vnc_import_bgp_del_route(bgp
, p
, ri
);
3725 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
3729 bgp_attr_unintern (&ri
->attr
);
3730 ri
->attr
= attr_new
;
3731 ri
->uptime
= bgp_clock ();
3733 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3735 if (vnc_implicit_withdraw
)
3737 vnc_import_bgp_add_route(bgp
, p
, ri
);
3738 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
3743 /* Nexthop reachability check. */
3744 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3746 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3747 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3750 if (BGP_DEBUG(nht
, NHT
))
3752 char buf1
[INET6_ADDRSTRLEN
];
3753 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3755 zlog_debug("%s(%s): Route not in table, not advertising",
3756 __FUNCTION__
, buf1
);
3758 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3763 /* Delete the NHT structure if any, if we're toggling between
3764 * enabling/disabling import check. We deregister the route
3765 * from NHT to avoid overloading NHT and the process interaction
3767 bgp_unlink_nexthop(ri
);
3768 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3770 /* Process change. */
3771 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3772 bgp_process (bgp
, rn
, afi
, safi
);
3773 bgp_unlock_node (rn
);
3774 aspath_unintern (&attr
.aspath
);
3775 bgp_attr_extra_free (&attr
);
3780 /* Make new BGP info. */
3781 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3783 /* Nexthop reachability check. */
3784 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3786 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3787 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3790 if (BGP_DEBUG(nht
, NHT
))
3792 char buf1
[INET6_ADDRSTRLEN
];
3793 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3795 zlog_debug("%s(%s): Route not in table, not advertising",
3796 __FUNCTION__
, buf1
);
3798 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3803 /* Delete the NHT structure if any, if we're toggling between
3804 * enabling/disabling import check. We deregister the route
3805 * from NHT to avoid overloading NHT and the process interaction
3807 bgp_unlink_nexthop(new);
3809 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3812 /* Aggregate address increment. */
3813 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3815 /* Register new BGP information. */
3816 bgp_info_add (rn
, new);
3818 /* route_node_get lock */
3819 bgp_unlock_node (rn
);
3821 /* Process change. */
3822 bgp_process (bgp
, rn
, afi
, safi
);
3824 /* Unintern original. */
3825 aspath_unintern (&attr
.aspath
);
3826 bgp_attr_extra_free (&attr
);
3830 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3831 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3833 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3837 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3840 struct bgp_node
*rn
;
3841 struct bgp_info
*ri
;
3843 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3845 /* Check selected route and self inserted route. */
3846 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3847 if (ri
->peer
== bgp
->peer_self
3848 && ri
->type
== ZEBRA_ROUTE_BGP
3849 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3852 /* Withdraw static BGP route from routing table. */
3855 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3856 bgp_unlink_nexthop(ri
);
3857 bgp_info_delete (rn
, ri
);
3858 bgp_process (bgp
, rn
, afi
, safi
);
3861 /* Unlock bgp_node_lookup. */
3862 bgp_unlock_node (rn
);
3866 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3869 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3870 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3872 struct bgp_node
*rn
;
3873 struct bgp_info
*ri
;
3875 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3877 /* Check selected route and self inserted route. */
3878 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3879 if (ri
->peer
== bgp
->peer_self
3880 && ri
->type
== ZEBRA_ROUTE_BGP
3881 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3884 /* Withdraw static BGP route from routing table. */
3888 rfapiProcessWithdraw(
3897 1); /* Kill, since it is an administrative change */
3899 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3900 bgp_info_delete (rn
, ri
);
3901 bgp_process (bgp
, rn
, afi
, safi
);
3904 /* Unlock bgp_node_lookup. */
3905 bgp_unlock_node (rn
);
3909 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3910 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3912 struct bgp_node
*rn
;
3913 struct bgp_info
*new;
3914 struct attr
*attr_new
;
3915 struct attr attr
= { 0 };
3916 struct bgp_info
*ri
;
3918 u_int32_t label
= 0;
3921 assert (bgp_static
);
3923 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3925 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3927 attr
.nexthop
= bgp_static
->igpnexthop
;
3928 attr
.med
= bgp_static
->igpmetric
;
3929 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3931 /* Apply route-map. */
3932 if (bgp_static
->rmap
.name
)
3934 struct attr attr_tmp
= attr
;
3935 struct bgp_info info
;
3938 info
.peer
= bgp
->peer_self
;
3939 info
.attr
= &attr_tmp
;
3941 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3943 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3945 bgp
->peer_self
->rmap_type
= 0;
3947 if (ret
== RMAP_DENYMATCH
)
3949 /* Free uninterned attribute. */
3950 bgp_attr_flush (&attr_tmp
);
3952 /* Unintern original. */
3953 aspath_unintern (&attr
.aspath
);
3954 bgp_attr_extra_free (&attr
);
3955 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3960 attr_new
= bgp_attr_intern (&attr_tmp
);
3964 attr_new
= bgp_attr_intern (&attr
);
3967 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3968 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3969 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3974 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3975 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3977 bgp_unlock_node (rn
);
3978 bgp_attr_unintern (&attr_new
);
3979 aspath_unintern (&attr
.aspath
);
3980 bgp_attr_extra_free (&attr
);
3985 /* The attribute is changed. */
3986 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3988 /* Rewrite BGP route information. */
3989 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3990 bgp_info_restore(rn
, ri
);
3992 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3993 bgp_attr_unintern (&ri
->attr
);
3994 ri
->attr
= attr_new
;
3995 ri
->uptime
= bgp_clock ();
3998 label
= decode_label (ri
->extra
->tag
);
4001 /* Process change. */
4002 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
4003 bgp_process (bgp
, rn
, afi
, safi
);
4005 rfapiProcessUpdate(ri
->peer
, NULL
, p
, &bgp_static
->prd
,
4006 ri
->attr
, afi
, safi
,
4007 ri
->type
, ri
->sub_type
, &label
);
4009 bgp_unlock_node (rn
);
4010 aspath_unintern (&attr
.aspath
);
4011 bgp_attr_extra_free (&attr
);
4017 /* Make new BGP info. */
4018 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
4020 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4021 new->extra
= bgp_info_extra_new();
4022 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
4024 label
= decode_label (bgp_static
->tag
);
4027 /* Aggregate address increment. */
4028 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
4030 /* Register new BGP information. */
4031 bgp_info_add (rn
, new);
4033 /* route_node_get lock */
4034 bgp_unlock_node (rn
);
4036 /* Process change. */
4037 bgp_process (bgp
, rn
, afi
, safi
);
4040 rfapiProcessUpdate(new->peer
, NULL
, p
, &bgp_static
->prd
,
4041 new->attr
, afi
, safi
,
4042 new->type
, new->sub_type
, &label
);
4045 /* Unintern original. */
4046 aspath_unintern (&attr
.aspath
);
4047 bgp_attr_extra_free (&attr
);
4050 /* Configure static BGP network. When user don't run zebra, static
4051 route should be installed as valid. */
4053 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4054 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
4058 struct bgp_static
*bgp_static
;
4059 struct bgp_node
*rn
;
4060 u_char need_update
= 0;
4062 /* Convert IP prefix string to struct prefix. */
4063 ret
= str2prefix (ip_str
, &p
);
4066 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4070 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4072 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4076 #endif /* HAVE_IPV6 */
4080 /* Set BGP static route configuration. */
4081 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
4085 /* Configuration change. */
4086 bgp_static
= rn
->info
;
4088 /* Check previous routes are installed into BGP. */
4089 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
4092 bgp_static
->backdoor
= backdoor
;
4096 if (bgp_static
->rmap
.name
)
4097 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4098 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4099 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4103 if (bgp_static
->rmap
.name
)
4104 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4105 bgp_static
->rmap
.name
= NULL
;
4106 bgp_static
->rmap
.map
= NULL
;
4107 bgp_static
->valid
= 0;
4109 bgp_unlock_node (rn
);
4113 /* New configuration. */
4114 bgp_static
= bgp_static_new ();
4115 bgp_static
->backdoor
= backdoor
;
4116 bgp_static
->valid
= 0;
4117 bgp_static
->igpmetric
= 0;
4118 bgp_static
->igpnexthop
.s_addr
= 0;
4122 if (bgp_static
->rmap
.name
)
4123 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4124 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4125 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4127 rn
->info
= bgp_static
;
4130 bgp_static
->valid
= 1;
4132 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4134 if (! bgp_static
->backdoor
)
4135 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
4140 /* Configure static BGP network. */
4142 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4143 afi_t afi
, safi_t safi
)
4147 struct bgp_static
*bgp_static
;
4148 struct bgp_node
*rn
;
4150 /* Convert IP prefix string to struct prefix. */
4151 ret
= str2prefix (ip_str
, &p
);
4154 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4158 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4160 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4164 #endif /* HAVE_IPV6 */
4168 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
4171 vty_out (vty
, "%% Can't find specified static route configuration.%s",
4176 bgp_static
= rn
->info
;
4178 /* Update BGP RIB. */
4179 if (! bgp_static
->backdoor
)
4180 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4182 /* Clear configuration. */
4183 bgp_static_free (bgp_static
);
4185 bgp_unlock_node (rn
);
4186 bgp_unlock_node (rn
);
4192 bgp_static_add (struct bgp
*bgp
)
4196 struct bgp_node
*rn
;
4197 struct bgp_node
*rm
;
4198 struct bgp_table
*table
;
4199 struct bgp_static
*bgp_static
;
4201 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4202 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4203 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4204 if (rn
->info
!= NULL
)
4206 if (safi
== SAFI_MPLS_VPN
)
4210 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4212 bgp_static
= rn
->info
;
4213 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
4218 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
4223 /* Called from bgp_delete(). Delete all static routes from the BGP
4226 bgp_static_delete (struct bgp
*bgp
)
4230 struct bgp_node
*rn
;
4231 struct bgp_node
*rm
;
4232 struct bgp_table
*table
;
4233 struct bgp_static
*bgp_static
;
4235 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4236 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4237 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4238 if (rn
->info
!= NULL
)
4240 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4244 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4246 bgp_static
= rn
->info
;
4247 bgp_static_withdraw_safi (bgp
, &rm
->p
,
4249 (struct prefix_rd
*)&rn
->p
,
4251 bgp_static_free (bgp_static
);
4253 bgp_unlock_node (rn
);
4258 bgp_static
= rn
->info
;
4259 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
4260 bgp_static_free (bgp_static
);
4262 bgp_unlock_node (rn
);
4268 bgp_static_redo_import_check (struct bgp
*bgp
)
4272 struct bgp_node
*rn
;
4273 struct bgp_static
*bgp_static
;
4275 /* Use this flag to force reprocessing of the route */
4276 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4277 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4278 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4279 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4280 if (rn
->info
!= NULL
)
4282 bgp_static
= rn
->info
;
4283 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
4285 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4289 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
4291 struct bgp_table
*table
;
4292 struct bgp_node
*rn
;
4293 struct bgp_info
*ri
;
4295 table
= bgp
->rib
[afi
][safi
];
4296 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
4298 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4300 if (ri
->peer
== bgp
->peer_self
&&
4301 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
4302 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
4303 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
4304 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
4306 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4307 bgp_unlink_nexthop(ri
);
4308 bgp_info_delete (rn
, ri
);
4309 bgp_process (bgp
, rn
, afi
, safi
);
4316 * Purge all networks and redistributed routes from routing table.
4317 * Invoked upon the instance going down.
4320 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4325 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4326 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4327 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4332 * Currently this is used to set static routes for VPN and ENCAP.
4333 * I think it can probably be factored with bgp_static_set.
4336 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4337 const char *rd_str
, const char *tag_str
,
4338 const char *rmap_str
)
4342 struct prefix_rd prd
;
4344 struct bgp_node
*prn
;
4345 struct bgp_node
*rn
;
4346 struct bgp_table
*table
;
4347 struct bgp_static
*bgp_static
;
4352 ret
= str2prefix (ip_str
, &p
);
4355 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4360 ret
= str2prefix_rd (rd_str
, &prd
);
4363 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4367 ret
= str2tag (tag_str
, tag
);
4370 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4374 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4375 (struct prefix
*)&prd
);
4376 if (prn
->info
== NULL
)
4377 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4379 bgp_unlock_node (prn
);
4382 rn
= bgp_node_get (table
, &p
);
4386 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4387 bgp_unlock_node (rn
);
4391 /* New configuration. */
4392 bgp_static
= bgp_static_new ();
4393 bgp_static
->backdoor
= 0;
4394 bgp_static
->valid
= 0;
4395 bgp_static
->igpmetric
= 0;
4396 bgp_static
->igpnexthop
.s_addr
= 0;
4397 memcpy(bgp_static
->tag
, tag
, 3);
4398 bgp_static
->prd
= prd
;
4402 if (bgp_static
->rmap
.name
)
4403 free (bgp_static
->rmap
.name
);
4404 bgp_static
->rmap
.name
= strdup (rmap_str
);
4405 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4407 rn
->info
= bgp_static
;
4409 bgp_static
->valid
= 1;
4410 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4416 /* Configure static BGP network. */
4418 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4419 const char *rd_str
, const char *tag_str
)
4424 struct prefix_rd prd
;
4425 struct bgp_node
*prn
;
4426 struct bgp_node
*rn
;
4427 struct bgp_table
*table
;
4428 struct bgp_static
*bgp_static
;
4433 /* Convert IP prefix string to struct prefix. */
4434 ret
= str2prefix (ip_str
, &p
);
4437 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4442 ret
= str2prefix_rd (rd_str
, &prd
);
4445 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4449 ret
= str2tag (tag_str
, tag
);
4452 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4456 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4457 (struct prefix
*)&prd
);
4458 if (prn
->info
== NULL
)
4459 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4461 bgp_unlock_node (prn
);
4464 rn
= bgp_node_lookup (table
, &p
);
4468 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4470 bgp_static
= rn
->info
;
4471 bgp_static_free (bgp_static
);
4473 bgp_unlock_node (rn
);
4474 bgp_unlock_node (rn
);
4477 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4483 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4484 const char *rmap_name
)
4486 struct bgp_rmap
*rmap
;
4488 rmap
= &bgp
->table_map
[afi
][safi
];
4492 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4493 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4494 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4499 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4504 bgp_zebra_announce_table(bgp
, afi
, safi
);
4510 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4511 const char *rmap_name
)
4513 struct bgp_rmap
*rmap
;
4515 rmap
= &bgp
->table_map
[afi
][safi
];
4517 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4521 bgp_zebra_announce_table(bgp
, afi
, safi
);
4527 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4528 safi_t safi
, int *write
)
4530 if (bgp
->table_map
[afi
][safi
].name
)
4532 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4533 vty_out (vty
, " table-map %s%s",
4534 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4541 DEFUN (bgp_table_map
,
4544 "BGP table to RIB route download filter\n"
4545 "Name of the route map\n")
4547 return bgp_table_map_set (vty
, vty
->index
,
4548 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4550 DEFUN (no_bgp_table_map
,
4551 no_bgp_table_map_cmd
,
4552 "no table-map WORD",
4553 "BGP table to RIB route download filter\n"
4554 "Name of the route map\n")
4556 return bgp_table_map_unset (vty
, vty
->index
,
4557 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4562 "network A.B.C.D/M",
4563 "Specify a network to announce via BGP\n"
4564 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4566 return bgp_static_set (vty
, vty
->index
, argv
[0],
4567 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4570 DEFUN (bgp_network_route_map
,
4571 bgp_network_route_map_cmd
,
4572 "network A.B.C.D/M route-map WORD",
4573 "Specify a network to announce via BGP\n"
4574 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4575 "Route-map to modify the attributes\n"
4576 "Name of the route map\n")
4578 return bgp_static_set (vty
, vty
->index
, argv
[0],
4579 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4582 DEFUN (bgp_network_backdoor
,
4583 bgp_network_backdoor_cmd
,
4584 "network A.B.C.D/M backdoor",
4585 "Specify a network to announce via BGP\n"
4586 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4587 "Specify a BGP backdoor route\n")
4589 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4593 DEFUN (bgp_network_mask
,
4594 bgp_network_mask_cmd
,
4595 "network A.B.C.D mask A.B.C.D",
4596 "Specify a network to announce via BGP\n"
4602 char prefix_str
[BUFSIZ
];
4604 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4607 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4611 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4612 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4615 DEFUN (bgp_network_mask_route_map
,
4616 bgp_network_mask_route_map_cmd
,
4617 "network A.B.C.D mask A.B.C.D route-map WORD",
4618 "Specify a network to announce via BGP\n"
4622 "Route-map to modify the attributes\n"
4623 "Name of the route map\n")
4626 char prefix_str
[BUFSIZ
];
4628 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4631 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4635 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4636 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4639 DEFUN (bgp_network_mask_backdoor
,
4640 bgp_network_mask_backdoor_cmd
,
4641 "network A.B.C.D mask A.B.C.D backdoor",
4642 "Specify a network to announce via BGP\n"
4646 "Specify a BGP backdoor route\n")
4649 char prefix_str
[BUFSIZ
];
4651 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4654 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4658 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4662 DEFUN (bgp_network_mask_natural
,
4663 bgp_network_mask_natural_cmd
,
4665 "Specify a network to announce via BGP\n"
4669 char prefix_str
[BUFSIZ
];
4671 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4674 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4678 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4679 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4682 DEFUN (bgp_network_mask_natural_route_map
,
4683 bgp_network_mask_natural_route_map_cmd
,
4684 "network A.B.C.D route-map WORD",
4685 "Specify a network to announce via BGP\n"
4687 "Route-map to modify the attributes\n"
4688 "Name of the route map\n")
4691 char prefix_str
[BUFSIZ
];
4693 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4696 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4700 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4701 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4704 DEFUN (bgp_network_mask_natural_backdoor
,
4705 bgp_network_mask_natural_backdoor_cmd
,
4706 "network A.B.C.D backdoor",
4707 "Specify a network to announce via BGP\n"
4709 "Specify a BGP backdoor route\n")
4712 char prefix_str
[BUFSIZ
];
4714 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4717 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4721 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4725 DEFUN (no_bgp_network
,
4727 "no network A.B.C.D/M",
4729 "Specify a network to announce via BGP\n"
4730 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4732 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4733 bgp_node_safi (vty
));
4736 ALIAS (no_bgp_network
,
4737 no_bgp_network_route_map_cmd
,
4738 "no network A.B.C.D/M route-map WORD",
4740 "Specify a network to announce via BGP\n"
4741 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4742 "Route-map to modify the attributes\n"
4743 "Name of the route map\n")
4745 ALIAS (no_bgp_network
,
4746 no_bgp_network_backdoor_cmd
,
4747 "no network A.B.C.D/M backdoor",
4749 "Specify a network to announce via BGP\n"
4750 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4751 "Specify a BGP backdoor route\n")
4753 DEFUN (no_bgp_network_mask
,
4754 no_bgp_network_mask_cmd
,
4755 "no network A.B.C.D mask A.B.C.D",
4757 "Specify a network to announce via BGP\n"
4763 char prefix_str
[BUFSIZ
];
4765 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4768 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4772 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4773 bgp_node_safi (vty
));
4776 ALIAS (no_bgp_network_mask
,
4777 no_bgp_network_mask_route_map_cmd
,
4778 "no network A.B.C.D mask A.B.C.D route-map WORD",
4780 "Specify a network to announce via BGP\n"
4784 "Route-map to modify the attributes\n"
4785 "Name of the route map\n")
4787 ALIAS (no_bgp_network_mask
,
4788 no_bgp_network_mask_backdoor_cmd
,
4789 "no network A.B.C.D mask A.B.C.D backdoor",
4791 "Specify a network to announce via BGP\n"
4795 "Specify a BGP backdoor route\n")
4797 DEFUN (no_bgp_network_mask_natural
,
4798 no_bgp_network_mask_natural_cmd
,
4799 "no network A.B.C.D",
4801 "Specify a network to announce via BGP\n"
4805 char prefix_str
[BUFSIZ
];
4807 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4810 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4814 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4815 bgp_node_safi (vty
));
4818 ALIAS (no_bgp_network_mask_natural
,
4819 no_bgp_network_mask_natural_route_map_cmd
,
4820 "no network A.B.C.D route-map WORD",
4822 "Specify a network to announce via BGP\n"
4824 "Route-map to modify the attributes\n"
4825 "Name of the route map\n")
4827 ALIAS (no_bgp_network_mask_natural
,
4828 no_bgp_network_mask_natural_backdoor_cmd
,
4829 "no network A.B.C.D backdoor",
4831 "Specify a network to announce via BGP\n"
4833 "Specify a BGP backdoor route\n")
4836 DEFUN (ipv6_bgp_network
,
4837 ipv6_bgp_network_cmd
,
4838 "network X:X::X:X/M",
4839 "Specify a network to announce via BGP\n"
4840 "IPv6 prefix <network>/<length>\n")
4842 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4846 DEFUN (ipv6_bgp_network_route_map
,
4847 ipv6_bgp_network_route_map_cmd
,
4848 "network X:X::X:X/M route-map WORD",
4849 "Specify a network to announce via BGP\n"
4850 "IPv6 prefix <network>/<length>\n"
4851 "Route-map to modify the attributes\n"
4852 "Name of the route map\n")
4854 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4855 bgp_node_safi (vty
), argv
[1], 0);
4858 DEFUN (no_ipv6_bgp_network
,
4859 no_ipv6_bgp_network_cmd
,
4860 "no network X:X::X:X/M",
4862 "Specify a network to announce via BGP\n"
4863 "IPv6 prefix <network>/<length>\n")
4865 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4868 ALIAS (no_ipv6_bgp_network
,
4869 no_ipv6_bgp_network_route_map_cmd
,
4870 "no network X:X::X:X/M route-map WORD",
4872 "Specify a network to announce via BGP\n"
4873 "IPv6 prefix <network>/<length>\n"
4874 "Route-map to modify the attributes\n"
4875 "Name of the route map\n")
4877 ALIAS (ipv6_bgp_network
,
4878 old_ipv6_bgp_network_cmd
,
4879 "ipv6 bgp network X:X::X:X/M",
4882 "Specify a network to announce via BGP\n"
4883 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4885 ALIAS (no_ipv6_bgp_network
,
4886 old_no_ipv6_bgp_network_cmd
,
4887 "no ipv6 bgp network X:X::X:X/M",
4891 "Specify a network to announce via BGP\n"
4892 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4893 #endif /* HAVE_IPV6 */
4895 /* Aggreagete address:
4897 advertise-map Set condition to advertise attribute
4898 as-set Generate AS set path information
4899 attribute-map Set attributes of aggregate
4900 route-map Set parameters of aggregate
4901 summary-only Filter more specific routes from updates
4902 suppress-map Conditionally filter more specific routes from updates
4905 struct bgp_aggregate
4907 /* Summary-only flag. */
4908 u_char summary_only
;
4910 /* AS set generation. */
4913 /* Route-map for aggregated route. */
4914 struct route_map
*map
;
4916 /* Suppress-count. */
4917 unsigned long count
;
4919 /* SAFI configuration. */
4923 static struct bgp_aggregate
*
4924 bgp_aggregate_new (void)
4926 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4930 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4932 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4935 /* Update an aggregate as routes are added/removed from the BGP table */
4937 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4938 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4939 struct bgp_aggregate
*aggregate
)
4941 struct bgp_table
*table
;
4942 struct bgp_node
*top
;
4943 struct bgp_node
*rn
;
4945 struct aspath
*aspath
= NULL
;
4946 struct aspath
*asmerge
= NULL
;
4947 struct community
*community
= NULL
;
4948 struct community
*commerge
= NULL
;
4949 #if defined(AGGREGATE_NEXTHOP_CHECK)
4950 struct in_addr nexthop
;
4953 struct bgp_info
*ri
;
4954 struct bgp_info
*new;
4956 unsigned long match
= 0;
4957 u_char atomic_aggregate
= 0;
4959 /* Record adding route's nexthop and med. */
4962 #if defined(AGGREGATE_NEXTHOP_CHECK)
4963 nexthop
= rinew
->attr
->nexthop
;
4964 med
= rinew
->attr
->med
;
4968 /* ORIGIN attribute: If at least one route among routes that are
4969 aggregated has ORIGIN with the value INCOMPLETE, then the
4970 aggregated route must have the ORIGIN attribute with the value
4971 INCOMPLETE. Otherwise, if at least one route among routes that
4972 are aggregated has ORIGIN with the value EGP, then the aggregated
4973 route must have the origin attribute with the value EGP. In all
4974 other case the value of the ORIGIN attribute of the aggregated
4975 route is INTERNAL. */
4976 origin
= BGP_ORIGIN_IGP
;
4978 table
= bgp
->rib
[afi
][safi
];
4980 top
= bgp_node_get (table
, p
);
4981 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4982 if (rn
->p
.prefixlen
> p
->prefixlen
)
4986 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4988 if (BGP_INFO_HOLDDOWN (ri
))
4991 if (del
&& ri
== del
)
4994 if (! rinew
&& first
)
4996 #if defined(AGGREGATE_NEXTHOP_CHECK)
4997 nexthop
= ri
->attr
->nexthop
;
4998 med
= ri
->attr
->med
;
5003 #ifdef AGGREGATE_NEXTHOP_CHECK
5004 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
5005 || ri
->attr
->med
!= med
)
5008 aspath_free (aspath
);
5010 community_free (community
);
5011 bgp_unlock_node (rn
);
5012 bgp_unlock_node (top
);
5015 #endif /* AGGREGATE_NEXTHOP_CHECK */
5017 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5018 atomic_aggregate
= 1;
5020 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5022 if (aggregate
->summary_only
)
5024 (bgp_info_extra_get (ri
))->suppress
++;
5025 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5031 if (origin
< ri
->attr
->origin
)
5032 origin
= ri
->attr
->origin
;
5034 if (aggregate
->as_set
)
5038 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5039 aspath_free (aspath
);
5043 aspath
= aspath_dup (ri
->attr
->aspath
);
5045 if (ri
->attr
->community
)
5049 commerge
= community_merge (community
,
5050 ri
->attr
->community
);
5051 community
= community_uniq_sort (commerge
);
5052 community_free (commerge
);
5055 community
= community_dup (ri
->attr
->community
);
5061 bgp_process (bgp
, rn
, afi
, safi
);
5063 bgp_unlock_node (top
);
5069 if (aggregate
->summary_only
)
5070 (bgp_info_extra_get (rinew
))->suppress
++;
5072 if (origin
< rinew
->attr
->origin
)
5073 origin
= rinew
->attr
->origin
;
5075 if (aggregate
->as_set
)
5079 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
5080 aspath_free (aspath
);
5084 aspath
= aspath_dup (rinew
->attr
->aspath
);
5086 if (rinew
->attr
->community
)
5090 commerge
= community_merge (community
,
5091 rinew
->attr
->community
);
5092 community
= community_uniq_sort (commerge
);
5093 community_free (commerge
);
5096 community
= community_dup (rinew
->attr
->community
);
5101 if (aggregate
->count
> 0)
5103 rn
= bgp_node_get (table
, p
);
5104 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5105 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5107 atomic_aggregate
), rn
);
5108 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5110 bgp_info_add (rn
, new);
5111 bgp_unlock_node (rn
);
5112 bgp_process (bgp
, rn
, afi
, safi
);
5117 aspath_free (aspath
);
5119 community_free (community
);
5123 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
5124 struct bgp_aggregate
*);
5127 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
5128 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
5130 struct bgp_node
*child
;
5131 struct bgp_node
*rn
;
5132 struct bgp_aggregate
*aggregate
;
5133 struct bgp_table
*table
;
5135 /* MPLS-VPN aggregation is not yet supported. */
5136 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5139 table
= bgp
->aggregate
[afi
][safi
];
5141 /* No aggregates configured. */
5142 if (bgp_table_top_nolock (table
) == NULL
)
5145 if (p
->prefixlen
== 0)
5148 if (BGP_INFO_HOLDDOWN (ri
))
5151 child
= bgp_node_get (table
, p
);
5153 /* Aggregate address configuration check. */
5154 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5155 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5157 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5158 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
5160 bgp_unlock_node (child
);
5164 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
5165 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
5167 struct bgp_node
*child
;
5168 struct bgp_node
*rn
;
5169 struct bgp_aggregate
*aggregate
;
5170 struct bgp_table
*table
;
5172 /* MPLS-VPN aggregation is not yet supported. */
5173 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5176 table
= bgp
->aggregate
[afi
][safi
];
5178 /* No aggregates configured. */
5179 if (bgp_table_top_nolock (table
) == NULL
)
5182 if (p
->prefixlen
== 0)
5185 child
= bgp_node_get (table
, p
);
5187 /* Aggregate address configuration check. */
5188 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5189 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5191 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5192 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
5194 bgp_unlock_node (child
);
5197 /* Called via bgp_aggregate_set when the user configures aggregate-address */
5199 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
5200 struct bgp_aggregate
*aggregate
)
5202 struct bgp_table
*table
;
5203 struct bgp_node
*top
;
5204 struct bgp_node
*rn
;
5205 struct bgp_info
*new;
5206 struct bgp_info
*ri
;
5207 unsigned long match
;
5208 u_char origin
= BGP_ORIGIN_IGP
;
5209 struct aspath
*aspath
= NULL
;
5210 struct aspath
*asmerge
= NULL
;
5211 struct community
*community
= NULL
;
5212 struct community
*commerge
= NULL
;
5213 u_char atomic_aggregate
= 0;
5215 table
= bgp
->rib
[afi
][safi
];
5218 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5220 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5223 /* If routes exists below this node, generate aggregate routes. */
5224 top
= bgp_node_get (table
, p
);
5225 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5226 if (rn
->p
.prefixlen
> p
->prefixlen
)
5230 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5232 if (BGP_INFO_HOLDDOWN (ri
))
5235 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5236 atomic_aggregate
= 1;
5238 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5240 /* summary-only aggregate route suppress aggregated
5241 route announcement. */
5242 if (aggregate
->summary_only
)
5244 (bgp_info_extra_get (ri
))->suppress
++;
5245 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5249 /* If at least one route among routes that are aggregated has
5250 * ORIGIN with the value INCOMPLETE, then the aggregated route
5251 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5252 * Otherwise, if at least one route among routes that are
5253 * aggregated has ORIGIN with the value EGP, then the aggregated
5254 * route MUST have the ORIGIN attribute with the value EGP.
5256 if (origin
< ri
->attr
->origin
)
5257 origin
= ri
->attr
->origin
;
5259 /* as-set aggregate route generate origin, as path,
5260 community aggregation. */
5261 if (aggregate
->as_set
)
5265 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5266 aspath_free (aspath
);
5270 aspath
= aspath_dup (ri
->attr
->aspath
);
5272 if (ri
->attr
->community
)
5276 commerge
= community_merge (community
,
5277 ri
->attr
->community
);
5278 community
= community_uniq_sort (commerge
);
5279 community_free (commerge
);
5282 community
= community_dup (ri
->attr
->community
);
5289 /* If this node is suppressed, process the change. */
5291 bgp_process (bgp
, rn
, afi
, safi
);
5293 bgp_unlock_node (top
);
5295 /* Add aggregate route to BGP table. */
5296 if (aggregate
->count
)
5298 rn
= bgp_node_get (table
, p
);
5299 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5300 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5302 atomic_aggregate
), rn
);
5303 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5305 bgp_info_add (rn
, new);
5306 bgp_unlock_node (rn
);
5308 /* Process change. */
5309 bgp_process (bgp
, rn
, afi
, safi
);
5314 aspath_free (aspath
);
5316 community_free (community
);
5321 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5322 safi_t safi
, struct bgp_aggregate
*aggregate
)
5324 struct bgp_table
*table
;
5325 struct bgp_node
*top
;
5326 struct bgp_node
*rn
;
5327 struct bgp_info
*ri
;
5328 unsigned long match
;
5330 table
= bgp
->rib
[afi
][safi
];
5332 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5334 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5337 /* If routes exists below this node, generate aggregate routes. */
5338 top
= bgp_node_get (table
, p
);
5339 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5340 if (rn
->p
.prefixlen
> p
->prefixlen
)
5344 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5346 if (BGP_INFO_HOLDDOWN (ri
))
5349 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5351 if (aggregate
->summary_only
&& ri
->extra
)
5353 ri
->extra
->suppress
--;
5355 if (ri
->extra
->suppress
== 0)
5357 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5365 /* If this node was suppressed, process the change. */
5367 bgp_process (bgp
, rn
, afi
, safi
);
5369 bgp_unlock_node (top
);
5371 /* Delete aggregate route from BGP table. */
5372 rn
= bgp_node_get (table
, p
);
5374 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5375 if (ri
->peer
== bgp
->peer_self
5376 && ri
->type
== ZEBRA_ROUTE_BGP
5377 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5380 /* Withdraw static BGP route from routing table. */
5383 bgp_info_delete (rn
, ri
);
5384 bgp_process (bgp
, rn
, afi
, safi
);
5387 /* Unlock bgp_node_lookup. */
5388 bgp_unlock_node (rn
);
5391 /* Aggregate route attribute. */
5392 #define AGGREGATE_SUMMARY_ONLY 1
5393 #define AGGREGATE_AS_SET 1
5396 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5397 afi_t afi
, safi_t safi
)
5401 struct bgp_node
*rn
;
5403 struct bgp_aggregate
*aggregate
;
5405 /* Convert string to prefix structure. */
5406 ret
= str2prefix (prefix_str
, &p
);
5409 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5414 /* Get BGP structure. */
5417 /* Old configuration check. */
5418 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5421 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5426 aggregate
= rn
->info
;
5427 if (aggregate
->safi
& SAFI_UNICAST
)
5428 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5429 if (aggregate
->safi
& SAFI_MULTICAST
)
5430 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5432 /* Unlock aggregate address configuration. */
5434 bgp_aggregate_free (aggregate
);
5435 bgp_unlock_node (rn
);
5436 bgp_unlock_node (rn
);
5442 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5443 afi_t afi
, safi_t safi
,
5444 u_char summary_only
, u_char as_set
)
5448 struct bgp_node
*rn
;
5450 struct bgp_aggregate
*aggregate
;
5452 /* Convert string to prefix structure. */
5453 ret
= str2prefix (prefix_str
, &p
);
5456 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5461 /* Get BGP structure. */
5464 /* Old configuration check. */
5465 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5469 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5470 /* try to remove the old entry */
5471 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5474 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5475 bgp_unlock_node (rn
);
5480 /* Make aggregate address structure. */
5481 aggregate
= bgp_aggregate_new ();
5482 aggregate
->summary_only
= summary_only
;
5483 aggregate
->as_set
= as_set
;
5484 aggregate
->safi
= safi
;
5485 rn
->info
= aggregate
;
5487 /* Aggregate address insert into BGP routing table. */
5488 if (safi
& SAFI_UNICAST
)
5489 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5490 if (safi
& SAFI_MULTICAST
)
5491 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5496 DEFUN (aggregate_address
,
5497 aggregate_address_cmd
,
5498 "aggregate-address A.B.C.D/M",
5499 "Configure BGP aggregate entries\n"
5500 "Aggregate prefix\n")
5502 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5505 DEFUN (aggregate_address_mask
,
5506 aggregate_address_mask_cmd
,
5507 "aggregate-address A.B.C.D A.B.C.D",
5508 "Configure BGP aggregate entries\n"
5509 "Aggregate address\n"
5513 char prefix_str
[BUFSIZ
];
5515 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5519 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5523 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5527 DEFUN (aggregate_address_summary_only
,
5528 aggregate_address_summary_only_cmd
,
5529 "aggregate-address A.B.C.D/M summary-only",
5530 "Configure BGP aggregate entries\n"
5531 "Aggregate prefix\n"
5532 "Filter more specific routes from updates\n")
5534 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5535 AGGREGATE_SUMMARY_ONLY
, 0);
5538 DEFUN (aggregate_address_mask_summary_only
,
5539 aggregate_address_mask_summary_only_cmd
,
5540 "aggregate-address A.B.C.D A.B.C.D summary-only",
5541 "Configure BGP aggregate entries\n"
5542 "Aggregate address\n"
5544 "Filter more specific routes from updates\n")
5547 char prefix_str
[BUFSIZ
];
5549 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5553 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5557 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5558 AGGREGATE_SUMMARY_ONLY
, 0);
5561 DEFUN (aggregate_address_as_set
,
5562 aggregate_address_as_set_cmd
,
5563 "aggregate-address A.B.C.D/M as-set",
5564 "Configure BGP aggregate entries\n"
5565 "Aggregate prefix\n"
5566 "Generate AS set path information\n")
5568 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5569 0, AGGREGATE_AS_SET
);
5572 DEFUN (aggregate_address_mask_as_set
,
5573 aggregate_address_mask_as_set_cmd
,
5574 "aggregate-address A.B.C.D A.B.C.D as-set",
5575 "Configure BGP aggregate entries\n"
5576 "Aggregate address\n"
5578 "Generate AS set path information\n")
5581 char prefix_str
[BUFSIZ
];
5583 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5587 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5591 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5592 0, AGGREGATE_AS_SET
);
5596 DEFUN (aggregate_address_as_set_summary
,
5597 aggregate_address_as_set_summary_cmd
,
5598 "aggregate-address A.B.C.D/M as-set summary-only",
5599 "Configure BGP aggregate entries\n"
5600 "Aggregate prefix\n"
5601 "Generate AS set path information\n"
5602 "Filter more specific routes from updates\n")
5604 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5605 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5608 ALIAS (aggregate_address_as_set_summary
,
5609 aggregate_address_summary_as_set_cmd
,
5610 "aggregate-address A.B.C.D/M summary-only as-set",
5611 "Configure BGP aggregate entries\n"
5612 "Aggregate prefix\n"
5613 "Filter more specific routes from updates\n"
5614 "Generate AS set path information\n")
5616 DEFUN (aggregate_address_mask_as_set_summary
,
5617 aggregate_address_mask_as_set_summary_cmd
,
5618 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5619 "Configure BGP aggregate entries\n"
5620 "Aggregate address\n"
5622 "Generate AS set path information\n"
5623 "Filter more specific routes from updates\n")
5626 char prefix_str
[BUFSIZ
];
5628 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5632 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5636 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5637 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5640 ALIAS (aggregate_address_mask_as_set_summary
,
5641 aggregate_address_mask_summary_as_set_cmd
,
5642 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5643 "Configure BGP aggregate entries\n"
5644 "Aggregate address\n"
5646 "Filter more specific routes from updates\n"
5647 "Generate AS set path information\n")
5649 DEFUN (no_aggregate_address
,
5650 no_aggregate_address_cmd
,
5651 "no aggregate-address A.B.C.D/M",
5653 "Configure BGP aggregate entries\n"
5654 "Aggregate prefix\n")
5656 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5659 ALIAS (no_aggregate_address
,
5660 no_aggregate_address_summary_only_cmd
,
5661 "no aggregate-address A.B.C.D/M summary-only",
5663 "Configure BGP aggregate entries\n"
5664 "Aggregate prefix\n"
5665 "Filter more specific routes from updates\n")
5667 ALIAS (no_aggregate_address
,
5668 no_aggregate_address_as_set_cmd
,
5669 "no aggregate-address A.B.C.D/M as-set",
5671 "Configure BGP aggregate entries\n"
5672 "Aggregate prefix\n"
5673 "Generate AS set path information\n")
5675 ALIAS (no_aggregate_address
,
5676 no_aggregate_address_as_set_summary_cmd
,
5677 "no aggregate-address A.B.C.D/M as-set summary-only",
5679 "Configure BGP aggregate entries\n"
5680 "Aggregate prefix\n"
5681 "Generate AS set path information\n"
5682 "Filter more specific routes from updates\n")
5684 ALIAS (no_aggregate_address
,
5685 no_aggregate_address_summary_as_set_cmd
,
5686 "no aggregate-address A.B.C.D/M summary-only as-set",
5688 "Configure BGP aggregate entries\n"
5689 "Aggregate prefix\n"
5690 "Filter more specific routes from updates\n"
5691 "Generate AS set path information\n")
5693 DEFUN (no_aggregate_address_mask
,
5694 no_aggregate_address_mask_cmd
,
5695 "no aggregate-address A.B.C.D A.B.C.D",
5697 "Configure BGP aggregate entries\n"
5698 "Aggregate address\n"
5702 char prefix_str
[BUFSIZ
];
5704 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5708 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5712 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5715 ALIAS (no_aggregate_address_mask
,
5716 no_aggregate_address_mask_summary_only_cmd
,
5717 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5719 "Configure BGP aggregate entries\n"
5720 "Aggregate address\n"
5722 "Filter more specific routes from updates\n")
5724 ALIAS (no_aggregate_address_mask
,
5725 no_aggregate_address_mask_as_set_cmd
,
5726 "no aggregate-address A.B.C.D A.B.C.D as-set",
5728 "Configure BGP aggregate entries\n"
5729 "Aggregate address\n"
5731 "Generate AS set path information\n")
5733 ALIAS (no_aggregate_address_mask
,
5734 no_aggregate_address_mask_as_set_summary_cmd
,
5735 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5737 "Configure BGP aggregate entries\n"
5738 "Aggregate address\n"
5740 "Generate AS set path information\n"
5741 "Filter more specific routes from updates\n")
5743 ALIAS (no_aggregate_address_mask
,
5744 no_aggregate_address_mask_summary_as_set_cmd
,
5745 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5747 "Configure BGP aggregate entries\n"
5748 "Aggregate address\n"
5750 "Filter more specific routes from updates\n"
5751 "Generate AS set path information\n")
5754 DEFUN (ipv6_aggregate_address
,
5755 ipv6_aggregate_address_cmd
,
5756 "aggregate-address X:X::X:X/M",
5757 "Configure BGP aggregate entries\n"
5758 "Aggregate prefix\n")
5760 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5763 DEFUN (ipv6_aggregate_address_summary_only
,
5764 ipv6_aggregate_address_summary_only_cmd
,
5765 "aggregate-address X:X::X:X/M summary-only",
5766 "Configure BGP aggregate entries\n"
5767 "Aggregate prefix\n"
5768 "Filter more specific routes from updates\n")
5770 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5771 AGGREGATE_SUMMARY_ONLY
, 0);
5774 DEFUN (no_ipv6_aggregate_address
,
5775 no_ipv6_aggregate_address_cmd
,
5776 "no aggregate-address X:X::X:X/M",
5778 "Configure BGP aggregate entries\n"
5779 "Aggregate prefix\n")
5781 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5784 DEFUN (no_ipv6_aggregate_address_summary_only
,
5785 no_ipv6_aggregate_address_summary_only_cmd
,
5786 "no aggregate-address X:X::X:X/M summary-only",
5788 "Configure BGP aggregate entries\n"
5789 "Aggregate prefix\n"
5790 "Filter more specific routes from updates\n")
5792 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5795 ALIAS (ipv6_aggregate_address
,
5796 old_ipv6_aggregate_address_cmd
,
5797 "ipv6 bgp aggregate-address X:X::X:X/M",
5800 "Configure BGP aggregate entries\n"
5801 "Aggregate prefix\n")
5803 ALIAS (ipv6_aggregate_address_summary_only
,
5804 old_ipv6_aggregate_address_summary_only_cmd
,
5805 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5808 "Configure BGP aggregate entries\n"
5809 "Aggregate prefix\n"
5810 "Filter more specific routes from updates\n")
5812 ALIAS (no_ipv6_aggregate_address
,
5813 old_no_ipv6_aggregate_address_cmd
,
5814 "no ipv6 bgp aggregate-address X:X::X:X/M",
5818 "Configure BGP aggregate entries\n"
5819 "Aggregate prefix\n")
5821 ALIAS (no_ipv6_aggregate_address_summary_only
,
5822 old_no_ipv6_aggregate_address_summary_only_cmd
,
5823 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5827 "Configure BGP aggregate entries\n"
5828 "Aggregate prefix\n"
5829 "Filter more specific routes from updates\n")
5830 #endif /* HAVE_IPV6 */
5832 /* Redistribute route treatment. */
5834 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5835 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5836 u_int32_t metric
, u_char type
, u_short instance
, route_tag_t tag
)
5838 struct bgp_info
*new;
5839 struct bgp_info
*bi
;
5840 struct bgp_info info
;
5841 struct bgp_node
*bn
;
5843 struct attr
*new_attr
;
5846 struct bgp_redist
*red
;
5848 /* Make default attribute. */
5849 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5851 attr
.nexthop
= *nexthop
;
5852 attr
.nh_ifindex
= ifindex
;
5857 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5858 extra
->mp_nexthop_global
= *nexthop6
;
5859 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5864 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5865 attr
.extra
->tag
= tag
;
5867 afi
= family2afi (p
->family
);
5869 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5872 struct attr attr_new
;
5873 struct attr_extra extra_new
;
5875 /* Copy attribute for modification. */
5876 attr_new
.extra
= &extra_new
;
5877 bgp_attr_dup (&attr_new
, &attr
);
5879 if (red
->redist_metric_flag
)
5880 attr_new
.med
= red
->redist_metric
;
5882 /* Apply route-map. */
5885 info
.peer
= bgp
->peer_self
;
5886 info
.attr
= &attr_new
;
5888 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5890 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5892 bgp
->peer_self
->rmap_type
= 0;
5894 if (ret
== RMAP_DENYMATCH
)
5896 /* Free uninterned attribute. */
5897 bgp_attr_flush (&attr_new
);
5899 /* Unintern original. */
5900 aspath_unintern (&attr
.aspath
);
5901 bgp_attr_extra_free (&attr
);
5902 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5907 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5908 afi
, SAFI_UNICAST
, p
, NULL
);
5910 new_attr
= bgp_attr_intern (&attr_new
);
5912 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5913 if (bi
->peer
== bgp
->peer_self
5914 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5919 /* Ensure the (source route) type is updated. */
5921 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5922 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5924 bgp_attr_unintern (&new_attr
);
5925 aspath_unintern (&attr
.aspath
);
5926 bgp_attr_extra_free (&attr
);
5927 bgp_unlock_node (bn
);
5932 /* The attribute is changed. */
5933 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5935 /* Rewrite BGP route information. */
5936 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5937 bgp_info_restore(bn
, bi
);
5939 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5940 bgp_attr_unintern (&bi
->attr
);
5941 bi
->attr
= new_attr
;
5942 bi
->uptime
= bgp_clock ();
5944 /* Process change. */
5945 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5946 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5947 bgp_unlock_node (bn
);
5948 aspath_unintern (&attr
.aspath
);
5949 bgp_attr_extra_free (&attr
);
5954 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5956 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5958 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5959 bgp_info_add (bn
, new);
5960 bgp_unlock_node (bn
);
5961 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5964 /* Unintern original. */
5965 aspath_unintern (&attr
.aspath
);
5966 bgp_attr_extra_free (&attr
);
5970 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5973 struct bgp_node
*rn
;
5974 struct bgp_info
*ri
;
5975 struct bgp_redist
*red
;
5977 afi
= family2afi (p
->family
);
5979 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5982 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5984 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5985 if (ri
->peer
== bgp
->peer_self
5986 && ri
->type
== type
)
5991 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5992 bgp_info_delete (rn
, ri
);
5993 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5995 bgp_unlock_node (rn
);
5999 /* Withdraw specified route type's route. */
6001 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
6003 struct bgp_node
*rn
;
6004 struct bgp_info
*ri
;
6005 struct bgp_table
*table
;
6007 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
6009 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6011 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6012 if (ri
->peer
== bgp
->peer_self
6014 && ri
->instance
== instance
)
6019 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
6020 bgp_info_delete (rn
, ri
);
6021 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
6026 /* Static function to display route. */
6028 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
6031 u_int32_t destination
;
6034 if (p
->family
== AF_INET
)
6036 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
6037 destination
= ntohl (p
->u
.prefix4
.s_addr
);
6039 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
6040 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
6041 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
6042 || p
->u
.prefix4
.s_addr
== 0)
6044 /* When mask is natural, mask is not displayed. */
6047 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
6050 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
6055 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
6057 vty_out (vty
, "%*s", len
, " ");
6060 enum bgp_display_type
6065 /* Print the short form route status for a bgp_info */
6067 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
6068 json_object
*json_path
)
6073 /* Route status display. */
6074 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6075 json_object_boolean_true_add(json_path
, "removed");
6077 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6078 json_object_boolean_true_add(json_path
, "stale");
6080 if (binfo
->extra
&& binfo
->extra
->suppress
)
6081 json_object_boolean_true_add(json_path
, "suppressed");
6083 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6084 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6085 json_object_boolean_true_add(json_path
, "valid");
6088 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6089 json_object_boolean_true_add(json_path
, "history");
6091 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6092 json_object_boolean_true_add(json_path
, "damped");
6094 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6095 json_object_boolean_true_add(json_path
, "bestpath");
6097 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6098 json_object_boolean_true_add(json_path
, "multipath");
6100 /* Internal route. */
6101 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6102 json_object_string_add(json_path
, "pathFrom", "internal");
6104 json_object_string_add(json_path
, "pathFrom", "external");
6109 /* Route status display. */
6110 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6112 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6114 else if (binfo
->extra
&& binfo
->extra
->suppress
)
6116 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6117 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6123 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6125 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6127 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6129 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6134 /* Internal route. */
6135 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6141 /* called from terminal list command */
6143 route_vty_out (struct vty
*vty
, struct prefix
*p
,
6144 struct bgp_info
*binfo
, int display
, safi_t safi
,
6145 json_object
*json_paths
)
6148 json_object
*json_path
= NULL
;
6149 json_object
*json_nexthops
= NULL
;
6150 json_object
*json_nexthop_global
= NULL
;
6151 json_object
*json_nexthop_ll
= NULL
;
6154 json_path
= json_object_new_object();
6156 /* short status lead text */
6157 route_vty_short_status_out (vty
, binfo
, json_path
);
6161 /* print prefix and mask */
6163 route_vty_out_route (p
, vty
);
6165 vty_out (vty
, "%*s", 17, " ");
6168 /* Print attribute */
6173 * For ENCAP routes, nexthop address family is not
6174 * neccessarily the same as the prefix address family.
6175 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
6177 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
6182 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
6187 vty_out (vty
, "%s", inet_ntop(af
,
6188 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
6192 vty_out (vty
, "%s", inet_ntop(af
,
6193 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
6205 else if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6209 json_nexthop_global
= json_object_new_object();
6211 if (safi
== SAFI_MPLS_VPN
)
6212 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6214 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6216 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6217 json_object_boolean_true_add(json_nexthop_global
, "used");
6221 if (safi
== SAFI_MPLS_VPN
)
6222 vty_out (vty
, "%-16s",
6223 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6225 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6230 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6237 json_nexthop_global
= json_object_new_object();
6238 json_object_string_add(json_nexthop_global
, "ip",
6239 inet_ntop (AF_INET6
,
6240 &attr
->extra
->mp_nexthop_global
,
6242 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6243 json_object_string_add(json_nexthop_global
, "scope", "global");
6245 /* We display both LL & GL if both have been received */
6246 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
6248 json_nexthop_ll
= json_object_new_object();
6249 json_object_string_add(json_nexthop_ll
, "ip",
6250 inet_ntop (AF_INET6
,
6251 &attr
->extra
->mp_nexthop_local
,
6253 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6254 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6256 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
6257 &attr
->extra
->mp_nexthop_local
) != 0) &&
6258 !attr
->extra
->mp_nexthop_prefer_global
)
6259 json_object_boolean_true_add(json_nexthop_ll
, "used");
6261 json_object_boolean_true_add(json_nexthop_global
, "used");
6264 json_object_boolean_true_add(json_nexthop_global
, "used");
6268 /* Display LL if LL/Global both in table unless prefer-global is set */
6269 if (((attr
->extra
->mp_nexthop_len
== 32) &&
6270 !attr
->extra
->mp_nexthop_prefer_global
) ||
6271 (binfo
->peer
->conf_if
))
6273 if (binfo
->peer
->conf_if
)
6275 len
= vty_out (vty
, "%s",
6276 binfo
->peer
->conf_if
);
6277 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6280 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6282 vty_out (vty
, "%*s", len
, " ");
6286 len
= vty_out (vty
, "%s",
6287 inet_ntop (AF_INET6
,
6288 &attr
->extra
->mp_nexthop_local
,
6293 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6295 vty_out (vty
, "%*s", len
, " ");
6300 len
= vty_out (vty
, "%s",
6301 inet_ntop (AF_INET6
,
6302 &attr
->extra
->mp_nexthop_global
,
6307 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6309 vty_out (vty
, "%*s", len
, " ");
6315 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6317 json_object_int_add(json_path
, "med", attr
->med
);
6319 vty_out (vty
, "%10u ", attr
->med
);
6325 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6327 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6329 vty_out (vty
, "%7u ", attr
->local_pref
);
6337 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6339 json_object_int_add(json_path
, "weight", 0);
6342 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6346 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6353 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6355 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6360 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6362 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6367 json_object_string_add(json_path
, "alert", "No attributes");
6369 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6374 if (json_nexthop_global
|| json_nexthop_ll
)
6376 json_nexthops
= json_object_new_array();
6378 if (json_nexthop_global
)
6379 json_object_array_add(json_nexthops
, json_nexthop_global
);
6381 if (json_nexthop_ll
)
6382 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6384 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6387 json_object_array_add(json_paths
, json_path
);
6391 vty_out (vty
, "%s", VTY_NEWLINE
);
6393 /* prints an additional line, indented, with VNC info, if present */
6394 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
) || (safi
== SAFI_UNICAST
))
6395 rfapi_vty_out_vncinfo(vty
, p
, binfo
, safi
);
6400 /* called from terminal list command */
6402 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6403 u_char use_json
, json_object
*json_ar
)
6405 json_object
*json_status
= NULL
;
6406 json_object
*json_net
= NULL
;
6408 /* Route status display. */
6411 json_status
= json_object_new_object();
6412 json_net
= json_object_new_object();
6421 /* print prefix and mask */
6423 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6425 route_vty_out_route (p
, vty
);
6427 /* Print attribute */
6432 if (p
->family
== AF_INET
&&
6433 (safi
== SAFI_MPLS_VPN
||
6434 safi
== SAFI_ENCAP
||
6435 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6437 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6438 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6440 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6443 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6447 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6450 #endif /* HAVE_IPV6 */
6452 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6453 json_object_int_add(json_net
, "metric", attr
->med
);
6455 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6456 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6459 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6461 json_object_int_add(json_net
, "weight", 0);
6465 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6468 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6472 if (p
->family
== AF_INET
&&
6473 (safi
== SAFI_MPLS_VPN
||
6474 safi
== SAFI_ENCAP
||
6475 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6477 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6478 vty_out (vty
, "%-16s",
6479 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6481 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6484 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6489 assert (attr
->extra
);
6491 len
= vty_out (vty
, "%s",
6492 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6496 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6498 vty_out (vty
, "%*s", len
, " ");
6500 #endif /* HAVE_IPV6 */
6501 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6502 vty_out (vty
, "%10u ", attr
->med
);
6506 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6507 vty_out (vty
, "%7u ", attr
->local_pref
);
6511 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6515 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6518 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6523 json_object_boolean_true_add(json_status
, "*");
6524 json_object_boolean_true_add(json_status
, ">");
6525 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6526 char buf_cut
[BUFSIZ
];
6527 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6530 vty_out (vty
, "%s", VTY_NEWLINE
);
6534 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6535 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6537 json_object
*json_out
= NULL
;
6539 u_int32_t label
= 0;
6545 json_out
= json_object_new_object();
6547 /* short status lead text */
6548 route_vty_short_status_out (vty
, binfo
, json_out
);
6550 /* print prefix and mask */
6554 route_vty_out_route (p
, vty
);
6556 vty_out (vty
, "%*s", 17, " ");
6559 /* Print attribute */
6563 if (p
->family
== AF_INET
6564 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6566 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6569 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6571 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6576 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6578 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6582 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6584 assert (attr
->extra
);
6588 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6591 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6592 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6595 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6598 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6602 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6604 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6606 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6607 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6610 vty_out (vty
, "%s(%s)",
6611 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6613 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6618 #endif /* HAVE_IPV6 */
6621 label
= decode_label (binfo
->extra
->tag
);
6626 json_object_int_add(json_out
, "notag", label
);
6627 json_object_array_add(json
, json_out
);
6631 vty_out (vty
, "notag/%d", label
);
6632 vty_out (vty
, "%s", VTY_NEWLINE
);
6636 /* dampening route */
6638 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6639 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6643 char timebuf
[BGP_UPTIME_LEN
];
6645 /* short status lead text */
6646 route_vty_short_status_out (vty
, binfo
, json
);
6648 /* print prefix and mask */
6652 route_vty_out_route (p
, vty
);
6654 vty_out (vty
, "%*s", 17, " ");
6657 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6662 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6667 json_object_int_add(json
, "peerHost", len
);
6669 vty_out (vty
, "%*s", len
, " ");
6673 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6675 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6677 /* Print attribute */
6685 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6687 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6692 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6694 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6697 vty_out (vty
, "%s", VTY_NEWLINE
);
6702 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6703 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6706 struct bgp_damp_info
*bdi
;
6707 char timebuf
[BGP_UPTIME_LEN
];
6713 bdi
= binfo
->extra
->damp_info
;
6715 /* short status lead text */
6716 route_vty_short_status_out (vty
, binfo
, json
);
6718 /* print prefix and mask */
6722 route_vty_out_route (p
, vty
);
6724 vty_out (vty
, "%*s", 17, " ");
6727 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6732 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6737 json_object_int_add(json
, "peerHost", len
);
6739 vty_out (vty
, "%*s", len
, " ");
6742 len
= vty_out (vty
, "%d", bdi
->flap
);
6752 json_object_int_add(json
, "bdiFlap", len
);
6754 vty_out (vty
, "%*s", len
, " ");
6758 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6760 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6761 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6763 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6764 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6767 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6769 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6774 vty_out (vty
, "%*s ", 8, " ");
6777 /* Print attribute */
6785 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6787 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6792 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6794 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6797 vty_out (vty
, "%s", VTY_NEWLINE
);
6801 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6802 const char *header
, json_object
*json_adv_to
)
6804 char buf1
[INET6_ADDRSTRLEN
];
6805 json_object
*json_peer
= NULL
;
6809 /* 'advertised-to' is a dictionary of peers we have advertised this
6810 * prefix too. The key is the peer's IP or swpX, the value is the
6811 * hostname if we know it and "" if not.
6813 json_peer
= json_object_new_object();
6816 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6819 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6821 json_object_object_add(json_adv_to
,
6822 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6829 vty_out (vty
, "%s", header
);
6833 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6836 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6838 vty_out (vty
, " %s(%s)", peer
->hostname
,
6839 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6844 vty_out (vty
, " %s", peer
->conf_if
);
6846 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6852 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6853 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6854 json_object
*json_paths
)
6856 char buf
[INET6_ADDRSTRLEN
];
6859 int sockunion_vty_out (struct vty
*, union sockunion
*);
6860 #ifdef HAVE_CLOCK_MONOTONIC
6863 json_object
*json_bestpath
= NULL
;
6864 json_object
*json_cluster_list
= NULL
;
6865 json_object
*json_cluster_list_list
= NULL
;
6866 json_object
*json_ext_community
= NULL
;
6867 json_object
*json_last_update
= NULL
;
6868 json_object
*json_nexthop_global
= NULL
;
6869 json_object
*json_nexthop_ll
= NULL
;
6870 json_object
*json_nexthops
= NULL
;
6871 json_object
*json_path
= NULL
;
6872 json_object
*json_peer
= NULL
;
6873 json_object
*json_string
= NULL
;
6874 json_object
*json_adv_to
= NULL
;
6876 struct listnode
*node
, *nnode
;
6878 int addpath_capable
;
6880 unsigned int first_as
;
6884 json_path
= json_object_new_object();
6885 json_peer
= json_object_new_object();
6886 json_nexthop_global
= json_object_new_object();
6893 /* Line1 display AS-path, Aggregator */
6898 json_object_lock(attr
->aspath
->json
);
6899 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6903 if (attr
->aspath
->segments
)
6904 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6906 vty_out (vty
, " Local");
6910 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6913 json_object_boolean_true_add(json_path
, "removed");
6915 vty_out (vty
, ", (removed)");
6918 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6921 json_object_boolean_true_add(json_path
, "stale");
6923 vty_out (vty
, ", (stale)");
6926 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6930 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6931 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6935 vty_out (vty
, ", (aggregated by %u %s)",
6936 attr
->extra
->aggregator_as
,
6937 inet_ntoa (attr
->extra
->aggregator_addr
));
6941 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6944 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6946 vty_out (vty
, ", (Received from a RR-client)");
6949 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6952 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6954 vty_out (vty
, ", (Received from a RS-client)");
6957 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6960 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6962 vty_out (vty
, ", (history entry)");
6964 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6967 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6969 vty_out (vty
, ", (suppressed due to dampening)");
6973 vty_out (vty
, "%s", VTY_NEWLINE
);
6975 /* Line2 display Next-hop, Neighbor, Router-id */
6976 /* Display the nexthop */
6977 if (p
->family
== AF_INET
&&
6978 (safi
== SAFI_MPLS_VPN
||
6979 safi
== SAFI_ENCAP
||
6980 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6982 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6985 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6987 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6992 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6994 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6998 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
7002 assert (attr
->extra
);
7005 json_object_string_add(json_nexthop_global
, "ip",
7006 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
7007 buf
, INET6_ADDRSTRLEN
));
7008 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
7009 json_object_string_add(json_nexthop_global
, "scope", "global");
7013 vty_out (vty
, " %s",
7014 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
7015 buf
, INET6_ADDRSTRLEN
));
7019 /* Display the IGP cost or 'inaccessible' */
7020 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7023 json_object_boolean_false_add(json_nexthop_global
, "accessible");
7025 vty_out (vty
, " (inaccessible)");
7029 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
7032 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
7034 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
7037 /* IGP cost is 0, display this only for json */
7041 json_object_int_add(json_nexthop_global
, "metric", 0);
7045 json_object_boolean_true_add(json_nexthop_global
, "accessible");
7048 /* Display peer "from" output */
7049 /* This path was originated locally */
7050 if (binfo
->peer
== bgp
->peer_self
)
7053 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
7056 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
7058 vty_out (vty
, " from 0.0.0.0 ");
7063 json_object_string_add(json_peer
, "peerId", "::");
7065 vty_out (vty
, " from :: ");
7069 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
7071 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
7074 /* We RXed this path from one of our peers */
7080 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7081 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7083 if (binfo
->peer
->hostname
)
7084 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
7086 if (binfo
->peer
->domainname
)
7087 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
7089 if (binfo
->peer
->conf_if
)
7090 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
7094 if (binfo
->peer
->conf_if
)
7096 if (binfo
->peer
->hostname
&&
7097 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7098 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7099 binfo
->peer
->conf_if
);
7101 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
7105 if (binfo
->peer
->hostname
&&
7106 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7107 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7110 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7113 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7114 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
7116 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7121 vty_out (vty
, "%s", VTY_NEWLINE
);
7123 /* display the link-local nexthop */
7124 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
7128 json_nexthop_ll
= json_object_new_object();
7129 json_object_string_add(json_nexthop_ll
, "ip",
7130 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7131 buf
, INET6_ADDRSTRLEN
));
7132 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
7133 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
7135 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
7137 if (!attr
->extra
->mp_nexthop_prefer_global
)
7138 json_object_boolean_true_add(json_nexthop_ll
, "used");
7140 json_object_boolean_true_add(json_nexthop_global
, "used");
7144 vty_out (vty
, " (%s) %s%s",
7145 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7146 buf
, INET6_ADDRSTRLEN
),
7147 attr
->extra
->mp_nexthop_prefer_global
?
7148 "(prefer-global)" : "(used)",
7152 /* If we do not have a link-local nexthop then we must flag the global as "used" */
7156 json_object_boolean_true_add(json_nexthop_global
, "used");
7159 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
7161 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
7163 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
7165 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
7168 json_object_int_add(json_path
, "med", attr
->med
);
7170 vty_out (vty
, ", metric %u", attr
->med
);
7173 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
7176 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
7178 vty_out (vty
, ", localpref %u", attr
->local_pref
);
7183 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
7185 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
7188 if (attr
->extra
&& attr
->extra
->weight
!= 0)
7191 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
7193 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
7196 if (attr
->extra
&& attr
->extra
->tag
!= 0)
7199 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
7201 vty_out (vty
, ", tag %"ROUTE_TAG_PRI
, attr
->extra
->tag
);
7204 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7207 json_object_boolean_false_add(json_path
, "valid");
7209 vty_out (vty
, ", invalid");
7211 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
7214 json_object_boolean_true_add(json_path
, "valid");
7216 vty_out (vty
, ", valid");
7219 if (binfo
->peer
!= bgp
->peer_self
)
7221 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
7223 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7226 json_object_string_add(json_peer
, "type", "confed-internal");
7228 vty_out (vty
, ", confed-internal");
7233 json_object_string_add(json_peer
, "type", "internal");
7235 vty_out (vty
, ", internal");
7240 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
7243 json_object_string_add(json_peer
, "type", "confed-external");
7245 vty_out (vty
, ", confed-external");
7250 json_object_string_add(json_peer
, "type", "external");
7252 vty_out (vty
, ", external");
7256 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
7260 json_object_boolean_true_add(json_path
, "aggregated");
7261 json_object_boolean_true_add(json_path
, "local");
7265 vty_out (vty
, ", aggregated, local");
7268 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
7271 json_object_boolean_true_add(json_path
, "sourced");
7273 vty_out (vty
, ", sourced");
7279 json_object_boolean_true_add(json_path
, "sourced");
7280 json_object_boolean_true_add(json_path
, "local");
7284 vty_out (vty
, ", sourced, local");
7288 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7291 json_object_boolean_true_add(json_path
, "atomicAggregate");
7293 vty_out (vty
, ", atomic-aggregate");
7296 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7297 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7298 bgp_info_mpath_count (binfo
)))
7301 json_object_boolean_true_add(json_path
, "multipath");
7303 vty_out (vty
, ", multipath");
7306 // Mark the bestpath(s)
7307 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7309 first_as
= aspath_get_first_as(attr
->aspath
);
7314 json_bestpath
= json_object_new_object();
7315 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7320 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7322 vty_out (vty
, ", bestpath-from-AS Local");
7326 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7331 json_bestpath
= json_object_new_object();
7332 json_object_boolean_true_add(json_bestpath
, "overall");
7335 vty_out (vty
, ", best");
7339 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7342 vty_out (vty
, "%s", VTY_NEWLINE
);
7344 /* Line 4 display Community */
7345 if (attr
->community
)
7349 json_object_lock(attr
->community
->json
);
7350 json_object_object_add(json_path
, "community", attr
->community
->json
);
7354 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7359 /* Line 5 display Extended-community */
7360 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7364 json_ext_community
= json_object_new_object();
7365 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7366 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7370 vty_out (vty
, " Extended Community: %s%s",
7371 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7375 /* Line 6 display Originator, Cluster-id */
7376 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7377 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7379 assert (attr
->extra
);
7380 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7383 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7385 vty_out (vty
, " Originator: %s",
7386 inet_ntoa (attr
->extra
->originator_id
));
7389 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7395 json_cluster_list
= json_object_new_object();
7396 json_cluster_list_list
= json_object_new_array();
7398 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7400 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7401 json_object_array_add(json_cluster_list_list
, json_string
);
7404 /* struct cluster_list does not have "str" variable like
7405 * aspath and community do. Add this someday if someone
7407 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7409 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7410 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7414 vty_out (vty
, ", Cluster list: ");
7416 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7418 vty_out (vty
, "%s ",
7419 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7425 vty_out (vty
, "%s", VTY_NEWLINE
);
7428 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7429 bgp_damp_info_vty (vty
, binfo
, json_path
);
7431 /* Line 7 display Addpath IDs */
7432 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7436 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7437 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7441 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7442 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7447 /* If we used addpath to TX a non-bestpath we need to display
7448 * "Advertised to" on a path-by-path basis */
7449 if (bgp
->addpath_tx_used
[afi
][safi
])
7453 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7455 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7456 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7458 if ((addpath_capable
&& has_adj
) ||
7459 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7461 if (json_path
&& !json_adv_to
)
7462 json_adv_to
= json_object_new_object();
7464 route_vty_out_advertised_to(vty
, peer
, &first
,
7474 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7481 vty_out (vty
, "%s", VTY_NEWLINE
);
7486 /* Line 8 display Uptime */
7487 #ifdef HAVE_CLOCK_MONOTONIC
7488 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7491 json_last_update
= json_object_new_object();
7492 json_object_int_add(json_last_update
, "epoch", tbuf
);
7493 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7494 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7497 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7501 json_last_update
= json_object_new_object();
7502 json_object_int_add(json_last_update
, "epoch", tbuf
);
7503 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7504 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7507 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7508 #endif /* HAVE_CLOCK_MONOTONIC */
7511 /* We've constructed the json object for this path, add it to the json
7516 if (json_nexthop_global
|| json_nexthop_ll
)
7518 json_nexthops
= json_object_new_array();
7520 if (json_nexthop_global
)
7521 json_object_array_add(json_nexthops
, json_nexthop_global
);
7523 if (json_nexthop_ll
)
7524 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7526 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7529 json_object_object_add(json_path
, "peer", json_peer
);
7530 json_object_array_add(json_paths
, json_path
);
7533 vty_out (vty
, "%s", VTY_NEWLINE
);
7536 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7537 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7538 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7542 bgp_show_type_normal
,
7543 bgp_show_type_regexp
,
7544 bgp_show_type_prefix_list
,
7545 bgp_show_type_filter_list
,
7546 bgp_show_type_route_map
,
7547 bgp_show_type_neighbor
,
7548 bgp_show_type_cidr_only
,
7549 bgp_show_type_prefix_longer
,
7550 bgp_show_type_community_all
,
7551 bgp_show_type_community
,
7552 bgp_show_type_community_exact
,
7553 bgp_show_type_community_list
,
7554 bgp_show_type_community_list_exact
,
7555 bgp_show_type_flap_statistics
,
7556 bgp_show_type_flap_address
,
7557 bgp_show_type_flap_prefix
,
7558 bgp_show_type_flap_cidr_only
,
7559 bgp_show_type_flap_regexp
,
7560 bgp_show_type_flap_filter_list
,
7561 bgp_show_type_flap_prefix_list
,
7562 bgp_show_type_flap_prefix_longer
,
7563 bgp_show_type_flap_route_map
,
7564 bgp_show_type_flap_neighbor
,
7565 bgp_show_type_dampend_paths
,
7566 bgp_show_type_damp_neighbor
7570 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7571 const char *prefix_list_str
, afi_t afi
,
7572 safi_t safi
, enum bgp_show_type type
);
7574 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7575 const char *filter
, afi_t afi
,
7576 safi_t safi
, enum bgp_show_type type
);
7578 bgp_show_route_map (struct vty
*vty
, const char *name
,
7579 const char *rmap_str
, afi_t afi
,
7580 safi_t safi
, enum bgp_show_type type
);
7582 bgp_show_community_list (struct vty
*vty
, const char *name
,
7583 const char *com
, int exact
,
7584 afi_t afi
, safi_t safi
);
7586 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7587 const char *prefix
, afi_t afi
,
7588 safi_t safi
, enum bgp_show_type type
);
7591 bgp_show_table (struct vty
*vty
, struct bgp_table
*table
,
7592 struct in_addr
*router_id
, enum bgp_show_type type
,
7593 void *output_arg
, u_char use_json
, json_object
*json
)
7595 struct bgp_info
*ri
;
7596 struct bgp_node
*rn
;
7599 unsigned long output_count
;
7600 unsigned long total_count
;
7604 json_object
*json_paths
= NULL
;
7605 json_object
*json_routes
= NULL
;
7610 json
= json_object_new_object();
7612 json_object_int_add(json
, "tableVersion", table
->version
);
7613 json_object_string_add(json
, "routerId", inet_ntoa (*router_id
));
7614 json_routes
= json_object_new_object();
7617 /* This is first entry point, so reset total line. */
7621 /* Start processing of routes. */
7622 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7623 if (rn
->info
!= NULL
)
7628 json_paths
= json_object_new_array();
7632 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7635 if (type
== bgp_show_type_flap_statistics
7636 || type
== bgp_show_type_flap_address
7637 || type
== bgp_show_type_flap_prefix
7638 || type
== bgp_show_type_flap_cidr_only
7639 || type
== bgp_show_type_flap_regexp
7640 || type
== bgp_show_type_flap_filter_list
7641 || type
== bgp_show_type_flap_prefix_list
7642 || type
== bgp_show_type_flap_prefix_longer
7643 || type
== bgp_show_type_flap_route_map
7644 || type
== bgp_show_type_flap_neighbor
7645 || type
== bgp_show_type_dampend_paths
7646 || type
== bgp_show_type_damp_neighbor
)
7648 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7651 if (type
== bgp_show_type_regexp
7652 || type
== bgp_show_type_flap_regexp
)
7654 regex_t
*regex
= output_arg
;
7656 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7659 if (type
== bgp_show_type_prefix_list
7660 || type
== bgp_show_type_flap_prefix_list
)
7662 struct prefix_list
*plist
= output_arg
;
7664 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7667 if (type
== bgp_show_type_filter_list
7668 || type
== bgp_show_type_flap_filter_list
)
7670 struct as_list
*as_list
= output_arg
;
7672 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7675 if (type
== bgp_show_type_route_map
7676 || type
== bgp_show_type_flap_route_map
)
7678 struct route_map
*rmap
= output_arg
;
7679 struct bgp_info binfo
;
7680 struct attr dummy_attr
;
7681 struct attr_extra dummy_extra
;
7684 dummy_attr
.extra
= &dummy_extra
;
7685 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7687 binfo
.peer
= ri
->peer
;
7688 binfo
.attr
= &dummy_attr
;
7690 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7691 if (ret
== RMAP_DENYMATCH
)
7694 if (type
== bgp_show_type_neighbor
7695 || type
== bgp_show_type_flap_neighbor
7696 || type
== bgp_show_type_damp_neighbor
)
7698 union sockunion
*su
= output_arg
;
7700 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7703 if (type
== bgp_show_type_cidr_only
7704 || type
== bgp_show_type_flap_cidr_only
)
7706 u_int32_t destination
;
7708 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7709 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7711 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7713 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7716 if (type
== bgp_show_type_prefix_longer
7717 || type
== bgp_show_type_flap_prefix_longer
)
7719 struct prefix
*p
= output_arg
;
7721 if (! prefix_match (p
, &rn
->p
))
7724 if (type
== bgp_show_type_community_all
)
7726 if (! ri
->attr
->community
)
7729 if (type
== bgp_show_type_community
)
7731 struct community
*com
= output_arg
;
7733 if (! ri
->attr
->community
||
7734 ! community_match (ri
->attr
->community
, com
))
7737 if (type
== bgp_show_type_community_exact
)
7739 struct community
*com
= output_arg
;
7741 if (! ri
->attr
->community
||
7742 ! community_cmp (ri
->attr
->community
, com
))
7745 if (type
== bgp_show_type_community_list
)
7747 struct community_list
*list
= output_arg
;
7749 if (! community_list_match (ri
->attr
->community
, list
))
7752 if (type
== bgp_show_type_community_list_exact
)
7754 struct community_list
*list
= output_arg
;
7756 if (! community_list_exact_match (ri
->attr
->community
, list
))
7759 if (type
== bgp_show_type_flap_address
7760 || type
== bgp_show_type_flap_prefix
)
7762 struct prefix
*p
= output_arg
;
7764 if (! prefix_match (&rn
->p
, p
))
7767 if (type
== bgp_show_type_flap_prefix
)
7768 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7771 if (type
== bgp_show_type_dampend_paths
7772 || type
== bgp_show_type_damp_neighbor
)
7774 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7775 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7779 if (!use_json
&& header
)
7781 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (*router_id
), VTY_NEWLINE
);
7782 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7783 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7784 if (type
== bgp_show_type_dampend_paths
7785 || type
== bgp_show_type_damp_neighbor
)
7786 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7787 else if (type
== bgp_show_type_flap_statistics
7788 || type
== bgp_show_type_flap_address
7789 || type
== bgp_show_type_flap_prefix
7790 || type
== bgp_show_type_flap_cidr_only
7791 || type
== bgp_show_type_flap_regexp
7792 || type
== bgp_show_type_flap_filter_list
7793 || type
== bgp_show_type_flap_prefix_list
7794 || type
== bgp_show_type_flap_prefix_longer
7795 || type
== bgp_show_type_flap_route_map
7796 || type
== bgp_show_type_flap_neighbor
)
7797 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7799 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7803 if (type
== bgp_show_type_dampend_paths
7804 || type
== bgp_show_type_damp_neighbor
)
7805 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7806 else if (type
== bgp_show_type_flap_statistics
7807 || type
== bgp_show_type_flap_address
7808 || type
== bgp_show_type_flap_prefix
7809 || type
== bgp_show_type_flap_cidr_only
7810 || type
== bgp_show_type_flap_regexp
7811 || type
== bgp_show_type_flap_filter_list
7812 || type
== bgp_show_type_flap_prefix_list
7813 || type
== bgp_show_type_flap_prefix_longer
7814 || type
== bgp_show_type_flap_route_map
7815 || type
== bgp_show_type_flap_neighbor
)
7816 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7818 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7828 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7829 json_object_object_add(json_routes
, buf2
, json_paths
);
7836 /* This can produce a LOT of text so do not use
7837 * JSON_C_TO_STRING_PRETTY here
7839 json_object_object_add(json
, "routes", json_routes
);
7840 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
7841 json_object_free(json
);
7845 /* No route is displayed */
7846 if (output_count
== 0)
7848 if (type
== bgp_show_type_normal
)
7849 vty_out (vty
, "No BGP prefixes displayed, %ld exist%s", total_count
, VTY_NEWLINE
);
7852 vty_out (vty
, "%sDisplayed %ld out of %ld total prefixes%s",
7853 VTY_NEWLINE
, output_count
, total_count
, VTY_NEWLINE
);
7860 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7861 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7863 struct bgp_table
*table
;
7867 bgp
= bgp_get_default ();
7873 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7877 table
= bgp
->rib
[afi
][safi
];
7879 return bgp_show_table (vty
, table
, &bgp
->router_id
, type
, output_arg
,
7884 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7887 struct listnode
*node
, *nnode
;
7889 struct bgp_table
*table
;
7890 json_object
*json
= NULL
;
7894 vty_out (vty
, "{%s", VTY_NEWLINE
);
7896 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7900 if (!(json
= json_object_new_object()))
7902 zlog_err("Unable to allocate memory for JSON object");
7904 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
7908 json_object_int_add(json
, "vrfId",
7909 (bgp
->vrf_id
== VRF_UNKNOWN
)
7910 ? -1 : bgp
->vrf_id
);
7911 json_object_string_add(json
, "vrfName",
7912 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7913 ? "Default" : bgp
->name
);
7915 vty_out (vty
, ",%s", VTY_NEWLINE
);
7919 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7920 ? "Default" : bgp
->name
);
7924 vty_out (vty
, "%sInstance %s:%s",
7926 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7927 ? "Default" : bgp
->name
,
7930 table
= bgp
->rib
[afi
][safi
];
7931 bgp_show_table (vty
, table
, &bgp
->router_id
,
7932 bgp_show_type_normal
, NULL
, use_json
, json
);
7937 vty_out (vty
, "}%s", VTY_NEWLINE
);
7940 /* Header of detailed BGP route information */
7942 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7943 struct bgp_node
*rn
,
7944 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7947 struct bgp_info
*ri
;
7950 struct listnode
*node
, *nnode
;
7951 char buf1
[INET6_ADDRSTRLEN
];
7952 char buf2
[INET6_ADDRSTRLEN
];
7957 int no_advertise
= 0;
7960 json_object
*json_adv_to
= NULL
;
7966 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7967 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7971 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7972 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7973 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7974 safi
== SAFI_MPLS_VPN
? ":" : "",
7975 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7976 p
->prefixlen
, VTY_NEWLINE
);
7979 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7982 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7985 if (ri
->extra
&& ri
->extra
->suppress
)
7987 if (ri
->attr
->community
!= NULL
)
7989 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7991 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7993 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
8001 vty_out (vty
, "Paths: (%d available", count
);
8004 vty_out (vty
, ", best #%d", best
);
8005 if (safi
== SAFI_UNICAST
)
8006 vty_out (vty
, ", table %s",
8007 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8008 ? "Default-IP-Routing-Table" : bgp
->name
);
8011 vty_out (vty
, ", no best path");
8014 vty_out (vty
, ", not advertised to any peer");
8016 vty_out (vty
, ", not advertised to EBGP peer");
8018 vty_out (vty
, ", not advertised outside local AS");
8021 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
8022 vty_out (vty
, ")%s", VTY_NEWLINE
);
8025 /* If we are not using addpath then we can display Advertised to and that will
8026 * show what peers we advertised the bestpath to. If we are using addpath
8027 * though then we must display Advertised to on a path-by-path basis. */
8028 if (!bgp
->addpath_tx_used
[afi
][safi
])
8030 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
8032 if (bgp_adj_out_lookup (peer
, rn
, 0))
8034 if (json
&& !json_adv_to
)
8035 json_adv_to
= json_object_new_object();
8037 route_vty_out_advertised_to(vty
, peer
, &first
,
8038 " Advertised to non peer-group peers:\n ",
8047 json_object_object_add(json
, "advertisedTo", json_adv_to
);
8053 vty_out (vty
, " Not advertised to any peer");
8054 vty_out (vty
, "%s", VTY_NEWLINE
);
8059 /* Display specified route of BGP table. */
8061 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
8062 struct bgp_table
*rib
, const char *ip_str
,
8063 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8064 int prefix_check
, enum bgp_path_type pathtype
,
8070 struct prefix match
;
8071 struct bgp_node
*rn
;
8072 struct bgp_node
*rm
;
8073 struct bgp_info
*ri
;
8074 struct bgp_table
*table
;
8075 json_object
*json
= NULL
;
8076 json_object
*json_paths
= NULL
;
8078 /* Check IP address argument. */
8079 ret
= str2prefix (ip_str
, &match
);
8082 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
8086 match
.family
= afi2family (afi
);
8090 json
= json_object_new_object();
8091 json_paths
= json_object_new_array();
8094 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
8096 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
8098 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
8101 if ((table
= rn
->info
) != NULL
)
8105 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
8107 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
8109 bgp_unlock_node (rm
);
8113 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
8117 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
8118 AFI_IP
, safi
, json
);
8123 if (pathtype
== BGP_PATH_ALL
||
8124 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8125 (pathtype
== BGP_PATH_MULTIPATH
&&
8126 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8127 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
8130 bgp_unlock_node (rm
);
8139 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
8141 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
8143 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8147 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
8152 if (pathtype
== BGP_PATH_ALL
||
8153 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8154 (pathtype
== BGP_PATH_MULTIPATH
&&
8155 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8156 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
8160 bgp_unlock_node (rn
);
8167 json_object_object_add(json
, "paths", json_paths
);
8169 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
8170 json_object_free(json
);
8176 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
8184 /* Display specified route of Main RIB */
8186 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
8187 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8188 int prefix_check
, enum bgp_path_type pathtype
,
8193 /* BGP structure lookup. */
8196 bgp
= bgp_lookup_by_name (view_name
);
8199 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
8205 bgp
= bgp_get_default ();
8208 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8213 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
8214 afi
, safi
, prd
, prefix_check
, pathtype
,
8218 /* BGP route print out function. */
8221 "show ip bgp {json}",
8225 "JavaScript Object Notation\n")
8227 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8230 DEFUN (show_ip_bgp_ipv4
,
8231 show_ip_bgp_ipv4_cmd
,
8232 "show ip bgp ipv4 (unicast|multicast) {json}",
8237 "Address Family modifier\n"
8238 "Address Family modifier\n"
8239 "JavaScript Object Notation\n")
8241 u_char uj
= use_json(argc
, argv
);
8243 if (strncmp (argv
[0], "m", 1) == 0)
8244 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
, bgp_show_type_normal
,
8247 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8250 ALIAS (show_ip_bgp_ipv4
,
8251 show_bgp_ipv4_safi_cmd
,
8252 "show bgp ipv4 (unicast|multicast) {json}",
8256 "Address Family modifier\n"
8257 "Address Family modifier\n"
8258 "JavaScript Object Notation\n")
8260 DEFUN (show_ip_bgp_route
,
8261 show_ip_bgp_route_cmd
,
8262 "show ip bgp A.B.C.D {json}",
8266 "Network in the BGP routing table to display\n"
8267 "JavaScript Object Notation\n")
8269 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8272 DEFUN (show_ip_bgp_route_pathtype
,
8273 show_ip_bgp_route_pathtype_cmd
,
8274 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
8278 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8279 "Display only the bestpath\n"
8280 "Display only multipaths\n"
8281 "JavaScript Object Notation\n")
8283 u_char uj
= use_json(argc
, argv
);
8285 if (strncmp (argv
[1], "b", 1) == 0)
8286 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8288 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8291 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
8292 show_bgp_ipv4_safi_route_pathtype_cmd
,
8293 "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
8297 "Address Family modifier\n"
8298 "Address Family modifier\n"
8299 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8300 "Display only the bestpath\n"
8301 "Display only multipaths\n"
8302 "JavaScript Object Notation\n")
8304 u_char uj
= use_json(argc
, argv
);
8306 if (strncmp (argv
[0], "m", 1) == 0)
8307 if (strncmp (argv
[2], "b", 1) == 0)
8308 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8310 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8312 if (strncmp (argv
[2], "b", 1) == 0)
8313 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8315 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8318 DEFUN (show_bgp_ipv4_prefix
,
8319 show_bgp_ipv4_prefix_cmd
,
8320 "show bgp ipv4 A.B.C.D/M {json}",
8324 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8327 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8330 DEFUN (show_bgp_ipv6_route
,
8331 show_bgp_ipv6_route_cmd
,
8332 "show bgp ipv6 X:X::X:X {json}",
8336 "Network in the BGP routing table to display\n"
8339 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8342 DEFUN (show_bgp_ipv6_prefix
,
8343 show_bgp_ipv6_prefix_cmd
,
8344 "show bgp ipv6 X:X::X:X/M {json}",
8348 "IPv6 prefix <network>/<length>\n"
8351 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
,argv
));
8354 DEFUN (show_ip_bgp_ipv4_route
,
8355 show_ip_bgp_ipv4_route_cmd
,
8356 "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
8361 "Address Family modifier\n"
8362 "Address Family modifier\n"
8363 "Network in the BGP routing table to display\n"
8364 "JavaScript Object Notation\n")
8366 u_char uj
= use_json(argc
, argv
);
8368 if (strncmp (argv
[0], "m", 1) == 0)
8369 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8371 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8374 ALIAS (show_ip_bgp_ipv4_route
,
8375 show_bgp_ipv4_safi_route_cmd
,
8376 "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
8380 "Address Family modifier\n"
8381 "Address Family modifier\n"
8382 "Network in the BGP routing table to display\n"
8383 "JavaScript Object Notation\n")
8385 DEFUN (show_ip_bgp_vpnv4_all_route
,
8386 show_ip_bgp_vpnv4_all_route_cmd
,
8387 "show ip bgp vpnv4 all A.B.C.D {json}",
8391 "Display VPNv4 NLRI specific information\n"
8392 "Display information about all VPNv4 NLRIs\n"
8393 "Network in the BGP routing table to display\n"
8394 "JavaScript Object Notation\n")
8396 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8399 DEFUN (show_bgp_ipv4_vpn_route
,
8400 show_bgp_ipv4_vpn_route_cmd
,
8401 "show bgp ipv4 vpn A.B.C.D {json}",
8405 "Display VPN NLRI specific information\n"
8406 "Network in the BGP routing table to display\n"
8409 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8412 DEFUN (show_bgp_ipv6_vpn_route
,
8413 show_bgp_ipv6_vpn_route_cmd
,
8414 "show bgp ipv6 vpn X:X::X:X {json}",
8418 "Display VPN NLRI specific information\n"
8419 "Network in the BGP routing table to display\n"
8422 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MPLS_VPN
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8425 DEFUN (show_bgp_ipv4_vpn_rd_route
,
8426 show_bgp_ipv4_vpn_rd_route_cmd
,
8427 "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8431 "Display VPN NLRI specific information\n"
8432 "Display information for a route distinguisher\n"
8433 "VPN Route Distinguisher\n"
8434 "Network in the BGP routing table to display\n"
8438 struct prefix_rd prd
;
8440 ret
= str2prefix_rd (argv
[0], &prd
);
8443 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8446 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8449 DEFUN (show_bgp_ipv6_vpn_rd_route
,
8450 show_bgp_ipv6_vpn_rd_route_cmd
,
8451 "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
8455 "Display VPN NLRI specific information\n"
8456 "Display information for a route distinguisher\n"
8457 "VPN Route Distinguisher\n"
8458 "Network in the BGP routing table to display\n"
8462 struct prefix_rd prd
;
8464 ret
= str2prefix_rd (argv
[0], &prd
);
8467 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8470 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8473 DEFUN (show_ip_bgp_vpnv4_rd_route
,
8474 show_ip_bgp_vpnv4_rd_route_cmd
,
8475 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8479 "Display VPNv4 NLRI specific information\n"
8480 "Display information for a route distinguisher\n"
8481 "VPN Route Distinguisher\n"
8482 "Network in the BGP routing table to display\n"
8483 "JavaScript Object Notation\n")
8486 struct prefix_rd prd
;
8487 u_char uj
= use_json(argc
, argv
);
8489 ret
= str2prefix_rd (argv
[0], &prd
);
8492 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8495 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, uj
);
8498 DEFUN (show_ip_bgp_prefix
,
8499 show_ip_bgp_prefix_cmd
,
8500 "show ip bgp A.B.C.D/M {json}",
8504 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8505 "JavaScript Object Notation\n")
8507 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8510 DEFUN (show_ip_bgp_prefix_pathtype
,
8511 show_ip_bgp_prefix_pathtype_cmd
,
8512 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8516 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8517 "Display only the bestpath\n"
8518 "Display only multipaths\n"
8519 "JavaScript Object Notation\n")
8521 u_char uj
= use_json(argc
, argv
);
8522 if (strncmp (argv
[1], "b", 1) == 0)
8523 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8525 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8528 DEFUN (show_ip_bgp_ipv4_prefix
,
8529 show_ip_bgp_ipv4_prefix_cmd
,
8530 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8535 "Address Family modifier\n"
8536 "Address Family modifier\n"
8537 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8538 "JavaScript Object Notation\n")
8540 u_char uj
= use_json(argc
, argv
);
8542 if (strncmp (argv
[0], "m", 1) == 0)
8543 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8545 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8548 ALIAS (show_ip_bgp_ipv4_prefix
,
8549 show_bgp_ipv4_safi_prefix_cmd
,
8550 "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
8554 "Address Family modifier\n"
8555 "Address Family modifier\n"
8556 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8557 "JavaScript Object Notation\n")
8559 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8560 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8561 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8566 "Address Family modifier\n"
8567 "Address Family modifier\n"
8568 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8569 "Display only the bestpath\n"
8570 "Display only multipaths\n"
8571 "JavaScript Object Notation\n")
8573 u_char uj
= use_json(argc
, argv
);
8575 if (strncmp (argv
[0], "m", 1) == 0)
8576 if (strncmp (argv
[2], "b", 1) == 0)
8577 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8579 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8581 if (strncmp (argv
[2], "b", 1) == 0)
8582 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8584 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8587 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8588 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8589 "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
8593 "Address Family modifier\n"
8594 "Address Family modifier\n"
8595 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8596 "Display only the bestpath\n"
8597 "Display only multipaths\n"
8598 "JavaScript Object Notation\n")
8600 DEFUN (show_ip_bgp_vpnv4_all_prefix
,
8601 show_ip_bgp_vpnv4_all_prefix_cmd
,
8602 "show ip bgp vpnv4 all A.B.C.D/M {json}",
8606 "Display VPNv4 NLRI specific information\n"
8607 "Display information about all VPNv4 NLRIs\n"
8608 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8609 "JavaScript Object Notation\n")
8611 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_MPLS_VPN
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8614 DEFUN (show_ip_bgp_vpnv4_rd_prefix
,
8615 show_ip_bgp_vpnv4_rd_prefix_cmd
,
8616 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8620 "Display VPNv4 NLRI specific information\n"
8621 "Display information for a route distinguisher\n"
8622 "VPN Route Distinguisher\n"
8623 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8624 "JavaScript Object Notation\n")
8627 struct prefix_rd prd
;
8629 ret
= str2prefix_rd (argv
[0], &prd
);
8632 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8635 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MPLS_VPN
, &prd
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8638 DEFUN (show_ip_bgp_view
,
8639 show_ip_bgp_instance_cmd
,
8640 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8644 BGP_INSTANCE_HELP_STR
8645 "JavaScript Object Notation\n")
8649 /* BGP structure lookup. */
8650 bgp
= bgp_lookup_by_name (argv
[1]);
8653 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8657 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8660 DEFUN (show_ip_bgp_instance_all
,
8661 show_ip_bgp_instance_all_cmd
,
8662 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8666 BGP_INSTANCE_ALL_HELP_STR
8667 "JavaScript Object Notation\n")
8669 u_char uj
= use_json(argc
, argv
);
8671 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8675 DEFUN (show_ip_bgp_instance_route
,
8676 show_ip_bgp_instance_route_cmd
,
8677 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8681 BGP_INSTANCE_HELP_STR
8682 "Network in the BGP routing table to display\n"
8683 "JavaScript Object Notation\n")
8685 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8688 DEFUN (show_ip_bgp_instance_route_pathtype
,
8689 show_ip_bgp_instance_route_pathtype_cmd
,
8690 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8694 BGP_INSTANCE_HELP_STR
8695 "Network in the BGP routing table to display\n"
8696 "Display only the bestpath\n"
8697 "Display only multipaths\n"
8698 "JavaScript Object Notation\n")
8700 u_char uj
= use_json(argc
, argv
);
8702 if (strncmp (argv
[3], "b", 1) == 0)
8703 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8705 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8708 DEFUN (show_ip_bgp_instance_prefix
,
8709 show_ip_bgp_instance_prefix_cmd
,
8710 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8714 BGP_INSTANCE_HELP_STR
8715 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8716 "JavaScript Object Notation\n")
8718 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8721 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8722 show_ip_bgp_instance_prefix_pathtype_cmd
,
8723 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8727 BGP_INSTANCE_HELP_STR
8728 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8729 "Display only the bestpath\n"
8730 "Display only multipaths\n"
8731 "JavaScript Object Notation\n")
8733 u_char uj
= use_json(argc
, argv
);
8734 if (strncmp (argv
[3], "b", 1) == 0)
8735 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8737 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8746 "JavaScript Object Notation\n")
8748 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8749 NULL
, use_json(argc
, argv
));
8754 "show bgp ipv6 {json}",
8758 "JavaScript Object Notation\n")
8760 DEFUN (show_bgp_ipv6_safi
,
8761 show_bgp_ipv6_safi_cmd
,
8762 "show bgp ipv6 (unicast|multicast) {json}",
8766 "Address Family modifier\n"
8767 "Address Family modifier\n"
8768 "JavaScript Object Notation\n")
8770 u_char uj
= use_json(argc
, argv
);
8771 if (strncmp (argv
[0], "m", 1) == 0)
8772 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
8775 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, uj
);
8779 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8781 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8782 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8783 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8787 DEFUN (show_ipv6_bgp
,
8789 "show ipv6 bgp {json}",
8793 "JavaScript Object Notation\n")
8795 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8796 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8797 NULL
, use_json(argc
, argv
));
8800 DEFUN (show_bgp_route
,
8802 "show bgp X:X::X:X {json}",
8805 "Network in the BGP routing table to display\n"
8806 "JavaScript Object Notation\n")
8808 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8811 DEFUN (show_bgp_ipv6_safi_route
,
8812 show_bgp_ipv6_safi_route_cmd
,
8813 "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
8817 "Address Family modifier\n"
8818 "Address Family modifier\n"
8819 "Network in the BGP routing table to display\n"
8820 "JavaScript Object Notation\n")
8822 u_char uj
= use_json(argc
, argv
);
8823 if (strncmp (argv
[0], "m", 1) == 0)
8824 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8826 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, uj
);
8829 DEFUN (show_bgp_route_pathtype
,
8830 show_bgp_route_pathtype_cmd
,
8831 "show bgp X:X::X:X (bestpath|multipath) {json}",
8834 "Network in the BGP routing table to display\n"
8835 "Display only the bestpath\n"
8836 "Display only multipaths\n"
8837 "JavaScript Object Notation\n")
8839 u_char uj
= use_json(argc
, argv
);
8840 if (strncmp (argv
[1], "b", 1) == 0)
8841 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8843 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8846 ALIAS (show_bgp_route_pathtype
,
8847 show_bgp_ipv6_route_pathtype_cmd
,
8848 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8852 "Network in the BGP routing table to display\n"
8853 "Display only the bestpath\n"
8854 "Display only multipaths\n"
8855 "JavaScript Object Notation\n")
8857 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8858 show_bgp_ipv6_safi_route_pathtype_cmd
,
8859 "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
8863 "Address Family modifier\n"
8864 "Address Family modifier\n"
8865 "Network in the BGP routing table to display\n"
8866 "Display only the bestpath\n"
8867 "Display only multipaths\n"
8868 "JavaScript Object Notation\n")
8870 u_char uj
= use_json(argc
, argv
);
8871 if (strncmp (argv
[0], "m", 1) == 0)
8872 if (strncmp (argv
[2], "b", 1) == 0)
8873 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8875 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8877 if (strncmp (argv
[2], "b", 1) == 0)
8878 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8880 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8884 DEFUN (show_ipv6_bgp_route
,
8885 show_ipv6_bgp_route_cmd
,
8886 "show ipv6 bgp X:X::X:X {json}",
8890 "Network in the BGP routing table to display\n"
8891 "JavaScript Object Notation\n")
8893 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8894 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8897 DEFUN (show_bgp_prefix
,
8898 show_bgp_prefix_cmd
,
8899 "show bgp X:X::X:X/M {json}",
8902 "IPv6 prefix <network>/<length>\n"
8903 "JavaScript Object Notation\n")
8905 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8908 DEFUN (show_bgp_ipv6_safi_prefix
,
8909 show_bgp_ipv6_safi_prefix_cmd
,
8910 "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
8914 "Address Family modifier\n"
8915 "Address Family modifier\n"
8916 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8917 "JavaScript Object Notation\n")
8919 u_char uj
= use_json(argc
, argv
);
8920 if (strncmp (argv
[0], "m", 1) == 0)
8921 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8923 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, uj
);
8926 DEFUN (show_bgp_prefix_pathtype
,
8927 show_bgp_prefix_pathtype_cmd
,
8928 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8931 "IPv6 prefix <network>/<length>\n"
8932 "Display only the bestpath\n"
8933 "Display only multipaths\n"
8934 "JavaScript Object Notation\n")
8936 u_char uj
= use_json(argc
, argv
);
8937 if (strncmp (argv
[1], "b", 1) == 0)
8938 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8940 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8943 ALIAS (show_bgp_prefix_pathtype
,
8944 show_bgp_ipv6_prefix_pathtype_cmd
,
8945 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8949 "IPv6 prefix <network>/<length>\n"
8950 "Display only the bestpath\n"
8951 "Display only multipaths\n"
8952 "JavaScript Object Notation\n")
8954 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8955 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8956 "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
8960 "Address Family modifier\n"
8961 "Address Family modifier\n"
8962 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8963 "Display only the bestpath\n"
8964 "Display only multipaths\n"
8965 "JavaScript Object Notation\n")
8967 u_char uj
= use_json(argc
, argv
);
8968 if (strncmp (argv
[0], "m", 1) == 0)
8969 if (strncmp (argv
[2], "b", 1) == 0)
8970 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8972 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8974 if (strncmp (argv
[2], "b", 1) == 0)
8975 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8977 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8981 DEFUN (show_ipv6_bgp_prefix
,
8982 show_ipv6_bgp_prefix_cmd
,
8983 "show ipv6 bgp X:X::X:X/M {json}",
8987 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8988 "JavaScript Object Notation\n")
8990 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8991 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8994 DEFUN (show_bgp_view
,
8995 show_bgp_instance_cmd
,
8996 "show bgp " BGP_INSTANCE_CMD
" {json}",
8999 BGP_INSTANCE_HELP_STR
9000 "JavaScript Object Notation\n")
9004 /* BGP structure lookup. */
9005 bgp
= bgp_lookup_by_name (argv
[1]);
9008 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
9012 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
9015 DEFUN (show_bgp_instance_all
,
9016 show_bgp_instance_all_cmd
,
9017 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
9020 BGP_INSTANCE_ALL_HELP_STR
9021 "JavaScript Object Notation\n")
9023 u_char uj
= use_json(argc
, argv
);
9025 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
9029 ALIAS (show_bgp_view
,
9030 show_bgp_instance_ipv6_cmd
,
9031 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
9034 BGP_INSTANCE_HELP_STR
9036 "JavaScript Object Notation\n")
9038 DEFUN (show_bgp_instance_route
,
9039 show_bgp_instance_route_cmd
,
9040 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
9043 BGP_INSTANCE_HELP_STR
9044 "Network in the BGP routing table to display\n"
9045 "JavaScript Object Notation\n")
9047 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9050 ALIAS (show_bgp_instance_route
,
9051 show_bgp_instance_ipv6_route_cmd
,
9052 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
9055 BGP_INSTANCE_HELP_STR
9057 "Network in the BGP routing table to display\n"
9058 "JavaScript Object Notation\n")
9060 DEFUN (show_bgp_instance_route_pathtype
,
9061 show_bgp_instance_route_pathtype_cmd
,
9062 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
9065 BGP_INSTANCE_HELP_STR
9066 "Network in the BGP routing table to display\n"
9067 "Display only the bestpath\n"
9068 "Display only multipaths\n"
9069 "JavaScript Object Notation\n")
9071 u_char uj
= use_json(argc
, argv
);
9072 if (strncmp (argv
[3], "b", 1) == 0)
9073 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
9075 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
9078 ALIAS (show_bgp_instance_route_pathtype
,
9079 show_bgp_instance_ipv6_route_pathtype_cmd
,
9080 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
9083 BGP_INSTANCE_HELP_STR
9085 "Network in the BGP routing table to display\n"
9086 "Display only the bestpath\n"
9087 "Display only multipaths\n"
9088 "JavaScript Object Notation\n")
9090 DEFUN (show_bgp_instance_prefix
,
9091 show_bgp_instance_prefix_cmd
,
9092 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
9095 BGP_INSTANCE_HELP_STR
9096 "IPv6 prefix <network>/<length>\n"
9097 "JavaScript Object Notation\n")
9099 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9102 ALIAS (show_bgp_instance_prefix
,
9103 show_bgp_instance_ipv6_prefix_cmd
,
9104 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
9107 BGP_INSTANCE_HELP_STR
9109 "IPv6 prefix <network>/<length>\n"
9110 "JavaScript Object Notation\n")
9112 DEFUN (show_bgp_instance_prefix_pathtype
,
9113 show_bgp_instance_prefix_pathtype_cmd
,
9114 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
9117 BGP_INSTANCE_HELP_STR
9118 "IPv6 prefix <network>/<length>\n"
9119 "Display only the bestpath\n"
9120 "Display only multipaths\n"
9121 "JavaScript Object Notation\n")
9123 u_char uj
= use_json(argc
, argv
);
9124 if (strncmp (argv
[3], "b", 1) == 0)
9125 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
9127 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
9130 ALIAS (show_bgp_instance_prefix_pathtype
,
9131 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
9132 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
9135 BGP_INSTANCE_HELP_STR
9137 "IPv6 prefix <network>/<length>\n"
9138 "Display only the bestpath\n"
9139 "Display only multipaths\n"
9140 "JavaScript Object Notation\n")
9142 DEFUN (show_bgp_instance_prefix_list
,
9143 show_bgp_instance_prefix_list_cmd
,
9144 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9147 BGP_INSTANCE_HELP_STR
9148 "Display routes conforming to the prefix-list\n"
9149 "IPv6 prefix-list name\n")
9151 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9152 bgp_show_type_prefix_list
);
9155 ALIAS (show_bgp_instance_prefix_list
,
9156 show_bgp_instance_ipv6_prefix_list_cmd
,
9157 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
9160 BGP_INSTANCE_HELP_STR
9162 "Display routes conforming to the prefix-list\n"
9163 "IPv6 prefix-list name\n")
9165 DEFUN (show_bgp_instance_filter_list
,
9166 show_bgp_instance_filter_list_cmd
,
9167 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9170 BGP_INSTANCE_HELP_STR
9171 "Display routes conforming to the filter-list\n"
9172 "Regular expression access list name\n")
9174 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9175 bgp_show_type_filter_list
);
9178 ALIAS (show_bgp_instance_filter_list
,
9179 show_bgp_instance_ipv6_filter_list_cmd
,
9180 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
9183 BGP_INSTANCE_HELP_STR
9185 "Display routes conforming to the filter-list\n"
9186 "Regular expression access list name\n")
9188 DEFUN (show_bgp_instance_route_map
,
9189 show_bgp_instance_route_map_cmd
,
9190 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
9193 BGP_INSTANCE_HELP_STR
9194 "Display routes matching the route-map\n"
9195 "A route-map to match on\n")
9197 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9198 bgp_show_type_route_map
);
9201 ALIAS (show_bgp_instance_route_map
,
9202 show_bgp_instance_ipv6_route_map_cmd
,
9203 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
9206 BGP_INSTANCE_HELP_STR
9208 "Display routes matching the route-map\n"
9209 "A route-map to match on\n")
9211 DEFUN (show_bgp_instance_community_list
,
9212 show_bgp_instance_community_list_cmd
,
9213 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
9216 BGP_INSTANCE_HELP_STR
9217 "Display routes matching the community-list\n"
9218 "community-list number\n"
9219 "community-list name\n")
9221 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
9224 ALIAS (show_bgp_instance_community_list
,
9225 show_bgp_instance_ipv6_community_list_cmd
,
9226 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
9229 BGP_INSTANCE_HELP_STR
9231 "Display routes matching the community-list\n"
9232 "community-list number\n"
9233 "community-list name\n")
9235 DEFUN (show_bgp_instance_prefix_longer
,
9236 show_bgp_instance_prefix_longer_cmd
,
9237 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
9240 BGP_INSTANCE_HELP_STR
9241 "IPv6 prefix <network>/<length>\n"
9242 "Display route and more specific routes\n")
9244 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9245 bgp_show_type_prefix_longer
);
9248 ALIAS (show_bgp_instance_prefix_longer
,
9249 show_bgp_instance_ipv6_prefix_longer_cmd
,
9250 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
9253 BGP_INSTANCE_HELP_STR
9255 "IPv6 prefix <network>/<length>\n"
9256 "Display route and more specific routes\n")
9259 DEFUN (show_ipv6_mbgp
,
9261 "show ipv6 mbgp {json}",
9265 "JavaScript Object Notation\n")
9267 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9268 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
9269 NULL
, use_json(argc
, argv
));
9273 DEFUN (show_ipv6_mbgp_route
,
9274 show_ipv6_mbgp_route_cmd
,
9275 "show ipv6 mbgp X:X::X:X {json}",
9279 "Network in the MBGP routing table to display\n"
9280 "JavaScript Object Notation\n")
9282 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9283 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9287 DEFUN (show_ipv6_mbgp_prefix
,
9288 show_ipv6_mbgp_prefix_cmd
,
9289 "show ipv6 mbgp X:X::X:X/M {json}",
9293 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9294 "JavaScript Object Notation\n")
9296 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9297 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9303 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
9304 safi_t safi
, enum bgp_show_type type
)
9314 b
= buffer_new (1024);
9315 for (i
= 0; i
< argc
; i
++)
9318 buffer_putc (b
, ' ');
9321 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9326 buffer_putstr (b
, argv
[i
]);
9328 buffer_putc (b
, '\0');
9330 regstr
= buffer_getstr (b
);
9333 regex
= bgp_regcomp (regstr
);
9334 XFREE(MTYPE_TMP
, regstr
);
9337 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
9342 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
9343 bgp_regex_free (regex
);
9347 DEFUN (show_ip_bgp_regexp
,
9348 show_ip_bgp_regexp_cmd
,
9349 "show ip bgp regexp .LINE",
9353 "Display routes matching the AS path regular expression\n"
9354 "A regular-expression to match the BGP AS paths\n")
9356 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9357 bgp_show_type_regexp
);
9360 DEFUN (show_ip_bgp_flap_regexp
,
9361 show_ip_bgp_flap_regexp_cmd
,
9362 "show ip bgp flap-statistics regexp .LINE",
9366 "Display flap statistics of routes\n"
9367 "Display routes matching the AS path regular expression\n"
9368 "A regular-expression to match the BGP AS paths\n")
9370 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9371 bgp_show_type_flap_regexp
);
9374 ALIAS (show_ip_bgp_flap_regexp
,
9375 show_ip_bgp_damp_flap_regexp_cmd
,
9376 "show ip bgp dampening flap-statistics regexp .LINE",
9380 "Display detailed information about dampening\n"
9381 "Display flap statistics of routes\n"
9382 "Display routes matching the AS path regular expression\n"
9383 "A regular-expression to match the BGP AS paths\n")
9385 DEFUN (show_ip_bgp_ipv4_regexp
,
9386 show_ip_bgp_ipv4_regexp_cmd
,
9387 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
9392 "Address Family modifier\n"
9393 "Address Family modifier\n"
9394 "Display routes matching the AS path regular expression\n"
9395 "A regular-expression to match the BGP AS paths\n")
9397 if (strncmp (argv
[0], "m", 1) == 0)
9398 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_MULTICAST
,
9399 bgp_show_type_regexp
);
9401 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9402 bgp_show_type_regexp
);
9406 DEFUN (show_bgp_regexp
,
9407 show_bgp_regexp_cmd
,
9408 "show bgp regexp .LINE",
9411 "Display routes matching the AS path regular expression\n"
9412 "A regular-expression to match the BGP AS paths\n")
9414 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9415 bgp_show_type_regexp
);
9418 ALIAS (show_bgp_regexp
,
9419 show_bgp_ipv6_regexp_cmd
,
9420 "show bgp ipv6 regexp .LINE",
9424 "Display routes matching the AS path regular expression\n"
9425 "A regular-expression to match the BGP AS paths\n")
9428 DEFUN (show_ipv6_bgp_regexp
,
9429 show_ipv6_bgp_regexp_cmd
,
9430 "show ipv6 bgp regexp .LINE",
9434 "Display routes matching the AS path regular expression\n"
9435 "A regular-expression to match the BGP AS paths\n")
9437 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9438 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9439 bgp_show_type_regexp
);
9443 DEFUN (show_ipv6_mbgp_regexp
,
9444 show_ipv6_mbgp_regexp_cmd
,
9445 "show ipv6 mbgp regexp .LINE",
9449 "Display routes matching the AS path regular expression\n"
9450 "A regular-expression to match the MBGP AS paths\n")
9452 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9453 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9454 bgp_show_type_regexp
);
9456 #endif /* HAVE_IPV6 */
9459 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9460 const char *prefix_list_str
, afi_t afi
,
9461 safi_t safi
, enum bgp_show_type type
)
9463 struct prefix_list
*plist
;
9464 struct bgp
*bgp
= NULL
;
9466 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9468 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9472 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9475 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9476 prefix_list_str
, VTY_NEWLINE
);
9480 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9483 DEFUN (show_ip_bgp_prefix_list
,
9484 show_ip_bgp_prefix_list_cmd
,
9485 "show ip bgp prefix-list WORD",
9489 "Display routes conforming to the prefix-list\n"
9490 "IP prefix-list name\n")
9492 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9493 bgp_show_type_prefix_list
);
9496 DEFUN (show_ip_bgp_instance_prefix_list
,
9497 show_ip_bgp_instance_prefix_list_cmd
,
9498 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9502 BGP_INSTANCE_HELP_STR
9503 "Display routes conforming to the prefix-list\n"
9504 "IP prefix-list name\n")
9506 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9507 bgp_show_type_prefix_list
);
9510 DEFUN (show_ip_bgp_flap_prefix_list
,
9511 show_ip_bgp_flap_prefix_list_cmd
,
9512 "show ip bgp flap-statistics prefix-list WORD",
9516 "Display flap statistics of routes\n"
9517 "Display routes conforming to the prefix-list\n"
9518 "IP prefix-list name\n")
9520 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9521 bgp_show_type_flap_prefix_list
);
9524 ALIAS (show_ip_bgp_flap_prefix_list
,
9525 show_ip_bgp_damp_flap_prefix_list_cmd
,
9526 "show ip bgp dampening flap-statistics prefix-list WORD",
9530 "Display detailed information about dampening\n"
9531 "Display flap statistics of routes\n"
9532 "Display routes conforming to the prefix-list\n"
9533 "IP prefix-list name\n")
9535 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9536 show_ip_bgp_ipv4_prefix_list_cmd
,
9537 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
9542 "Address Family modifier\n"
9543 "Address Family modifier\n"
9544 "Display routes conforming to the prefix-list\n"
9545 "IP prefix-list name\n")
9547 if (strncmp (argv
[0], "m", 1) == 0)
9548 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9549 bgp_show_type_prefix_list
);
9551 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9552 bgp_show_type_prefix_list
);
9556 DEFUN (show_bgp_prefix_list
,
9557 show_bgp_prefix_list_cmd
,
9558 "show bgp prefix-list WORD",
9561 "Display routes conforming to the prefix-list\n"
9562 "IPv6 prefix-list name\n")
9564 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9565 bgp_show_type_prefix_list
);
9568 ALIAS (show_bgp_prefix_list
,
9569 show_bgp_ipv6_prefix_list_cmd
,
9570 "show bgp ipv6 prefix-list WORD",
9574 "Display routes conforming to the prefix-list\n"
9575 "IPv6 prefix-list name\n")
9578 DEFUN (show_ipv6_bgp_prefix_list
,
9579 show_ipv6_bgp_prefix_list_cmd
,
9580 "show ipv6 bgp prefix-list WORD",
9584 "Display routes matching the prefix-list\n"
9585 "IPv6 prefix-list name\n")
9587 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9588 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9589 bgp_show_type_prefix_list
);
9593 DEFUN (show_ipv6_mbgp_prefix_list
,
9594 show_ipv6_mbgp_prefix_list_cmd
,
9595 "show ipv6 mbgp prefix-list WORD",
9599 "Display routes matching the prefix-list\n"
9600 "IPv6 prefix-list name\n")
9602 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9603 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9604 bgp_show_type_prefix_list
);
9606 #endif /* HAVE_IPV6 */
9609 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9610 const char *filter
, afi_t afi
,
9611 safi_t safi
, enum bgp_show_type type
)
9613 struct as_list
*as_list
;
9614 struct bgp
*bgp
= NULL
;
9616 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9618 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9622 as_list
= as_list_lookup (filter
);
9623 if (as_list
== NULL
)
9625 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9629 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9632 DEFUN (show_ip_bgp_filter_list
,
9633 show_ip_bgp_filter_list_cmd
,
9634 "show ip bgp filter-list WORD",
9638 "Display routes conforming to the filter-list\n"
9639 "Regular expression access list name\n")
9641 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9642 bgp_show_type_filter_list
);
9645 DEFUN (show_ip_bgp_instance_filter_list
,
9646 show_ip_bgp_instance_filter_list_cmd
,
9647 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9651 BGP_INSTANCE_HELP_STR
9652 "Display routes conforming to the filter-list\n"
9653 "Regular expression access list name\n")
9655 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9656 bgp_show_type_filter_list
);
9659 DEFUN (show_ip_bgp_flap_filter_list
,
9660 show_ip_bgp_flap_filter_list_cmd
,
9661 "show ip bgp flap-statistics filter-list WORD",
9665 "Display flap statistics of routes\n"
9666 "Display routes conforming to the filter-list\n"
9667 "Regular expression access list name\n")
9669 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9670 bgp_show_type_flap_filter_list
);
9673 ALIAS (show_ip_bgp_flap_filter_list
,
9674 show_ip_bgp_damp_flap_filter_list_cmd
,
9675 "show ip bgp dampening flap-statistics filter-list WORD",
9679 "Display detailed information about dampening\n"
9680 "Display flap statistics of routes\n"
9681 "Display routes conforming to the filter-list\n"
9682 "Regular expression access list name\n")
9684 DEFUN (show_ip_bgp_ipv4_filter_list
,
9685 show_ip_bgp_ipv4_filter_list_cmd
,
9686 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9691 "Address Family modifier\n"
9692 "Address Family modifier\n"
9693 "Display routes conforming to the filter-list\n"
9694 "Regular expression access list name\n")
9696 if (strncmp (argv
[0], "m", 1) == 0)
9697 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9698 bgp_show_type_filter_list
);
9700 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9701 bgp_show_type_filter_list
);
9705 DEFUN (show_bgp_filter_list
,
9706 show_bgp_filter_list_cmd
,
9707 "show bgp filter-list WORD",
9710 "Display routes conforming to the filter-list\n"
9711 "Regular expression access list name\n")
9713 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9714 bgp_show_type_filter_list
);
9717 ALIAS (show_bgp_filter_list
,
9718 show_bgp_ipv6_filter_list_cmd
,
9719 "show bgp ipv6 filter-list WORD",
9723 "Display routes conforming to the filter-list\n"
9724 "Regular expression access list name\n")
9727 DEFUN (show_ipv6_bgp_filter_list
,
9728 show_ipv6_bgp_filter_list_cmd
,
9729 "show ipv6 bgp filter-list WORD",
9733 "Display routes conforming to the filter-list\n"
9734 "Regular expression access list name\n")
9736 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9737 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9738 bgp_show_type_filter_list
);
9742 DEFUN (show_ipv6_mbgp_filter_list
,
9743 show_ipv6_mbgp_filter_list_cmd
,
9744 "show ipv6 mbgp filter-list WORD",
9748 "Display routes conforming to the filter-list\n"
9749 "Regular expression access list name\n")
9751 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9752 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9753 bgp_show_type_filter_list
);
9755 #endif /* HAVE_IPV6 */
9757 DEFUN (show_ip_bgp_dampening_info
,
9758 show_ip_bgp_dampening_params_cmd
,
9759 "show ip bgp dampening parameters",
9763 "Display detailed information about dampening\n"
9764 "Display detail of configured dampening parameters\n")
9766 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9770 DEFUN (show_ip_bgp_ipv4_dampening_parameters
,
9771 show_ip_bgp_ipv4_dampening_parameters_cmd
,
9772 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
9777 "Address Family modifier\n"
9778 "Address Family modifier\n"
9779 "Display detailed information about dampening\n"
9780 "Display detail of configured dampening parameters\n")
9782 if (strncmp(argv
[0], "m", 1) == 0)
9783 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_MULTICAST
);
9785 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9789 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats
,
9790 show_ip_bgp_ipv4_dampening_flap_stats_cmd
,
9791 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
9796 "Address Family modifier\n"
9797 "Address Family modifier\n"
9798 "Display detailed information about dampening\n"
9799 "Display flap statistics of routes\n")
9801 if (strncmp(argv
[0], "m", 1) == 0)
9802 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9803 bgp_show_type_flap_statistics
, NULL
, 0);
9805 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9806 bgp_show_type_flap_statistics
, NULL
, 0);
9809 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths
,
9810 show_ip_bgp_ipv4_dampening_dampd_paths_cmd
,
9811 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
9816 "Address Family modifier\n"
9817 "Address Family modifier\n"
9818 "Display detailed information about dampening\n"
9819 "Display paths suppressed due to dampening\n")
9821 if (strncmp(argv
[0], "m", 1) == 0)
9822 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9823 bgp_show_type_dampend_paths
, NULL
, 0);
9825 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9826 bgp_show_type_dampend_paths
, NULL
, 0);
9830 bgp_show_route_map (struct vty
*vty
, const char *name
,
9831 const char *rmap_str
, afi_t afi
,
9832 safi_t safi
, enum bgp_show_type type
)
9834 struct route_map
*rmap
;
9835 struct bgp
*bgp
= NULL
;
9837 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9839 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9843 rmap
= route_map_lookup_by_name (rmap_str
);
9846 vty_out (vty
, "%% %s is not a valid route-map name%s",
9847 rmap_str
, VTY_NEWLINE
);
9851 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9854 DEFUN (show_ip_bgp_route_map
,
9855 show_ip_bgp_route_map_cmd
,
9856 "show ip bgp route-map WORD",
9860 "Display routes matching the route-map\n"
9861 "A route-map to match on\n")
9863 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9864 bgp_show_type_route_map
);
9867 DEFUN (show_ip_bgp_instance_route_map
,
9868 show_ip_bgp_instance_route_map_cmd
,
9869 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9873 BGP_INSTANCE_HELP_STR
9874 "Display routes matching the route-map\n"
9875 "A route-map to match on\n")
9877 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9878 bgp_show_type_route_map
);
9881 DEFUN (show_ip_bgp_flap_route_map
,
9882 show_ip_bgp_flap_route_map_cmd
,
9883 "show ip bgp flap-statistics route-map WORD",
9887 "Display flap statistics of routes\n"
9888 "Display routes matching the route-map\n"
9889 "A route-map to match on\n")
9891 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9892 bgp_show_type_flap_route_map
);
9895 ALIAS (show_ip_bgp_flap_route_map
,
9896 show_ip_bgp_damp_flap_route_map_cmd
,
9897 "show ip bgp dampening flap-statistics route-map WORD",
9901 "Display detailed information about dampening\n"
9902 "Display flap statistics of routes\n"
9903 "Display routes matching the route-map\n"
9904 "A route-map to match on\n")
9906 DEFUN (show_ip_bgp_ipv4_route_map
,
9907 show_ip_bgp_ipv4_route_map_cmd
,
9908 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9913 "Address Family modifier\n"
9914 "Address Family modifier\n"
9915 "Display routes matching the route-map\n"
9916 "A route-map to match on\n")
9918 if (strncmp (argv
[0], "m", 1) == 0)
9919 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
9920 bgp_show_type_route_map
);
9922 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
9923 bgp_show_type_route_map
);
9926 DEFUN (show_bgp_route_map
,
9927 show_bgp_route_map_cmd
,
9928 "show bgp route-map WORD",
9931 "Display routes matching the route-map\n"
9932 "A route-map to match on\n")
9934 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9935 bgp_show_type_route_map
);
9938 ALIAS (show_bgp_route_map
,
9939 show_bgp_ipv6_route_map_cmd
,
9940 "show bgp ipv6 route-map WORD",
9944 "Display routes matching the route-map\n"
9945 "A route-map to match on\n")
9947 DEFUN (show_ip_bgp_cidr_only
,
9948 show_ip_bgp_cidr_only_cmd
,
9949 "show ip bgp cidr-only",
9953 "Display only routes with non-natural netmasks\n")
9955 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9956 bgp_show_type_cidr_only
, NULL
, 0);
9959 DEFUN (show_ip_bgp_flap_cidr_only
,
9960 show_ip_bgp_flap_cidr_only_cmd
,
9961 "show ip bgp flap-statistics cidr-only",
9965 "Display flap statistics of routes\n"
9966 "Display only routes with non-natural netmasks\n")
9968 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9969 bgp_show_type_flap_cidr_only
, NULL
, 0);
9972 ALIAS (show_ip_bgp_flap_cidr_only
,
9973 show_ip_bgp_damp_flap_cidr_only_cmd
,
9974 "show ip bgp dampening flap-statistics cidr-only",
9978 "Display detailed information about dampening\n"
9979 "Display flap statistics of routes\n"
9980 "Display only routes with non-natural netmasks\n")
9982 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9983 show_ip_bgp_ipv4_cidr_only_cmd
,
9984 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9989 "Address Family modifier\n"
9990 "Address Family modifier\n"
9991 "Display only routes with non-natural netmasks\n")
9993 if (strncmp (argv
[0], "m", 1) == 0)
9994 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
9995 bgp_show_type_cidr_only
, NULL
, 0);
9997 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9998 bgp_show_type_cidr_only
, NULL
, 0);
10001 DEFUN (show_ip_bgp_community_all
,
10002 show_ip_bgp_community_all_cmd
,
10003 "show ip bgp community",
10007 "Display routes matching the communities\n")
10009 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10010 bgp_show_type_community_all
, NULL
, 0);
10013 DEFUN (show_ip_bgp_ipv4_community_all
,
10014 show_ip_bgp_ipv4_community_all_cmd
,
10015 "show ip bgp ipv4 (unicast|multicast) community",
10020 "Address Family modifier\n"
10021 "Address Family modifier\n"
10022 "Display routes matching the communities\n")
10024 if (strncmp (argv
[0], "m", 1) == 0)
10025 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_MULTICAST
,
10026 bgp_show_type_community_all
, NULL
, 0);
10028 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
10029 bgp_show_type_community_all
, NULL
, 0);
10033 DEFUN (show_bgp_community_all
,
10034 show_bgp_community_all_cmd
,
10035 "show bgp community",
10038 "Display routes matching the communities\n")
10040 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10041 bgp_show_type_community_all
, NULL
, 0);
10044 ALIAS (show_bgp_community_all
,
10045 show_bgp_ipv6_community_all_cmd
,
10046 "show bgp ipv6 community",
10050 "Display routes matching the communities\n")
10053 DEFUN (show_ipv6_bgp_community_all
,
10054 show_ipv6_bgp_community_all_cmd
,
10055 "show ipv6 bgp community",
10059 "Display routes matching the communities\n")
10061 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10062 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
10063 bgp_show_type_community_all
, NULL
, 0);
10067 DEFUN (show_ipv6_mbgp_community_all
,
10068 show_ipv6_mbgp_community_all_cmd
,
10069 "show ipv6 mbgp community",
10073 "Display routes matching the communities\n")
10075 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10076 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
10077 bgp_show_type_community_all
, NULL
, 0);
10079 #endif /* HAVE_IPV6 */
10082 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
10083 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
10085 struct community
*com
;
10092 /* BGP structure lookup */
10095 bgp
= bgp_lookup_by_name (view_name
);
10098 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
10099 return CMD_WARNING
;
10104 bgp
= bgp_get_default ();
10107 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10108 return CMD_WARNING
;
10112 b
= buffer_new (1024);
10113 for (i
= 0; i
< argc
; i
++)
10116 buffer_putc (b
, ' ');
10119 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
10124 buffer_putstr (b
, argv
[i
]);
10126 buffer_putc (b
, '\0');
10128 str
= buffer_getstr (b
);
10131 com
= community_str2com (str
);
10132 XFREE (MTYPE_TMP
, str
);
10135 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
10136 return CMD_WARNING
;
10139 return bgp_show (vty
, bgp
, afi
, safi
,
10140 (exact
? bgp_show_type_community_exact
:
10141 bgp_show_type_community
), com
, 0);
10144 DEFUN (show_ip_bgp_community
,
10145 show_ip_bgp_community_cmd
,
10146 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
10150 "Display routes matching the communities\n"
10152 "Do not send outside local AS (well-known community)\n"
10153 "Do not advertise to any peer (well-known community)\n"
10154 "Do not export to next AS (well-known community)\n")
10156 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
10159 ALIAS (show_ip_bgp_community
,
10160 show_ip_bgp_community2_cmd
,
10161 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10165 "Display routes matching the communities\n"
10167 "Do not send outside local AS (well-known community)\n"
10168 "Do not advertise to any peer (well-known community)\n"
10169 "Do not export to next AS (well-known community)\n"
10171 "Do not send outside local AS (well-known community)\n"
10172 "Do not advertise to any peer (well-known community)\n"
10173 "Do not export to next AS (well-known community)\n")
10175 ALIAS (show_ip_bgp_community
,
10176 show_ip_bgp_community3_cmd
,
10177 "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)",
10181 "Display routes matching the communities\n"
10183 "Do not send outside local AS (well-known community)\n"
10184 "Do not advertise to any peer (well-known community)\n"
10185 "Do not export to next AS (well-known community)\n"
10187 "Do not send outside local AS (well-known community)\n"
10188 "Do not advertise to any peer (well-known community)\n"
10189 "Do not export to next AS (well-known community)\n"
10191 "Do not send outside local AS (well-known community)\n"
10192 "Do not advertise to any peer (well-known community)\n"
10193 "Do not export to next AS (well-known community)\n")
10195 ALIAS (show_ip_bgp_community
,
10196 show_ip_bgp_community4_cmd
,
10197 "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)",
10201 "Display routes matching the communities\n"
10203 "Do not send outside local AS (well-known community)\n"
10204 "Do not advertise to any peer (well-known community)\n"
10205 "Do not export to next AS (well-known community)\n"
10207 "Do not send outside local AS (well-known community)\n"
10208 "Do not advertise to any peer (well-known community)\n"
10209 "Do not export to next AS (well-known community)\n"
10211 "Do not send outside local AS (well-known community)\n"
10212 "Do not advertise to any peer (well-known community)\n"
10213 "Do not export to next AS (well-known community)\n"
10215 "Do not send outside local AS (well-known community)\n"
10216 "Do not advertise to any peer (well-known community)\n"
10217 "Do not export to next AS (well-known community)\n")
10219 DEFUN (show_ip_bgp_ipv4_community
,
10220 show_ip_bgp_ipv4_community_cmd
,
10221 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10226 "Address Family modifier\n"
10227 "Address Family modifier\n"
10228 "Display routes matching the communities\n"
10230 "Do not send outside local AS (well-known community)\n"
10231 "Do not advertise to any peer (well-known community)\n"
10232 "Do not export to next AS (well-known community)\n")
10234 if (strncmp (argv
[0], "m", 1) == 0)
10235 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_MULTICAST
);
10237 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
10240 ALIAS (show_ip_bgp_ipv4_community
,
10241 show_ip_bgp_ipv4_community2_cmd
,
10242 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10247 "Address Family modifier\n"
10248 "Address Family modifier\n"
10249 "Display routes matching the communities\n"
10251 "Do not send outside local AS (well-known community)\n"
10252 "Do not advertise to any peer (well-known community)\n"
10253 "Do not export to next AS (well-known community)\n"
10255 "Do not send outside local AS (well-known community)\n"
10256 "Do not advertise to any peer (well-known community)\n"
10257 "Do not export to next AS (well-known community)\n")
10259 ALIAS (show_ip_bgp_ipv4_community
,
10260 show_ip_bgp_ipv4_community3_cmd
,
10261 "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)",
10266 "Address Family modifier\n"
10267 "Address Family modifier\n"
10268 "Display routes matching the communities\n"
10270 "Do not send outside local AS (well-known community)\n"
10271 "Do not advertise to any peer (well-known community)\n"
10272 "Do not export to next AS (well-known community)\n"
10274 "Do not send outside local AS (well-known community)\n"
10275 "Do not advertise to any peer (well-known community)\n"
10276 "Do not export to next AS (well-known community)\n"
10278 "Do not send outside local AS (well-known community)\n"
10279 "Do not advertise to any peer (well-known community)\n"
10280 "Do not export to next AS (well-known community)\n")
10282 ALIAS (show_ip_bgp_ipv4_community
,
10283 show_ip_bgp_ipv4_community4_cmd
,
10284 "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)",
10289 "Address Family modifier\n"
10290 "Address Family modifier\n"
10291 "Display routes matching the communities\n"
10293 "Do not send outside local AS (well-known community)\n"
10294 "Do not advertise to any peer (well-known community)\n"
10295 "Do not export to next AS (well-known community)\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 DEFUN (show_bgp_instance_afi_safi_community_all
,
10310 show_bgp_instance_afi_safi_community_all_cmd
,
10311 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
10314 BGP_INSTANCE_HELP_STR
10317 "Address Family modifier\n"
10318 "Address Family modifier\n"
10319 "Display routes matching the communities\n")
10325 /* BGP structure lookup. */
10326 bgp
= bgp_lookup_by_name (argv
[1]);
10329 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
10330 return CMD_WARNING
;
10333 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10334 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10335 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
10338 DEFUN (show_bgp_instance_afi_safi_community
,
10339 show_bgp_instance_afi_safi_community_cmd
,
10340 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10343 BGP_INSTANCE_HELP_STR
10346 "Address family modifier\n"
10347 "Address family modifier\n"
10348 "Display routes matching the communities\n"
10350 "Do not send outside local AS (well-known community)\n"
10351 "Do not advertise to any peer (well-known community)\n"
10352 "Do not export to next AS (well-known community)\n")
10357 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
10358 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
10359 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
10362 ALIAS (show_bgp_instance_afi_safi_community
,
10363 show_bgp_instance_afi_safi_community2_cmd
,
10364 "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)",
10367 BGP_INSTANCE_HELP_STR
10370 "Address family modifier\n"
10371 "Address family modifier\n"
10372 "Display routes matching the communities\n"
10374 "Do not send outside local AS (well-known community)\n"
10375 "Do not advertise to any peer (well-known community)\n"
10376 "Do not export to next AS (well-known community)\n"
10378 "Do not send outside local AS (well-known community)\n"
10379 "Do not advertise to any peer (well-known community)\n"
10380 "Do not export to next AS (well-known community)\n")
10382 ALIAS (show_bgp_instance_afi_safi_community
,
10383 show_bgp_instance_afi_safi_community3_cmd
,
10384 "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)",
10387 BGP_INSTANCE_HELP_STR
10390 "Address family modifier\n"
10391 "Address family modifier\n"
10392 "Display routes matching the communities\n"
10394 "Do not send outside local AS (well-known community)\n"
10395 "Do not advertise to any peer (well-known community)\n"
10396 "Do not export to next AS (well-known community)\n"
10398 "Do not send outside local AS (well-known community)\n"
10399 "Do not advertise to any peer (well-known community)\n"
10400 "Do not export to next AS (well-known community)\n"
10402 "Do not send outside local AS (well-known community)\n"
10403 "Do not advertise to any peer (well-known community)\n"
10404 "Do not export to next AS (well-known community)\n")
10406 ALIAS (show_bgp_instance_afi_safi_community
,
10407 show_bgp_instance_afi_safi_community4_cmd
,
10408 "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)",
10411 BGP_INSTANCE_HELP_STR
10414 "Address family modifier\n"
10415 "Address family modifier\n"
10416 "Display routes matching the communities\n"
10418 "Do not send outside local AS (well-known community)\n"
10419 "Do not advertise to any peer (well-known community)\n"
10420 "Do not export to next AS (well-known community)\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 DEFUN (show_ip_bgp_community_exact
,
10435 show_ip_bgp_community_exact_cmd
,
10436 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10440 "Display routes matching the communities\n"
10442 "Do not send outside local AS (well-known community)\n"
10443 "Do not advertise to any peer (well-known community)\n"
10444 "Do not export to next AS (well-known community)\n"
10445 "Exact match of the communities")
10447 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10450 ALIAS (show_ip_bgp_community_exact
,
10451 show_ip_bgp_community2_exact_cmd
,
10452 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10456 "Display routes matching the communities\n"
10458 "Do not send outside local AS (well-known community)\n"
10459 "Do not advertise to any peer (well-known community)\n"
10460 "Do not export to next AS (well-known community)\n"
10462 "Do not send outside local AS (well-known community)\n"
10463 "Do not advertise to any peer (well-known community)\n"
10464 "Do not export to next AS (well-known community)\n"
10465 "Exact match of the communities")
10467 ALIAS (show_ip_bgp_community_exact
,
10468 show_ip_bgp_community3_exact_cmd
,
10469 "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",
10473 "Display routes matching the communities\n"
10475 "Do not send outside local AS (well-known community)\n"
10476 "Do not advertise to any peer (well-known community)\n"
10477 "Do not export to next AS (well-known community)\n"
10479 "Do not send outside local AS (well-known community)\n"
10480 "Do not advertise to any peer (well-known community)\n"
10481 "Do not export to next AS (well-known community)\n"
10483 "Do not send outside local AS (well-known community)\n"
10484 "Do not advertise to any peer (well-known community)\n"
10485 "Do not export to next AS (well-known community)\n"
10486 "Exact match of the communities")
10488 ALIAS (show_ip_bgp_community_exact
,
10489 show_ip_bgp_community4_exact_cmd
,
10490 "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",
10494 "Display routes matching the communities\n"
10496 "Do not send outside local AS (well-known community)\n"
10497 "Do not advertise to any peer (well-known community)\n"
10498 "Do not export to next AS (well-known community)\n"
10500 "Do not send outside local AS (well-known community)\n"
10501 "Do not advertise to any peer (well-known community)\n"
10502 "Do not export to next AS (well-known community)\n"
10504 "Do not send outside local AS (well-known community)\n"
10505 "Do not advertise to any peer (well-known community)\n"
10506 "Do not export to next AS (well-known community)\n"
10508 "Do not send outside local AS (well-known community)\n"
10509 "Do not advertise to any peer (well-known community)\n"
10510 "Do not export to next AS (well-known community)\n"
10511 "Exact match of the communities")
10513 DEFUN (show_ip_bgp_ipv4_community_exact
,
10514 show_ip_bgp_ipv4_community_exact_cmd
,
10515 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10520 "Address Family modifier\n"
10521 "Address Family modifier\n"
10522 "Display routes matching the communities\n"
10524 "Do not send outside local AS (well-known community)\n"
10525 "Do not advertise to any peer (well-known community)\n"
10526 "Do not export to next AS (well-known community)\n"
10527 "Exact match of the communities")
10529 if (strncmp (argv
[0], "m", 1) == 0)
10530 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_MULTICAST
);
10532 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10535 ALIAS (show_ip_bgp_ipv4_community_exact
,
10536 show_ip_bgp_ipv4_community2_exact_cmd
,
10537 "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",
10542 "Address Family modifier\n"
10543 "Address Family modifier\n"
10544 "Display routes matching the communities\n"
10546 "Do not send outside local AS (well-known community)\n"
10547 "Do not advertise to any peer (well-known community)\n"
10548 "Do not export to next AS (well-known community)\n"
10550 "Do not send outside local AS (well-known community)\n"
10551 "Do not advertise to any peer (well-known community)\n"
10552 "Do not export to next AS (well-known community)\n"
10553 "Exact match of the communities")
10555 ALIAS (show_ip_bgp_ipv4_community_exact
,
10556 show_ip_bgp_ipv4_community3_exact_cmd
,
10557 "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",
10562 "Address Family modifier\n"
10563 "Address Family modifier\n"
10564 "Display routes matching the communities\n"
10566 "Do not send outside local AS (well-known community)\n"
10567 "Do not advertise to any peer (well-known community)\n"
10568 "Do not export to next AS (well-known community)\n"
10570 "Do not send outside local AS (well-known community)\n"
10571 "Do not advertise to any peer (well-known community)\n"
10572 "Do not export to next AS (well-known community)\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"
10577 "Exact match of the communities")
10579 ALIAS (show_ip_bgp_ipv4_community_exact
,
10580 show_ip_bgp_ipv4_community4_exact_cmd
,
10581 "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",
10586 "Address Family modifier\n"
10587 "Address Family modifier\n"
10588 "Display routes matching the communities\n"
10590 "Do not send outside local AS (well-known community)\n"
10591 "Do not advertise to any peer (well-known community)\n"
10592 "Do not export to next AS (well-known community)\n"
10594 "Do not send outside local AS (well-known community)\n"
10595 "Do not advertise to any peer (well-known community)\n"
10596 "Do not export to next AS (well-known community)\n"
10598 "Do not send outside local AS (well-known community)\n"
10599 "Do not advertise to any peer (well-known community)\n"
10600 "Do not export to next AS (well-known community)\n"
10602 "Do not send outside local AS (well-known community)\n"
10603 "Do not advertise to any peer (well-known community)\n"
10604 "Do not export to next AS (well-known community)\n"
10605 "Exact match of the communities")
10608 DEFUN (show_bgp_community
,
10609 show_bgp_community_cmd
,
10610 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10613 "Display routes matching the communities\n"
10615 "Do not send outside local AS (well-known community)\n"
10616 "Do not advertise to any peer (well-known community)\n"
10617 "Do not export to next AS (well-known community)\n")
10619 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10622 ALIAS (show_bgp_community
,
10623 show_bgp_ipv6_community_cmd
,
10624 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10628 "Display routes matching the communities\n"
10630 "Do not send outside local AS (well-known community)\n"
10631 "Do not advertise to any peer (well-known community)\n"
10632 "Do not export to next AS (well-known community)\n")
10634 ALIAS (show_bgp_community
,
10635 show_bgp_community2_cmd
,
10636 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10639 "Display routes matching the communities\n"
10641 "Do not send outside local AS (well-known community)\n"
10642 "Do not advertise to any peer (well-known community)\n"
10643 "Do not export to next AS (well-known community)\n"
10645 "Do not send outside local AS (well-known community)\n"
10646 "Do not advertise to any peer (well-known community)\n"
10647 "Do not export to next AS (well-known community)\n")
10649 ALIAS (show_bgp_community
,
10650 show_bgp_ipv6_community2_cmd
,
10651 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10655 "Display routes matching the communities\n"
10657 "Do not send outside local AS (well-known community)\n"
10658 "Do not advertise to any peer (well-known community)\n"
10659 "Do not export to next AS (well-known community)\n"
10661 "Do not send outside local AS (well-known community)\n"
10662 "Do not advertise to any peer (well-known community)\n"
10663 "Do not export to next AS (well-known community)\n")
10665 ALIAS (show_bgp_community
,
10666 show_bgp_community3_cmd
,
10667 "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)",
10670 "Display routes matching the communities\n"
10672 "Do not send outside local AS (well-known community)\n"
10673 "Do not advertise to any peer (well-known community)\n"
10674 "Do not export to next AS (well-known community)\n"
10676 "Do not send outside local AS (well-known community)\n"
10677 "Do not advertise to any peer (well-known community)\n"
10678 "Do not export to next AS (well-known community)\n"
10680 "Do not send outside local AS (well-known community)\n"
10681 "Do not advertise to any peer (well-known community)\n"
10682 "Do not export to next AS (well-known community)\n")
10684 ALIAS (show_bgp_community
,
10685 show_bgp_ipv6_community3_cmd
,
10686 "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)",
10690 "Display routes matching the communities\n"
10692 "Do not send outside local AS (well-known community)\n"
10693 "Do not advertise to any peer (well-known community)\n"
10694 "Do not export to next AS (well-known community)\n"
10696 "Do not send outside local AS (well-known community)\n"
10697 "Do not advertise to any peer (well-known community)\n"
10698 "Do not export to next AS (well-known community)\n"
10700 "Do not send outside local AS (well-known community)\n"
10701 "Do not advertise to any peer (well-known community)\n"
10702 "Do not export to next AS (well-known community)\n")
10704 ALIAS (show_bgp_community
,
10705 show_bgp_community4_cmd
,
10706 "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)",
10709 "Display routes matching the communities\n"
10711 "Do not send outside local AS (well-known community)\n"
10712 "Do not advertise to any peer (well-known community)\n"
10713 "Do not export to next AS (well-known community)\n"
10715 "Do not send outside local AS (well-known community)\n"
10716 "Do not advertise to any peer (well-known community)\n"
10717 "Do not export to next AS (well-known community)\n"
10719 "Do not send outside local AS (well-known community)\n"
10720 "Do not advertise to any peer (well-known community)\n"
10721 "Do not export to next AS (well-known community)\n"
10723 "Do not send outside local AS (well-known community)\n"
10724 "Do not advertise to any peer (well-known community)\n"
10725 "Do not export to next AS (well-known community)\n")
10727 ALIAS (show_bgp_community
,
10728 show_bgp_ipv6_community4_cmd
,
10729 "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)",
10733 "Display routes matching the communities\n"
10735 "Do not send outside local AS (well-known community)\n"
10736 "Do not advertise to any peer (well-known community)\n"
10737 "Do not export to next AS (well-known community)\n"
10739 "Do not send outside local AS (well-known community)\n"
10740 "Do not advertise to any peer (well-known community)\n"
10741 "Do not export to next AS (well-known community)\n"
10743 "Do not send outside local AS (well-known community)\n"
10744 "Do not advertise to any peer (well-known community)\n"
10745 "Do not export to next AS (well-known community)\n"
10747 "Do not send outside local AS (well-known community)\n"
10748 "Do not advertise to any peer (well-known community)\n"
10749 "Do not export to next AS (well-known community)\n")
10752 DEFUN (show_ipv6_bgp_community
,
10753 show_ipv6_bgp_community_cmd
,
10754 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10758 "Display routes matching the communities\n"
10760 "Do not send outside local AS (well-known community)\n"
10761 "Do not advertise to any peer (well-known community)\n"
10762 "Do not export to next AS (well-known community)\n")
10764 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10765 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10769 ALIAS (show_ipv6_bgp_community
,
10770 show_ipv6_bgp_community2_cmd
,
10771 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10775 "Display routes matching the communities\n"
10777 "Do not send outside local AS (well-known community)\n"
10778 "Do not advertise to any peer (well-known community)\n"
10779 "Do not export to next AS (well-known community)\n"
10781 "Do not send outside local AS (well-known community)\n"
10782 "Do not advertise to any peer (well-known community)\n"
10783 "Do not export to next AS (well-known community)\n")
10786 ALIAS (show_ipv6_bgp_community
,
10787 show_ipv6_bgp_community3_cmd
,
10788 "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)",
10792 "Display routes matching the communities\n"
10794 "Do not send outside local AS (well-known community)\n"
10795 "Do not advertise to any peer (well-known community)\n"
10796 "Do not export to next AS (well-known community)\n"
10798 "Do not send outside local AS (well-known community)\n"
10799 "Do not advertise to any peer (well-known community)\n"
10800 "Do not export to next AS (well-known community)\n"
10802 "Do not send outside local AS (well-known community)\n"
10803 "Do not advertise to any peer (well-known community)\n"
10804 "Do not export to next AS (well-known community)\n")
10807 ALIAS (show_ipv6_bgp_community
,
10808 show_ipv6_bgp_community4_cmd
,
10809 "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)",
10813 "Display routes matching the communities\n"
10815 "Do not send outside local AS (well-known community)\n"
10816 "Do not advertise to any peer (well-known community)\n"
10817 "Do not export to next AS (well-known community)\n"
10819 "Do not send outside local AS (well-known community)\n"
10820 "Do not advertise to any peer (well-known community)\n"
10821 "Do not export to next AS (well-known community)\n"
10823 "Do not send outside local AS (well-known community)\n"
10824 "Do not advertise to any peer (well-known community)\n"
10825 "Do not export to next AS (well-known community)\n"
10827 "Do not send outside local AS (well-known community)\n"
10828 "Do not advertise to any peer (well-known community)\n"
10829 "Do not export to next AS (well-known community)\n")
10831 DEFUN (show_bgp_community_exact
,
10832 show_bgp_community_exact_cmd
,
10833 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10836 "Display routes matching the communities\n"
10838 "Do not send outside local AS (well-known community)\n"
10839 "Do not advertise to any peer (well-known community)\n"
10840 "Do not export to next AS (well-known community)\n"
10841 "Exact match of the communities")
10843 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10846 ALIAS (show_bgp_community_exact
,
10847 show_bgp_ipv6_community_exact_cmd
,
10848 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10852 "Display routes matching the communities\n"
10854 "Do not send outside local AS (well-known community)\n"
10855 "Do not advertise to any peer (well-known community)\n"
10856 "Do not export to next AS (well-known community)\n"
10857 "Exact match of the communities")
10859 ALIAS (show_bgp_community_exact
,
10860 show_bgp_community2_exact_cmd
,
10861 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10864 "Display routes matching the communities\n"
10866 "Do not send outside local AS (well-known community)\n"
10867 "Do not advertise to any peer (well-known community)\n"
10868 "Do not export to next AS (well-known community)\n"
10870 "Do not send outside local AS (well-known community)\n"
10871 "Do not advertise to any peer (well-known community)\n"
10872 "Do not export to next AS (well-known community)\n"
10873 "Exact match of the communities")
10875 ALIAS (show_bgp_community_exact
,
10876 show_bgp_ipv6_community2_exact_cmd
,
10877 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10881 "Display routes matching the communities\n"
10883 "Do not send outside local AS (well-known community)\n"
10884 "Do not advertise to any peer (well-known community)\n"
10885 "Do not export to next AS (well-known community)\n"
10887 "Do not send outside local AS (well-known community)\n"
10888 "Do not advertise to any peer (well-known community)\n"
10889 "Do not export to next AS (well-known community)\n"
10890 "Exact match of the communities")
10892 ALIAS (show_bgp_community_exact
,
10893 show_bgp_community3_exact_cmd
,
10894 "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",
10897 "Display routes matching the communities\n"
10899 "Do not send outside local AS (well-known community)\n"
10900 "Do not advertise to any peer (well-known community)\n"
10901 "Do not export to next AS (well-known community)\n"
10903 "Do not send outside local AS (well-known community)\n"
10904 "Do not advertise to any peer (well-known community)\n"
10905 "Do not export to next AS (well-known community)\n"
10907 "Do not send outside local AS (well-known community)\n"
10908 "Do not advertise to any peer (well-known community)\n"
10909 "Do not export to next AS (well-known community)\n"
10910 "Exact match of the communities")
10912 ALIAS (show_bgp_community_exact
,
10913 show_bgp_ipv6_community3_exact_cmd
,
10914 "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",
10918 "Display routes matching the communities\n"
10920 "Do not send outside local AS (well-known community)\n"
10921 "Do not advertise to any peer (well-known community)\n"
10922 "Do not export to next AS (well-known community)\n"
10924 "Do not send outside local AS (well-known community)\n"
10925 "Do not advertise to any peer (well-known community)\n"
10926 "Do not export to next AS (well-known community)\n"
10928 "Do not send outside local AS (well-known community)\n"
10929 "Do not advertise to any peer (well-known community)\n"
10930 "Do not export to next AS (well-known community)\n"
10931 "Exact match of the communities")
10933 ALIAS (show_bgp_community_exact
,
10934 show_bgp_community4_exact_cmd
,
10935 "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",
10938 "Display routes matching the communities\n"
10940 "Do not send outside local AS (well-known community)\n"
10941 "Do not advertise to any peer (well-known community)\n"
10942 "Do not export to next AS (well-known community)\n"
10944 "Do not send outside local AS (well-known community)\n"
10945 "Do not advertise to any peer (well-known community)\n"
10946 "Do not export to next AS (well-known community)\n"
10948 "Do not send outside local AS (well-known community)\n"
10949 "Do not advertise to any peer (well-known community)\n"
10950 "Do not export to next AS (well-known community)\n"
10952 "Do not send outside local AS (well-known community)\n"
10953 "Do not advertise to any peer (well-known community)\n"
10954 "Do not export to next AS (well-known community)\n"
10955 "Exact match of the communities")
10957 ALIAS (show_bgp_community_exact
,
10958 show_bgp_ipv6_community4_exact_cmd
,
10959 "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",
10963 "Display routes matching the communities\n"
10965 "Do not send outside local AS (well-known community)\n"
10966 "Do not advertise to any peer (well-known community)\n"
10967 "Do not export to next AS (well-known community)\n"
10969 "Do not send outside local AS (well-known community)\n"
10970 "Do not advertise to any peer (well-known community)\n"
10971 "Do not export to next AS (well-known community)\n"
10973 "Do not send outside local AS (well-known community)\n"
10974 "Do not advertise to any peer (well-known community)\n"
10975 "Do not export to next AS (well-known community)\n"
10977 "Do not send outside local AS (well-known community)\n"
10978 "Do not advertise to any peer (well-known community)\n"
10979 "Do not export to next AS (well-known community)\n"
10980 "Exact match of the communities")
10983 DEFUN (show_ipv6_bgp_community_exact
,
10984 show_ipv6_bgp_community_exact_cmd
,
10985 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10989 "Display routes matching the communities\n"
10991 "Do not send outside local AS (well-known community)\n"
10992 "Do not advertise to any peer (well-known community)\n"
10993 "Do not export to next AS (well-known community)\n"
10994 "Exact match of the communities")
10996 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10997 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
11001 ALIAS (show_ipv6_bgp_community_exact
,
11002 show_ipv6_bgp_community2_exact_cmd
,
11003 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11007 "Display routes matching the communities\n"
11009 "Do not send outside local AS (well-known community)\n"
11010 "Do not advertise to any peer (well-known community)\n"
11011 "Do not export to next AS (well-known community)\n"
11013 "Do not send outside local AS (well-known community)\n"
11014 "Do not advertise to any peer (well-known community)\n"
11015 "Do not export to next AS (well-known community)\n"
11016 "Exact match of the communities")
11019 ALIAS (show_ipv6_bgp_community_exact
,
11020 show_ipv6_bgp_community3_exact_cmd
,
11021 "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",
11025 "Display routes matching the communities\n"
11027 "Do not send outside local AS (well-known community)\n"
11028 "Do not advertise to any peer (well-known community)\n"
11029 "Do not export to next AS (well-known community)\n"
11031 "Do not send outside local AS (well-known community)\n"
11032 "Do not advertise to any peer (well-known community)\n"
11033 "Do not export to next AS (well-known community)\n"
11035 "Do not send outside local AS (well-known community)\n"
11036 "Do not advertise to any peer (well-known community)\n"
11037 "Do not export to next AS (well-known community)\n"
11038 "Exact match of the communities")
11041 ALIAS (show_ipv6_bgp_community_exact
,
11042 show_ipv6_bgp_community4_exact_cmd
,
11043 "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",
11047 "Display routes matching the communities\n"
11049 "Do not send outside local AS (well-known community)\n"
11050 "Do not advertise to any peer (well-known community)\n"
11051 "Do not export to next AS (well-known community)\n"
11053 "Do not send outside local AS (well-known community)\n"
11054 "Do not advertise to any peer (well-known community)\n"
11055 "Do not export to next AS (well-known community)\n"
11057 "Do not send outside local AS (well-known community)\n"
11058 "Do not advertise to any peer (well-known community)\n"
11059 "Do not export to next AS (well-known community)\n"
11061 "Do not send outside local AS (well-known community)\n"
11062 "Do not advertise to any peer (well-known community)\n"
11063 "Do not export to next AS (well-known community)\n"
11064 "Exact match of the communities")
11067 DEFUN (show_ipv6_mbgp_community
,
11068 show_ipv6_mbgp_community_cmd
,
11069 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
11073 "Display routes matching the communities\n"
11075 "Do not send outside local AS (well-known community)\n"
11076 "Do not advertise to any peer (well-known community)\n"
11077 "Do not export to next AS (well-known community)\n")
11079 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11080 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
11084 ALIAS (show_ipv6_mbgp_community
,
11085 show_ipv6_mbgp_community2_cmd
,
11086 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
11090 "Display routes matching the communities\n"
11092 "Do not send outside local AS (well-known community)\n"
11093 "Do not advertise to any peer (well-known community)\n"
11094 "Do not export to next AS (well-known community)\n"
11096 "Do not send outside local AS (well-known community)\n"
11097 "Do not advertise to any peer (well-known community)\n"
11098 "Do not export to next AS (well-known community)\n")
11101 ALIAS (show_ipv6_mbgp_community
,
11102 show_ipv6_mbgp_community3_cmd
,
11103 "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)",
11107 "Display routes matching the communities\n"
11109 "Do not send outside local AS (well-known community)\n"
11110 "Do not advertise to any peer (well-known community)\n"
11111 "Do not export to next AS (well-known community)\n"
11113 "Do not send outside local AS (well-known community)\n"
11114 "Do not advertise to any peer (well-known community)\n"
11115 "Do not export to next AS (well-known community)\n"
11117 "Do not send outside local AS (well-known community)\n"
11118 "Do not advertise to any peer (well-known community)\n"
11119 "Do not export to next AS (well-known community)\n")
11122 ALIAS (show_ipv6_mbgp_community
,
11123 show_ipv6_mbgp_community4_cmd
,
11124 "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)",
11128 "Display routes matching the communities\n"
11130 "Do not send outside local AS (well-known community)\n"
11131 "Do not advertise to any peer (well-known community)\n"
11132 "Do not export to next AS (well-known community)\n"
11134 "Do not send outside local AS (well-known community)\n"
11135 "Do not advertise to any peer (well-known community)\n"
11136 "Do not export to next AS (well-known community)\n"
11138 "Do not send outside local AS (well-known community)\n"
11139 "Do not advertise to any peer (well-known community)\n"
11140 "Do not export to next AS (well-known community)\n"
11142 "Do not send outside local AS (well-known community)\n"
11143 "Do not advertise to any peer (well-known community)\n"
11144 "Do not export to next AS (well-known community)\n")
11147 DEFUN (show_ipv6_mbgp_community_exact
,
11148 show_ipv6_mbgp_community_exact_cmd
,
11149 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
11153 "Display routes matching the communities\n"
11155 "Do not send outside local AS (well-known community)\n"
11156 "Do not advertise to any peer (well-known community)\n"
11157 "Do not export to next AS (well-known community)\n"
11158 "Exact match of the communities")
11160 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11161 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
11165 ALIAS (show_ipv6_mbgp_community_exact
,
11166 show_ipv6_mbgp_community2_exact_cmd
,
11167 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11171 "Display routes matching the communities\n"
11173 "Do not send outside local AS (well-known community)\n"
11174 "Do not advertise to any peer (well-known community)\n"
11175 "Do not export to next AS (well-known community)\n"
11177 "Do not send outside local AS (well-known community)\n"
11178 "Do not advertise to any peer (well-known community)\n"
11179 "Do not export to next AS (well-known community)\n"
11180 "Exact match of the communities")
11183 ALIAS (show_ipv6_mbgp_community_exact
,
11184 show_ipv6_mbgp_community3_exact_cmd
,
11185 "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",
11189 "Display routes matching the communities\n"
11191 "Do not send outside local AS (well-known community)\n"
11192 "Do not advertise to any peer (well-known community)\n"
11193 "Do not export to next AS (well-known community)\n"
11195 "Do not send outside local AS (well-known community)\n"
11196 "Do not advertise to any peer (well-known community)\n"
11197 "Do not export to next AS (well-known community)\n"
11199 "Do not send outside local AS (well-known community)\n"
11200 "Do not advertise to any peer (well-known community)\n"
11201 "Do not export to next AS (well-known community)\n"
11202 "Exact match of the communities")
11205 ALIAS (show_ipv6_mbgp_community_exact
,
11206 show_ipv6_mbgp_community4_exact_cmd
,
11207 "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",
11211 "Display routes matching the communities\n"
11213 "Do not send outside local AS (well-known community)\n"
11214 "Do not advertise to any peer (well-known community)\n"
11215 "Do not export to next AS (well-known community)\n"
11217 "Do not send outside local AS (well-known community)\n"
11218 "Do not advertise to any peer (well-known community)\n"
11219 "Do not export to next AS (well-known community)\n"
11221 "Do not send outside local AS (well-known community)\n"
11222 "Do not advertise to any peer (well-known community)\n"
11223 "Do not export to next AS (well-known community)\n"
11225 "Do not send outside local AS (well-known community)\n"
11226 "Do not advertise to any peer (well-known community)\n"
11227 "Do not export to next AS (well-known community)\n"
11228 "Exact match of the communities")
11229 #endif /* HAVE_IPV6 */
11232 bgp_show_community_list (struct vty
*vty
, const char *name
,
11233 const char *com
, int exact
,
11234 afi_t afi
, safi_t safi
)
11236 struct community_list
*list
;
11237 struct bgp
*bgp
= NULL
;
11239 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11241 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11242 return CMD_WARNING
;
11245 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
11248 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
11250 return CMD_WARNING
;
11253 return bgp_show (vty
, bgp
, afi
, safi
,
11254 (exact
? bgp_show_type_community_list_exact
:
11255 bgp_show_type_community_list
), list
, 0);
11258 DEFUN (show_ip_bgp_community_list
,
11259 show_ip_bgp_community_list_cmd
,
11260 "show ip bgp community-list (<1-500>|WORD)",
11264 "Display routes matching the community-list\n"
11265 "community-list number\n"
11266 "community-list name\n")
11268 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
11271 DEFUN (show_ip_bgp_instance_community_list
,
11272 show_ip_bgp_instance_community_list_cmd
,
11273 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
11277 BGP_INSTANCE_HELP_STR
11278 "Display routes matching the community-list\n"
11279 "community-list number\n"
11280 "community-list name\n")
11282 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
11285 DEFUN (show_ip_bgp_ipv4_community_list
,
11286 show_ip_bgp_ipv4_community_list_cmd
,
11287 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11292 "Address Family modifier\n"
11293 "Address Family modifier\n"
11294 "Display routes matching the community-list\n"
11295 "community-list number\n"
11296 "community-list name\n")
11298 if (strncmp (argv
[0], "m", 1) == 0)
11299 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_MULTICAST
);
11301 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, SAFI_UNICAST
);
11304 DEFUN (show_ip_bgp_community_list_exact
,
11305 show_ip_bgp_community_list_exact_cmd
,
11306 "show ip bgp community-list (<1-500>|WORD) exact-match",
11310 "Display routes matching the community-list\n"
11311 "community-list number\n"
11312 "community-list name\n"
11313 "Exact match of the communities\n")
11315 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
11318 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
11319 show_ip_bgp_ipv4_community_list_exact_cmd
,
11320 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11325 "Address Family modifier\n"
11326 "Address Family modifier\n"
11327 "Display routes matching the community-list\n"
11328 "community-list number\n"
11329 "community-list name\n"
11330 "Exact match of the communities\n")
11332 if (strncmp (argv
[0], "m", 1) == 0)
11333 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_MULTICAST
);
11335 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, SAFI_UNICAST
);
11339 DEFUN (show_bgp_community_list
,
11340 show_bgp_community_list_cmd
,
11341 "show bgp community-list (<1-500>|WORD)",
11344 "Display routes matching the community-list\n"
11345 "community-list number\n"
11346 "community-list name\n")
11348 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11351 ALIAS (show_bgp_community_list
,
11352 show_bgp_ipv6_community_list_cmd
,
11353 "show bgp ipv6 community-list (<1-500>|WORD)",
11357 "Display routes matching the community-list\n"
11358 "community-list number\n"
11359 "community-list name\n")
11362 DEFUN (show_ipv6_bgp_community_list
,
11363 show_ipv6_bgp_community_list_cmd
,
11364 "show ipv6 bgp community-list WORD",
11368 "Display routes matching the community-list\n"
11369 "community-list name\n")
11371 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11372 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11376 DEFUN (show_ipv6_mbgp_community_list
,
11377 show_ipv6_mbgp_community_list_cmd
,
11378 "show ipv6 mbgp community-list WORD",
11382 "Display routes matching the community-list\n"
11383 "community-list name\n")
11385 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11386 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
11389 DEFUN (show_bgp_community_list_exact
,
11390 show_bgp_community_list_exact_cmd
,
11391 "show bgp community-list (<1-500>|WORD) exact-match",
11394 "Display routes matching the community-list\n"
11395 "community-list number\n"
11396 "community-list name\n"
11397 "Exact match of the communities\n")
11399 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11402 ALIAS (show_bgp_community_list_exact
,
11403 show_bgp_ipv6_community_list_exact_cmd
,
11404 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11408 "Display routes matching the community-list\n"
11409 "community-list number\n"
11410 "community-list name\n"
11411 "Exact match of the communities\n")
11414 DEFUN (show_ipv6_bgp_community_list_exact
,
11415 show_ipv6_bgp_community_list_exact_cmd
,
11416 "show ipv6 bgp community-list WORD exact-match",
11420 "Display routes matching the community-list\n"
11421 "community-list name\n"
11422 "Exact match of the communities\n")
11424 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11425 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11429 DEFUN (show_ipv6_mbgp_community_list_exact
,
11430 show_ipv6_mbgp_community_list_exact_cmd
,
11431 "show ipv6 mbgp community-list WORD exact-match",
11435 "Display routes matching the community-list\n"
11436 "community-list name\n"
11437 "Exact match of the communities\n")
11439 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11440 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
11442 #endif /* HAVE_IPV6 */
11445 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11446 const char *prefix
, afi_t afi
,
11447 safi_t safi
, enum bgp_show_type type
)
11451 struct bgp
*bgp
= NULL
;
11453 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11455 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11456 return CMD_WARNING
;
11461 ret
= str2prefix (prefix
, p
);
11464 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11465 return CMD_WARNING
;
11468 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11473 DEFUN (show_ip_bgp_prefix_longer
,
11474 show_ip_bgp_prefix_longer_cmd
,
11475 "show ip bgp A.B.C.D/M longer-prefixes",
11479 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11480 "Display route and more specific routes\n")
11482 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11483 bgp_show_type_prefix_longer
);
11486 DEFUN (show_ip_bgp_instance_prefix_longer
,
11487 show_ip_bgp_instance_prefix_longer_cmd
,
11488 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11492 BGP_INSTANCE_HELP_STR
11493 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11494 "Display route and more specific routes\n")
11496 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
11497 bgp_show_type_prefix_longer
);
11500 DEFUN (show_ip_bgp_flap_prefix_longer
,
11501 show_ip_bgp_flap_prefix_longer_cmd
,
11502 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11506 "Display flap statistics of routes\n"
11507 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11508 "Display route and more specific routes\n")
11510 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11511 bgp_show_type_flap_prefix_longer
);
11514 ALIAS (show_ip_bgp_flap_prefix_longer
,
11515 show_ip_bgp_damp_flap_prefix_longer_cmd
,
11516 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11520 "Display detailed information about dampening\n"
11521 "Display flap statistics of routes\n"
11522 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11523 "Display route and more specific routes\n")
11525 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11526 show_ip_bgp_ipv4_prefix_longer_cmd
,
11527 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11532 "Address Family modifier\n"
11533 "Address Family modifier\n"
11534 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11535 "Display route and more specific routes\n")
11537 if (strncmp (argv
[0], "m", 1) == 0)
11538 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_MULTICAST
,
11539 bgp_show_type_prefix_longer
);
11541 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, SAFI_UNICAST
,
11542 bgp_show_type_prefix_longer
);
11545 DEFUN (show_ip_bgp_flap_address
,
11546 show_ip_bgp_flap_address_cmd
,
11547 "show ip bgp flap-statistics A.B.C.D",
11551 "Display flap statistics of routes\n"
11552 "Network in the BGP routing table to display\n")
11554 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11555 bgp_show_type_flap_address
);
11558 ALIAS (show_ip_bgp_flap_address
,
11559 show_ip_bgp_damp_flap_address_cmd
,
11560 "show ip bgp dampening flap-statistics A.B.C.D",
11564 "Display detailed information about dampening\n"
11565 "Display flap statistics of routes\n"
11566 "Network in the BGP routing table to display\n")
11568 DEFUN (show_ip_bgp_flap_prefix
,
11569 show_ip_bgp_flap_prefix_cmd
,
11570 "show ip bgp flap-statistics A.B.C.D/M",
11574 "Display flap statistics of routes\n"
11575 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11577 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11578 bgp_show_type_flap_prefix
);
11581 ALIAS (show_ip_bgp_flap_prefix
,
11582 show_ip_bgp_damp_flap_prefix_cmd
,
11583 "show ip bgp dampening flap-statistics A.B.C.D/M",
11587 "Display detailed information about dampening\n"
11588 "Display flap statistics of routes\n"
11589 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11592 DEFUN (show_bgp_prefix_longer
,
11593 show_bgp_prefix_longer_cmd
,
11594 "show bgp X:X::X:X/M longer-prefixes",
11597 "IPv6 prefix <network>/<length>\n"
11598 "Display route and more specific routes\n")
11600 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11601 bgp_show_type_prefix_longer
);
11604 ALIAS (show_bgp_prefix_longer
,
11605 show_bgp_ipv6_prefix_longer_cmd
,
11606 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11610 "IPv6 prefix <network>/<length>\n"
11611 "Display route and more specific routes\n")
11614 DEFUN (show_ipv6_bgp_prefix_longer
,
11615 show_ipv6_bgp_prefix_longer_cmd
,
11616 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11620 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11621 "Display route and more specific routes\n")
11623 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11624 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11625 bgp_show_type_prefix_longer
);
11629 DEFUN (show_ipv6_mbgp_prefix_longer
,
11630 show_ipv6_mbgp_prefix_longer_cmd
,
11631 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11635 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11636 "Display route and more specific routes\n")
11638 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11639 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11640 bgp_show_type_prefix_longer
);
11642 #endif /* HAVE_IPV6 */
11644 static struct peer
*
11645 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11646 const char *ip_str
, u_char use_json
)
11651 union sockunion su
;
11653 /* BGP structure lookup. */
11656 bgp
= bgp_lookup_by_name (view_name
);
11661 json_object
*json_no
= NULL
;
11662 json_no
= json_object_new_object();
11663 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11664 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11665 json_object_free(json_no
);
11668 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11674 bgp
= bgp_get_default ();
11679 json_object
*json_no
= NULL
;
11680 json_no
= json_object_new_object();
11681 json_object_string_add(json_no
, "warning", "No BGP process configured");
11682 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11683 json_object_free(json_no
);
11686 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11691 /* Get peer sockunion. */
11692 ret
= str2sockunion (ip_str
, &su
);
11695 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11698 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11704 json_object
*json_no
= NULL
;
11705 json_no
= json_object_new_object();
11706 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11707 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11708 json_object_free(json_no
);
11711 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11718 /* Peer structure lookup. */
11719 peer
= peer_lookup (bgp
, &su
);
11724 json_object
*json_no
= NULL
;
11725 json_no
= json_object_new_object();
11726 json_object_string_add(json_no
, "warning","No such neighbor");
11727 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11728 json_object_free(json_no
);
11731 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11740 BGP_STATS_MAXBITLEN
= 0,
11742 BGP_STATS_PREFIXES
,
11744 BGP_STATS_UNAGGREGATEABLE
,
11745 BGP_STATS_MAX_AGGREGATEABLE
,
11746 BGP_STATS_AGGREGATES
,
11748 BGP_STATS_ASPATH_COUNT
,
11749 BGP_STATS_ASPATH_MAXHOPS
,
11750 BGP_STATS_ASPATH_TOTHOPS
,
11751 BGP_STATS_ASPATH_MAXSIZE
,
11752 BGP_STATS_ASPATH_TOTSIZE
,
11753 BGP_STATS_ASN_HIGHEST
,
11757 static const char *table_stats_strs
[] =
11759 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11760 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11761 [BGP_STATS_RIB
] = "Total Advertisements",
11762 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11763 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11764 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11765 [BGP_STATS_SPACE
] = "Address space advertised",
11766 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11767 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11768 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11769 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11770 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11771 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11772 [BGP_STATS_MAX
] = NULL
,
11775 struct bgp_table_stats
11777 struct bgp_table
*table
;
11778 unsigned long long counts
[BGP_STATS_MAX
];
11782 #define TALLY_SIGFIG 100000
11783 static unsigned long
11784 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11786 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11787 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11788 unsigned long ret
= newtot
/ count
;
11790 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11798 bgp_table_stats_walker (struct thread
*t
)
11800 struct bgp_node
*rn
;
11801 struct bgp_node
*top
;
11802 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11803 unsigned int space
= 0;
11805 if (!(top
= bgp_table_top (ts
->table
)))
11808 switch (top
->p
.family
)
11811 space
= IPV4_MAX_BITLEN
;
11814 space
= IPV6_MAX_BITLEN
;
11818 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11820 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11822 struct bgp_info
*ri
;
11823 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11824 unsigned int rinum
= 0;
11832 ts
->counts
[BGP_STATS_PREFIXES
]++;
11833 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11836 ts
->counts
[BGP_STATS_AVGPLEN
]
11837 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11838 ts
->counts
[BGP_STATS_AVGPLEN
],
11842 /* check if the prefix is included by any other announcements */
11843 while (prn
&& !prn
->info
)
11844 prn
= bgp_node_parent_nolock (prn
);
11846 if (prn
== NULL
|| prn
== top
)
11848 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11849 /* announced address space */
11851 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11853 else if (prn
->info
)
11854 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11856 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11859 ts
->counts
[BGP_STATS_RIB
]++;
11862 (CHECK_FLAG (ri
->attr
->flag
,
11863 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11864 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11866 /* as-path stats */
11867 if (ri
->attr
&& ri
->attr
->aspath
)
11869 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11870 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11871 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11873 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11875 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11876 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11878 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11879 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11881 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11882 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11884 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11885 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11886 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11888 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11889 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11890 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11893 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11894 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11902 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11904 struct bgp_table_stats ts
;
11907 if (!bgp
->rib
[afi
][safi
])
11909 vty_out (vty
, "%% No RIB exists for the AFI(%d)/SAFI(%d)%s",
11910 afi
, safi
, VTY_NEWLINE
);
11911 return CMD_WARNING
;
11914 memset (&ts
, 0, sizeof (ts
));
11915 ts
.table
= bgp
->rib
[afi
][safi
];
11916 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11918 vty_out (vty
, "BGP %s RIB statistics%s%s",
11919 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11921 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11923 if (!table_stats_strs
[i
])
11929 case BGP_STATS_ASPATH_AVGHOPS
:
11930 case BGP_STATS_ASPATH_AVGSIZE
:
11931 case BGP_STATS_AVGPLEN
:
11932 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11933 vty_out (vty
, "%12.2f",
11934 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11937 case BGP_STATS_ASPATH_TOTHOPS
:
11938 case BGP_STATS_ASPATH_TOTSIZE
:
11939 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11940 vty_out (vty
, "%12.2f",
11942 (float)ts
.counts
[i
] /
11943 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11946 case BGP_STATS_TOTPLEN
:
11947 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11948 vty_out (vty
, "%12.2f",
11950 (float)ts
.counts
[i
] /
11951 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11954 case BGP_STATS_SPACE
:
11955 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11956 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11957 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11959 vty_out (vty
, "%30s: ", "%% announced ");
11960 vty_out (vty
, "%12.2f%s",
11961 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11962 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11964 vty_out (vty
, "%30s: ", "/8 equivalent ");
11965 vty_out (vty
, "%12.2f%s",
11966 (float)ts
.counts
[BGP_STATS_SPACE
] /
11967 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11969 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11971 vty_out (vty
, "%30s: ", "/24 equivalent ");
11972 vty_out (vty
, "%12.2f",
11973 (float)ts
.counts
[BGP_STATS_SPACE
] /
11974 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11977 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11978 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11981 vty_out (vty
, "%s", VTY_NEWLINE
);
11983 return CMD_SUCCESS
;
11987 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11988 const char *afi_str
, const char *safi_str
)
11995 bgp
= bgp_lookup_by_name (name
);
11997 bgp
= bgp_get_default ();
12001 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
12002 return CMD_WARNING
;
12004 if (strncmp (afi_str
, "ipv", 3) == 0)
12006 if (strncmp (afi_str
, "ipv4", 4) == 0)
12008 else if (strncmp (afi_str
, "ipv6", 4) == 0)
12012 vty_out (vty
, "%% Invalid address family %s%s",
12013 afi_str
, VTY_NEWLINE
);
12014 return CMD_WARNING
;
12016 if (strncmp (safi_str
, "m", 1) == 0)
12017 safi
= SAFI_MULTICAST
;
12018 else if (strncmp (safi_str
, "u", 1) == 0)
12019 safi
= SAFI_UNICAST
;
12020 else if (strncmp (safi_str
, "e", 1) == 0)
12022 else if (strncmp (safi_str
, "vpnv4", 5) == 0 || strncmp (safi_str
, "vpnv6", 5) == 0)
12023 safi
= SAFI_MPLS_VPN
;
12026 vty_out (vty
, "%% Invalid subsequent address family %s%s",
12027 safi_str
, VTY_NEWLINE
);
12028 return CMD_WARNING
;
12033 vty_out (vty
, "%% Invalid address family \"%s\"%s",
12034 afi_str
, VTY_NEWLINE
);
12035 return CMD_WARNING
;
12038 return bgp_table_stats (vty
, bgp
, afi
, safi
);
12041 DEFUN (show_bgp_statistics
,
12042 show_bgp_statistics_cmd
,
12043 "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
12048 "Address Family modifier\n"
12049 "Address Family modifier\n"
12050 "Address Family modifier\n"
12051 "Address Family modifier\n"
12052 "BGP RIB advertisement statistics\n")
12054 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
12057 DEFUN (show_bgp_statistics_view
,
12058 show_bgp_statistics_view_cmd
,
12059 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics",
12062 BGP_INSTANCE_HELP_STR
12065 "Address Family modifier\n"
12066 "Address Family modifier\n"
12067 "Address Family modifier\n"
12068 "Address Family modifier\n"
12069 "BGP RIB advertisement statistics\n")
12071 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
12084 PCOUNT_PFCNT
, /* the figure we display to users */
12088 static const char *pcount_strs
[] =
12090 [PCOUNT_ADJ_IN
] = "Adj-in",
12091 [PCOUNT_DAMPED
] = "Damped",
12092 [PCOUNT_REMOVED
] = "Removed",
12093 [PCOUNT_HISTORY
] = "History",
12094 [PCOUNT_STALE
] = "Stale",
12095 [PCOUNT_VALID
] = "Valid",
12096 [PCOUNT_ALL
] = "All RIB",
12097 [PCOUNT_COUNTED
] = "PfxCt counted",
12098 [PCOUNT_PFCNT
] = "Useable",
12099 [PCOUNT_MAX
] = NULL
,
12102 struct peer_pcounts
12104 unsigned int count
[PCOUNT_MAX
];
12105 const struct peer
*peer
;
12106 const struct bgp_table
*table
;
12110 bgp_peer_count_walker (struct thread
*t
)
12112 struct bgp_node
*rn
;
12113 struct peer_pcounts
*pc
= THREAD_ARG (t
);
12114 const struct peer
*peer
= pc
->peer
;
12116 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
12118 struct bgp_adj_in
*ain
;
12119 struct bgp_info
*ri
;
12121 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12122 if (ain
->peer
== peer
)
12123 pc
->count
[PCOUNT_ADJ_IN
]++;
12125 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
12127 char buf
[SU_ADDRSTRLEN
];
12129 if (ri
->peer
!= peer
)
12132 pc
->count
[PCOUNT_ALL
]++;
12134 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
12135 pc
->count
[PCOUNT_DAMPED
]++;
12136 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
12137 pc
->count
[PCOUNT_HISTORY
]++;
12138 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
12139 pc
->count
[PCOUNT_REMOVED
]++;
12140 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
12141 pc
->count
[PCOUNT_STALE
]++;
12142 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
12143 pc
->count
[PCOUNT_VALID
]++;
12144 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12145 pc
->count
[PCOUNT_PFCNT
]++;
12147 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
12149 pc
->count
[PCOUNT_COUNTED
]++;
12150 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12151 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
12153 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12154 buf
, SU_ADDRSTRLEN
),
12160 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12161 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
12163 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12164 buf
, SU_ADDRSTRLEN
),
12174 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
12176 struct peer_pcounts pcounts
= { .peer
= peer
};
12178 json_object
*json
= NULL
;
12179 json_object
*json_loop
= NULL
;
12183 json
= json_object_new_object();
12184 json_loop
= json_object_new_object();
12187 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
12188 || !peer
->bgp
->rib
[afi
][safi
])
12192 json_object_string_add(json
, "warning", "No such neighbor or address family");
12193 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12194 json_object_free(json
);
12197 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12199 return CMD_WARNING
;
12202 memset (&pcounts
, 0, sizeof(pcounts
));
12203 pcounts
.peer
= peer
;
12204 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
12206 /* in-place call via thread subsystem so as to record execution time
12207 * * stats for the thread-walk (i.e. ensure this can't be blamed on
12208 * * on just vty_read()).
12210 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
12214 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
12215 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
12216 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
12218 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12219 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
12221 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
12223 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12225 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
12226 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
12228 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12229 json_object_free(json
);
12234 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
12236 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
12237 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
12242 vty_out (vty
, "Prefix counts for %s, %s%s",
12243 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
12246 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
12247 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
12248 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
12250 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12251 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
12253 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12255 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
12256 peer
->host
, VTY_NEWLINE
);
12257 vty_out (vty
, "Please report this bug, with the above command output%s",
12262 return CMD_SUCCESS
;
12265 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
12266 show_ip_bgp_neighbor_prefix_counts_cmd
,
12267 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12271 "Detailed information on TCP and BGP neighbor connections\n"
12272 "Neighbor to display information about\n"
12273 "Neighbor to display information about\n"
12274 "Neighbor on bgp configured interface\n"
12275 "Display detailed prefix count information\n"
12276 "JavaScript Object Notation\n")
12279 u_char uj
= use_json(argc
, argv
);
12281 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12283 return CMD_WARNING
;
12285 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12288 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
12289 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
12290 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12294 BGP_INSTANCE_HELP_STR
12295 "Detailed information on TCP and BGP neighbor connections\n"
12296 "Neighbor to display information about\n"
12297 "Neighbor to display information about\n"
12298 "Neighbor on bgp configured interface\n"
12299 "Display detailed prefix count information\n"
12300 "JavaScript Object Notation\n")
12303 u_char uj
= use_json(argc
, argv
);
12305 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12307 return CMD_WARNING
;
12309 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12312 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
12313 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
12314 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12318 "Detailed information on TCP and BGP neighbor connections\n"
12319 "Neighbor to display information about\n"
12320 "Neighbor to display information about\n"
12321 "Neighbor on bgp configured interface\n"
12322 "Display detailed prefix count information\n"
12323 "JavaScript Object Notation\n")
12326 u_char uj
= use_json(argc
, argv
);
12328 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12330 return CMD_WARNING
;
12332 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12335 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
12336 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
12337 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12340 BGP_INSTANCE_HELP_STR
12342 "Detailed information on TCP and BGP neighbor connections\n"
12343 "Neighbor to display information about\n"
12344 "Neighbor to display information about\n"
12345 "Neighbor on bgp configured interface\n"
12346 "Display detailed prefix count information\n"
12347 "JavaScript Object Notation\n")
12350 u_char uj
= use_json(argc
, argv
);
12352 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12354 return CMD_WARNING
;
12356 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12359 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
12360 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
12361 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12366 "Address Family modifier\n"
12367 "Address Family modifier\n"
12368 "Detailed information on TCP and BGP neighbor connections\n"
12369 "Neighbor to display information about\n"
12370 "Neighbor to display information about\n"
12371 "Neighbor on bgp configured interface\n"
12372 "Display detailed prefix count information\n"
12373 "JavaScript Object Notation\n")
12376 u_char uj
= use_json(argc
, argv
);
12378 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12380 return CMD_WARNING
;
12382 if (strncmp (argv
[0], "m", 1) == 0)
12383 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, uj
);
12385 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12388 DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts
,
12389 show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
,
12390 "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12395 "Address Family modifier\n"
12396 "Address Family modifier\n"
12397 "Detailed information on TCP and BGP neighbor connections\n"
12398 "Neighbor to display information about\n"
12399 "Neighbor to display information about\n"
12400 "Neighbor on bgp configured interface\n"
12401 "Display detailed prefix count information\n"
12402 "JavaScript Object Notation\n")
12405 u_char uj
= use_json(argc
, argv
);
12407 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12409 return CMD_WARNING
;
12411 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_MPLS_VPN
, uj
);
12415 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12416 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
12418 struct bgp_table
*table
;
12419 struct bgp_adj_in
*ain
;
12420 struct bgp_adj_out
*adj
;
12421 unsigned long output_count
;
12422 unsigned long filtered_count
;
12423 struct bgp_node
*rn
;
12428 struct attr_extra extra
;
12430 struct update_subgroup
*subgrp
;
12431 json_object
*json_scode
= NULL
;
12432 json_object
*json_ocode
= NULL
;
12433 json_object
*json_ar
= NULL
;
12434 struct peer_af
*paf
;
12438 json_scode
= json_object_new_object();
12439 json_ocode
= json_object_new_object();
12440 json_ar
= json_object_new_object();
12442 json_object_string_add(json_scode
, "suppressed", "s");
12443 json_object_string_add(json_scode
, "damped", "d");
12444 json_object_string_add(json_scode
, "history", "h");
12445 json_object_string_add(json_scode
, "valid", "*");
12446 json_object_string_add(json_scode
, "best", ">");
12447 json_object_string_add(json_scode
, "multipath", "=");
12448 json_object_string_add(json_scode
, "internal", "i");
12449 json_object_string_add(json_scode
, "ribFailure", "r");
12450 json_object_string_add(json_scode
, "stale", "S");
12451 json_object_string_add(json_scode
, "removed", "R");
12453 json_object_string_add(json_ocode
, "igp", "i");
12454 json_object_string_add(json_ocode
, "egp", "e");
12455 json_object_string_add(json_ocode
, "incomplete", "?");
12464 json_object_string_add(json
, "alert", "no BGP");
12465 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12466 json_object_free(json
);
12469 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12473 table
= bgp
->rib
[afi
][safi
];
12475 output_count
= filtered_count
= 0;
12476 subgrp
= peer_subgroup(peer
, afi
, safi
);
12478 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12482 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12483 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12484 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12485 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12486 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12490 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12491 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12492 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12494 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12495 VTY_NEWLINE
, VTY_NEWLINE
);
12500 attr
.extra
= &extra
;
12501 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12505 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12507 if (ain
->peer
== peer
)
12513 json_object_int_add(json
, "bgpTableVersion", 0);
12514 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12515 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12516 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12520 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12521 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12522 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12529 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12534 bgp_attr_dup(&attr
, ain
->attr
);
12535 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12537 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12548 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12549 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12550 if (paf
->peer
== peer
)
12556 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12557 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12558 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12559 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12563 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12564 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12565 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12566 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12574 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12580 bgp_attr_dup(&attr
, adj
->attr
);
12581 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12582 if (ret
!= RMAP_DENY
)
12584 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12594 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12596 if (output_count
!= 0)
12599 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12601 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12602 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12606 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12607 json_object_free(json
);
12613 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12614 int in
, const char *rmap_name
, u_char use_json
)
12616 json_object
*json
= NULL
;
12619 json
= json_object_new_object();
12621 if (!peer
|| !peer
->afc
[afi
][safi
])
12625 json_object_string_add(json
, "warning", "No such neighbor or address family");
12626 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12627 json_object_free(json
);
12630 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12632 return CMD_WARNING
;
12635 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12639 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12640 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12641 json_object_free(json
);
12644 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12646 return CMD_WARNING
;
12649 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12651 return CMD_SUCCESS
;
12654 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12655 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12656 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12660 BGP_INSTANCE_HELP_STR
12661 "Detailed information on TCP and BGP neighbor connections\n"
12662 "Neighbor to display information about\n"
12663 "Neighbor to display information about\n"
12664 "Display the routes advertised to a BGP neighbor\n"
12665 "JavaScript Object Notation\n")
12668 u_char uj
= use_json(argc
, argv
);
12670 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12671 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12673 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12676 return CMD_WARNING
;
12678 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12681 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12682 show_ip_bgp_neighbor_advertised_route_cmd
,
12683 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12687 "Detailed information on TCP and BGP neighbor connections\n"
12688 "Neighbor to display information about\n"
12689 "Neighbor to display information about\n"
12690 "Neighbor on bgp configured interface\n"
12691 "Display the routes advertised to a BGP neighbor\n"
12692 "JavaScript Object Notation\n")
12696 const char *rmap_name
= NULL
;
12697 u_char uj
= use_json(argc
, argv
);
12699 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12702 return CMD_WARNING
;
12704 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12706 rmap_name
= argv
[1];
12708 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12711 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12712 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12713 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12717 "Detailed information on TCP and BGP neighbor connections\n"
12718 "Neighbor to display information about\n"
12719 "Neighbor to display information about\n"
12720 "Neighbor on bgp configured interface\n"
12721 "Display the routes advertised to a BGP neighbor\n"
12722 "JavaScript Object Notation\n")
12724 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12725 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12726 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12730 BGP_INSTANCE_HELP_STR
12731 "Detailed information on TCP and BGP neighbor connections\n"
12732 "Neighbor to display information about\n"
12733 "Neighbor to display information about\n"
12734 "Neighbor on bgp configured interface\n"
12735 "Display the routes advertised to a BGP neighbor\n"
12736 "JavaScript Object Notation\n")
12737 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12738 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12739 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12744 "Address Family modifier\n"
12745 "Address Family modifier\n"
12746 "Detailed information on TCP and BGP neighbor connections\n"
12747 "Neighbor to display information about\n"
12748 "Neighbor to display information about\n"
12749 "Neighbor on bgp configured interface\n"
12750 "Display the routes advertised to a BGP neighbor\n"
12751 "JavaScript Object Notation\n")
12754 const char *rmap_name
= NULL
;
12755 u_char uj
= use_json(argc
, argv
);
12757 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12759 return CMD_WARNING
;
12761 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12762 rmap_name
= argv
[2];
12764 if (strncmp (argv
[0], "m", 1) == 0)
12765 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 0, rmap_name
, uj
);
12767 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12770 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12771 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12772 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12777 "Address Family modifier\n"
12778 "Address Family modifier\n"
12779 "Detailed information on TCP and BGP neighbor connections\n"
12780 "Neighbor to display information about\n"
12781 "Neighbor to display information about\n"
12782 "Neighbor on bgp configured interface\n"
12783 "Display the routes advertised to a BGP neighbor\n"
12784 "Route-map to control what is displayed\n"
12785 "JavaScript Object Notation\n")
12788 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12789 show_bgp_instance_neighbor_advertised_route_cmd
,
12790 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12793 BGP_INSTANCE_HELP_STR
12794 "Detailed information on TCP and BGP neighbor connections\n"
12795 "Neighbor to display information about\n"
12796 "Neighbor to display information about\n"
12797 "Neighbor on bgp configured interface\n"
12798 "Display the routes advertised to a BGP neighbor\n"
12799 "JavaScript Object Notation\n")
12802 u_char uj
= use_json(argc
, argv
);
12804 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12805 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12807 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12810 return CMD_WARNING
;
12812 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12815 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12816 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12817 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12820 BGP_INSTANCE_HELP_STR
12822 "Detailed information on TCP and BGP neighbor connections\n"
12823 "Neighbor to display information about\n"
12824 "Neighbor to display information about\n"
12825 "Neighbor on bgp configured interface\n"
12826 "Display the routes advertised to a BGP neighbor\n"
12827 "JavaScript Object Notation\n")
12829 DEFUN (show_bgp_neighbor_advertised_route
,
12830 show_bgp_neighbor_advertised_route_cmd
,
12831 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12834 "Detailed information on TCP and BGP neighbor connections\n"
12835 "Neighbor to display information about\n"
12836 "Neighbor to display information about\n"
12837 "Neighbor on bgp configured interface\n"
12838 "Display the routes advertised to a BGP neighbor\n"
12839 "JavaScript Object Notation\n")
12843 const char *rmap_name
= NULL
;
12844 u_char uj
= use_json(argc
, argv
);
12846 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12849 return CMD_WARNING
;
12851 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12852 rmap_name
= argv
[1];
12854 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12857 ALIAS (show_bgp_neighbor_advertised_route
,
12858 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12859 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12863 "Detailed information on TCP and BGP neighbor connections\n"
12864 "Neighbor to display information about\n"
12865 "Neighbor to display information about\n"
12866 "Neighbor on bgp configured interface\n"
12867 "Display the routes advertised to a BGP neighbor\n"
12868 "JavaScript Object Notation\n")
12871 ALIAS (show_bgp_neighbor_advertised_route
,
12872 ipv6_bgp_neighbor_advertised_route_cmd
,
12873 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12877 "Detailed information on TCP and BGP neighbor connections\n"
12878 "Neighbor to display information about\n"
12879 "Neighbor to display information about\n"
12880 "Neighbor on bgp configured interface\n"
12881 "Display the routes advertised to a BGP neighbor\n"
12882 "JavaScript Object Notation\n")
12885 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12886 ipv6_mbgp_neighbor_advertised_route_cmd
,
12887 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12891 "Detailed information on TCP and BGP neighbor connections\n"
12892 "Neighbor to display information about\n"
12893 "Neighbor to display information about\n"
12894 "Neighbor on bgp configured interface\n"
12895 "Neighbor on bgp configured interface\n"
12896 "Display the routes advertised to a BGP neighbor\n"
12897 "JavaScript Object Notation\n")
12900 u_char uj
= use_json(argc
, argv
);
12902 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12904 return CMD_WARNING
;
12906 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12907 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12909 #endif /* HAVE_IPV6 */
12911 DEFUN (show_bgp_instance_neighbor_received_routes
,
12912 show_bgp_instance_neighbor_received_routes_cmd
,
12913 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12916 BGP_INSTANCE_HELP_STR
12917 "Detailed information on TCP and BGP neighbor connections\n"
12918 "Neighbor to display information about\n"
12919 "Neighbor to display information about\n"
12920 "Neighbor on bgp configured interface\n"
12921 "Display the received routes from neighbor\n"
12922 "JavaScript Object Notation\n")
12925 u_char uj
= use_json(argc
, argv
);
12927 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12929 return CMD_WARNING
;
12931 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12934 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12935 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12936 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12940 BGP_INSTANCE_HELP_STR
12941 "Detailed information on TCP and BGP neighbor connections\n"
12942 "Neighbor to display information about\n"
12943 "Neighbor to display information about\n"
12944 "Neighbor on bgp configured interface\n"
12945 "Display the received routes from neighbor\n"
12946 "JavaScript Object Notation\n")
12949 u_char uj
= use_json(argc
, argv
);
12951 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12953 return CMD_WARNING
;
12955 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12958 ALIAS (show_bgp_instance_neighbor_received_routes
,
12959 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12960 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12963 BGP_INSTANCE_HELP_STR
12965 "Detailed information on TCP and BGP neighbor connections\n"
12966 "Neighbor to display information about\n"
12967 "Neighbor to display information about\n"
12968 "Neighbor on bgp configured interface\n"
12969 "Display the received routes from neighbor\n"
12970 "JavaScript Object Notation\n")
12972 DEFUN (show_ip_bgp_neighbor_received_routes
,
12973 show_ip_bgp_neighbor_received_routes_cmd
,
12974 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12978 "Detailed information on TCP and BGP neighbor connections\n"
12979 "Neighbor to display information about\n"
12980 "Neighbor to display information about\n"
12981 "Neighbor on bgp configured interface\n"
12982 "Display the received routes from neighbor\n"
12983 "JavaScript Object Notation\n")
12987 const char *rmap_name
= NULL
;
12988 u_char uj
= use_json(argc
, argv
);
12990 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12993 return CMD_WARNING
;
12995 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12996 rmap_name
= argv
[1];
12998 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13001 ALIAS (show_ip_bgp_neighbor_received_routes
,
13002 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
13003 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
13007 "Detailed information on TCP and BGP neighbor connections\n"
13008 "Neighbor to display information about\n"
13009 "Neighbor to display information about\n"
13010 "Neighbor on bgp configured interface\n"
13011 "Display the received routes from neighbor\n"
13012 "JavaScript Object Notation\n")
13014 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
13015 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
13016 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
13020 BGP_INSTANCE_HELP_STR
13021 "Detailed information on TCP and BGP neighbor connections\n"
13022 "Neighbor to display information about\n"
13023 "Neighbor to display information about\n"
13024 "Neighbor on bgp configured interface\n"
13025 "Display the received routes from neighbor\n"
13026 "JavaScript Object Notation\n")
13028 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
13029 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
13030 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13035 "Address Family modifier\n"
13036 "Address Family modifier\n"
13037 "Detailed information on TCP and BGP neighbor connections\n"
13038 "Neighbor to display information about\n"
13039 "Neighbor to display information about\n"
13040 "Neighbor on bgp configured interface\n"
13041 "Display the received routes from neighbor\n"
13042 "JavaScript Object Notation\n")
13045 const char *rmap_name
= NULL
;
13046 u_char uj
= use_json(argc
, argv
);
13048 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13050 return CMD_WARNING
;
13052 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13053 rmap_name
= argv
[2];
13055 if (strncmp (argv
[0], "m", 1) == 0)
13056 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_MULTICAST
, 1, rmap_name
, uj
);
13058 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13061 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
13062 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
13063 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
13068 "Address Family modifier\n"
13069 "Address Family modifier\n"
13070 "Detailed information on TCP and BGP neighbor connections\n"
13071 "Neighbor to display information about\n"
13072 "Neighbor to display information about\n"
13073 "Neighbor on bgp configured interface\n"
13074 "Display the received routes from neighbor\n"
13075 "JavaScript Object Notation\n")
13077 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
13078 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
13079 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
13082 BGP_INSTANCE_HELP_STR
13085 "Address family modifier\n"
13086 "Address family modifier\n"
13087 "Detailed information on TCP and BGP neighbor connections\n"
13088 "Neighbor to display information about\n"
13089 "Neighbor to display information about\n"
13090 "Neighbor on bgp configured interface\n"
13091 "Display the advertised routes to neighbor\n"
13092 "Display the received routes from neighbor\n"
13093 "JavaScript Object Notation\n")
13099 u_char uj
= use_json(argc
, argv
);
13101 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
13104 return CMD_WARNING
;
13106 afi
= (strncmp (argv
[2], "ipv6", 4) == 0) ? AFI_IP6
: AFI_IP
;
13107 safi
= (strncmp (argv
[3], "m", 1) == 0) ? SAFI_MULTICAST
: SAFI_UNICAST
;
13108 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
13110 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
13113 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
13114 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
13115 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13119 "Detailed information on TCP and BGP neighbor connections\n"
13120 "Neighbor to display information about\n"
13121 "Neighbor to display information about\n"
13122 "Neighbor on bgp configured interface\n"
13123 "Display information received from a BGP neighbor\n"
13124 "Display the prefixlist filter\n"
13125 "JavaScript Object Notation\n")
13128 union sockunion su
;
13131 u_char uj
= use_json(argc
, argv
);
13133 ret
= str2sockunion (argv
[0], &su
);
13136 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13141 json_object
*json_no
= NULL
;
13142 json_object
*json_sub
= NULL
;
13143 json_no
= json_object_new_object();
13144 json_sub
= json_object_new_object();
13145 json_object_string_add(json_no
, "warning", "Malformed address or name");
13146 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13147 json_object_object_add(json_no
, "detail", json_sub
);
13148 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13149 json_object_free(json_no
);
13152 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13153 return CMD_WARNING
;
13158 peer
= peer_lookup (NULL
, &su
);
13163 json_object
*json_no
= NULL
;
13164 json_no
= json_object_new_object();
13165 json_object_string_add(json_no
, "warning", "Peer not found");
13166 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13167 json_object_free(json_no
);
13170 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13171 return CMD_WARNING
;
13175 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
13176 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13180 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
13181 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13187 json_object
*json_no
= NULL
;
13188 json_no
= json_object_new_object();
13189 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13190 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13191 json_object_free(json_no
);
13194 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13197 return CMD_SUCCESS
;
13200 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
13201 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
13202 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13207 "Address Family modifier\n"
13208 "Address Family modifier\n"
13209 "Detailed information on TCP and BGP neighbor connections\n"
13210 "Neighbor to display information about\n"
13211 "Neighbor to display information about\n"
13212 "Neighbor on bgp configured interface\n"
13213 "Display information received from a BGP neighbor\n"
13214 "Display the prefixlist filter\n"
13215 "JavaScript Object Notation\n")
13218 union sockunion su
;
13221 u_char uj
= use_json(argc
, argv
);
13223 ret
= str2sockunion (argv
[1], &su
);
13226 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
13231 json_object
*json_no
= NULL
;
13232 json_object
*json_sub
= NULL
;
13233 json_no
= json_object_new_object();
13234 json_sub
= json_object_new_object();
13235 json_object_string_add(json_no
, "warning", "Malformed address or name");
13236 json_object_string_add(json_sub
, "warningCause", argv
[1]);
13237 json_object_object_add(json_no
, "detail", json_sub
);
13238 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13239 json_object_free(json_no
);
13242 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
13243 return CMD_WARNING
;
13248 peer
= peer_lookup (NULL
, &su
);
13253 json_object
*json_no
= NULL
;
13254 json_no
= json_object_new_object();
13255 json_object_string_add(json_no
, "warning", "Peer not found");
13256 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13257 json_object_free(json_no
);
13260 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13261 return CMD_WARNING
;
13265 if (strncmp (argv
[0], "m", 1) == 0)
13267 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_MULTICAST
);
13268 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13272 vty_out (vty
, "Address family: IPv4 Multicast%s", VTY_NEWLINE
);
13273 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13279 json_object
*json_no
= NULL
;
13280 json_no
= json_object_new_object();
13281 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13282 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13283 json_object_free(json_no
);
13286 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13291 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
13292 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13296 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
13297 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13303 json_object
*json_no
= NULL
;
13304 json_no
= json_object_new_object();
13305 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13306 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13307 json_object_free(json_no
);
13310 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13314 return CMD_SUCCESS
;
13317 DEFUN (show_bgp_neighbor_received_routes
,
13318 show_bgp_neighbor_received_routes_cmd
,
13319 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13322 "Detailed information on TCP and BGP neighbor connections\n"
13323 "Neighbor to display information about\n"
13324 "Neighbor to display information about\n"
13325 "Neighbor on bgp configured interface\n"
13326 "Display the received routes from neighbor\n"
13327 "JavaScript Object Notation\n")
13330 const char *rmap_name
= NULL
;
13331 u_char uj
= use_json(argc
, argv
);
13333 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13336 return CMD_WARNING
;
13338 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
13339 rmap_name
= argv
[1];
13341 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13344 ALIAS (show_bgp_neighbor_received_routes
,
13345 show_bgp_ipv6_neighbor_received_routes_cmd
,
13346 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13350 "Detailed information on TCP and BGP neighbor connections\n"
13351 "Neighbor to display information about\n"
13352 "Neighbor to display information about\n"
13353 "Neighbor on bgp configured interface\n"
13354 "Display the received routes from neighbor\n"
13355 "JavaScript Object Notation\n")
13357 DEFUN (show_bgp_neighbor_received_prefix_filter
,
13358 show_bgp_neighbor_received_prefix_filter_cmd
,
13359 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13362 "Detailed information on TCP and BGP neighbor connections\n"
13363 "Neighbor to display information about\n"
13364 "Neighbor to display information about\n"
13365 "Neighbor on bgp configured interface\n"
13366 "Display information received from a BGP neighbor\n"
13367 "Display the prefixlist filter\n"
13368 "JavaScript Object Notation\n")
13371 union sockunion su
;
13374 u_char uj
= use_json(argc
, argv
);
13376 ret
= str2sockunion (argv
[0], &su
);
13379 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13384 json_object
*json_no
= NULL
;
13385 json_object
*json_sub
= NULL
;
13386 json_no
= json_object_new_object();
13387 json_sub
= json_object_new_object();
13388 json_object_string_add(json_no
, "warning", "Malformed address or name");
13389 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13390 json_object_object_add(json_no
, "detail", json_sub
);
13391 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13392 json_object_free(json_no
);
13395 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13396 return CMD_WARNING
;
13401 peer
= peer_lookup (NULL
, &su
);
13406 json_object
*json_no
= NULL
;
13407 json_no
= json_object_new_object();
13408 json_object_string_add(json_no
, "warning", "No Peer");
13409 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13410 json_object_free(json_no
);
13413 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13414 return CMD_WARNING
;
13418 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13419 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13423 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13424 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13430 json_object
*json_no
= NULL
;
13431 json_no
= json_object_new_object();
13432 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13433 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13434 json_object_free(json_no
);
13437 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13440 return CMD_SUCCESS
;
13443 ALIAS (show_bgp_neighbor_received_prefix_filter
,
13444 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
13445 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13449 "Detailed information on TCP and BGP neighbor connections\n"
13450 "Neighbor to display information about\n"
13451 "Neighbor to display information about\n"
13452 "Neighbor on bgp configured interface\n"
13453 "Display information received from a BGP neighbor\n"
13454 "Display the prefixlist filter\n"
13455 "JavaScript Object Notation\n")
13458 ALIAS (show_bgp_neighbor_received_routes
,
13459 ipv6_bgp_neighbor_received_routes_cmd
,
13460 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13464 "Detailed information on TCP and BGP neighbor connections\n"
13465 "Neighbor to display information about\n"
13466 "Neighbor to display information about\n"
13467 "Neighbor on bgp configured interface\n"
13468 "Display the received routes from neighbor\n"
13469 "JavaScript Object Notation\n")
13472 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13473 ipv6_mbgp_neighbor_received_routes_cmd
,
13474 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13478 "Detailed information on TCP and BGP neighbor connections\n"
13479 "Neighbor to display information about\n"
13480 "Neighbor to display information about\n"
13481 "Neighbor on bgp configured interface\n"
13482 "Display the received routes from neighbor\n"
13483 "JavaScript Object Notation\n")
13486 u_char uj
= use_json(argc
, argv
);
13488 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13490 return CMD_WARNING
;
13492 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13493 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13496 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13497 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13498 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13501 BGP_INSTANCE_HELP_STR
13502 "Detailed information on TCP and BGP neighbor connections\n"
13503 "Neighbor to display information about\n"
13504 "Neighbor to display information about\n"
13505 "Neighbor on bgp configured interface\n"
13506 "Display information received from a BGP neighbor\n"
13507 "Display the prefixlist filter\n"
13508 "JavaScript Object Notation\n")
13511 union sockunion su
;
13515 u_char uj
= use_json(argc
, argv
);
13517 /* BGP structure lookup. */
13518 bgp
= bgp_lookup_by_name (argv
[1]);
13523 json_object
*json_no
= NULL
;
13524 json_no
= json_object_new_object();
13525 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13526 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13527 json_object_free(json_no
);
13530 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13531 return CMD_WARNING
;
13534 ret
= str2sockunion (argv
[2], &su
);
13537 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13542 json_object
*json_no
= NULL
;
13543 json_object
*json_sub
= NULL
;
13544 json_no
= json_object_new_object();
13545 json_sub
= json_object_new_object();
13546 json_object_string_add(json_no
, "warning", "Malformed address or name");
13547 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13548 json_object_object_add(json_no
, "detail", json_sub
);
13549 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13550 json_object_free(json_no
);
13553 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13554 return CMD_WARNING
;
13559 peer
= peer_lookup (bgp
, &su
);
13564 json_object
*json_no
= NULL
;
13565 json_no
= json_object_new_object();
13566 json_object_boolean_true_add(json_no
, "noPeer");
13567 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13568 json_object_free(json_no
);
13571 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13572 return CMD_WARNING
;
13577 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13578 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13582 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13583 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13586 return CMD_SUCCESS
;
13588 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13589 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13590 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13593 BGP_INSTANCE_HELP_STR
13595 "Detailed information on TCP and BGP neighbor connections\n"
13596 "Neighbor to display information about\n"
13597 "Neighbor to display information about\n"
13598 "Neighbor on bgp configured interface\n"
13599 "Display information received from a BGP neighbor\n"
13600 "Display the prefixlist filter\n"
13601 "JavaScript Object NOtation\n")
13602 #endif /* HAVE_IPV6 */
13605 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13606 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13608 if (! peer
|| ! peer
->afc
[afi
][safi
])
13612 json_object
*json_no
= NULL
;
13613 json_no
= json_object_new_object();
13614 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13615 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13616 json_object_free(json_no
);
13619 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13620 return CMD_WARNING
;
13623 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13626 DEFUN (show_ip_bgp_neighbor_routes
,
13627 show_ip_bgp_neighbor_routes_cmd
,
13628 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13632 "Detailed information on TCP and BGP neighbor connections\n"
13633 "Neighbor to display information about\n"
13634 "Neighbor to display information about\n"
13635 "Neighbor on bgp configured interface\n"
13636 "Display routes learned from neighbor\n"
13637 "JavaScript Object Notation\n")
13640 u_char uj
= use_json(argc
, argv
);
13642 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13644 return CMD_WARNING
;
13646 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13647 bgp_show_type_neighbor
, uj
);
13650 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13651 show_ip_bgp_instance_neighbor_routes_cmd
,
13652 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13656 BGP_INSTANCE_HELP_STR
13657 "Detailed information on TCP and BGP neighbor connections\n"
13658 "Neighbor to display information about\n"
13659 "Neighbor to display information about\n"
13660 "Neighbor on bgp configured interface\n"
13661 "Display routes learned from neighbor\n"
13662 "JavaScript Object Notation\n")
13665 u_char uj
= use_json(argc
, argv
);
13667 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13669 return CMD_WARNING
;
13671 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13672 bgp_show_type_neighbor
, uj
);
13675 DEFUN (show_ip_bgp_neighbor_flap
,
13676 show_ip_bgp_neighbor_flap_cmd
,
13677 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13681 "Detailed information on TCP and BGP neighbor connections\n"
13682 "Neighbor to display information about\n"
13683 "Neighbor to display information about\n"
13684 "Neighbor on bgp configured interface\n"
13685 "Display flap statistics of the routes learned from neighbor\n"
13686 "JavaScript Object Notation\n")
13689 u_char uj
= use_json(argc
, argv
);
13691 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13693 return CMD_WARNING
;
13695 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13696 bgp_show_type_flap_neighbor
, uj
);
13699 DEFUN (show_ip_bgp_neighbor_damp
,
13700 show_ip_bgp_neighbor_damp_cmd
,
13701 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13705 "Detailed information on TCP and BGP neighbor connections\n"
13706 "Neighbor to display information about\n"
13707 "Neighbor to display information about\n"
13708 "Neighbor on bgp configured interface\n"
13709 "Display the dampened routes received from neighbor\n"
13710 "JavaScript Object Notation\n")
13713 u_char uj
= use_json(argc
, argv
);
13715 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13717 return CMD_WARNING
;
13719 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13720 bgp_show_type_damp_neighbor
, uj
);
13723 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13724 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13725 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13730 "Address Family modifier\n"
13731 "Address Family modifier\n"
13732 "Detailed information on TCP and BGP neighbor connections\n"
13733 "Neighbor to display information about\n"
13734 "Neighbor to display information about\n"
13735 "Neighbor on bgp configured interface\n"
13736 "Display routes learned from neighbor\n"
13737 "JavaScript Object Notation\n")
13740 u_char uj
= use_json(argc
, argv
);
13742 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13744 return CMD_WARNING
;
13746 if (strncmp (argv
[0], "m", 1) == 0)
13747 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_MULTICAST
,
13748 bgp_show_type_neighbor
, uj
);
13750 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13751 bgp_show_type_neighbor
, uj
);
13755 DEFUN (show_bgp_instance_neighbor_routes
,
13756 show_bgp_instance_neighbor_routes_cmd
,
13757 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13760 BGP_INSTANCE_HELP_STR
13761 "Detailed information on TCP and BGP neighbor connections\n"
13762 "Neighbor to display information about\n"
13763 "Neighbor to display information about\n"
13764 "Neighbor on bgp configured interface\n"
13765 "Display routes learned from neighbor\n"
13766 "JavaScript Object Notation\n")
13769 u_char uj
= use_json(argc
, argv
);
13771 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13773 return CMD_WARNING
;
13775 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13776 bgp_show_type_neighbor
, uj
);
13779 ALIAS (show_bgp_instance_neighbor_routes
,
13780 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13781 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13784 BGP_INSTANCE_HELP_STR
13786 "Detailed information on TCP and BGP neighbor connections\n"
13787 "Neighbor to display information about\n"
13788 "Neighbor to display information about\n"
13789 "Neighbor on bgp configured interface\n"
13790 "Display routes learned from neighbor\n"
13791 "JavaScript Object Notation\n")
13793 DEFUN (show_bgp_instance_neighbor_damp
,
13794 show_bgp_instance_neighbor_damp_cmd
,
13795 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13798 BGP_INSTANCE_HELP_STR
13799 "Detailed information on TCP and BGP neighbor connections\n"
13800 "Neighbor to display information about\n"
13801 "Neighbor to display information about\n"
13802 "Neighbor on bgp configured interface\n"
13803 "Display the dampened routes received from neighbor\n"
13804 "JavaScript Object Notation\n")
13807 u_char uj
= use_json(argc
, argv
);
13809 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13810 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13811 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13813 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13816 return CMD_WARNING
;
13818 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13819 bgp_show_type_damp_neighbor
, uj
);
13822 ALIAS (show_bgp_instance_neighbor_damp
,
13823 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13824 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13827 BGP_INSTANCE_HELP_STR
13829 "Detailed information on TCP and BGP neighbor connections\n"
13830 "Neighbor to display information about\n"
13831 "Neighbor to display information about\n"
13832 "Neighbor on bgp configured interface\n"
13833 "Display the dampened routes received from neighbor\n"
13834 "JavaScript Object Notation\n")
13836 DEFUN (show_bgp_instance_neighbor_flap
,
13837 show_bgp_instance_neighbor_flap_cmd
,
13838 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13841 BGP_INSTANCE_HELP_STR
13842 "Detailed information on TCP and BGP neighbor connections\n"
13843 "Neighbor to display information about\n"
13844 "Neighbor to display information about\n"
13845 "Neighbor on bgp configured interface\n"
13846 "Display flap statistics of the routes learned from neighbor\n"
13847 "JavaScript Object Notation\n")
13850 u_char uj
= use_json(argc
, argv
);
13852 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13853 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13854 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13856 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13859 return CMD_WARNING
;
13861 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13862 bgp_show_type_flap_neighbor
, uj
);
13865 ALIAS (show_bgp_instance_neighbor_flap
,
13866 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13867 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13870 BGP_INSTANCE_HELP_STR
13872 "Detailed information on TCP and BGP neighbor connections\n"
13873 "Neighbor to display information about\n"
13874 "Neighbor to display information about\n"
13875 "Neighbor on bgp configured interface\n"
13876 "Display flap statistics of the routes learned from neighbor\n"
13877 "JavaScript Object Notation\n")
13879 DEFUN (show_bgp_neighbor_routes
,
13880 show_bgp_neighbor_routes_cmd
,
13881 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13884 "Detailed information on TCP and BGP neighbor connections\n"
13885 "Neighbor to display information about\n"
13886 "Neighbor to display information about\n"
13887 "Neighbor on bgp configured interface\n"
13888 "Display routes learned from neighbor\n"
13889 "JavaScript Object Notation\n")
13892 u_char uj
= use_json(argc
, argv
);
13894 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13896 return CMD_WARNING
;
13898 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13899 bgp_show_type_neighbor
, uj
);
13903 ALIAS (show_bgp_neighbor_routes
,
13904 show_bgp_ipv6_neighbor_routes_cmd
,
13905 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13909 "Detailed information on TCP and BGP neighbor connections\n"
13910 "Neighbor to display information about\n"
13911 "Neighbor to display information about\n"
13912 "Neighbor on bgp configured interface\n"
13913 "Display routes learned from neighbor\n"
13914 "JavaScript Object Notation\n")
13917 ALIAS (show_bgp_neighbor_routes
,
13918 ipv6_bgp_neighbor_routes_cmd
,
13919 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13923 "Detailed information on TCP and BGP neighbor connections\n"
13924 "Neighbor to display information about\n"
13925 "Neighbor to display information about\n"
13926 "Neighbor on bgp configured interface\n"
13927 "Display routes learned from neighbor\n"
13928 "JavaScript Object Notation\n")
13931 DEFUN (ipv6_mbgp_neighbor_routes
,
13932 ipv6_mbgp_neighbor_routes_cmd
,
13933 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13937 "Detailed information on TCP and BGP neighbor connections\n"
13938 "Neighbor to display information about\n"
13939 "Neighbor to display information about\n"
13940 "Neighbor on bgp configured interface\n"
13941 "Display routes learned from neighbor\n"
13942 "JavaScript Object Notation\n")
13945 u_char uj
= use_json(argc
, argv
);
13947 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13949 return CMD_WARNING
;
13951 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13952 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13953 bgp_show_type_neighbor
, uj
);
13956 ALIAS (show_bgp_instance_neighbor_flap
,
13957 show_bgp_neighbor_flap_cmd
,
13958 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13961 "Detailed information on TCP and BGP neighbor connections\n"
13962 "Neighbor to display information about\n"
13963 "Neighbor to display information about\n"
13964 "Neighbor on bgp configured interface\n"
13965 "Display flap statistics of the routes learned from neighbor\n"
13966 "JavaScript Object Notation\n")
13968 ALIAS (show_bgp_instance_neighbor_flap
,
13969 show_bgp_ipv6_neighbor_flap_cmd
,
13970 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13974 "Detailed information on TCP and BGP neighbor connections\n"
13975 "Neighbor to display information about\n"
13976 "Neighbor to display information about\n"
13977 "Neighbor on bgp configured interface\n"
13978 "Display flap statistics of the routes learned from neighbor\n"
13979 "JavaScript Object Notation\n")
13981 ALIAS (show_bgp_instance_neighbor_damp
,
13982 show_bgp_neighbor_damp_cmd
,
13983 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13986 "Detailed information on TCP and BGP neighbor connections\n"
13987 "Neighbor to display information about\n"
13988 "Neighbor to display information about\n"
13989 "Neighbor on bgp configured interface\n"
13990 "Display the dampened routes received from neighbor\n"
13991 "JavaScript Object Notation\n")
13993 ALIAS (show_bgp_instance_neighbor_damp
,
13994 show_bgp_ipv6_neighbor_damp_cmd
,
13995 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13999 "Detailed information on TCP and BGP neighbor connections\n"
14000 "Neighbor to display information about\n"
14001 "Neighbor to display information about\n"
14002 "Neighbor on bgp configured interface\n"
14003 "Display the dampened routes received from neighbor\n"
14004 "JavaScript Object Notation\n")
14006 #endif /* HAVE_IPV6 */
14008 struct bgp_table
*bgp_distance_table
[AFI_MAX
][SAFI_MAX
];
14010 struct bgp_distance
14012 /* Distance value for the IP source prefix. */
14015 /* Name of the access-list to be matched. */
14019 static struct bgp_distance
*
14020 bgp_distance_new (void)
14022 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
14026 bgp_distance_free (struct bgp_distance
*bdistance
)
14028 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
14032 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
14033 const char *ip_str
, const char *access_list_str
)
14040 struct bgp_node
*rn
;
14041 struct bgp_distance
*bdistance
;
14043 afi
= bgp_node_afi (vty
);
14044 safi
= bgp_node_safi (vty
);
14046 ret
= str2prefix (ip_str
, &p
);
14049 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
14050 return CMD_WARNING
;
14053 distance
= atoi (distance_str
);
14055 /* Get BGP distance node. */
14056 rn
= bgp_node_get (bgp_distance_table
[afi
][safi
], (struct prefix
*) &p
);
14059 bdistance
= rn
->info
;
14060 bgp_unlock_node (rn
);
14064 bdistance
= bgp_distance_new ();
14065 rn
->info
= bdistance
;
14068 /* Set distance value. */
14069 bdistance
->distance
= distance
;
14071 /* Reset access-list configuration. */
14072 if (bdistance
->access_list
)
14074 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
14075 bdistance
->access_list
= NULL
;
14077 if (access_list_str
)
14078 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
14080 return CMD_SUCCESS
;
14084 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
14085 const char *ip_str
, const char *access_list_str
)
14092 struct bgp_node
*rn
;
14093 struct bgp_distance
*bdistance
;
14095 afi
= bgp_node_afi (vty
);
14096 safi
= bgp_node_safi (vty
);
14098 ret
= str2prefix (ip_str
, &p
);
14101 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
14102 return CMD_WARNING
;
14105 rn
= bgp_node_lookup (bgp_distance_table
[afi
][safi
], (struct prefix
*)&p
);
14108 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
14109 return CMD_WARNING
;
14112 bdistance
= rn
->info
;
14113 distance
= atoi(distance_str
);
14115 if (bdistance
->distance
!= distance
)
14117 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
14118 return CMD_WARNING
;
14121 if (bdistance
->access_list
)
14122 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
14123 bgp_distance_free (bdistance
);
14126 bgp_unlock_node (rn
);
14127 bgp_unlock_node (rn
);
14129 return CMD_SUCCESS
;
14132 /* Apply BGP information to distance method. */
14134 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, afi_t afi
,
14135 safi_t safi
, struct bgp
*bgp
)
14137 struct bgp_node
*rn
;
14140 struct bgp_distance
*bdistance
;
14141 struct access_list
*alist
;
14142 struct bgp_static
*bgp_static
;
14147 peer
= rinfo
->peer
;
14149 /* Check source address. */
14150 sockunion2hostprefix (&peer
->su
, &q
);
14151 rn
= bgp_node_match (bgp_distance_table
[afi
][safi
], &q
);
14154 bdistance
= rn
->info
;
14155 bgp_unlock_node (rn
);
14157 if (bdistance
->access_list
)
14159 alist
= access_list_lookup (afi
, bdistance
->access_list
);
14160 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
14161 return bdistance
->distance
;
14164 return bdistance
->distance
;
14167 /* Backdoor check. */
14168 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], p
);
14171 bgp_static
= rn
->info
;
14172 bgp_unlock_node (rn
);
14174 if (bgp_static
->backdoor
)
14176 if (bgp
->distance_local
[afi
][safi
])
14177 return bgp
->distance_local
[afi
][safi
];
14179 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
14183 if (peer
->sort
== BGP_PEER_EBGP
)
14185 if (bgp
->distance_ebgp
[afi
][safi
])
14186 return bgp
->distance_ebgp
[afi
][safi
];
14187 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
14191 if (bgp
->distance_ibgp
[afi
][safi
])
14192 return bgp
->distance_ibgp
[afi
][safi
];
14193 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
14197 DEFUN (bgp_distance
,
14199 "distance bgp <1-255> <1-255> <1-255>",
14200 "Define an administrative distance\n"
14202 "Distance for routes external to the AS\n"
14203 "Distance for routes internal to the AS\n"
14204 "Distance for local routes\n")
14211 afi
= bgp_node_afi (vty
);
14212 safi
= bgp_node_safi (vty
);
14214 bgp
->distance_ebgp
[afi
][safi
] = atoi (argv
[0]);
14215 bgp
->distance_ibgp
[afi
][safi
] = atoi (argv
[1]);
14216 bgp
->distance_local
[afi
][safi
] = atoi (argv
[2]);
14217 return CMD_SUCCESS
;
14220 DEFUN (no_bgp_distance
,
14221 no_bgp_distance_cmd
,
14222 "no distance bgp <1-255> <1-255> <1-255>",
14224 "Define an administrative distance\n"
14226 "Distance for routes external to the AS\n"
14227 "Distance for routes internal to the AS\n"
14228 "Distance for local routes\n")
14235 afi
= bgp_node_afi (vty
);
14236 safi
= bgp_node_safi (vty
);
14238 bgp
->distance_ebgp
[afi
][safi
] = 0;
14239 bgp
->distance_ibgp
[afi
][safi
] = 0;
14240 bgp
->distance_local
[afi
][safi
] = 0;
14241 return CMD_SUCCESS
;
14244 ALIAS (no_bgp_distance
,
14245 no_bgp_distance2_cmd
,
14248 "Define an administrative distance\n"
14251 DEFUN (bgp_distance_source
,
14252 bgp_distance_source_cmd
,
14253 "distance <1-255> A.B.C.D/M",
14254 "Define an administrative distance\n"
14255 "Administrative distance\n"
14256 "IP source prefix\n")
14258 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14259 return CMD_SUCCESS
;
14262 DEFUN (no_bgp_distance_source
,
14263 no_bgp_distance_source_cmd
,
14264 "no distance <1-255> A.B.C.D/M",
14266 "Define an administrative distance\n"
14267 "Administrative distance\n"
14268 "IP source prefix\n")
14270 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14271 return CMD_SUCCESS
;
14274 DEFUN (bgp_distance_source_access_list
,
14275 bgp_distance_source_access_list_cmd
,
14276 "distance <1-255> A.B.C.D/M WORD",
14277 "Define an administrative distance\n"
14278 "Administrative distance\n"
14279 "IP source prefix\n"
14280 "Access list name\n")
14282 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14283 return CMD_SUCCESS
;
14286 DEFUN (no_bgp_distance_source_access_list
,
14287 no_bgp_distance_source_access_list_cmd
,
14288 "no distance <1-255> A.B.C.D/M WORD",
14290 "Define an administrative distance\n"
14291 "Administrative distance\n"
14292 "IP source prefix\n"
14293 "Access list name\n")
14295 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14296 return CMD_SUCCESS
;
14299 DEFUN (ipv6_bgp_distance_source
,
14300 ipv6_bgp_distance_source_cmd
,
14301 "distance <1-255> X:X::X:X/M",
14302 "Define an administrative distance\n"
14303 "Administrative distance\n"
14304 "IP source prefix\n")
14306 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14307 return CMD_SUCCESS
;
14310 DEFUN (no_ipv6_bgp_distance_source
,
14311 no_ipv6_bgp_distance_source_cmd
,
14312 "no distance <1-255> X:X::X:X/M",
14314 "Define an administrative distance\n"
14315 "Administrative distance\n"
14316 "IP source prefix\n")
14318 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14319 return CMD_SUCCESS
;
14322 DEFUN (ipv6_bgp_distance_source_access_list
,
14323 ipv6_bgp_distance_source_access_list_cmd
,
14324 "distance <1-255> X:X::X:X/M WORD",
14325 "Define an administrative distance\n"
14326 "Administrative distance\n"
14327 "IP source prefix\n"
14328 "Access list name\n")
14330 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14331 return CMD_SUCCESS
;
14334 DEFUN (no_ipv6_bgp_distance_source_access_list
,
14335 no_ipv6_bgp_distance_source_access_list_cmd
,
14336 "no distance <1-255> X:X::X:X/M WORD",
14338 "Define an administrative distance\n"
14339 "Administrative distance\n"
14340 "IP source prefix\n"
14341 "Access list name\n")
14343 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14344 return CMD_SUCCESS
;
14347 DEFUN (bgp_damp_set
,
14349 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14350 "BGP Specific commands\n"
14351 "Enable route-flap dampening\n"
14352 "Half-life time for the penalty\n"
14353 "Value to start reusing a route\n"
14354 "Value to start suppressing a route\n"
14355 "Maximum duration to suppress a stable route\n")
14358 int half
= DEFAULT_HALF_LIFE
* 60;
14359 int reuse
= DEFAULT_REUSE
;
14360 int suppress
= DEFAULT_SUPPRESS
;
14361 int max
= 4 * half
;
14365 half
= atoi (argv
[0]) * 60;
14366 reuse
= atoi (argv
[1]);
14367 suppress
= atoi (argv
[2]);
14368 max
= atoi (argv
[3]) * 60;
14370 else if (argc
== 1)
14372 half
= atoi (argv
[0]) * 60;
14378 if (suppress
< reuse
)
14380 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
14385 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
14386 half
, reuse
, suppress
, max
);
14389 ALIAS (bgp_damp_set
,
14391 "bgp dampening <1-45>",
14392 "BGP Specific commands\n"
14393 "Enable route-flap dampening\n"
14394 "Half-life time for the penalty\n")
14396 ALIAS (bgp_damp_set
,
14399 "BGP Specific commands\n"
14400 "Enable route-flap dampening\n")
14402 DEFUN (bgp_damp_unset
,
14403 bgp_damp_unset_cmd
,
14404 "no bgp dampening",
14406 "BGP Specific commands\n"
14407 "Enable route-flap dampening\n")
14412 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
14415 ALIAS (bgp_damp_unset
,
14416 bgp_damp_unset2_cmd
,
14417 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14419 "BGP Specific commands\n"
14420 "Enable route-flap dampening\n"
14421 "Half-life time for the penalty\n"
14422 "Value to start reusing a route\n"
14423 "Value to start suppressing a route\n"
14424 "Maximum duration to suppress a stable route\n")
14426 ALIAS (bgp_damp_unset
,
14427 bgp_damp_unset3_cmd
,
14428 "no bgp dampening <1-45>",
14430 "BGP Specific commands\n"
14431 "Enable route-flap dampening\n"
14432 "Half-life time for the penalty\n")
14434 DEFUN (show_ip_bgp_dampened_paths
,
14435 show_ip_bgp_dampened_paths_cmd
,
14436 "show ip bgp dampened-paths",
14440 "Display paths suppressed due to dampening\n")
14442 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
14446 ALIAS (show_ip_bgp_dampened_paths
,
14447 show_ip_bgp_damp_dampened_paths_cmd
,
14448 "show ip bgp dampening dampened-paths",
14452 "Display detailed information about dampening\n"
14453 "Display paths suppressed due to dampening\n")
14455 DEFUN (show_ip_bgp_flap_statistics
,
14456 show_ip_bgp_flap_statistics_cmd
,
14457 "show ip bgp flap-statistics",
14461 "Display flap statistics of routes\n")
14463 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
14464 bgp_show_type_flap_statistics
, NULL
, 0);
14467 ALIAS (show_ip_bgp_flap_statistics
,
14468 show_ip_bgp_damp_flap_statistics_cmd
,
14469 "show ip bgp dampening flap-statistics",
14473 "Display detailed information about dampening\n"
14474 "Display flap statistics of routes\n")
14476 /* Display specified route of BGP table. */
14478 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
14479 const char *ip_str
, afi_t afi
, safi_t safi
,
14480 struct prefix_rd
*prd
, int prefix_check
)
14483 struct prefix match
;
14484 struct bgp_node
*rn
;
14485 struct bgp_node
*rm
;
14486 struct bgp_info
*ri
;
14487 struct bgp_info
*ri_temp
;
14489 struct bgp_table
*table
;
14491 /* BGP structure lookup. */
14494 bgp
= bgp_lookup_by_name (view_name
);
14497 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
14498 return CMD_WARNING
;
14503 bgp
= bgp_get_default ();
14506 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14507 return CMD_WARNING
;
14511 /* Check IP address argument. */
14512 ret
= str2prefix (ip_str
, &match
);
14515 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14516 return CMD_WARNING
;
14519 match
.family
= afi2family (afi
);
14521 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14523 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14525 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14528 if ((table
= rn
->info
) != NULL
)
14529 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14531 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14536 if (ri
->extra
&& ri
->extra
->damp_info
)
14538 ri_temp
= ri
->next
;
14539 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14547 bgp_unlock_node (rm
);
14553 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14555 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14560 if (ri
->extra
&& ri
->extra
->damp_info
)
14562 ri_temp
= ri
->next
;
14563 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14571 bgp_unlock_node (rn
);
14575 return CMD_SUCCESS
;
14578 DEFUN (clear_ip_bgp_dampening
,
14579 clear_ip_bgp_dampening_cmd
,
14580 "clear ip bgp dampening",
14584 "Clear route flap dampening information\n")
14586 bgp_damp_info_clean ();
14587 return CMD_SUCCESS
;
14590 DEFUN (clear_ip_bgp_dampening_prefix
,
14591 clear_ip_bgp_dampening_prefix_cmd
,
14592 "clear ip bgp dampening A.B.C.D/M",
14596 "Clear route flap dampening information\n"
14597 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14599 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14600 SAFI_UNICAST
, NULL
, 1);
14603 DEFUN (clear_ip_bgp_dampening_address
,
14604 clear_ip_bgp_dampening_address_cmd
,
14605 "clear ip bgp dampening A.B.C.D",
14609 "Clear route flap dampening information\n"
14610 "Network to clear damping information\n")
14612 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14613 SAFI_UNICAST
, NULL
, 0);
14616 DEFUN (clear_ip_bgp_dampening_address_mask
,
14617 clear_ip_bgp_dampening_address_mask_cmd
,
14618 "clear ip bgp dampening A.B.C.D A.B.C.D",
14622 "Clear route flap dampening information\n"
14623 "Network to clear damping information\n"
14627 char prefix_str
[BUFSIZ
];
14629 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14632 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14633 return CMD_WARNING
;
14636 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14637 SAFI_UNICAST
, NULL
, 0);
14640 /* also used for encap safi */
14642 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14643 afi_t afi
, safi_t safi
, int *write
)
14645 struct bgp_node
*prn
;
14646 struct bgp_node
*rn
;
14647 struct bgp_table
*table
;
14649 struct prefix_rd
*prd
;
14650 struct bgp_static
*bgp_static
;
14652 char buf
[SU_ADDRSTRLEN
];
14653 char rdbuf
[RD_ADDRSTRLEN
];
14655 /* Network configuration. */
14656 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14657 if ((table
= prn
->info
) != NULL
)
14658 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14659 if ((bgp_static
= rn
->info
) != NULL
)
14662 prd
= (struct prefix_rd
*) &prn
->p
;
14664 /* "address-family" display. */
14665 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14667 /* "network" configuration display. */
14668 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14669 label
= decode_label (bgp_static
->tag
);
14671 vty_out (vty
, " network %s/%d rd %s tag %d",
14672 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14675 vty_out (vty
, "%s", VTY_NEWLINE
);
14680 /* Configuration of static route announcement and aggregate
14683 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14684 afi_t afi
, safi_t safi
, int *write
)
14686 struct bgp_node
*rn
;
14688 struct bgp_static
*bgp_static
;
14689 struct bgp_aggregate
*bgp_aggregate
;
14690 char buf
[SU_ADDRSTRLEN
];
14692 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14693 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14695 /* Network configuration. */
14696 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14697 if ((bgp_static
= rn
->info
) != NULL
)
14701 /* "address-family" display. */
14702 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14704 /* "network" configuration display. */
14705 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14707 u_int32_t destination
;
14708 struct in_addr netmask
;
14710 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14711 masklen2ip (p
->prefixlen
, &netmask
);
14712 vty_out (vty
, " network %s",
14713 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14715 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14716 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14717 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14718 || p
->u
.prefix4
.s_addr
== 0)
14720 /* Natural mask is not display. */
14723 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14727 vty_out (vty
, " network %s/%d",
14728 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14732 if (bgp_static
->rmap
.name
)
14733 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14736 if (bgp_static
->backdoor
)
14737 vty_out (vty
, " backdoor");
14740 vty_out (vty
, "%s", VTY_NEWLINE
);
14743 /* Aggregate-address configuration. */
14744 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14745 if ((bgp_aggregate
= rn
->info
) != NULL
)
14749 /* "address-family" display. */
14750 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14752 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14754 struct in_addr netmask
;
14756 masklen2ip (p
->prefixlen
, &netmask
);
14757 vty_out (vty
, " aggregate-address %s %s",
14758 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14759 inet_ntoa (netmask
));
14763 vty_out (vty
, " aggregate-address %s/%d",
14764 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14768 if (bgp_aggregate
->as_set
)
14769 vty_out (vty
, " as-set");
14771 if (bgp_aggregate
->summary_only
)
14772 vty_out (vty
, " summary-only");
14774 vty_out (vty
, "%s", VTY_NEWLINE
);
14781 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
14782 safi_t safi
, int *write
)
14784 struct bgp_node
*rn
;
14785 struct bgp_distance
*bdistance
;
14787 /* Distance configuration. */
14788 if (bgp
->distance_ebgp
[afi
][safi
]
14789 && bgp
->distance_ibgp
[afi
][safi
]
14790 && bgp
->distance_local
[afi
][safi
]
14791 && (bgp
->distance_ebgp
[afi
][safi
] != ZEBRA_EBGP_DISTANCE_DEFAULT
14792 || bgp
->distance_ibgp
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
14793 || bgp
->distance_local
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
))
14795 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14796 vty_out (vty
, " distance bgp %d %d %d%s",
14797 bgp
->distance_ebgp
[afi
][safi
], bgp
->distance_ibgp
[afi
][safi
],
14798 bgp
->distance_local
[afi
][safi
], VTY_NEWLINE
);
14801 for (rn
= bgp_table_top (bgp_distance_table
[afi
][safi
]); rn
;
14802 rn
= bgp_route_next (rn
))
14803 if ((bdistance
= rn
->info
) != NULL
)
14805 char buf
[PREFIX_STRLEN
];
14807 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14808 vty_out (vty
, " distance %d %s %s%s", bdistance
->distance
,
14809 prefix2str (&rn
->p
, buf
, sizeof (buf
)),
14810 bdistance
->access_list
? bdistance
->access_list
: "",
14817 /* Allocate routing table structure and install commands. */
14819 bgp_route_init (void)
14824 /* Init BGP distance table. */
14825 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
14826 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
14827 bgp_distance_table
[afi
][safi
] = bgp_table_init (afi
, safi
);
14829 /* IPv4 BGP commands. */
14830 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14831 install_element (BGP_NODE
, &bgp_network_cmd
);
14832 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14833 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14834 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14835 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14836 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14837 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14838 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14839 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14840 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14841 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14842 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14843 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14844 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14845 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14846 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14847 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14848 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14849 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14851 install_element (BGP_NODE
, &aggregate_address_cmd
);
14852 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14853 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14854 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14855 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14856 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14857 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14858 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14859 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14860 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14861 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14862 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14863 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14864 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14865 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14866 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14867 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14868 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14869 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14870 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14872 /* IPv4 unicast configuration. */
14873 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14874 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14875 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14876 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14877 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14878 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14879 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14880 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14881 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14882 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14883 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14884 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14885 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14886 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14888 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14889 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14890 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14891 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14892 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14893 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14894 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14895 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14896 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14897 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14898 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14899 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14900 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14901 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14902 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14903 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14904 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14905 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14906 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14907 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14909 /* IPv4 multicast configuration. */
14910 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14911 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14912 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14913 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14914 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14915 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14916 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14917 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14918 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14919 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14920 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14921 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14922 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14923 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14924 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14925 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14926 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14927 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14928 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14929 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14930 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14931 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14932 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14933 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14934 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14935 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14936 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14937 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14938 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14939 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14940 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14941 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14942 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14943 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14945 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14946 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14947 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14948 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14949 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14950 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14951 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14952 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14953 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14954 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14955 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14956 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14957 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_route_cmd
);
14958 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_route_cmd
);
14959 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14960 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14961 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14962 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14963 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14964 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14965 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14966 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14967 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_prefix_cmd
);
14968 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_prefix_cmd
);
14970 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14971 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14972 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14973 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14974 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14975 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14976 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14977 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14978 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14979 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14980 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14981 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14982 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14983 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14984 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14985 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14986 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14987 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14988 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14989 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14990 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14991 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14992 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14993 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14994 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14995 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14996 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14997 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14998 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14999 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
15000 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
15001 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
15002 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
15003 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
15004 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
15005 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
15006 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
15007 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
15008 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
15009 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
15010 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
15011 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
15012 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
15013 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
15014 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
15015 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
15016 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
15017 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
15018 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
15019 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
15020 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
15021 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
15022 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
15023 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
15024 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
15025 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
15026 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
15027 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
15028 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
15029 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
15030 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
15031 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
15032 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
15033 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
15034 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
15035 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
15036 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
15037 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
15038 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
15039 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
15040 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
15041 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
15042 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
15043 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
15044 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
15045 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
15046 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
15047 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
15048 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
15049 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
15050 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
15051 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
15052 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
15053 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
15054 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
15055 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
15057 install_element (VIEW_NODE
, &show_bgp_ipv4_prefix_cmd
);
15058 install_element (VIEW_NODE
, &show_bgp_ipv4_vpn_rd_route_cmd
);
15059 install_element (VIEW_NODE
, &show_bgp_ipv4_vpn_route_cmd
);
15061 install_element (VIEW_NODE
, &show_bgp_ipv6_vpn_rd_route_cmd
);
15062 install_element (VIEW_NODE
, &show_bgp_ipv6_vpn_route_cmd
);
15064 /* BGP dampening clear commands */
15065 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
15066 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
15067 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
15068 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
15071 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
15072 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
15073 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
15074 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd
);
15076 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
15077 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
15079 /* New config IPv6 BGP commands. */
15080 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
15081 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
15082 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
15083 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
15084 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
15085 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
15087 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
15088 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
15089 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
15090 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
15092 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
15093 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
15095 /* Old config IPv6 BGP commands. */
15096 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
15097 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
15099 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
15100 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
15101 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
15102 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
15104 install_element (VIEW_NODE
, &show_bgp_cmd
);
15105 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
15106 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
15107 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
15108 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
15109 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
15110 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
15111 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
15112 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
15113 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
15114 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
15115 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
15116 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
15117 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
15118 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
15119 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
15120 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
15121 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
15122 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
15123 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
15124 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
15125 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
15126 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
15127 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
15128 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
15129 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
15130 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
15131 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
15132 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
15133 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
15134 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
15135 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
15136 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
15137 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
15138 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
15139 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
15140 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
15141 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
15142 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
15143 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
15144 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
15145 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
15146 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
15147 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
15148 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
15149 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
15150 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
15151 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
15152 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
15153 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
15154 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
15155 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
15156 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
15157 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
15158 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
15159 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
15160 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
15161 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
15162 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
15163 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
15164 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
15165 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
15166 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
15167 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
15168 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
15169 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
15170 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
15171 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
15172 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
15173 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
15174 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
15175 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
15176 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
15177 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
15178 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
15179 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
15180 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
15181 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
15182 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
15183 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
15184 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
15185 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
15186 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
15187 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
15188 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
15189 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
15190 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
15191 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
15192 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
15193 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
15194 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
15195 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
15198 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
15199 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
15200 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
15201 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
15204 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
15205 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
15206 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
15207 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
15208 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
15209 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
15210 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
15211 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
15212 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
15213 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
15214 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
15215 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
15216 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
15217 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
15218 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
15219 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
15220 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15221 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15222 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
15223 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
15224 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15225 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15226 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15227 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15228 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15229 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
15230 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
15231 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
15232 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
15233 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15234 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
15235 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
15236 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
15237 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15238 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15239 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15242 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
15243 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15246 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
15247 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15250 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
15251 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15252 #endif /* HAVE_IPV6 */
15254 install_element (BGP_NODE
, &bgp_distance_cmd
);
15255 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
15256 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
15257 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
15258 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
15259 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
15260 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
15261 install_element (BGP_IPV4_NODE
, &bgp_distance_cmd
);
15262 install_element (BGP_IPV4_NODE
, &no_bgp_distance_cmd
);
15263 install_element (BGP_IPV4_NODE
, &no_bgp_distance2_cmd
);
15264 install_element (BGP_IPV4_NODE
, &bgp_distance_source_cmd
);
15265 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_cmd
);
15266 install_element (BGP_IPV4_NODE
, &bgp_distance_source_access_list_cmd
);
15267 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_access_list_cmd
);
15268 install_element (BGP_IPV4M_NODE
, &bgp_distance_cmd
);
15269 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_cmd
);
15270 install_element (BGP_IPV4M_NODE
, &no_bgp_distance2_cmd
);
15271 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_cmd
);
15272 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_cmd
);
15273 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_access_list_cmd
);
15274 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_access_list_cmd
);
15275 install_element (BGP_IPV6_NODE
, &bgp_distance_cmd
);
15276 install_element (BGP_IPV6_NODE
, &no_bgp_distance_cmd
);
15277 install_element (BGP_IPV6_NODE
, &no_bgp_distance2_cmd
);
15278 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_cmd
);
15279 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15280 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15281 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15282 install_element (BGP_IPV6M_NODE
, &bgp_distance_cmd
);
15283 install_element (BGP_IPV6M_NODE
, &no_bgp_distance_cmd
);
15284 install_element (BGP_IPV6M_NODE
, &no_bgp_distance2_cmd
);
15285 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_cmd
);
15286 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15287 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15288 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15290 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15291 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15292 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15293 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15294 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15295 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15296 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15297 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15298 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15299 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15300 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15301 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15303 /* IPv4 Multicast Mode */
15304 install_element (BGP_IPV4M_NODE
, &bgp_damp_set_cmd
);
15305 install_element (BGP_IPV4M_NODE
, &bgp_damp_set2_cmd
);
15306 install_element (BGP_IPV4M_NODE
, &bgp_damp_set3_cmd
);
15307 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset_cmd
);
15308 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset2_cmd
);
15312 bgp_route_finish (void)
15317 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
15318 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
15320 bgp_table_unlock (bgp_distance_table
[afi
][safi
]);
15321 bgp_distance_table
[afi
][safi
] = NULL
;