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
33 #include "sockunion.h"
36 #include "workqueue.h"
40 #include "bgpd/bgpd.h"
41 #include "bgpd/bgp_table.h"
42 #include "bgpd/bgp_route.h"
43 #include "bgpd/bgp_attr.h"
44 #include "bgpd/bgp_debug.h"
45 #include "bgpd/bgp_aspath.h"
46 #include "bgpd/bgp_regex.h"
47 #include "bgpd/bgp_community.h"
48 #include "bgpd/bgp_ecommunity.h"
49 #include "bgpd/bgp_clist.h"
50 #include "bgpd/bgp_packet.h"
51 #include "bgpd/bgp_filter.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_mplsvpn.h"
54 #include "bgpd/bgp_nexthop.h"
55 #include "bgpd/bgp_damp.h"
56 #include "bgpd/bgp_advertise.h"
57 #include "bgpd/bgp_zebra.h"
58 #include "bgpd/bgp_vty.h"
59 #include "bgpd/bgp_mpath.h"
60 #include "bgpd/bgp_nht.h"
61 #include "bgpd/bgp_updgrp.h"
62 #include "bgpd/bgp_vty.h"
65 #include "bgpd/rfapi/rfapi_backend.h"
66 #include "bgpd/rfapi/vnc_import_bgp.h"
67 #include "bgpd/rfapi/vnc_export_bgp.h"
70 /* Extern from bgp_dump.c */
71 extern const char *bgp_origin_str
[];
72 extern const char *bgp_origin_long_str
[];
75 bgp_afi_node_get (struct bgp_table
*table
, afi_t afi
, safi_t safi
, struct prefix
*p
,
76 struct prefix_rd
*prd
)
79 struct bgp_node
*prn
= NULL
;
85 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
87 prn
= bgp_node_get (table
, (struct prefix
*) prd
);
89 if (prn
->info
== NULL
)
90 prn
->info
= bgp_table_init (afi
, safi
);
92 bgp_unlock_node (prn
);
96 rn
= bgp_node_get (table
, p
);
98 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
104 /* Allocate bgp_info_extra */
105 static struct bgp_info_extra
*
106 bgp_info_extra_new (void)
108 struct bgp_info_extra
*new;
109 new = XCALLOC (MTYPE_BGP_ROUTE_EXTRA
, sizeof (struct bgp_info_extra
));
114 bgp_info_extra_free (struct bgp_info_extra
**extra
)
118 if ((*extra
)->damp_info
)
119 bgp_damp_info_free ((*extra
)->damp_info
, 0);
121 (*extra
)->damp_info
= NULL
;
123 XFREE (MTYPE_BGP_ROUTE_EXTRA
, *extra
);
129 /* Get bgp_info extra information for the given bgp_info, lazy allocated
132 struct bgp_info_extra
*
133 bgp_info_extra_get (struct bgp_info
*ri
)
136 ri
->extra
= bgp_info_extra_new();
140 /* Allocate new bgp info structure. */
144 return XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
147 /* Free bgp route information. */
149 bgp_info_free (struct bgp_info
*binfo
)
152 bgp_attr_unintern (&binfo
->attr
);
154 bgp_unlink_nexthop(binfo
);
155 bgp_info_extra_free (&binfo
->extra
);
156 bgp_info_mpath_free (&binfo
->mpath
);
158 peer_unlock (binfo
->peer
); /* bgp_info peer reference */
160 XFREE (MTYPE_BGP_ROUTE
, binfo
);
164 bgp_info_lock (struct bgp_info
*binfo
)
171 bgp_info_unlock (struct bgp_info
*binfo
)
173 assert (binfo
&& binfo
->lock
> 0);
176 if (binfo
->lock
== 0)
179 zlog_debug ("%s: unlocked and freeing", __func__
);
180 zlog_backtrace (LOG_DEBUG
);
182 bgp_info_free (binfo
);
187 if (binfo
->lock
== 1)
189 zlog_debug ("%s: unlocked to 1", __func__
);
190 zlog_backtrace (LOG_DEBUG
);
198 bgp_info_add (struct bgp_node
*rn
, struct bgp_info
*ri
)
200 struct bgp_info
*top
;
212 peer_lock (ri
->peer
); /* bgp_info peer reference */
215 /* Do the actual removal of info from RIB, for use by bgp_process
216 completion callback *only* */
218 bgp_info_reap (struct bgp_node
*rn
, struct bgp_info
*ri
)
221 ri
->next
->prev
= ri
->prev
;
223 ri
->prev
->next
= ri
->next
;
227 bgp_info_mpath_dequeue (ri
);
228 bgp_info_unlock (ri
);
229 bgp_unlock_node (rn
);
233 bgp_info_delete (struct bgp_node
*rn
, struct bgp_info
*ri
)
235 bgp_info_set_flag (rn
, ri
, BGP_INFO_REMOVED
);
236 /* set of previous already took care of pcount */
237 UNSET_FLAG (ri
->flags
, BGP_INFO_VALID
);
240 /* undo the effects of a previous call to bgp_info_delete; typically
241 called when a route is deleted and then quickly re-added before the
242 deletion has been processed */
244 bgp_info_restore (struct bgp_node
*rn
, struct bgp_info
*ri
)
246 bgp_info_unset_flag (rn
, ri
, BGP_INFO_REMOVED
);
247 /* unset of previous already took care of pcount */
248 SET_FLAG (ri
->flags
, BGP_INFO_VALID
);
251 /* Adjust pcount as required */
253 bgp_pcount_adjust (struct bgp_node
*rn
, struct bgp_info
*ri
)
255 struct bgp_table
*table
;
257 assert (rn
&& bgp_node_table (rn
));
258 assert (ri
&& ri
->peer
&& ri
->peer
->bgp
);
260 table
= bgp_node_table (rn
);
262 if (ri
->peer
== ri
->peer
->bgp
->peer_self
)
265 if (!BGP_INFO_COUNTABLE (ri
)
266 && CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
269 UNSET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
271 /* slight hack, but more robust against errors. */
272 if (ri
->peer
->pcount
[table
->afi
][table
->safi
])
273 ri
->peer
->pcount
[table
->afi
][table
->safi
]--;
276 zlog_warn ("%s: Asked to decrement 0 prefix count for peer %s",
277 __func__
, ri
->peer
->host
);
278 zlog_backtrace (LOG_WARNING
);
279 zlog_warn ("%s: Please report to Quagga bugzilla", __func__
);
282 else if (BGP_INFO_COUNTABLE (ri
)
283 && !CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
285 SET_FLAG (ri
->flags
, BGP_INFO_COUNTED
);
286 ri
->peer
->pcount
[table
->afi
][table
->safi
]++;
291 /* Set/unset bgp_info flags, adjusting any other state as needed.
292 * This is here primarily to keep prefix-count in check.
295 bgp_info_set_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
297 SET_FLAG (ri
->flags
, flag
);
299 /* early bath if we know it's not a flag that changes countability state */
300 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
303 bgp_pcount_adjust (rn
, ri
);
307 bgp_info_unset_flag (struct bgp_node
*rn
, struct bgp_info
*ri
, u_int32_t flag
)
309 UNSET_FLAG (ri
->flags
, flag
);
311 /* early bath if we know it's not a flag that changes countability state */
312 if (!CHECK_FLAG (flag
, BGP_INFO_VALID
|BGP_INFO_HISTORY
|BGP_INFO_REMOVED
))
315 bgp_pcount_adjust (rn
, ri
);
318 /* Get MED value. If MED value is missing and "bgp bestpath
319 missing-as-worst" is specified, treat it as the worst value. */
321 bgp_med_value (struct attr
*attr
, struct bgp
*bgp
)
323 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
327 if (bgp_flag_check (bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
335 bgp_info_path_with_addpath_rx_str (struct bgp_info
*ri
, char *buf
)
337 if (ri
->addpath_rx_id
)
338 sprintf(buf
, "path %s (addpath rxid %d)", ri
->peer
->host
, ri
->addpath_rx_id
);
340 sprintf(buf
, "path %s", ri
->peer
->host
);
343 /* Compare two bgp route entity. If 'new' is preferable over 'exist' return 1. */
345 bgp_info_cmp (struct bgp
*bgp
, struct bgp_info
*new, struct bgp_info
*exist
,
346 int *paths_eq
, struct bgp_maxpaths_cfg
*mpath_cfg
, int debug
,
349 struct attr
*newattr
, *existattr
;
350 struct attr_extra
*newattre
, *existattre
;
351 bgp_peer_sort_t new_sort
;
352 bgp_peer_sort_t exist_sort
;
354 u_int32_t exist_pref
;
357 u_int32_t new_weight
;
358 u_int32_t exist_weight
;
359 uint32_t newm
, existm
;
360 struct in_addr new_id
;
361 struct in_addr exist_id
;
364 int internal_as_route
;
367 char new_buf
[PATH_ADDPATH_STR_BUFFER
];
368 char exist_buf
[PATH_ADDPATH_STR_BUFFER
];
376 zlog_debug("%s: new is NULL", pfx_buf
);
381 bgp_info_path_with_addpath_rx_str (new, new_buf
);
386 zlog_debug("%s: %s is the initial bestpath", pfx_buf
, new_buf
);
392 bgp_info_path_with_addpath_rx_str (exist
, exist_buf
);
393 zlog_debug("%s: Comparing %s flags 0x%x with %s flags 0x%x",
394 pfx_buf
, new_buf
, new->flags
, exist_buf
, exist
->flags
);
398 existattr
= exist
->attr
;
399 newattre
= newattr
->extra
;
400 existattre
= existattr
->extra
;
402 /* 1. Weight check. */
403 new_weight
= exist_weight
= 0;
406 new_weight
= newattre
->weight
;
408 exist_weight
= existattre
->weight
;
410 if (new_weight
> exist_weight
)
413 zlog_debug("%s: %s wins over %s due to weight %d > %d",
414 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
418 if (new_weight
< exist_weight
)
421 zlog_debug("%s: %s loses to %s due to weight %d < %d",
422 pfx_buf
, new_buf
, exist_buf
, new_weight
, exist_weight
);
426 /* 2. Local preference check. */
427 new_pref
= exist_pref
= bgp
->default_local_pref
;
429 if (newattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
430 new_pref
= newattr
->local_pref
;
431 if (existattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
432 exist_pref
= existattr
->local_pref
;
434 if (new_pref
> exist_pref
)
437 zlog_debug("%s: %s wins over %s due to localpref %d > %d",
438 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
442 if (new_pref
< exist_pref
)
445 zlog_debug("%s: %s loses to %s due to localpref %d < %d",
446 pfx_buf
, new_buf
, exist_buf
, new_pref
, exist_pref
);
450 /* 3. Local route check. We prefer:
452 * - BGP_ROUTE_AGGREGATE
453 * - BGP_ROUTE_REDISTRIBUTE
455 if (! (new->sub_type
== BGP_ROUTE_NORMAL
))
458 zlog_debug("%s: %s wins over %s due to preferred BGP_ROUTE type",
459 pfx_buf
, new_buf
, exist_buf
);
463 if (! (exist
->sub_type
== BGP_ROUTE_NORMAL
))
466 zlog_debug("%s: %s loses to %s due to preferred BGP_ROUTE type",
467 pfx_buf
, new_buf
, exist_buf
);
471 /* 4. AS path length check. */
472 if (! bgp_flag_check (bgp
, BGP_FLAG_ASPATH_IGNORE
))
474 int exist_hops
= aspath_count_hops (existattr
->aspath
);
475 int exist_confeds
= aspath_count_confeds (existattr
->aspath
);
477 if (bgp_flag_check (bgp
, BGP_FLAG_ASPATH_CONFED
))
481 aspath_hops
= aspath_count_hops (newattr
->aspath
);
482 aspath_hops
+= aspath_count_confeds (newattr
->aspath
);
484 if ( aspath_hops
< (exist_hops
+ exist_confeds
))
487 zlog_debug("%s: %s wins over %s due to aspath (with confeds) hopcount %d < %d",
488 pfx_buf
, new_buf
, exist_buf
,
489 aspath_hops
, (exist_hops
+ exist_confeds
));
493 if ( aspath_hops
> (exist_hops
+ exist_confeds
))
496 zlog_debug("%s: %s loses to %s due to aspath (with confeds) hopcount %d > %d",
497 pfx_buf
, new_buf
, exist_buf
,
498 aspath_hops
, (exist_hops
+ exist_confeds
));
504 int newhops
= aspath_count_hops (newattr
->aspath
);
506 if (newhops
< exist_hops
)
509 zlog_debug("%s: %s wins over %s due to aspath hopcount %d < %d",
510 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
514 if (newhops
> exist_hops
)
517 zlog_debug("%s: %s loses to %s due to aspath hopcount %d > %d",
518 pfx_buf
, new_buf
, exist_buf
, newhops
, exist_hops
);
524 /* 5. Origin check. */
525 if (newattr
->origin
< existattr
->origin
)
528 zlog_debug("%s: %s wins over %s due to ORIGIN %s < %s",
529 pfx_buf
, new_buf
, exist_buf
,
530 bgp_origin_long_str
[newattr
->origin
],
531 bgp_origin_long_str
[existattr
->origin
]);
535 if (newattr
->origin
> existattr
->origin
)
538 zlog_debug("%s: %s loses to %s due to ORIGIN %s > %s",
539 pfx_buf
, new_buf
, exist_buf
,
540 bgp_origin_long_str
[newattr
->origin
],
541 bgp_origin_long_str
[existattr
->origin
]);
546 internal_as_route
= (aspath_count_hops (newattr
->aspath
) == 0
547 && aspath_count_hops (existattr
->aspath
) == 0);
548 confed_as_route
= (aspath_count_confeds (newattr
->aspath
) > 0
549 && aspath_count_confeds (existattr
->aspath
) > 0
550 && aspath_count_hops (newattr
->aspath
) == 0
551 && aspath_count_hops (existattr
->aspath
) == 0);
553 if (bgp_flag_check (bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
)
554 || (bgp_flag_check (bgp
, BGP_FLAG_MED_CONFED
)
556 || aspath_cmp_left (newattr
->aspath
, existattr
->aspath
)
557 || aspath_cmp_left_confed (newattr
->aspath
, existattr
->aspath
)
558 || internal_as_route
)
560 new_med
= bgp_med_value (new->attr
, bgp
);
561 exist_med
= bgp_med_value (exist
->attr
, bgp
);
563 if (new_med
< exist_med
)
566 zlog_debug("%s: %s wins over %s due to MED %d < %d",
567 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
571 if (new_med
> exist_med
)
574 zlog_debug("%s: %s loses to %s due to MED %d > %d",
575 pfx_buf
, new_buf
, exist_buf
, new_med
, exist_med
);
580 /* 7. Peer type check. */
581 new_sort
= new->peer
->sort
;
582 exist_sort
= exist
->peer
->sort
;
584 if (new_sort
== BGP_PEER_EBGP
585 && (exist_sort
== BGP_PEER_IBGP
|| exist_sort
== BGP_PEER_CONFED
))
588 zlog_debug("%s: %s wins over %s due to eBGP peer > iBGP peer",
589 pfx_buf
, new_buf
, exist_buf
);
593 if (exist_sort
== BGP_PEER_EBGP
594 && (new_sort
== BGP_PEER_IBGP
|| new_sort
== BGP_PEER_CONFED
))
597 zlog_debug("%s: %s loses to %s due to iBGP peer < eBGP peer",
598 pfx_buf
, new_buf
, exist_buf
);
602 /* 8. IGP metric check. */
606 newm
= new->extra
->igpmetric
;
608 existm
= exist
->extra
->igpmetric
;
613 zlog_debug("%s: %s wins over %s due to IGP metric %d < %d",
614 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
621 zlog_debug("%s: %s loses to %s due to IGP metric %d > %d",
622 pfx_buf
, new_buf
, exist_buf
, newm
, existm
);
626 /* 9. Same IGP metric. Compare the cluster list length as
627 representative of IGP hops metric. Rewrite the metric value
628 pair (newm, existm) with the cluster list length. Prefer the
629 path with smaller cluster list length. */
632 if (peer_sort (new->peer
) == BGP_PEER_IBGP
633 && peer_sort (exist
->peer
) == BGP_PEER_IBGP
634 && (mpath_cfg
== NULL
||
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
)
873 ret
= bgp_info_cmp (bgp
, new, exist
, &paths_eq
, NULL
, 0, __func__
);
887 static enum filter_type
888 bgp_input_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
889 afi_t afi
, safi_t safi
)
891 struct bgp_filter
*filter
;
893 filter
= &peer
->filter
[afi
][safi
];
895 #define FILTER_EXIST_WARN(F,f,filter) \
896 if (BGP_DEBUG (update, UPDATE_IN) \
897 && !(F ## _IN (filter))) \
898 zlog_warn ("%s: Could not find configured input %s-list %s!", \
899 peer->host, #f, F ## _IN_NAME(filter));
901 if (DISTRIBUTE_IN_NAME (filter
)) {
902 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
904 if (access_list_apply (DISTRIBUTE_IN (filter
), p
) == FILTER_DENY
)
908 if (PREFIX_LIST_IN_NAME (filter
)) {
909 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
911 if (prefix_list_apply (PREFIX_LIST_IN (filter
), p
) == PREFIX_DENY
)
915 if (FILTER_LIST_IN_NAME (filter
)) {
916 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
918 if (as_list_apply (FILTER_LIST_IN (filter
), attr
->aspath
)== AS_FILTER_DENY
)
922 return FILTER_PERMIT
;
923 #undef FILTER_EXIST_WARN
926 static enum filter_type
927 bgp_output_filter (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
928 afi_t afi
, safi_t safi
)
930 struct bgp_filter
*filter
;
932 filter
= &peer
->filter
[afi
][safi
];
934 #define FILTER_EXIST_WARN(F,f,filter) \
935 if (BGP_DEBUG (update, UPDATE_OUT) \
936 && !(F ## _OUT (filter))) \
937 zlog_warn ("%s: Could not find configured output %s-list %s!", \
938 peer->host, #f, F ## _OUT_NAME(filter));
940 if (DISTRIBUTE_OUT_NAME (filter
)) {
941 FILTER_EXIST_WARN(DISTRIBUTE
, distribute
, filter
);
943 if (access_list_apply (DISTRIBUTE_OUT (filter
), p
) == FILTER_DENY
)
947 if (PREFIX_LIST_OUT_NAME (filter
)) {
948 FILTER_EXIST_WARN(PREFIX_LIST
, prefix
, filter
);
950 if (prefix_list_apply (PREFIX_LIST_OUT (filter
), p
) == PREFIX_DENY
)
954 if (FILTER_LIST_OUT_NAME (filter
)) {
955 FILTER_EXIST_WARN(FILTER_LIST
, as
, filter
);
957 if (as_list_apply (FILTER_LIST_OUT (filter
), attr
->aspath
) == AS_FILTER_DENY
)
961 return FILTER_PERMIT
;
962 #undef FILTER_EXIST_WARN
965 /* If community attribute includes no_export then return 1. */
967 bgp_community_filter (struct peer
*peer
, struct attr
*attr
)
971 /* NO_ADVERTISE check. */
972 if (community_include (attr
->community
, COMMUNITY_NO_ADVERTISE
))
975 /* NO_EXPORT check. */
976 if (peer
->sort
== BGP_PEER_EBGP
&&
977 community_include (attr
->community
, COMMUNITY_NO_EXPORT
))
980 /* NO_EXPORT_SUBCONFED check. */
981 if (peer
->sort
== BGP_PEER_EBGP
982 || peer
->sort
== BGP_PEER_CONFED
)
983 if (community_include (attr
->community
, COMMUNITY_NO_EXPORT_SUBCONFED
))
989 /* Route reflection loop check. */
991 bgp_cluster_filter (struct peer
*peer
, struct attr
*attr
)
993 struct in_addr cluster_id
;
995 if (attr
->extra
&& attr
->extra
->cluster
)
997 if (peer
->bgp
->config
& BGP_CONFIG_CLUSTER_ID
)
998 cluster_id
= peer
->bgp
->cluster_id
;
1000 cluster_id
= peer
->bgp
->router_id
;
1002 if (cluster_loop_check (attr
->extra
->cluster
, cluster_id
))
1009 bgp_input_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1010 afi_t afi
, safi_t safi
, const char *rmap_name
)
1012 struct bgp_filter
*filter
;
1013 struct bgp_info info
;
1014 route_map_result_t ret
;
1015 struct route_map
*rmap
= NULL
;
1017 filter
= &peer
->filter
[afi
][safi
];
1019 /* Apply default weight value. */
1020 if (peer
->weight
[afi
][safi
])
1021 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
[afi
][safi
];
1025 rmap
= route_map_lookup_by_name(rmap_name
);
1032 if (ROUTE_MAP_IN_NAME(filter
))
1034 rmap
= ROUTE_MAP_IN (filter
);
1041 /* Route map apply. */
1044 /* Duplicate current value to new strucutre for modification. */
1048 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_IN
);
1050 /* Apply BGP route map to the attribute. */
1051 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1053 peer
->rmap_type
= 0;
1055 if (ret
== RMAP_DENYMATCH
)
1057 /* Free newly generated AS path and community by route-map. */
1058 bgp_attr_flush (attr
);
1066 bgp_output_modifier (struct peer
*peer
, struct prefix
*p
, struct attr
*attr
,
1067 afi_t afi
, safi_t safi
, const char *rmap_name
)
1069 struct bgp_filter
*filter
;
1070 struct bgp_info info
;
1071 route_map_result_t ret
;
1072 struct route_map
*rmap
= NULL
;
1074 filter
= &peer
->filter
[afi
][safi
];
1076 /* Apply default weight value. */
1077 if (peer
->weight
[afi
][safi
])
1078 (bgp_attr_extra_get (attr
))->weight
= peer
->weight
[afi
][safi
];
1082 rmap
= route_map_lookup_by_name(rmap_name
);
1089 if (ROUTE_MAP_OUT_NAME(filter
))
1091 rmap
= ROUTE_MAP_OUT (filter
);
1098 /* Route map apply. */
1101 /* Duplicate current value to new strucutre for modification. */
1105 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1107 /* Apply BGP route map to the attribute. */
1108 ret
= route_map_apply (rmap
, p
, RMAP_BGP
, &info
);
1110 peer
->rmap_type
= 0;
1112 if (ret
== RMAP_DENYMATCH
)
1113 /* caller has multiple error paths with bgp_attr_flush() */
1119 /* If this is an EBGP peer with remove-private-AS */
1121 bgp_peer_remove_private_as(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1122 struct peer
*peer
, struct attr
*attr
)
1124 if (peer
->sort
== BGP_PEER_EBGP
&&
1125 (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1126 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
) ||
1127 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
) ||
1128 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS
)))
1130 // Take action on the entire aspath
1131 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
) ||
1132 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
1134 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
1135 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1137 // The entire aspath consists of private ASNs so create an empty aspath
1138 else if (aspath_private_as_check (attr
->aspath
))
1139 attr
->aspath
= aspath_empty_get ();
1141 // There are some public and some private ASNs, remove the private ASNs
1143 attr
->aspath
= aspath_remove_private_asns (attr
->aspath
);
1146 // 'all' was not specified so the entire aspath must be private ASNs
1147 // for us to do anything
1148 else if (aspath_private_as_check (attr
->aspath
))
1150 if (peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
1151 attr
->aspath
= aspath_replace_private_asns (attr
->aspath
, bgp
->as
);
1153 attr
->aspath
= aspath_empty_get ();
1158 /* If this is an EBGP peer with as-override */
1160 bgp_peer_as_override(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1161 struct peer
*peer
, struct attr
*attr
)
1163 if (peer
->sort
== BGP_PEER_EBGP
&&
1164 peer_af_flag_check (peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
))
1166 if (aspath_single_asn_check (attr
->aspath
, peer
->as
))
1167 attr
->aspath
= aspath_replace_specific_asn (attr
->aspath
, peer
->as
, bgp
->as
);
1172 subgroup_announce_reset_nhop (u_char family
, struct attr
*attr
)
1174 if (family
== AF_INET
)
1175 attr
->nexthop
.s_addr
= 0;
1177 if (family
== AF_INET6
)
1178 memset (&attr
->extra
->mp_nexthop_global
, 0, IPV6_MAX_BYTELEN
);
1183 subgroup_announce_check (struct bgp_info
*ri
, struct update_subgroup
*subgrp
,
1184 struct prefix
*p
, struct attr
*attr
)
1186 struct bgp_filter
*filter
;
1189 struct peer
*onlypeer
;
1191 struct attr
*riattr
;
1192 struct peer_af
*paf
;
1193 char buf
[SU_ADDRSTRLEN
];
1199 int samepeer_safe
= 0; /* for synthetic mplsvpns routes */
1201 if (DISABLE_BGP_ANNOUNCE
)
1204 afi
= SUBGRP_AFI(subgrp
);
1205 safi
= SUBGRP_SAFI(subgrp
);
1206 peer
= SUBGRP_PEER(subgrp
);
1208 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_LONESOUL
))
1209 onlypeer
= SUBGRP_PFIRST(subgrp
)->peer
;
1212 filter
= &peer
->filter
[afi
][safi
];
1213 bgp
= SUBGRP_INST(subgrp
);
1214 riattr
= bgp_info_mpath_count (ri
) ? bgp_info_mpath_attr (ri
) : ri
->attr
;
1217 if (((afi
== AFI_IP
) || (afi
== AFI_IP6
)) && (safi
== SAFI_MPLS_VPN
) &&
1218 ((ri
->type
== ZEBRA_ROUTE_BGP_DIRECT
) ||
1219 (ri
->type
== ZEBRA_ROUTE_BGP_DIRECT_EXT
))) {
1222 * direct and direct_ext type routes originate internally even
1223 * though they can have peer pointers that reference other systems
1226 prefix2str(p
, buf
, BUFSIZ
);
1227 zlog_debug("%s: pfx %s bgp_direct->vpn route peer safe", __func__
, buf
);
1232 /* With addpath we may be asked to TX all kinds of paths so make sure
1234 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
) ||
1235 CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
) ||
1236 CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
1241 /* If this is not the bestpath then check to see if there is an enabled addpath
1242 * feature that requires us to advertise it */
1243 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1245 if (! bgp_addpath_tx_path(peer
, afi
, safi
, ri
))
1251 /* Aggregate-address suppress check. */
1252 if (ri
->extra
&& ri
->extra
->suppress
)
1253 if (! UNSUPPRESS_MAP_NAME (filter
))
1258 /* Do not send back route to sender. */
1259 if (onlypeer
&& from
== onlypeer
)
1264 /* Do not send the default route in the BGP table if the neighbor is
1265 * configured for default-originate */
1266 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_DEFAULT_ORIGINATE
))
1268 if (p
->family
== AF_INET
&& p
->u
.prefix4
.s_addr
== INADDR_ANY
)
1271 else if (p
->family
== AF_INET6
&& p
->prefixlen
== 0)
1273 #endif /* HAVE_IPV6 */
1276 /* Transparency check. */
1277 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
)
1278 && CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
1283 /* If community is not disabled check the no-export and local. */
1284 if (! transparent
&& bgp_community_filter (peer
, riattr
))
1286 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1287 zlog_debug ("subgrpannouncecheck: community filter check fail");
1291 /* If the attribute has originator-id and it is same as remote
1294 riattr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
) &&
1295 (IPV4_ADDR_SAME (&onlypeer
->remote_id
, &riattr
->extra
->originator_id
)))
1297 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1298 zlog_debug ("%s [Update:SEND] %s/%d originator-id is same as "
1301 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1306 /* ORF prefix-list filter check */
1307 if (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_RM_ADV
)
1308 && (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_RCV
)
1309 || CHECK_FLAG (peer
->af_cap
[afi
][safi
],
1310 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)))
1311 if (peer
->orf_plist
[afi
][safi
])
1313 if (prefix_list_apply (peer
->orf_plist
[afi
][safi
], p
) == PREFIX_DENY
)
1315 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1316 zlog_debug ("%s [Update:SEND] %s/%d is filtered via ORF",
1318 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1324 /* Output filter check. */
1325 if (bgp_output_filter (peer
, p
, riattr
, afi
, safi
) == FILTER_DENY
)
1327 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1328 zlog_debug ("%s [Update:SEND] %s/%d is filtered",
1330 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
1335 #ifdef BGP_SEND_ASPATH_CHECK
1336 /* AS path loop check. */
1337 if (onlypeer
&& aspath_loop_check (riattr
->aspath
, onlypeer
->as
))
1339 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1340 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u "
1341 "that is part of AS path.",
1342 onlypeer
->host
, onlypeer
->as
);
1345 #endif /* BGP_SEND_ASPATH_CHECK */
1347 /* If we're a CONFED we need to loop check the CONFED ID too */
1348 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
1350 if (aspath_loop_check(riattr
->aspath
, bgp
->confed_id
))
1352 if (bgp_debug_update(NULL
, p
, subgrp
->update_group
, 0))
1353 zlog_debug ("%s [Update:SEND] suppress announcement to peer AS %u"
1361 /* Route-Reflect check. */
1362 if (from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1367 /* IBGP reflection check. */
1368 if (reflect
&& !samepeer_safe
)
1370 /* A route from a Client peer. */
1371 if (CHECK_FLAG (from
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
1373 /* Reflect to all the Non-Client peers and also to the
1374 Client peers other than the originator. Originator check
1375 is already done. So there is noting to do. */
1376 /* no bgp client-to-client reflection check. */
1377 if (bgp_flag_check (bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
1378 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1379 PEER_FLAG_REFLECTOR_CLIENT
))
1384 /* A route from a Non-client peer. Reflect to all other
1386 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1387 PEER_FLAG_REFLECTOR_CLIENT
))
1392 /* For modify attribute, copy it to temporary structure. */
1393 bgp_attr_dup (attr
, riattr
);
1395 /* If local-preference is not set. */
1396 if ((peer
->sort
== BGP_PEER_IBGP
1397 || peer
->sort
== BGP_PEER_CONFED
)
1398 && (! (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))))
1400 attr
->flag
|= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
);
1401 attr
->local_pref
= bgp
->default_local_pref
;
1404 /* If originator-id is not set and the route is to be reflected,
1405 set the originator id */
1406 if (reflect
&& (!(attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))))
1408 attr
->extra
= bgp_attr_extra_get(attr
);
1409 IPV4_ADDR_COPY(&(attr
->extra
->originator_id
), &(from
->remote_id
));
1410 SET_FLAG(attr
->flag
, BGP_ATTR_ORIGINATOR_ID
);
1413 /* Remove MED if its an EBGP peer - will get overwritten by route-maps */
1414 if (peer
->sort
== BGP_PEER_EBGP
1415 && attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
1417 if (from
!= bgp
->peer_self
&& ! transparent
1418 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
1419 attr
->flag
&= ~(ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
));
1422 /* Since the nexthop attribute can vary per peer, it is not explicitly set
1423 * in announce check, only certain flags and length (or number of nexthops
1424 * -- for IPv6/MP_REACH) are set here in order to guide the update formation
1425 * code in setting the nexthop(s) on a per peer basis in reformat_peer().
1426 * Typically, the source nexthop in the attribute is preserved but in the
1427 * scenarios where we know it will always be overwritten, we reset the
1428 * nexthop to "0" in an attempt to achieve better Update packing. An
1429 * example of this is when a prefix from each of 2 IBGP peers needs to be
1430 * announced to an EBGP peer (and they have the same attributes barring
1434 SET_FLAG(attr
->rmap_change_flags
, BATTR_REFLECTED
);
1437 #define NEXTHOP_IS_V6 (\
1438 (safi != SAFI_ENCAP && safi != SAFI_MPLS_VPN &&\
1439 (p->family == AF_INET6 || peer_cap_enhe(peer))) || \
1440 ((safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN) &&\
1441 attr->extra->mp_nexthop_len >= IPV6_MAX_BYTELEN))
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 memset(&extra
, 0, sizeof(struct attr_extra
));
1805 /* It's initialized in bgp_announce_check() */
1806 attr
.extra
= &extra
;
1808 /* Announcement to the subgroup. If the route is filtered withdraw it. */
1811 if (subgroup_announce_check(selected
, subgrp
, p
, &attr
))
1812 bgp_adj_out_set_subgroup(rn
, subgrp
, &attr
, selected
);
1814 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, selected
->addpath_tx_id
);
1817 /* If selected is NULL we must withdraw the path using addpath_tx_id */
1820 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, addpath_tx_id
);
1827 * Clear IGP changed flag and attribute changed flag for a route (all paths).
1828 * This is called at the end of route processing.
1831 bgp_zebra_clear_route_change_flags (struct bgp_node
*rn
)
1833 struct bgp_info
*ri
;
1835 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1837 if (BGP_INFO_HOLDDOWN (ri
))
1839 UNSET_FLAG (ri
->flags
, BGP_INFO_IGP_CHANGED
);
1840 UNSET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
1845 * Has the route changed from the RIB's perspective? This is invoked only
1846 * if the route selection returns the same best route as earlier - to
1847 * determine if we need to update zebra or not.
1850 bgp_zebra_has_route_changed (struct bgp_node
*rn
, struct bgp_info
*selected
)
1852 struct bgp_info
*mpinfo
;
1854 /* If this is multipath, check all selected paths for any nexthop change or
1855 * attribute change. Some attribute changes (e.g., community) aren't of
1856 * relevance to the RIB, but we'll update zebra to ensure we handle the
1857 * case of BGP nexthop change. This is the behavior when the best path has
1858 * an attribute change anyway.
1860 if (CHECK_FLAG (selected
->flags
, BGP_INFO_IGP_CHANGED
) ||
1861 CHECK_FLAG (selected
->flags
, BGP_INFO_MULTIPATH_CHG
))
1864 /* If this is multipath, check all selected paths for any nexthop change */
1865 for (mpinfo
= bgp_info_mpath_first (selected
); mpinfo
;
1866 mpinfo
= bgp_info_mpath_next (mpinfo
))
1868 if (CHECK_FLAG (mpinfo
->flags
, BGP_INFO_IGP_CHANGED
)
1869 || CHECK_FLAG (mpinfo
->flags
, BGP_INFO_ATTR_CHANGED
))
1873 /* Nothing has changed from the RIB's perspective. */
1877 struct bgp_process_queue
1880 struct bgp_node
*rn
;
1885 static wq_item_status
1886 bgp_process_main (struct work_queue
*wq
, void *data
)
1888 struct bgp_process_queue
*pq
= data
;
1889 struct bgp
*bgp
= pq
->bgp
;
1890 struct bgp_node
*rn
= pq
->rn
;
1891 afi_t afi
= pq
->afi
;
1892 safi_t safi
= pq
->safi
;
1893 struct prefix
*p
= &rn
->p
;
1894 struct bgp_info
*new_select
;
1895 struct bgp_info
*old_select
;
1896 struct bgp_info_pair old_and_new
;
1898 /* Is it end of initial update? (after startup) */
1901 quagga_timestamp(3, bgp
->update_delay_zebra_resume_time
,
1902 sizeof(bgp
->update_delay_zebra_resume_time
));
1904 bgp
->main_zebra_update_hold
= 0;
1905 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1906 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1908 bgp_zebra_announce_table(bgp
, afi
, safi
);
1910 bgp
->main_peers_update_hold
= 0;
1912 bgp_start_routeadv(bgp
);
1916 /* Best path selection. */
1917 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1918 old_select
= old_and_new
.old
;
1919 new_select
= old_and_new
.new;
1921 /* Nothing to do. */
1922 if (old_select
&& old_select
== new_select
&&
1923 !CHECK_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
) &&
1924 !CHECK_FLAG(old_select
->flags
, BGP_INFO_ATTR_CHANGED
) &&
1925 !bgp
->addpath_tx_used
[afi
][safi
])
1927 if (bgp_zebra_has_route_changed (rn
, old_select
))
1930 vnc_import_bgp_add_route(bgp
, p
, old_select
);
1931 vnc_import_bgp_exterior_add_route(bgp
, p
, old_select
);
1933 bgp_zebra_announce (p
, old_select
, bgp
, afi
, safi
);
1935 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1936 bgp_zebra_clear_route_change_flags (rn
);
1937 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1941 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1942 UNSET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
1944 /* bestpath has changed; bump version */
1945 if (old_select
|| new_select
)
1947 bgp_bump_version(rn
);
1949 if (!bgp
->t_rmap_def_originate_eval
)
1952 THREAD_TIMER_ON(bm
->master
, bgp
->t_rmap_def_originate_eval
,
1953 update_group_refresh_default_originate_route_map
,
1954 bgp
, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER
);
1959 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1962 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1963 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1964 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1968 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
1969 if (old_select
!= new_select
) {
1971 vnc_import_bgp_exterior_del_route(bgp
, p
, old_select
);
1972 vnc_import_bgp_del_route(bgp
, p
, old_select
);
1975 vnc_import_bgp_exterior_add_route(bgp
, p
, new_select
);
1976 vnc_import_bgp_add_route(bgp
, p
, new_select
);
1982 group_announce_route(bgp
, afi
, safi
, rn
, new_select
);
1985 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) &&
1986 (bgp
->inst_type
!= BGP_INSTANCE_TYPE_VIEW
) &&
1987 !bgp_option_check (BGP_OPT_NO_FIB
))
1990 && new_select
->type
== ZEBRA_ROUTE_BGP
1991 && (new_select
->sub_type
== BGP_ROUTE_NORMAL
||
1992 new_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1993 bgp_zebra_announce (p
, new_select
, bgp
, afi
, safi
);
1996 /* Withdraw the route from the kernel. */
1998 && old_select
->type
== ZEBRA_ROUTE_BGP
1999 && (old_select
->sub_type
== BGP_ROUTE_NORMAL
||
2000 old_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
2001 bgp_zebra_withdraw (p
, old_select
, safi
);
2005 /* Clear any route change flags. */
2006 bgp_zebra_clear_route_change_flags (rn
);
2008 /* Reap old select bgp_info, if it has been removed */
2009 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
2010 bgp_info_reap (rn
, old_select
);
2012 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2017 bgp_processq_del (struct work_queue
*wq
, void *data
)
2019 struct bgp_process_queue
*pq
= data
;
2020 struct bgp_table
*table
;
2022 bgp_unlock (pq
->bgp
);
2025 table
= bgp_node_table (pq
->rn
);
2026 bgp_unlock_node (pq
->rn
);
2027 bgp_table_unlock (table
);
2029 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
2033 bgp_process_queue_init (void)
2035 if (!bm
->process_main_queue
)
2037 bm
->process_main_queue
2038 = work_queue_new (bm
->master
, "process_main_queue");
2040 if ( !bm
->process_main_queue
)
2042 zlog_err ("%s: Failed to allocate work queue", __func__
);
2047 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
2048 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
2049 bm
->process_main_queue
->spec
.max_retries
= 0;
2050 bm
->process_main_queue
->spec
.hold
= 50;
2051 /* Use a higher yield value of 50ms for main queue processing */
2052 bm
->process_main_queue
->spec
.yield
= 50 * 1000L;
2056 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
2058 struct bgp_process_queue
*pqnode
;
2060 /* already scheduled for processing? */
2061 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
2064 if (bm
->process_main_queue
== NULL
)
2067 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2068 sizeof (struct bgp_process_queue
));
2072 /* all unlocked in bgp_processq_del */
2073 bgp_table_lock (bgp_node_table (rn
));
2074 pqnode
->rn
= bgp_lock_node (rn
);
2078 pqnode
->safi
= safi
;
2079 work_queue_add (bm
->process_main_queue
, pqnode
);
2080 SET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2085 bgp_add_eoiu_mark (struct bgp
*bgp
)
2087 struct bgp_process_queue
*pqnode
;
2089 if (bm
->process_main_queue
== NULL
)
2092 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2093 sizeof (struct bgp_process_queue
));
2100 work_queue_add (bm
->process_main_queue
, pqnode
);
2104 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
2108 peer
= THREAD_ARG (thread
);
2109 peer
->t_pmax_restart
= NULL
;
2111 if (bgp_debug_neighbor_events(peer
))
2112 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
2115 peer_clear (peer
, NULL
);
2121 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
2122 safi_t safi
, int always
)
2124 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
2127 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
2129 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
2133 zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
2134 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
2135 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
2136 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2138 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
2144 if (safi
== SAFI_MPLS_VPN
)
2145 safi
= SAFI_MPLS_LABELED_VPN
;
2147 ndata
[0] = (afi
>> 8);
2150 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
2151 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
2152 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
2153 ndata
[6] = (peer
->pmax
[afi
][safi
]);
2155 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
2156 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
2157 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
2160 /* Dynamic peers will just close their connection. */
2161 if (peer_dynamic_neighbor (peer
))
2164 /* restart timer start */
2165 if (peer
->pmax_restart
[afi
][safi
])
2167 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
2169 if (bgp_debug_neighbor_events(peer
))
2170 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
2171 peer
->host
, peer
->v_pmax_restart
);
2173 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
2174 peer
->v_pmax_restart
);
2180 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2182 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
2184 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
2188 zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
2189 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
2190 peer
->pmax
[afi
][safi
]);
2191 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2194 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2198 /* Unconditionally remove the route from the RIB, without taking
2199 * damping into consideration (eg, because the session went down)
2202 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2203 afi_t afi
, safi_t safi
)
2205 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2207 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2208 bgp_info_delete (rn
, ri
); /* keep historical info */
2210 bgp_process (peer
->bgp
, rn
, afi
, safi
);
2214 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2215 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
)
2217 int status
= BGP_DAMP_NONE
;
2219 /* apply dampening, if result is suppressed, we'll be retaining
2220 * the bgp_info in the RIB for historical reference.
2222 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2223 && peer
->sort
== BGP_PEER_EBGP
)
2224 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
2225 == BGP_DAMP_SUPPRESSED
)
2227 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2232 if (safi
== SAFI_MPLS_VPN
) {
2233 struct bgp_node
*prn
= NULL
;
2234 struct bgp_table
*table
= NULL
;
2236 prn
= bgp_node_get(peer
->bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2238 table
= (struct bgp_table
*)(prn
->info
);
2240 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2247 bgp_unlock_node(prn
);
2249 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2250 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2252 vnc_import_bgp_del_route(peer
->bgp
, &rn
->p
, ri
);
2253 vnc_import_bgp_exterior_del_route(peer
->bgp
, &rn
->p
, ri
);
2257 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2260 static struct bgp_info
*
2261 info_make (int type
, int sub_type
, u_short instance
, struct peer
*peer
, struct attr
*attr
,
2262 struct bgp_node
*rn
)
2264 struct bgp_info
*new;
2266 /* Make new BGP info. */
2267 new = XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
2269 new->instance
= instance
;
2270 new->sub_type
= sub_type
;
2273 new->uptime
= bgp_clock ();
2275 new->addpath_tx_id
= ++peer
->bgp
->addpath_tx_id
;
2280 bgp_info_addpath_rx_str(u_int32_t addpath_id
, char *buf
)
2283 sprintf(buf
, " with addpath ID %d", addpath_id
);
2289 /* Check if received nexthop is valid or not. */
2291 bgp_update_martian_nexthop (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct attr
*attr
)
2293 struct attr_extra
*attre
= attr
->extra
;
2296 /* Only validated for unicast and multicast currently. */
2297 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2300 /* If NEXT_HOP is present, validate it. */
2301 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2303 if (attr
->nexthop
.s_addr
== 0 ||
2304 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2305 bgp_nexthop_self (bgp
, attr
))
2309 /* If MP_NEXTHOP is present, validate it. */
2310 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2311 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2312 * it is not an IPv6 link-local address.
2314 if (attre
&& attre
->mp_nexthop_len
)
2316 switch (attre
->mp_nexthop_len
)
2318 case BGP_ATTR_NHLEN_IPV4
:
2319 case BGP_ATTR_NHLEN_VPNV4
:
2320 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2321 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2325 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2326 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2327 case BGP_ATTR_NHLEN_VPNV6_GLOBAL
:
2328 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2329 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2330 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2332 #endif /* HAVE_IPV6 */
2344 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2345 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2346 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2350 int aspath_loop_count
= 0;
2351 struct bgp_node
*rn
;
2353 struct attr new_attr
;
2354 struct attr_extra new_extra
;
2355 struct attr
*attr_new
;
2356 struct bgp_info
*ri
;
2357 struct bgp_info
*new;
2359 char buf
[SU_ADDRSTRLEN
];
2362 int do_loop_check
= 1;
2364 int vnc_implicit_withdraw
= 0;
2367 memset (&new_attr
, 0, sizeof(struct attr
));
2368 memset (&new_extra
, 0, sizeof(struct attr_extra
));
2371 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2373 /* When peer's soft reconfiguration enabled. Record input packet in
2375 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2376 && peer
!= bgp
->peer_self
)
2377 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2379 /* Check previously received route. */
2380 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2381 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2382 ri
->addpath_rx_id
== addpath_id
)
2385 /* AS path local-as loop check. */
2386 if (peer
->change_local_as
)
2388 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2389 aspath_loop_count
= 1;
2391 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2393 reason
= "as-path contains our own AS;";
2398 /* If the peer is configured for "allowas-in origin" and the last ASN in the
2399 * as-path is our ASN then we do not need to call aspath_loop_check
2401 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN_ORIGIN
))
2402 if (aspath_get_last_as(attr
->aspath
) == bgp
->as
)
2405 /* AS path loop check. */
2408 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2409 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2410 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
) > peer
->allowas_in
[afi
][safi
]))
2412 reason
= "as-path contains our own AS;";
2417 /* Route reflector originator ID check. */
2418 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2419 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2421 reason
= "originator is us;";
2425 /* Route reflector cluster ID check. */
2426 if (bgp_cluster_filter (peer
, attr
))
2428 reason
= "reflected from the same cluster;";
2432 /* Apply incoming filter. */
2433 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2439 new_attr
.extra
= &new_extra
;
2440 bgp_attr_dup (&new_attr
, attr
);
2442 /* Apply incoming route-map.
2443 * NB: new_attr may now contain newly allocated values from route-map "set"
2444 * commands, so we need bgp_attr_flush in the error paths, until we intern
2445 * the attr (which takes over the memory references) */
2446 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2448 reason
= "route-map;";
2449 bgp_attr_flush (&new_attr
);
2453 /* next hop check. */
2454 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2456 reason
= "martian or self next-hop;";
2457 bgp_attr_flush (&new_attr
);
2461 attr_new
= bgp_attr_intern (&new_attr
);
2463 /* If the update is implicit withdraw. */
2466 ri
->uptime
= bgp_clock ();
2468 /* Same attribute comes in. */
2469 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2470 && attrhash_cmp (ri
->attr
, attr_new
))
2472 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2473 && peer
->sort
== BGP_PEER_EBGP
2474 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2476 if (bgp_debug_update(peer
, p
, NULL
, 1))
2478 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2479 zlog_debug ("%s rcvd %s/%d%s",
2481 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2482 p
->prefixlen
, buf2
);
2485 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2487 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2488 bgp_process (bgp
, rn
, afi
, safi
);
2491 else /* Duplicate - odd */
2493 if (bgp_debug_update(peer
, p
, NULL
, 1))
2495 if (!peer
->rcvd_attr_printed
)
2497 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2498 peer
->rcvd_attr_printed
= 1;
2501 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2502 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2504 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2505 p
->prefixlen
, buf2
);
2508 /* graceful restart STALE flag unset. */
2509 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2511 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2512 bgp_process (bgp
, rn
, afi
, safi
);
2516 bgp_unlock_node (rn
);
2517 bgp_attr_unintern (&attr_new
);
2522 /* Withdraw/Announce before we fully processed the withdraw */
2523 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2525 if (bgp_debug_update(peer
, p
, NULL
, 1))
2527 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2528 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2530 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2531 p
->prefixlen
, buf2
);
2533 bgp_info_restore (rn
, ri
);
2536 /* Received Logging. */
2537 if (bgp_debug_update(peer
, p
, NULL
, 1))
2539 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2540 zlog_debug ("%s rcvd %s/%d%s",
2542 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2543 p
->prefixlen
, buf2
);
2546 /* graceful restart STALE flag unset. */
2547 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2548 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2550 /* The attribute is changed. */
2551 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2553 /* implicit withdraw, decrement aggregate and pcount here.
2554 * only if update is accepted, they'll increment below.
2556 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2558 /* Update bgp route dampening information. */
2559 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2560 && peer
->sort
== BGP_PEER_EBGP
)
2562 /* This is implicit withdraw so we should update dampening
2564 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2565 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2568 if (safi
== SAFI_MPLS_VPN
) {
2569 struct bgp_node
*prn
= NULL
;
2570 struct bgp_table
*table
= NULL
;
2572 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2574 table
= (struct bgp_table
*)(prn
->info
);
2576 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2583 bgp_unlock_node(prn
);
2585 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2586 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2588 * Implicit withdraw case.
2590 ++vnc_implicit_withdraw
;
2591 vnc_import_bgp_del_route(bgp
, p
, ri
);
2592 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
2597 /* Update to new attribute. */
2598 bgp_attr_unintern (&ri
->attr
);
2599 ri
->attr
= attr_new
;
2601 /* Update MPLS tag. */
2602 if (safi
== SAFI_MPLS_VPN
)
2603 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2606 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
2608 if (vnc_implicit_withdraw
)
2611 * Add back the route with its new attributes (e.g., nexthop).
2612 * The route is still selected, until the route selection
2613 * queued by bgp_process actually runs. We have to make this
2614 * update to the VNC side immediately to avoid racing against
2615 * configuration changes (e.g., route-map changes) which
2616 * trigger re-importation of the entire RIB.
2618 vnc_import_bgp_add_route(bgp
, p
, ri
);
2619 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
2624 /* Update bgp route dampening information. */
2625 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2626 && peer
->sort
== BGP_PEER_EBGP
)
2628 /* Now we do normal update dampening. */
2629 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2630 if (ret
== BGP_DAMP_SUPPRESSED
)
2632 bgp_unlock_node (rn
);
2637 /* Nexthop reachability check. */
2638 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2640 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2641 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2642 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2647 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2648 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2651 if (BGP_DEBUG(nht
, NHT
))
2653 char buf1
[INET6_ADDRSTRLEN
];
2654 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2655 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2657 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2661 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2664 if (safi
== SAFI_MPLS_VPN
)
2666 struct bgp_node
*prn
= NULL
;
2667 struct bgp_table
*table
= NULL
;
2669 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2672 table
= (struct bgp_table
*)(prn
->info
);
2674 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2681 bgp_unlock_node(prn
);
2685 /* Process change. */
2686 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2688 bgp_process (bgp
, rn
, afi
, safi
);
2689 bgp_unlock_node (rn
);
2692 if (SAFI_MPLS_VPN
== safi
)
2694 uint32_t label
= decode_label(tag
);
2696 rfapiProcessUpdate(peer
, NULL
, p
, prd
, attr
, afi
, safi
, type
, sub_type
,
2699 if (SAFI_ENCAP
== safi
)
2701 rfapiProcessUpdate(peer
, NULL
, p
, prd
, attr
, afi
, safi
, type
, sub_type
,
2707 } // End of implicit withdraw
2709 /* Received Logging. */
2710 if (bgp_debug_update(peer
, p
, NULL
, 1))
2712 if (!peer
->rcvd_attr_printed
)
2714 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2715 peer
->rcvd_attr_printed
= 1;
2718 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2719 zlog_debug ("%s rcvd %s/%d%s",
2721 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2722 p
->prefixlen
, buf2
);
2725 /* Make new BGP info. */
2726 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2728 /* Update MPLS tag. */
2729 if (safi
== SAFI_MPLS_VPN
)
2730 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2732 /* Nexthop reachability check. */
2733 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2735 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2736 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2737 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2742 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2743 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2746 if (BGP_DEBUG(nht
, NHT
))
2748 char buf1
[INET6_ADDRSTRLEN
];
2749 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2750 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2752 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2756 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2759 new->addpath_rx_id
= addpath_id
;
2761 /* Increment prefix */
2762 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2764 /* Register new BGP information. */
2765 bgp_info_add (rn
, new);
2767 /* route_node_get lock */
2768 bgp_unlock_node (rn
);
2771 if (safi
== SAFI_MPLS_VPN
)
2773 struct bgp_node
*prn
= NULL
;
2774 struct bgp_table
*table
= NULL
;
2776 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2779 table
= (struct bgp_table
*)(prn
->info
);
2781 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2788 bgp_unlock_node(prn
);
2792 /* If maximum prefix count is configured and current prefix
2794 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2797 /* Process change. */
2798 bgp_process (bgp
, rn
, afi
, safi
);
2801 if (SAFI_MPLS_VPN
== safi
)
2803 uint32_t label
= decode_label(tag
);
2805 rfapiProcessUpdate(peer
, NULL
, p
, prd
, attr
, afi
, safi
, type
, sub_type
,
2808 if (SAFI_ENCAP
== safi
)
2810 rfapiProcessUpdate(peer
, NULL
, p
, prd
, attr
, afi
, safi
, type
, sub_type
,
2817 /* This BGP update is filtered. Log the reason then update BGP
2820 if (bgp_debug_update(peer
, p
, NULL
, 1))
2822 if (!peer
->rcvd_attr_printed
)
2824 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2825 peer
->rcvd_attr_printed
= 1;
2828 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2829 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2831 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2832 p
->prefixlen
, buf2
, reason
);
2836 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2838 bgp_unlock_node (rn
);
2842 * Filtered update is treated as an implicit withdrawal (see bgp_rib_remove()
2843 * a few lines above)
2845 if ((SAFI_MPLS_VPN
== safi
) || (SAFI_ENCAP
== safi
))
2847 rfapiProcessWithdraw(peer
, NULL
, p
, prd
, NULL
, afi
, safi
, type
, 0);
2855 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2856 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2857 struct prefix_rd
*prd
, u_char
*tag
)
2860 char buf
[SU_ADDRSTRLEN
];
2862 struct bgp_node
*rn
;
2863 struct bgp_info
*ri
;
2866 if ((SAFI_MPLS_VPN
== safi
) || (SAFI_ENCAP
== safi
))
2868 rfapiProcessWithdraw(peer
, NULL
, p
, prd
, NULL
, afi
, safi
, type
, 0);
2875 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2877 /* If peer is soft reconfiguration enabled. Record input packet for
2878 * further calculation.
2880 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2881 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2882 * the iteration over all RS clients.
2883 * Since we need to remove the entry from adj_in anyway, do that first and
2884 * if there was no entry, we don't need to do anything more.
2886 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2887 && peer
!= bgp
->peer_self
)
2888 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2890 if (bgp_debug_update (peer
, p
, NULL
, 1))
2891 zlog_debug ("%s withdrawing route %s/%d "
2892 "not in adj-in", peer
->host
,
2893 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2895 bgp_unlock_node (rn
);
2899 /* Lookup withdrawn route. */
2900 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2901 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2902 ri
->addpath_rx_id
== addpath_id
)
2906 if (bgp_debug_update(peer
, p
, NULL
, 1))
2908 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2909 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2911 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2912 p
->prefixlen
, buf2
);
2915 /* Withdraw specified route from routing table. */
2916 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2917 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
, prd
);
2918 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2919 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2920 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2923 /* Unlock bgp_node_get() lock. */
2924 bgp_unlock_node (rn
);
2930 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2932 struct update_subgroup
*subgrp
;
2933 subgrp
= peer_subgroup(peer
, afi
, safi
);
2934 subgroup_default_originate(subgrp
, withdraw
);
2939 * bgp_stop_announce_route_timer
2942 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2944 if (!paf
->t_announce_route
)
2947 THREAD_TIMER_OFF (paf
->t_announce_route
);
2951 * bgp_announce_route_timer_expired
2953 * Callback that is invoked when the route announcement timer for a
2957 bgp_announce_route_timer_expired (struct thread
*t
)
2959 struct peer_af
*paf
;
2962 paf
= THREAD_ARG (t
);
2965 assert (paf
->t_announce_route
);
2966 paf
->t_announce_route
= NULL
;
2968 if (peer
->status
!= Established
)
2971 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2974 peer_af_announce_route (paf
, 1);
2979 * bgp_announce_route
2981 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2984 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2986 struct peer_af
*paf
;
2987 struct update_subgroup
*subgrp
;
2989 paf
= peer_af_find (peer
, afi
, safi
);
2992 subgrp
= PAF_SUBGRP(paf
);
2995 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2996 * or a refresh has already been triggered.
2998 if (!subgrp
|| paf
->t_announce_route
)
3002 * Start a timer to stagger/delay the announce. This serves
3003 * two purposes - announcement can potentially be combined for
3004 * multiple peers and the announcement doesn't happen in the
3007 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
3008 bgp_announce_route_timer_expired
, paf
,
3009 (subgrp
->peer_count
== 1) ?
3010 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
3011 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
3015 * Announce routes from all AF tables to a peer.
3017 * This should ONLY be called when there is a need to refresh the
3018 * routes to the peer based on a policy change for this peer alone
3019 * or a route refresh request received from the peer.
3020 * The operation will result in splitting the peer from its existing
3021 * subgroups and putting it in new subgroups.
3024 bgp_announce_route_all (struct peer
*peer
)
3029 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3030 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3031 bgp_announce_route (peer
, afi
, safi
);
3035 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3036 struct bgp_table
*table
, struct prefix_rd
*prd
)
3039 struct bgp_node
*rn
;
3040 struct bgp_adj_in
*ain
;
3043 table
= peer
->bgp
->rib
[afi
][safi
];
3045 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3046 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
3048 if (ain
->peer
== peer
)
3050 struct bgp_info
*ri
= rn
->info
;
3051 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
3053 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
3054 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
3059 bgp_unlock_node (rn
);
3067 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3069 struct bgp_node
*rn
;
3070 struct bgp_table
*table
;
3072 if (peer
->status
!= Established
)
3075 if ((safi
!= SAFI_MPLS_VPN
) && (safi
!= SAFI_ENCAP
))
3076 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
3078 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3079 rn
= bgp_route_next (rn
))
3080 if ((table
= rn
->info
) != NULL
)
3082 struct prefix_rd prd
;
3083 prd
.family
= AF_UNSPEC
;
3085 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
3087 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
3092 struct bgp_clear_node_queue
3094 struct bgp_node
*rn
;
3097 static wq_item_status
3098 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
3100 struct bgp_clear_node_queue
*cnq
= data
;
3101 struct bgp_node
*rn
= cnq
->rn
;
3102 struct peer
*peer
= wq
->spec
.data
;
3103 struct bgp_info
*ri
;
3104 afi_t afi
= bgp_node_table (rn
)->afi
;
3105 safi_t safi
= bgp_node_table (rn
)->safi
;
3107 assert (rn
&& peer
);
3109 /* It is possible that we have multiple paths for a prefix from a peer
3110 * if that peer is using AddPath.
3112 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3113 if (ri
->peer
== peer
)
3115 /* graceful restart STALE flag set. */
3116 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
3117 && peer
->nsf
[afi
][safi
]
3118 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
3119 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
3120 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
3122 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3128 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
3130 struct bgp_clear_node_queue
*cnq
= data
;
3131 struct bgp_node
*rn
= cnq
->rn
;
3132 struct bgp_table
*table
= bgp_node_table (rn
);
3134 bgp_unlock_node (rn
);
3135 bgp_table_unlock (table
);
3136 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
3140 bgp_clear_node_complete (struct work_queue
*wq
)
3142 struct peer
*peer
= wq
->spec
.data
;
3144 /* Tickle FSM to start moving again */
3145 BGP_EVENT_ADD (peer
, Clearing_Completed
);
3147 peer_unlock (peer
); /* bgp_clear_route */
3151 bgp_clear_node_queue_init (struct peer
*peer
)
3153 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
3155 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
3156 #undef CLEAR_QUEUE_NAME_LEN
3158 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
3160 zlog_err ("%s: Failed to allocate work queue", __func__
);
3163 peer
->clear_node_queue
->spec
.hold
= 10;
3164 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
3165 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
3166 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
3167 peer
->clear_node_queue
->spec
.max_retries
= 0;
3169 /* we only 'lock' this peer reference when the queue is actually active */
3170 peer
->clear_node_queue
->spec
.data
= peer
;
3174 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3175 struct bgp_table
*table
)
3177 struct bgp_node
*rn
;
3178 int force
= bm
->process_main_queue
? 0 : 1;
3181 table
= peer
->bgp
->rib
[afi
][safi
];
3183 /* If still no table => afi/safi isn't configured at all or smth. */
3187 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3189 struct bgp_info
*ri
, *next
;
3190 struct bgp_adj_in
*ain
;
3191 struct bgp_adj_in
*ain_next
;
3193 /* XXX:TODO: This is suboptimal, every non-empty route_node is
3194 * queued for every clearing peer, regardless of whether it is
3195 * relevant to the peer at hand.
3197 * Overview: There are 3 different indices which need to be
3198 * scrubbed, potentially, when a peer is removed:
3200 * 1 peer's routes visible via the RIB (ie accepted routes)
3201 * 2 peer's routes visible by the (optional) peer's adj-in index
3202 * 3 other routes visible by the peer's adj-out index
3204 * 3 there is no hurry in scrubbing, once the struct peer is
3205 * removed from bgp->peer, we could just GC such deleted peer's
3206 * adj-outs at our leisure.
3208 * 1 and 2 must be 'scrubbed' in some way, at least made
3209 * invisible via RIB index before peer session is allowed to be
3210 * brought back up. So one needs to know when such a 'search' is
3215 * - there'd be a single global queue or a single RIB walker
3216 * - rather than tracking which route_nodes still need to be
3217 * examined on a peer basis, we'd track which peers still
3220 * Given that our per-peer prefix-counts now should be reliable,
3221 * this may actually be achievable. It doesn't seem to be a huge
3222 * problem at this time,
3224 * It is possible that we have multiple paths for a prefix from a peer
3225 * if that peer is using AddPath.
3230 ain_next
= ain
->next
;
3232 if (ain
->peer
== peer
)
3234 bgp_adj_in_remove (rn
, ain
);
3235 bgp_unlock_node (rn
);
3241 for (ri
= rn
->info
; ri
; ri
= next
)
3244 if (ri
->peer
!= peer
)
3248 bgp_info_reap (rn
, ri
);
3251 struct bgp_clear_node_queue
*cnq
;
3253 /* both unlocked in bgp_clear_node_queue_del */
3254 bgp_table_lock (bgp_node_table (rn
));
3256 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
3257 sizeof (struct bgp_clear_node_queue
));
3259 work_queue_add (peer
->clear_node_queue
, cnq
);
3268 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3270 struct bgp_node
*rn
;
3271 struct bgp_table
*table
;
3273 if (peer
->clear_node_queue
== NULL
)
3274 bgp_clear_node_queue_init (peer
);
3276 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3277 * Idle until it receives a Clearing_Completed event. This protects
3278 * against peers which flap faster than we can we clear, which could
3281 * a) race with routes from the new session being installed before
3282 * clear_route_node visits the node (to delete the route of that
3284 * b) resource exhaustion, clear_route_node likely leads to an entry
3285 * on the process_main queue. Fast-flapping could cause that queue
3289 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3290 * the unlock will happen upon work-queue completion; other wise, the
3291 * unlock happens at the end of this function.
3293 if (!peer
->clear_node_queue
->thread
)
3296 if (safi
!= SAFI_MPLS_VPN
&& safi
!= SAFI_ENCAP
)
3297 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
3299 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3300 rn
= bgp_route_next (rn
))
3301 if ((table
= rn
->info
) != NULL
)
3302 bgp_clear_route_table (peer
, afi
, safi
, table
);
3304 /* unlock if no nodes got added to the clear-node-queue. */
3305 if (!peer
->clear_node_queue
->thread
)
3311 bgp_clear_route_all (struct peer
*peer
)
3316 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3317 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3318 bgp_clear_route (peer
, afi
, safi
);
3321 rfapiProcessPeerDown(peer
);
3326 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3328 struct bgp_table
*table
;
3329 struct bgp_node
*rn
;
3330 struct bgp_adj_in
*ain
;
3331 struct bgp_adj_in
*ain_next
;
3333 table
= peer
->bgp
->rib
[afi
][safi
];
3335 /* It is possible that we have multiple paths for a prefix from a peer
3336 * if that peer is using AddPath.
3338 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3344 ain_next
= ain
->next
;
3346 if (ain
->peer
== peer
)
3348 bgp_adj_in_remove (rn
, ain
);
3349 bgp_unlock_node (rn
);
3358 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3360 struct bgp_node
*rn
;
3361 struct bgp_info
*ri
;
3362 struct bgp_table
*table
;
3364 table
= peer
->bgp
->rib
[afi
][safi
];
3366 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3368 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3369 if (ri
->peer
== peer
)
3371 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3372 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3379 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3381 struct bgp_node
*rn
;
3382 struct bgp_info
*ri
;
3383 struct bgp_info
*next
;
3385 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3386 for (ri
= rn
->info
; ri
; ri
= next
)
3389 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3390 && ri
->type
== ZEBRA_ROUTE_BGP
3391 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3392 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3395 if (table
->owner
&& table
->owner
->bgp
)
3396 vnc_import_bgp_del_route(table
->owner
->bgp
, &rn
->p
, ri
);
3398 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3399 bgp_info_reap (rn
, ri
);
3404 /* Delete all kernel routes. */
3406 bgp_cleanup_routes (struct bgp
*bgp
)
3410 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3412 struct bgp_node
*rn
;
3414 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3417 * VPN and ENCAP tables are two-level (RD is top level)
3419 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3420 rn
= bgp_route_next (rn
))
3424 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3425 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3427 bgp_unlock_node(rn
);
3431 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_ENCAP
]); rn
;
3432 rn
= bgp_route_next (rn
))
3436 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_ENCAP
);
3437 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3439 bgp_unlock_node(rn
);
3449 bgp_zclient_reset ();
3450 access_list_reset ();
3451 prefix_list_reset ();
3455 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3457 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3458 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3461 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3464 bgp_nlri_parse_ip (struct peer
*peer
, struct attr
*attr
,
3465 struct bgp_nlri
*packet
)
3474 int addpath_encoded
;
3475 u_int32_t addpath_id
;
3477 /* Check peer status. */
3478 if (peer
->status
!= Established
)
3482 lim
= pnt
+ packet
->length
;
3484 safi
= packet
->safi
;
3486 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3488 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3489 syntactic validity. If the field is syntactically incorrect,
3490 then the Error Subcode is set to Invalid Network Field. */
3491 for (; pnt
< lim
; pnt
+= psize
)
3493 /* Clear prefix structure. */
3494 memset (&p
, 0, sizeof (struct prefix
));
3496 if (addpath_encoded
)
3499 /* When packet overflow occurs return immediately. */
3500 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3503 addpath_id
= ntohl(*((uint32_t*) pnt
));
3504 pnt
+= BGP_ADDPATH_ID_LEN
;
3507 /* Fetch prefix length. */
3508 p
.prefixlen
= *pnt
++;
3509 /* afi/safi validity already verified by caller, bgp_update_receive */
3510 p
.family
= afi2family (afi
);
3512 /* Prefix length check. */
3513 if (p
.prefixlen
> prefix_blen (&p
) * 8)
3515 zlog_err("%s [Error] Update packet error (wrong perfix length %d for afi %u)",
3516 peer
->host
, p
.prefixlen
, packet
->afi
);
3520 /* Packet size overflow check. */
3521 psize
= PSIZE (p
.prefixlen
);
3523 /* When packet overflow occur return immediately. */
3524 if (pnt
+ psize
> lim
)
3526 zlog_err("%s [Error] Update packet error (prefix length %d overflows packet)",
3527 peer
->host
, p
.prefixlen
);
3531 /* Defensive coding, double-check the psize fits in a struct prefix */
3532 if (psize
> (ssize_t
) sizeof(p
.u
))
3534 zlog_err("%s [Error] Update packet error (prefix length %d too large for prefix storage %zu)",
3535 peer
->host
, p
.prefixlen
, sizeof(p
.u
));
3539 /* Fetch prefix from NLRI packet. */
3540 memcpy (&p
.u
.prefix
, pnt
, psize
);
3542 /* Check address. */
3543 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3545 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3547 /* From RFC4271 Section 6.3:
3549 * If a prefix in the NLRI field is semantically incorrect
3550 * (e.g., an unexpected multicast IP address), an error SHOULD
3551 * be logged locally, and the prefix SHOULD be ignored.
3553 zlog_err ("%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3554 peer
->host
, inet_ntoa (p
.u
.prefix4
));
3560 /* Check address. */
3561 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3563 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3567 zlog_err ("%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3568 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3572 if (IN6_IS_ADDR_MULTICAST (&p
.u
.prefix6
))
3576 zlog_err ("%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3577 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3582 #endif /* HAVE_IPV6 */
3584 /* Normal process. */
3586 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3587 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3589 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3590 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3592 /* Address family configuration mismatch or maximum-prefix count
3598 /* Packet length consistency check. */
3601 zlog_err ("%s [Error] Update packet error (prefix length mismatch with total length)",
3609 static struct bgp_static
*
3610 bgp_static_new (void)
3612 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3616 bgp_static_free (struct bgp_static
*bgp_static
)
3618 if (bgp_static
->rmap
.name
)
3619 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3620 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3624 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3625 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3627 struct bgp_node
*rn
;
3628 struct bgp_info
*ri
;
3629 struct bgp_info
*new;
3630 struct bgp_info info
;
3632 struct attr
*attr_new
;
3635 int vnc_implicit_withdraw
= 0;
3638 assert (bgp_static
);
3642 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3644 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3646 attr
.nexthop
= bgp_static
->igpnexthop
;
3647 attr
.med
= bgp_static
->igpmetric
;
3648 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3650 if (bgp_static
->atomic
)
3651 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3653 /* Apply route-map. */
3654 if (bgp_static
->rmap
.name
)
3656 struct attr attr_tmp
= attr
;
3657 info
.peer
= bgp
->peer_self
;
3658 info
.attr
= &attr_tmp
;
3660 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3662 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3664 bgp
->peer_self
->rmap_type
= 0;
3666 if (ret
== RMAP_DENYMATCH
)
3668 /* Free uninterned attribute. */
3669 bgp_attr_flush (&attr_tmp
);
3671 /* Unintern original. */
3672 aspath_unintern (&attr
.aspath
);
3673 bgp_attr_extra_free (&attr
);
3674 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3677 attr_new
= bgp_attr_intern (&attr_tmp
);
3680 attr_new
= bgp_attr_intern (&attr
);
3682 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3683 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3684 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3689 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3690 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3691 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3693 bgp_unlock_node (rn
);
3694 bgp_attr_unintern (&attr_new
);
3695 aspath_unintern (&attr
.aspath
);
3696 bgp_attr_extra_free (&attr
);
3701 /* The attribute is changed. */
3702 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3704 /* Rewrite BGP route information. */
3705 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3706 bgp_info_restore(rn
, ri
);
3708 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3710 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3712 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
3715 * Implicit withdraw case.
3716 * We have to do this before ri is changed
3718 ++vnc_implicit_withdraw
;
3719 vnc_import_bgp_del_route(bgp
, p
, ri
);
3720 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
3724 bgp_attr_unintern (&ri
->attr
);
3725 ri
->attr
= attr_new
;
3726 ri
->uptime
= bgp_clock ();
3728 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3730 if (vnc_implicit_withdraw
)
3732 vnc_import_bgp_add_route(bgp
, p
, ri
);
3733 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
3738 /* Nexthop reachability check. */
3739 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3741 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3742 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3745 if (BGP_DEBUG(nht
, NHT
))
3747 char buf1
[INET6_ADDRSTRLEN
];
3748 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3750 zlog_debug("%s(%s): Route not in table, not advertising",
3751 __FUNCTION__
, buf1
);
3753 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3758 /* Delete the NHT structure if any, if we're toggling between
3759 * enabling/disabling import check. We deregister the route
3760 * from NHT to avoid overloading NHT and the process interaction
3762 bgp_unlink_nexthop(ri
);
3763 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3765 /* Process change. */
3766 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3767 bgp_process (bgp
, rn
, afi
, safi
);
3768 bgp_unlock_node (rn
);
3769 aspath_unintern (&attr
.aspath
);
3770 bgp_attr_extra_free (&attr
);
3775 /* Make new BGP info. */
3776 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3778 /* Nexthop reachability check. */
3779 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3781 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3782 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3785 if (BGP_DEBUG(nht
, NHT
))
3787 char buf1
[INET6_ADDRSTRLEN
];
3788 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3790 zlog_debug("%s(%s): Route not in table, not advertising",
3791 __FUNCTION__
, buf1
);
3793 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3798 /* Delete the NHT structure if any, if we're toggling between
3799 * enabling/disabling import check. We deregister the route
3800 * from NHT to avoid overloading NHT and the process interaction
3802 bgp_unlink_nexthop(new);
3804 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3807 /* Aggregate address increment. */
3808 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3810 /* Register new BGP information. */
3811 bgp_info_add (rn
, new);
3813 /* route_node_get lock */
3814 bgp_unlock_node (rn
);
3816 /* Process change. */
3817 bgp_process (bgp
, rn
, afi
, safi
);
3819 /* Unintern original. */
3820 aspath_unintern (&attr
.aspath
);
3821 bgp_attr_extra_free (&attr
);
3825 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3826 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3828 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3832 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3835 struct bgp_node
*rn
;
3836 struct bgp_info
*ri
;
3838 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3840 /* Check selected route and self inserted route. */
3841 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3842 if (ri
->peer
== bgp
->peer_self
3843 && ri
->type
== ZEBRA_ROUTE_BGP
3844 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3847 /* Withdraw static BGP route from routing table. */
3850 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3851 bgp_unlink_nexthop(ri
);
3852 bgp_info_delete (rn
, ri
);
3853 bgp_process (bgp
, rn
, afi
, safi
);
3856 /* Unlock bgp_node_lookup. */
3857 bgp_unlock_node (rn
);
3861 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3864 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3865 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3867 struct bgp_node
*rn
;
3868 struct bgp_info
*ri
;
3870 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3872 /* Check selected route and self inserted route. */
3873 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3874 if (ri
->peer
== bgp
->peer_self
3875 && ri
->type
== ZEBRA_ROUTE_BGP
3876 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3879 /* Withdraw static BGP route from routing table. */
3883 rfapiProcessWithdraw(
3892 1); /* Kill, since it is an administrative change */
3894 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3895 bgp_info_delete (rn
, ri
);
3896 bgp_process (bgp
, rn
, afi
, safi
);
3899 /* Unlock bgp_node_lookup. */
3900 bgp_unlock_node (rn
);
3904 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3905 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3907 struct bgp_node
*rn
;
3908 struct bgp_info
*new;
3909 struct attr
*attr_new
;
3910 struct attr attr
= { 0 };
3911 struct bgp_info
*ri
;
3913 u_int32_t label
= 0;
3916 assert (bgp_static
);
3918 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3920 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3922 attr
.nexthop
= bgp_static
->igpnexthop
;
3923 attr
.med
= bgp_static
->igpmetric
;
3924 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3926 /* Apply route-map. */
3927 if (bgp_static
->rmap
.name
)
3929 struct attr attr_tmp
= attr
;
3930 struct bgp_info info
;
3933 info
.peer
= bgp
->peer_self
;
3934 info
.attr
= &attr_tmp
;
3936 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3938 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3940 bgp
->peer_self
->rmap_type
= 0;
3942 if (ret
== RMAP_DENYMATCH
)
3944 /* Free uninterned attribute. */
3945 bgp_attr_flush (&attr_tmp
);
3947 /* Unintern original. */
3948 aspath_unintern (&attr
.aspath
);
3949 bgp_attr_extra_free (&attr
);
3950 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3955 attr_new
= bgp_attr_intern (&attr_tmp
);
3959 attr_new
= bgp_attr_intern (&attr
);
3962 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3963 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3964 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3969 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3970 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3972 bgp_unlock_node (rn
);
3973 bgp_attr_unintern (&attr_new
);
3974 aspath_unintern (&attr
.aspath
);
3975 bgp_attr_extra_free (&attr
);
3980 /* The attribute is changed. */
3981 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3983 /* Rewrite BGP route information. */
3984 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3985 bgp_info_restore(rn
, ri
);
3987 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3988 bgp_attr_unintern (&ri
->attr
);
3989 ri
->attr
= attr_new
;
3990 ri
->uptime
= bgp_clock ();
3993 label
= decode_label (ri
->extra
->tag
);
3996 /* Process change. */
3997 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3998 bgp_process (bgp
, rn
, afi
, safi
);
4000 rfapiProcessUpdate(ri
->peer
, NULL
, p
, &bgp_static
->prd
,
4001 ri
->attr
, afi
, safi
,
4002 ri
->type
, ri
->sub_type
, &label
);
4004 bgp_unlock_node (rn
);
4005 aspath_unintern (&attr
.aspath
);
4006 bgp_attr_extra_free (&attr
);
4012 /* Make new BGP info. */
4013 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
4015 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4016 new->extra
= bgp_info_extra_new();
4017 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
4019 label
= decode_label (bgp_static
->tag
);
4022 /* Aggregate address increment. */
4023 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
4025 /* Register new BGP information. */
4026 bgp_info_add (rn
, new);
4028 /* route_node_get lock */
4029 bgp_unlock_node (rn
);
4031 /* Process change. */
4032 bgp_process (bgp
, rn
, afi
, safi
);
4035 rfapiProcessUpdate(new->peer
, NULL
, p
, &bgp_static
->prd
,
4036 new->attr
, afi
, safi
,
4037 new->type
, new->sub_type
, &label
);
4040 /* Unintern original. */
4041 aspath_unintern (&attr
.aspath
);
4042 bgp_attr_extra_free (&attr
);
4045 /* Configure static BGP network. When user don't run zebra, static
4046 route should be installed as valid. */
4048 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4049 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
4053 struct bgp_static
*bgp_static
;
4054 struct bgp_node
*rn
;
4055 u_char need_update
= 0;
4057 /* Convert IP prefix string to struct prefix. */
4058 ret
= str2prefix (ip_str
, &p
);
4061 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4065 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4067 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4071 #endif /* HAVE_IPV6 */
4075 /* Set BGP static route configuration. */
4076 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
4080 /* Configuration change. */
4081 bgp_static
= rn
->info
;
4083 /* Check previous routes are installed into BGP. */
4084 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
4087 bgp_static
->backdoor
= backdoor
;
4091 if (bgp_static
->rmap
.name
)
4092 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4093 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4094 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4098 if (bgp_static
->rmap
.name
)
4099 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4100 bgp_static
->rmap
.name
= NULL
;
4101 bgp_static
->rmap
.map
= NULL
;
4102 bgp_static
->valid
= 0;
4104 bgp_unlock_node (rn
);
4108 /* New configuration. */
4109 bgp_static
= bgp_static_new ();
4110 bgp_static
->backdoor
= backdoor
;
4111 bgp_static
->valid
= 0;
4112 bgp_static
->igpmetric
= 0;
4113 bgp_static
->igpnexthop
.s_addr
= 0;
4117 if (bgp_static
->rmap
.name
)
4118 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4119 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4120 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4122 rn
->info
= bgp_static
;
4125 bgp_static
->valid
= 1;
4127 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4129 if (! bgp_static
->backdoor
)
4130 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
4135 /* Configure static BGP network. */
4137 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4138 afi_t afi
, safi_t safi
)
4142 struct bgp_static
*bgp_static
;
4143 struct bgp_node
*rn
;
4145 /* Convert IP prefix string to struct prefix. */
4146 ret
= str2prefix (ip_str
, &p
);
4149 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4153 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4155 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4159 #endif /* HAVE_IPV6 */
4163 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
4166 vty_out (vty
, "%% Can't find specified static route configuration.%s",
4171 bgp_static
= rn
->info
;
4173 /* Update BGP RIB. */
4174 if (! bgp_static
->backdoor
)
4175 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4177 /* Clear configuration. */
4178 bgp_static_free (bgp_static
);
4180 bgp_unlock_node (rn
);
4181 bgp_unlock_node (rn
);
4187 bgp_static_add (struct bgp
*bgp
)
4191 struct bgp_node
*rn
;
4192 struct bgp_node
*rm
;
4193 struct bgp_table
*table
;
4194 struct bgp_static
*bgp_static
;
4196 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4197 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4198 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4199 if (rn
->info
!= NULL
)
4201 if (safi
== SAFI_MPLS_VPN
)
4205 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4207 bgp_static
= rn
->info
;
4208 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
4213 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
4218 /* Called from bgp_delete(). Delete all static routes from the BGP
4221 bgp_static_delete (struct bgp
*bgp
)
4225 struct bgp_node
*rn
;
4226 struct bgp_node
*rm
;
4227 struct bgp_table
*table
;
4228 struct bgp_static
*bgp_static
;
4230 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4231 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4232 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4233 if (rn
->info
!= NULL
)
4235 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4239 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4241 bgp_static
= rn
->info
;
4242 bgp_static_withdraw_safi (bgp
, &rm
->p
,
4244 (struct prefix_rd
*)&rn
->p
,
4246 bgp_static_free (bgp_static
);
4248 bgp_unlock_node (rn
);
4253 bgp_static
= rn
->info
;
4254 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
4255 bgp_static_free (bgp_static
);
4257 bgp_unlock_node (rn
);
4263 bgp_static_redo_import_check (struct bgp
*bgp
)
4267 struct bgp_node
*rn
;
4268 struct bgp_static
*bgp_static
;
4270 /* Use this flag to force reprocessing of the route */
4271 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4272 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4273 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4274 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4275 if (rn
->info
!= NULL
)
4277 bgp_static
= rn
->info
;
4278 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
4280 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4284 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
4286 struct bgp_table
*table
;
4287 struct bgp_node
*rn
;
4288 struct bgp_info
*ri
;
4290 table
= bgp
->rib
[afi
][safi
];
4291 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
4293 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4295 if (ri
->peer
== bgp
->peer_self
&&
4296 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
4297 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
4298 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
4299 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
4301 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4302 bgp_unlink_nexthop(ri
);
4303 bgp_info_delete (rn
, ri
);
4304 bgp_process (bgp
, rn
, afi
, safi
);
4311 * Purge all networks and redistributed routes from routing table.
4312 * Invoked upon the instance going down.
4315 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4320 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4321 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4322 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4327 * Currently this is used to set static routes for VPN and ENCAP.
4328 * I think it can probably be factored with bgp_static_set.
4331 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4332 const char *rd_str
, const char *tag_str
,
4333 const char *rmap_str
)
4337 struct prefix_rd prd
;
4339 struct bgp_node
*prn
;
4340 struct bgp_node
*rn
;
4341 struct bgp_table
*table
;
4342 struct bgp_static
*bgp_static
;
4347 ret
= str2prefix (ip_str
, &p
);
4350 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4355 ret
= str2prefix_rd (rd_str
, &prd
);
4358 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4362 ret
= str2tag (tag_str
, tag
);
4365 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4369 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4370 (struct prefix
*)&prd
);
4371 if (prn
->info
== NULL
)
4372 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4374 bgp_unlock_node (prn
);
4377 rn
= bgp_node_get (table
, &p
);
4381 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4382 bgp_unlock_node (rn
);
4386 /* New configuration. */
4387 bgp_static
= bgp_static_new ();
4388 bgp_static
->backdoor
= 0;
4389 bgp_static
->valid
= 0;
4390 bgp_static
->igpmetric
= 0;
4391 bgp_static
->igpnexthop
.s_addr
= 0;
4392 memcpy(bgp_static
->tag
, tag
, 3);
4393 bgp_static
->prd
= prd
;
4397 if (bgp_static
->rmap
.name
)
4398 free (bgp_static
->rmap
.name
);
4399 bgp_static
->rmap
.name
= strdup (rmap_str
);
4400 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4402 rn
->info
= bgp_static
;
4404 bgp_static
->valid
= 1;
4405 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4411 /* Configure static BGP network. */
4413 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4414 const char *rd_str
, const char *tag_str
)
4419 struct prefix_rd prd
;
4420 struct bgp_node
*prn
;
4421 struct bgp_node
*rn
;
4422 struct bgp_table
*table
;
4423 struct bgp_static
*bgp_static
;
4428 /* Convert IP prefix string to struct prefix. */
4429 ret
= str2prefix (ip_str
, &p
);
4432 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4437 ret
= str2prefix_rd (rd_str
, &prd
);
4440 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4444 ret
= str2tag (tag_str
, tag
);
4447 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4451 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4452 (struct prefix
*)&prd
);
4453 if (prn
->info
== NULL
)
4454 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4456 bgp_unlock_node (prn
);
4459 rn
= bgp_node_lookup (table
, &p
);
4463 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4465 bgp_static
= rn
->info
;
4466 bgp_static_free (bgp_static
);
4468 bgp_unlock_node (rn
);
4469 bgp_unlock_node (rn
);
4472 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4478 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4479 const char *rmap_name
)
4481 struct bgp_rmap
*rmap
;
4483 rmap
= &bgp
->table_map
[afi
][safi
];
4487 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4488 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4489 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4494 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4499 bgp_zebra_announce_table(bgp
, afi
, safi
);
4505 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4506 const char *rmap_name
)
4508 struct bgp_rmap
*rmap
;
4510 rmap
= &bgp
->table_map
[afi
][safi
];
4512 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4516 bgp_zebra_announce_table(bgp
, afi
, safi
);
4522 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4523 safi_t safi
, int *write
)
4525 if (bgp
->table_map
[afi
][safi
].name
)
4527 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4528 vty_out (vty
, " table-map %s%s",
4529 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4535 DEFUN (bgp_table_map
,
4538 "BGP table to RIB route download filter\n"
4539 "Name of the route map\n")
4541 return bgp_table_map_set (vty
, vty
->index
,
4542 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4544 DEFUN (no_bgp_table_map
,
4545 no_bgp_table_map_cmd
,
4546 "no table-map WORD",
4547 "BGP table to RIB route download filter\n"
4548 "Name of the route map\n")
4550 return bgp_table_map_unset (vty
, vty
->index
,
4551 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4556 "network A.B.C.D/M",
4557 "Specify a network to announce via BGP\n"
4558 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4560 return bgp_static_set (vty
, vty
->index
, argv
[0],
4561 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4564 DEFUN (bgp_network_route_map
,
4565 bgp_network_route_map_cmd
,
4566 "network A.B.C.D/M route-map WORD",
4567 "Specify a network to announce via BGP\n"
4568 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4569 "Route-map to modify the attributes\n"
4570 "Name of the route map\n")
4572 return bgp_static_set (vty
, vty
->index
, argv
[0],
4573 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4576 DEFUN (bgp_network_backdoor
,
4577 bgp_network_backdoor_cmd
,
4578 "network A.B.C.D/M backdoor",
4579 "Specify a network to announce via BGP\n"
4580 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4581 "Specify a BGP backdoor route\n")
4583 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4587 DEFUN (bgp_network_mask
,
4588 bgp_network_mask_cmd
,
4589 "network A.B.C.D mask A.B.C.D",
4590 "Specify a network to announce via BGP\n"
4596 char prefix_str
[BUFSIZ
];
4598 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4601 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4605 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4606 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4609 DEFUN (bgp_network_mask_route_map
,
4610 bgp_network_mask_route_map_cmd
,
4611 "network A.B.C.D mask A.B.C.D route-map WORD",
4612 "Specify a network to announce via BGP\n"
4616 "Route-map to modify the attributes\n"
4617 "Name of the route map\n")
4620 char prefix_str
[BUFSIZ
];
4622 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4625 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4629 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4630 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4633 DEFUN (bgp_network_mask_backdoor
,
4634 bgp_network_mask_backdoor_cmd
,
4635 "network A.B.C.D mask A.B.C.D backdoor",
4636 "Specify a network to announce via BGP\n"
4640 "Specify a BGP backdoor route\n")
4643 char prefix_str
[BUFSIZ
];
4645 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4648 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4652 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4656 DEFUN (bgp_network_mask_natural
,
4657 bgp_network_mask_natural_cmd
,
4659 "Specify a network to announce via BGP\n"
4663 char prefix_str
[BUFSIZ
];
4665 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4668 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4672 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4673 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4676 DEFUN (bgp_network_mask_natural_route_map
,
4677 bgp_network_mask_natural_route_map_cmd
,
4678 "network A.B.C.D route-map WORD",
4679 "Specify a network to announce via BGP\n"
4681 "Route-map to modify the attributes\n"
4682 "Name of the route map\n")
4685 char prefix_str
[BUFSIZ
];
4687 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4690 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4694 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4695 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4698 DEFUN (bgp_network_mask_natural_backdoor
,
4699 bgp_network_mask_natural_backdoor_cmd
,
4700 "network A.B.C.D backdoor",
4701 "Specify a network to announce via BGP\n"
4703 "Specify a BGP backdoor route\n")
4706 char prefix_str
[BUFSIZ
];
4708 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4711 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4715 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4719 DEFUN (no_bgp_network
,
4721 "no network A.B.C.D/M",
4723 "Specify a network to announce via BGP\n"
4724 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4726 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4727 bgp_node_safi (vty
));
4730 ALIAS (no_bgp_network
,
4731 no_bgp_network_route_map_cmd
,
4732 "no network A.B.C.D/M route-map WORD",
4734 "Specify a network to announce via BGP\n"
4735 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4736 "Route-map to modify the attributes\n"
4737 "Name of the route map\n")
4739 ALIAS (no_bgp_network
,
4740 no_bgp_network_backdoor_cmd
,
4741 "no network A.B.C.D/M backdoor",
4743 "Specify a network to announce via BGP\n"
4744 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4745 "Specify a BGP backdoor route\n")
4747 DEFUN (no_bgp_network_mask
,
4748 no_bgp_network_mask_cmd
,
4749 "no network A.B.C.D mask A.B.C.D",
4751 "Specify a network to announce via BGP\n"
4757 char prefix_str
[BUFSIZ
];
4759 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4762 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4766 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4767 bgp_node_safi (vty
));
4770 ALIAS (no_bgp_network_mask
,
4771 no_bgp_network_mask_route_map_cmd
,
4772 "no network A.B.C.D mask A.B.C.D route-map WORD",
4774 "Specify a network to announce via BGP\n"
4778 "Route-map to modify the attributes\n"
4779 "Name of the route map\n")
4781 ALIAS (no_bgp_network_mask
,
4782 no_bgp_network_mask_backdoor_cmd
,
4783 "no network A.B.C.D mask A.B.C.D backdoor",
4785 "Specify a network to announce via BGP\n"
4789 "Specify a BGP backdoor route\n")
4791 DEFUN (no_bgp_network_mask_natural
,
4792 no_bgp_network_mask_natural_cmd
,
4793 "no network A.B.C.D",
4795 "Specify a network to announce via BGP\n"
4799 char prefix_str
[BUFSIZ
];
4801 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4804 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4808 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4809 bgp_node_safi (vty
));
4812 ALIAS (no_bgp_network_mask_natural
,
4813 no_bgp_network_mask_natural_route_map_cmd
,
4814 "no network A.B.C.D route-map WORD",
4816 "Specify a network to announce via BGP\n"
4818 "Route-map to modify the attributes\n"
4819 "Name of the route map\n")
4821 ALIAS (no_bgp_network_mask_natural
,
4822 no_bgp_network_mask_natural_backdoor_cmd
,
4823 "no network A.B.C.D backdoor",
4825 "Specify a network to announce via BGP\n"
4827 "Specify a BGP backdoor route\n")
4830 DEFUN (ipv6_bgp_network
,
4831 ipv6_bgp_network_cmd
,
4832 "network X:X::X:X/M",
4833 "Specify a network to announce via BGP\n"
4834 "IPv6 prefix <network>/<length>\n")
4836 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4840 DEFUN (ipv6_bgp_network_route_map
,
4841 ipv6_bgp_network_route_map_cmd
,
4842 "network X:X::X:X/M route-map WORD",
4843 "Specify a network to announce via BGP\n"
4844 "IPv6 prefix <network>/<length>\n"
4845 "Route-map to modify the attributes\n"
4846 "Name of the route map\n")
4848 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4849 bgp_node_safi (vty
), argv
[1], 0);
4852 DEFUN (no_ipv6_bgp_network
,
4853 no_ipv6_bgp_network_cmd
,
4854 "no network X:X::X:X/M",
4856 "Specify a network to announce via BGP\n"
4857 "IPv6 prefix <network>/<length>\n")
4859 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4862 ALIAS (no_ipv6_bgp_network
,
4863 no_ipv6_bgp_network_route_map_cmd
,
4864 "no network X:X::X:X/M route-map WORD",
4866 "Specify a network to announce via BGP\n"
4867 "IPv6 prefix <network>/<length>\n"
4868 "Route-map to modify the attributes\n"
4869 "Name of the route map\n")
4871 ALIAS (ipv6_bgp_network
,
4872 old_ipv6_bgp_network_cmd
,
4873 "ipv6 bgp network X:X::X:X/M",
4876 "Specify a network to announce via BGP\n"
4877 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4879 ALIAS (no_ipv6_bgp_network
,
4880 old_no_ipv6_bgp_network_cmd
,
4881 "no ipv6 bgp network X:X::X:X/M",
4885 "Specify a network to announce via BGP\n"
4886 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4887 #endif /* HAVE_IPV6 */
4889 /* Aggreagete address:
4891 advertise-map Set condition to advertise attribute
4892 as-set Generate AS set path information
4893 attribute-map Set attributes of aggregate
4894 route-map Set parameters of aggregate
4895 summary-only Filter more specific routes from updates
4896 suppress-map Conditionally filter more specific routes from updates
4899 struct bgp_aggregate
4901 /* Summary-only flag. */
4902 u_char summary_only
;
4904 /* AS set generation. */
4907 /* Route-map for aggregated route. */
4908 struct route_map
*map
;
4910 /* Suppress-count. */
4911 unsigned long count
;
4913 /* SAFI configuration. */
4917 static struct bgp_aggregate
*
4918 bgp_aggregate_new (void)
4920 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4924 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4926 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4929 /* Update an aggregate as routes are added/removed from the BGP table */
4931 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4932 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4933 struct bgp_aggregate
*aggregate
)
4935 struct bgp_table
*table
;
4936 struct bgp_node
*top
;
4937 struct bgp_node
*rn
;
4939 struct aspath
*aspath
= NULL
;
4940 struct aspath
*asmerge
= NULL
;
4941 struct community
*community
= NULL
;
4942 struct community
*commerge
= NULL
;
4943 #if defined(AGGREGATE_NEXTHOP_CHECK)
4944 struct in_addr nexthop
;
4947 struct bgp_info
*ri
;
4948 struct bgp_info
*new;
4950 unsigned long match
= 0;
4951 u_char atomic_aggregate
= 0;
4953 /* Record adding route's nexthop and med. */
4956 #if defined(AGGREGATE_NEXTHOP_CHECK)
4957 nexthop
= rinew
->attr
->nexthop
;
4958 med
= rinew
->attr
->med
;
4962 /* ORIGIN attribute: If at least one route among routes that are
4963 aggregated has ORIGIN with the value INCOMPLETE, then the
4964 aggregated route must have the ORIGIN attribute with the value
4965 INCOMPLETE. Otherwise, if at least one route among routes that
4966 are aggregated has ORIGIN with the value EGP, then the aggregated
4967 route must have the origin attribute with the value EGP. In all
4968 other case the value of the ORIGIN attribute of the aggregated
4969 route is INTERNAL. */
4970 origin
= BGP_ORIGIN_IGP
;
4972 table
= bgp
->rib
[afi
][safi
];
4974 top
= bgp_node_get (table
, p
);
4975 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4976 if (rn
->p
.prefixlen
> p
->prefixlen
)
4980 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4982 if (BGP_INFO_HOLDDOWN (ri
))
4985 if (del
&& ri
== del
)
4988 if (! rinew
&& first
)
4990 #if defined(AGGREGATE_NEXTHOP_CHECK)
4991 nexthop
= ri
->attr
->nexthop
;
4992 med
= ri
->attr
->med
;
4997 #ifdef AGGREGATE_NEXTHOP_CHECK
4998 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4999 || ri
->attr
->med
!= med
)
5002 aspath_free (aspath
);
5004 community_free (community
);
5005 bgp_unlock_node (rn
);
5006 bgp_unlock_node (top
);
5009 #endif /* AGGREGATE_NEXTHOP_CHECK */
5011 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5012 atomic_aggregate
= 1;
5014 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5016 if (aggregate
->summary_only
)
5018 (bgp_info_extra_get (ri
))->suppress
++;
5019 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5025 if (origin
< ri
->attr
->origin
)
5026 origin
= ri
->attr
->origin
;
5028 if (aggregate
->as_set
)
5032 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5033 aspath_free (aspath
);
5037 aspath
= aspath_dup (ri
->attr
->aspath
);
5039 if (ri
->attr
->community
)
5043 commerge
= community_merge (community
,
5044 ri
->attr
->community
);
5045 community
= community_uniq_sort (commerge
);
5046 community_free (commerge
);
5049 community
= community_dup (ri
->attr
->community
);
5055 bgp_process (bgp
, rn
, afi
, safi
);
5057 bgp_unlock_node (top
);
5063 if (aggregate
->summary_only
)
5064 (bgp_info_extra_get (rinew
))->suppress
++;
5066 if (origin
< rinew
->attr
->origin
)
5067 origin
= rinew
->attr
->origin
;
5069 if (aggregate
->as_set
)
5073 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
5074 aspath_free (aspath
);
5078 aspath
= aspath_dup (rinew
->attr
->aspath
);
5080 if (rinew
->attr
->community
)
5084 commerge
= community_merge (community
,
5085 rinew
->attr
->community
);
5086 community
= community_uniq_sort (commerge
);
5087 community_free (commerge
);
5090 community
= community_dup (rinew
->attr
->community
);
5095 if (aggregate
->count
> 0)
5097 rn
= bgp_node_get (table
, p
);
5098 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5099 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5101 atomic_aggregate
), rn
);
5102 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5104 bgp_info_add (rn
, new);
5105 bgp_unlock_node (rn
);
5106 bgp_process (bgp
, rn
, afi
, safi
);
5111 aspath_free (aspath
);
5113 community_free (community
);
5117 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
5118 struct bgp_aggregate
*);
5121 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
5122 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
5124 struct bgp_node
*child
;
5125 struct bgp_node
*rn
;
5126 struct bgp_aggregate
*aggregate
;
5127 struct bgp_table
*table
;
5129 /* MPLS-VPN aggregation is not yet supported. */
5130 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5133 table
= bgp
->aggregate
[afi
][safi
];
5135 /* No aggregates configured. */
5136 if (bgp_table_top_nolock (table
) == NULL
)
5139 if (p
->prefixlen
== 0)
5142 if (BGP_INFO_HOLDDOWN (ri
))
5145 child
= bgp_node_get (table
, p
);
5147 /* Aggregate address configuration check. */
5148 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5149 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5151 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5152 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
5154 bgp_unlock_node (child
);
5158 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
5159 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
5161 struct bgp_node
*child
;
5162 struct bgp_node
*rn
;
5163 struct bgp_aggregate
*aggregate
;
5164 struct bgp_table
*table
;
5166 /* MPLS-VPN aggregation is not yet supported. */
5167 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5170 table
= bgp
->aggregate
[afi
][safi
];
5172 /* No aggregates configured. */
5173 if (bgp_table_top_nolock (table
) == NULL
)
5176 if (p
->prefixlen
== 0)
5179 child
= bgp_node_get (table
, p
);
5181 /* Aggregate address configuration check. */
5182 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5183 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5185 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5186 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
5188 bgp_unlock_node (child
);
5191 /* Called via bgp_aggregate_set when the user configures aggregate-address */
5193 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
5194 struct bgp_aggregate
*aggregate
)
5196 struct bgp_table
*table
;
5197 struct bgp_node
*top
;
5198 struct bgp_node
*rn
;
5199 struct bgp_info
*new;
5200 struct bgp_info
*ri
;
5201 unsigned long match
;
5202 u_char origin
= BGP_ORIGIN_IGP
;
5203 struct aspath
*aspath
= NULL
;
5204 struct aspath
*asmerge
= NULL
;
5205 struct community
*community
= NULL
;
5206 struct community
*commerge
= NULL
;
5207 u_char atomic_aggregate
= 0;
5209 table
= bgp
->rib
[afi
][safi
];
5212 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5214 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5217 /* If routes exists below this node, generate aggregate routes. */
5218 top
= bgp_node_get (table
, p
);
5219 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5220 if (rn
->p
.prefixlen
> p
->prefixlen
)
5224 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5226 if (BGP_INFO_HOLDDOWN (ri
))
5229 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5230 atomic_aggregate
= 1;
5232 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5234 /* summary-only aggregate route suppress aggregated
5235 route announcement. */
5236 if (aggregate
->summary_only
)
5238 (bgp_info_extra_get (ri
))->suppress
++;
5239 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5243 /* If at least one route among routes that are aggregated has
5244 * ORIGIN with the value INCOMPLETE, then the aggregated route
5245 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5246 * Otherwise, if at least one route among routes that are
5247 * aggregated has ORIGIN with the value EGP, then the aggregated
5248 * route MUST have the ORIGIN attribute with the value EGP.
5250 if (origin
< ri
->attr
->origin
)
5251 origin
= ri
->attr
->origin
;
5253 /* as-set aggregate route generate origin, as path,
5254 community aggregation. */
5255 if (aggregate
->as_set
)
5259 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5260 aspath_free (aspath
);
5264 aspath
= aspath_dup (ri
->attr
->aspath
);
5266 if (ri
->attr
->community
)
5270 commerge
= community_merge (community
,
5271 ri
->attr
->community
);
5272 community
= community_uniq_sort (commerge
);
5273 community_free (commerge
);
5276 community
= community_dup (ri
->attr
->community
);
5283 /* If this node is suppressed, process the change. */
5285 bgp_process (bgp
, rn
, afi
, safi
);
5287 bgp_unlock_node (top
);
5289 /* Add aggregate route to BGP table. */
5290 if (aggregate
->count
)
5292 rn
= bgp_node_get (table
, p
);
5293 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5294 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5296 atomic_aggregate
), rn
);
5297 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5299 bgp_info_add (rn
, new);
5300 bgp_unlock_node (rn
);
5302 /* Process change. */
5303 bgp_process (bgp
, rn
, afi
, safi
);
5308 aspath_free (aspath
);
5310 community_free (community
);
5315 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5316 safi_t safi
, struct bgp_aggregate
*aggregate
)
5318 struct bgp_table
*table
;
5319 struct bgp_node
*top
;
5320 struct bgp_node
*rn
;
5321 struct bgp_info
*ri
;
5322 unsigned long match
;
5324 table
= bgp
->rib
[afi
][safi
];
5326 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5328 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5331 /* If routes exists below this node, generate aggregate routes. */
5332 top
= bgp_node_get (table
, p
);
5333 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5334 if (rn
->p
.prefixlen
> p
->prefixlen
)
5338 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5340 if (BGP_INFO_HOLDDOWN (ri
))
5343 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5345 if (aggregate
->summary_only
&& ri
->extra
)
5347 ri
->extra
->suppress
--;
5349 if (ri
->extra
->suppress
== 0)
5351 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5359 /* If this node was suppressed, process the change. */
5361 bgp_process (bgp
, rn
, afi
, safi
);
5363 bgp_unlock_node (top
);
5365 /* Delete aggregate route from BGP table. */
5366 rn
= bgp_node_get (table
, p
);
5368 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5369 if (ri
->peer
== bgp
->peer_self
5370 && ri
->type
== ZEBRA_ROUTE_BGP
5371 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5374 /* Withdraw static BGP route from routing table. */
5377 bgp_info_delete (rn
, ri
);
5378 bgp_process (bgp
, rn
, afi
, safi
);
5381 /* Unlock bgp_node_lookup. */
5382 bgp_unlock_node (rn
);
5385 /* Aggregate route attribute. */
5386 #define AGGREGATE_SUMMARY_ONLY 1
5387 #define AGGREGATE_AS_SET 1
5390 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5391 afi_t afi
, safi_t safi
)
5395 struct bgp_node
*rn
;
5397 struct bgp_aggregate
*aggregate
;
5399 /* Convert string to prefix structure. */
5400 ret
= str2prefix (prefix_str
, &p
);
5403 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5408 /* Get BGP structure. */
5411 /* Old configuration check. */
5412 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5415 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5420 aggregate
= rn
->info
;
5421 if (aggregate
->safi
& SAFI_UNICAST
)
5422 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5423 if (aggregate
->safi
& SAFI_MULTICAST
)
5424 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5426 /* Unlock aggregate address configuration. */
5428 bgp_aggregate_free (aggregate
);
5429 bgp_unlock_node (rn
);
5430 bgp_unlock_node (rn
);
5436 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5437 afi_t afi
, safi_t safi
,
5438 u_char summary_only
, u_char as_set
)
5442 struct bgp_node
*rn
;
5444 struct bgp_aggregate
*aggregate
;
5446 /* Convert string to prefix structure. */
5447 ret
= str2prefix (prefix_str
, &p
);
5450 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5455 /* Get BGP structure. */
5458 /* Old configuration check. */
5459 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5463 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5464 /* try to remove the old entry */
5465 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5468 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5469 bgp_unlock_node (rn
);
5474 /* Make aggregate address structure. */
5475 aggregate
= bgp_aggregate_new ();
5476 aggregate
->summary_only
= summary_only
;
5477 aggregate
->as_set
= as_set
;
5478 aggregate
->safi
= safi
;
5479 rn
->info
= aggregate
;
5481 /* Aggregate address insert into BGP routing table. */
5482 if (safi
& SAFI_UNICAST
)
5483 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5484 if (safi
& SAFI_MULTICAST
)
5485 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5490 DEFUN (aggregate_address
,
5491 aggregate_address_cmd
,
5492 "aggregate-address A.B.C.D/M",
5493 "Configure BGP aggregate entries\n"
5494 "Aggregate prefix\n")
5496 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5499 DEFUN (aggregate_address_mask
,
5500 aggregate_address_mask_cmd
,
5501 "aggregate-address A.B.C.D A.B.C.D",
5502 "Configure BGP aggregate entries\n"
5503 "Aggregate address\n"
5507 char prefix_str
[BUFSIZ
];
5509 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5513 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5517 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5521 DEFUN (aggregate_address_summary_only
,
5522 aggregate_address_summary_only_cmd
,
5523 "aggregate-address A.B.C.D/M summary-only",
5524 "Configure BGP aggregate entries\n"
5525 "Aggregate prefix\n"
5526 "Filter more specific routes from updates\n")
5528 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5529 AGGREGATE_SUMMARY_ONLY
, 0);
5532 DEFUN (aggregate_address_mask_summary_only
,
5533 aggregate_address_mask_summary_only_cmd
,
5534 "aggregate-address A.B.C.D A.B.C.D summary-only",
5535 "Configure BGP aggregate entries\n"
5536 "Aggregate address\n"
5538 "Filter more specific routes from updates\n")
5541 char prefix_str
[BUFSIZ
];
5543 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5547 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5551 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5552 AGGREGATE_SUMMARY_ONLY
, 0);
5555 DEFUN (aggregate_address_as_set
,
5556 aggregate_address_as_set_cmd
,
5557 "aggregate-address A.B.C.D/M as-set",
5558 "Configure BGP aggregate entries\n"
5559 "Aggregate prefix\n"
5560 "Generate AS set path information\n")
5562 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5563 0, AGGREGATE_AS_SET
);
5566 DEFUN (aggregate_address_mask_as_set
,
5567 aggregate_address_mask_as_set_cmd
,
5568 "aggregate-address A.B.C.D A.B.C.D as-set",
5569 "Configure BGP aggregate entries\n"
5570 "Aggregate address\n"
5572 "Generate AS set path information\n")
5575 char prefix_str
[BUFSIZ
];
5577 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5581 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5585 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5586 0, AGGREGATE_AS_SET
);
5590 DEFUN (aggregate_address_as_set_summary
,
5591 aggregate_address_as_set_summary_cmd
,
5592 "aggregate-address A.B.C.D/M as-set summary-only",
5593 "Configure BGP aggregate entries\n"
5594 "Aggregate prefix\n"
5595 "Generate AS set path information\n"
5596 "Filter more specific routes from updates\n")
5598 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5599 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5602 ALIAS (aggregate_address_as_set_summary
,
5603 aggregate_address_summary_as_set_cmd
,
5604 "aggregate-address A.B.C.D/M summary-only as-set",
5605 "Configure BGP aggregate entries\n"
5606 "Aggregate prefix\n"
5607 "Filter more specific routes from updates\n"
5608 "Generate AS set path information\n")
5610 DEFUN (aggregate_address_mask_as_set_summary
,
5611 aggregate_address_mask_as_set_summary_cmd
,
5612 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5613 "Configure BGP aggregate entries\n"
5614 "Aggregate address\n"
5616 "Generate AS set path information\n"
5617 "Filter more specific routes from updates\n")
5620 char prefix_str
[BUFSIZ
];
5622 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5626 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5630 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5631 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5634 ALIAS (aggregate_address_mask_as_set_summary
,
5635 aggregate_address_mask_summary_as_set_cmd
,
5636 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5637 "Configure BGP aggregate entries\n"
5638 "Aggregate address\n"
5640 "Filter more specific routes from updates\n"
5641 "Generate AS set path information\n")
5643 DEFUN (no_aggregate_address
,
5644 no_aggregate_address_cmd
,
5645 "no aggregate-address A.B.C.D/M",
5647 "Configure BGP aggregate entries\n"
5648 "Aggregate prefix\n")
5650 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5653 ALIAS (no_aggregate_address
,
5654 no_aggregate_address_summary_only_cmd
,
5655 "no aggregate-address A.B.C.D/M summary-only",
5657 "Configure BGP aggregate entries\n"
5658 "Aggregate prefix\n"
5659 "Filter more specific routes from updates\n")
5661 ALIAS (no_aggregate_address
,
5662 no_aggregate_address_as_set_cmd
,
5663 "no aggregate-address A.B.C.D/M as-set",
5665 "Configure BGP aggregate entries\n"
5666 "Aggregate prefix\n"
5667 "Generate AS set path information\n")
5669 ALIAS (no_aggregate_address
,
5670 no_aggregate_address_as_set_summary_cmd
,
5671 "no aggregate-address A.B.C.D/M as-set summary-only",
5673 "Configure BGP aggregate entries\n"
5674 "Aggregate prefix\n"
5675 "Generate AS set path information\n"
5676 "Filter more specific routes from updates\n")
5678 ALIAS (no_aggregate_address
,
5679 no_aggregate_address_summary_as_set_cmd
,
5680 "no aggregate-address A.B.C.D/M summary-only as-set",
5682 "Configure BGP aggregate entries\n"
5683 "Aggregate prefix\n"
5684 "Filter more specific routes from updates\n"
5685 "Generate AS set path information\n")
5687 DEFUN (no_aggregate_address_mask
,
5688 no_aggregate_address_mask_cmd
,
5689 "no aggregate-address A.B.C.D A.B.C.D",
5691 "Configure BGP aggregate entries\n"
5692 "Aggregate address\n"
5696 char prefix_str
[BUFSIZ
];
5698 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5702 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5706 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5709 ALIAS (no_aggregate_address_mask
,
5710 no_aggregate_address_mask_summary_only_cmd
,
5711 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5713 "Configure BGP aggregate entries\n"
5714 "Aggregate address\n"
5716 "Filter more specific routes from updates\n")
5718 ALIAS (no_aggregate_address_mask
,
5719 no_aggregate_address_mask_as_set_cmd
,
5720 "no aggregate-address A.B.C.D A.B.C.D as-set",
5722 "Configure BGP aggregate entries\n"
5723 "Aggregate address\n"
5725 "Generate AS set path information\n")
5727 ALIAS (no_aggregate_address_mask
,
5728 no_aggregate_address_mask_as_set_summary_cmd
,
5729 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5731 "Configure BGP aggregate entries\n"
5732 "Aggregate address\n"
5734 "Generate AS set path information\n"
5735 "Filter more specific routes from updates\n")
5737 ALIAS (no_aggregate_address_mask
,
5738 no_aggregate_address_mask_summary_as_set_cmd
,
5739 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5741 "Configure BGP aggregate entries\n"
5742 "Aggregate address\n"
5744 "Filter more specific routes from updates\n"
5745 "Generate AS set path information\n")
5748 DEFUN (ipv6_aggregate_address
,
5749 ipv6_aggregate_address_cmd
,
5750 "aggregate-address X:X::X:X/M",
5751 "Configure BGP aggregate entries\n"
5752 "Aggregate prefix\n")
5754 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5757 DEFUN (ipv6_aggregate_address_summary_only
,
5758 ipv6_aggregate_address_summary_only_cmd
,
5759 "aggregate-address X:X::X:X/M summary-only",
5760 "Configure BGP aggregate entries\n"
5761 "Aggregate prefix\n"
5762 "Filter more specific routes from updates\n")
5764 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5765 AGGREGATE_SUMMARY_ONLY
, 0);
5768 DEFUN (no_ipv6_aggregate_address
,
5769 no_ipv6_aggregate_address_cmd
,
5770 "no aggregate-address X:X::X:X/M",
5772 "Configure BGP aggregate entries\n"
5773 "Aggregate prefix\n")
5775 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5778 DEFUN (no_ipv6_aggregate_address_summary_only
,
5779 no_ipv6_aggregate_address_summary_only_cmd
,
5780 "no aggregate-address X:X::X:X/M summary-only",
5782 "Configure BGP aggregate entries\n"
5783 "Aggregate prefix\n"
5784 "Filter more specific routes from updates\n")
5786 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5789 ALIAS (ipv6_aggregate_address
,
5790 old_ipv6_aggregate_address_cmd
,
5791 "ipv6 bgp aggregate-address X:X::X:X/M",
5794 "Configure BGP aggregate entries\n"
5795 "Aggregate prefix\n")
5797 ALIAS (ipv6_aggregate_address_summary_only
,
5798 old_ipv6_aggregate_address_summary_only_cmd
,
5799 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5802 "Configure BGP aggregate entries\n"
5803 "Aggregate prefix\n"
5804 "Filter more specific routes from updates\n")
5806 ALIAS (no_ipv6_aggregate_address
,
5807 old_no_ipv6_aggregate_address_cmd
,
5808 "no ipv6 bgp aggregate-address X:X::X:X/M",
5812 "Configure BGP aggregate entries\n"
5813 "Aggregate prefix\n")
5815 ALIAS (no_ipv6_aggregate_address_summary_only
,
5816 old_no_ipv6_aggregate_address_summary_only_cmd
,
5817 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5821 "Configure BGP aggregate entries\n"
5822 "Aggregate prefix\n"
5823 "Filter more specific routes from updates\n")
5824 #endif /* HAVE_IPV6 */
5826 /* Redistribute route treatment. */
5828 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5829 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5830 u_int32_t metric
, u_char type
, u_short instance
, route_tag_t tag
)
5832 struct bgp_info
*new;
5833 struct bgp_info
*bi
;
5834 struct bgp_info info
;
5835 struct bgp_node
*bn
;
5837 struct attr
*new_attr
;
5840 struct bgp_redist
*red
;
5842 /* Make default attribute. */
5843 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5845 attr
.nexthop
= *nexthop
;
5846 attr
.nh_ifindex
= ifindex
;
5851 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5852 extra
->mp_nexthop_global
= *nexthop6
;
5853 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5858 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5859 attr
.extra
->tag
= tag
;
5861 afi
= family2afi (p
->family
);
5863 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5866 struct attr attr_new
;
5867 struct attr_extra extra_new
;
5869 /* Copy attribute for modification. */
5870 attr_new
.extra
= &extra_new
;
5871 bgp_attr_dup (&attr_new
, &attr
);
5873 if (red
->redist_metric_flag
)
5874 attr_new
.med
= red
->redist_metric
;
5876 /* Apply route-map. */
5879 info
.peer
= bgp
->peer_self
;
5880 info
.attr
= &attr_new
;
5882 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5884 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5886 bgp
->peer_self
->rmap_type
= 0;
5888 if (ret
== RMAP_DENYMATCH
)
5890 /* Free uninterned attribute. */
5891 bgp_attr_flush (&attr_new
);
5893 /* Unintern original. */
5894 aspath_unintern (&attr
.aspath
);
5895 bgp_attr_extra_free (&attr
);
5896 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5901 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5902 afi
, SAFI_UNICAST
, p
, NULL
);
5904 new_attr
= bgp_attr_intern (&attr_new
);
5906 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5907 if (bi
->peer
== bgp
->peer_self
5908 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5913 /* Ensure the (source route) type is updated. */
5915 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5916 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5918 bgp_attr_unintern (&new_attr
);
5919 aspath_unintern (&attr
.aspath
);
5920 bgp_attr_extra_free (&attr
);
5921 bgp_unlock_node (bn
);
5926 /* The attribute is changed. */
5927 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5929 /* Rewrite BGP route information. */
5930 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5931 bgp_info_restore(bn
, bi
);
5933 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5934 bgp_attr_unintern (&bi
->attr
);
5935 bi
->attr
= new_attr
;
5936 bi
->uptime
= bgp_clock ();
5938 /* Process change. */
5939 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5940 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5941 bgp_unlock_node (bn
);
5942 aspath_unintern (&attr
.aspath
);
5943 bgp_attr_extra_free (&attr
);
5948 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5950 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5952 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5953 bgp_info_add (bn
, new);
5954 bgp_unlock_node (bn
);
5955 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5958 /* Unintern original. */
5959 aspath_unintern (&attr
.aspath
);
5960 bgp_attr_extra_free (&attr
);
5964 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5967 struct bgp_node
*rn
;
5968 struct bgp_info
*ri
;
5969 struct bgp_redist
*red
;
5971 afi
= family2afi (p
->family
);
5973 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5976 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5978 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5979 if (ri
->peer
== bgp
->peer_self
5980 && ri
->type
== type
)
5985 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5986 bgp_info_delete (rn
, ri
);
5987 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5989 bgp_unlock_node (rn
);
5993 /* Withdraw specified route type's route. */
5995 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5997 struct bgp_node
*rn
;
5998 struct bgp_info
*ri
;
5999 struct bgp_table
*table
;
6001 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
6003 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6005 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6006 if (ri
->peer
== bgp
->peer_self
6008 && ri
->instance
== instance
)
6013 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
6014 bgp_info_delete (rn
, ri
);
6015 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
6020 /* Static function to display route. */
6022 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
6025 u_int32_t destination
;
6028 if (p
->family
== AF_INET
)
6030 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
6031 destination
= ntohl (p
->u
.prefix4
.s_addr
);
6033 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
6034 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
6035 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
6036 || p
->u
.prefix4
.s_addr
== 0)
6038 /* When mask is natural, mask is not displayed. */
6041 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
6044 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
6049 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
6051 vty_out (vty
, "%*s", len
, " ");
6054 enum bgp_display_type
6059 /* Print the short form route status for a bgp_info */
6061 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
6062 json_object
*json_path
)
6067 /* Route status display. */
6068 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6069 json_object_boolean_true_add(json_path
, "removed");
6071 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6072 json_object_boolean_true_add(json_path
, "stale");
6074 if (binfo
->extra
&& binfo
->extra
->suppress
)
6075 json_object_boolean_true_add(json_path
, "suppressed");
6077 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6078 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6079 json_object_boolean_true_add(json_path
, "valid");
6082 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6083 json_object_boolean_true_add(json_path
, "history");
6085 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6086 json_object_boolean_true_add(json_path
, "damped");
6088 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6089 json_object_boolean_true_add(json_path
, "bestpath");
6091 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6092 json_object_boolean_true_add(json_path
, "multipath");
6094 /* Internal route. */
6095 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6096 json_object_string_add(json_path
, "pathFrom", "internal");
6098 json_object_string_add(json_path
, "pathFrom", "external");
6103 /* Route status display. */
6104 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6106 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6108 else if (binfo
->extra
&& binfo
->extra
->suppress
)
6110 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6111 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6117 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6119 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6121 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6123 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6128 /* Internal route. */
6129 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6135 /* called from terminal list command */
6137 route_vty_out (struct vty
*vty
, struct prefix
*p
,
6138 struct bgp_info
*binfo
, int display
, safi_t safi
,
6139 json_object
*json_paths
)
6142 json_object
*json_path
= NULL
;
6143 json_object
*json_nexthops
= NULL
;
6144 json_object
*json_nexthop_global
= NULL
;
6145 json_object
*json_nexthop_ll
= NULL
;
6148 json_path
= json_object_new_object();
6150 /* short status lead text */
6151 route_vty_short_status_out (vty
, binfo
, json_path
);
6155 /* print prefix and mask */
6157 route_vty_out_route (p
, vty
);
6159 vty_out (vty
, "%*s", 17, " ");
6162 /* Print attribute */
6167 * For ENCAP routes, nexthop address family is not
6168 * neccessarily the same as the prefix address family.
6169 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
6171 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
6176 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
6181 vty_out (vty
, "%s", inet_ntop(af
,
6182 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
6186 vty_out (vty
, "%s", inet_ntop(af
,
6187 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
6199 else if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6203 json_nexthop_global
= json_object_new_object();
6205 if (safi
== SAFI_MPLS_VPN
)
6206 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6208 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6210 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6211 json_object_boolean_true_add(json_nexthop_global
, "used");
6215 if (safi
== SAFI_MPLS_VPN
)
6216 vty_out (vty
, "%-16s",
6217 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6219 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6224 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6231 json_nexthop_global
= json_object_new_object();
6232 json_object_string_add(json_nexthop_global
, "ip",
6233 inet_ntop (AF_INET6
,
6234 &attr
->extra
->mp_nexthop_global
,
6236 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6237 json_object_string_add(json_nexthop_global
, "scope", "global");
6239 /* We display both LL & GL if both have been received */
6240 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
6242 json_nexthop_ll
= json_object_new_object();
6243 json_object_string_add(json_nexthop_ll
, "ip",
6244 inet_ntop (AF_INET6
,
6245 &attr
->extra
->mp_nexthop_local
,
6247 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6248 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6250 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
6251 &attr
->extra
->mp_nexthop_local
) != 0) &&
6252 !attr
->extra
->mp_nexthop_prefer_global
)
6253 json_object_boolean_true_add(json_nexthop_ll
, "used");
6255 json_object_boolean_true_add(json_nexthop_global
, "used");
6258 json_object_boolean_true_add(json_nexthop_global
, "used");
6262 /* Display LL if LL/Global both in table unless prefer-global is set */
6263 if (((attr
->extra
->mp_nexthop_len
== 32) &&
6264 !attr
->extra
->mp_nexthop_prefer_global
) ||
6265 (binfo
->peer
->conf_if
))
6267 if (binfo
->peer
->conf_if
)
6269 len
= vty_out (vty
, "%s",
6270 binfo
->peer
->conf_if
);
6271 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6274 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6276 vty_out (vty
, "%*s", len
, " ");
6280 len
= vty_out (vty
, "%s",
6281 inet_ntop (AF_INET6
,
6282 &attr
->extra
->mp_nexthop_local
,
6287 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6289 vty_out (vty
, "%*s", len
, " ");
6294 len
= vty_out (vty
, "%s",
6295 inet_ntop (AF_INET6
,
6296 &attr
->extra
->mp_nexthop_global
,
6301 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6303 vty_out (vty
, "%*s", len
, " ");
6309 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6311 json_object_int_add(json_path
, "med", attr
->med
);
6313 vty_out (vty
, "%10u", attr
->med
);
6319 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6321 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6323 vty_out (vty
, "%7u", attr
->local_pref
);
6331 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6333 json_object_int_add(json_path
, "weight", 0);
6336 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6340 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6347 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6349 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6354 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6356 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6361 json_object_string_add(json_path
, "alert", "No attributes");
6363 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6368 if (json_nexthop_global
|| json_nexthop_ll
)
6370 json_nexthops
= json_object_new_array();
6372 if (json_nexthop_global
)
6373 json_object_array_add(json_nexthops
, json_nexthop_global
);
6375 if (json_nexthop_ll
)
6376 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6378 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6381 json_object_array_add(json_paths
, json_path
);
6385 vty_out (vty
, "%s", VTY_NEWLINE
);
6387 /* prints an additional line, indented, with VNC info, if present */
6388 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
6389 rfapi_vty_out_vncinfo(vty
, p
, binfo
, safi
);
6394 /* called from terminal list command */
6396 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6397 u_char use_json
, json_object
*json_ar
)
6399 json_object
*json_status
= NULL
;
6400 json_object
*json_net
= NULL
;
6402 /* Route status display. */
6405 json_status
= json_object_new_object();
6406 json_net
= json_object_new_object();
6415 /* print prefix and mask */
6417 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6419 route_vty_out_route (p
, vty
);
6421 /* Print attribute */
6426 if (p
->family
== AF_INET
&&
6427 (safi
== SAFI_MPLS_VPN
||
6428 safi
== SAFI_ENCAP
||
6429 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6431 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6432 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6434 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6437 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6441 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6444 #endif /* HAVE_IPV6 */
6446 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6447 json_object_int_add(json_net
, "metric", attr
->med
);
6449 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6450 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6453 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6455 json_object_int_add(json_net
, "weight", 0);
6459 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6462 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6466 if (p
->family
== AF_INET
&&
6467 (safi
== SAFI_MPLS_VPN
||
6468 safi
== SAFI_ENCAP
||
6469 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6472 (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
))
6473 vty_out (vty
, "%-16s",
6474 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6476 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6479 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6485 len
= vty_out (vty
, "%s",
6486 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6493 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6495 vty_out (vty
, "%*s", len
, " ");
6497 #endif /* HAVE_IPV6 */
6498 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6499 vty_out (vty
, "%10u", attr
->med
);
6503 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6504 vty_out (vty
, "%7u", attr
->local_pref
);
6508 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6512 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6515 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6520 json_object_boolean_true_add(json_status
, "*");
6521 json_object_boolean_true_add(json_status
, ">");
6522 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6523 char buf_cut
[BUFSIZ
];
6524 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6527 vty_out (vty
, "%s", VTY_NEWLINE
);
6531 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6532 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6534 json_object
*json_out
= NULL
;
6536 u_int32_t label
= 0;
6542 json_out
= json_object_new_object();
6544 /* short status lead text */
6545 route_vty_short_status_out (vty
, binfo
, json_out
);
6547 /* print prefix and mask */
6551 route_vty_out_route (p
, vty
);
6553 vty_out (vty
, "%*s", 17, " ");
6556 /* Print attribute */
6560 if (p
->family
== AF_INET
6561 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6563 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6566 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6568 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6573 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6575 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6579 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6581 assert (attr
->extra
);
6585 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6588 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6589 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6592 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6595 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6599 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6601 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6603 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6604 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6607 vty_out (vty
, "%s(%s)",
6608 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6610 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6615 #endif /* HAVE_IPV6 */
6618 label
= decode_label (binfo
->extra
->tag
);
6623 json_object_int_add(json_out
, "notag", label
);
6624 json_object_array_add(json
, json_out
);
6628 vty_out (vty
, "notag/%d", label
);
6629 vty_out (vty
, "%s", VTY_NEWLINE
);
6633 /* dampening route */
6635 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6636 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6640 char timebuf
[BGP_UPTIME_LEN
];
6642 /* short status lead text */
6643 route_vty_short_status_out (vty
, binfo
, json
);
6645 /* print prefix and mask */
6649 route_vty_out_route (p
, vty
);
6651 vty_out (vty
, "%*s", 17, " ");
6654 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6659 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6664 json_object_int_add(json
, "peerHost", len
);
6666 vty_out (vty
, "%*s", len
, " ");
6670 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6672 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6674 /* Print attribute */
6682 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6684 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6689 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6691 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6694 vty_out (vty
, "%s", VTY_NEWLINE
);
6699 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6700 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6703 struct bgp_damp_info
*bdi
;
6704 char timebuf
[BGP_UPTIME_LEN
];
6710 bdi
= binfo
->extra
->damp_info
;
6712 /* short status lead text */
6713 route_vty_short_status_out (vty
, binfo
, json
);
6715 /* print prefix and mask */
6719 route_vty_out_route (p
, vty
);
6721 vty_out (vty
, "%*s", 17, " ");
6724 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6729 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6734 json_object_int_add(json
, "peerHost", len
);
6736 vty_out (vty
, "%*s", len
, " ");
6739 len
= vty_out (vty
, "%d", bdi
->flap
);
6749 json_object_int_add(json
, "bdiFlap", len
);
6751 vty_out (vty
, "%*s", len
, " ");
6755 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6757 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6758 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6760 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6761 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6764 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6766 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6771 vty_out (vty
, "%*s ", 8, " ");
6774 /* Print attribute */
6782 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6784 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6789 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6791 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6794 vty_out (vty
, "%s", VTY_NEWLINE
);
6798 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6799 const char *header
, json_object
*json_adv_to
)
6801 char buf1
[INET6_ADDRSTRLEN
];
6802 json_object
*json_peer
= NULL
;
6806 /* 'advertised-to' is a dictionary of peers we have advertised this
6807 * prefix too. The key is the peer's IP or swpX, the value is the
6808 * hostname if we know it and "" if not.
6810 json_peer
= json_object_new_object();
6813 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6816 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6818 json_object_object_add(json_adv_to
,
6819 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6826 vty_out (vty
, "%s", header
);
6830 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6833 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6835 vty_out (vty
, " %s(%s)", peer
->hostname
,
6836 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6841 vty_out (vty
, " %s", peer
->conf_if
);
6843 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6849 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6850 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6851 json_object
*json_paths
)
6853 char buf
[INET6_ADDRSTRLEN
];
6856 int sockunion_vty_out (struct vty
*, union sockunion
*);
6857 #ifdef HAVE_CLOCK_MONOTONIC
6860 json_object
*json_bestpath
= NULL
;
6861 json_object
*json_cluster_list
= NULL
;
6862 json_object
*json_cluster_list_list
= NULL
;
6863 json_object
*json_ext_community
= NULL
;
6864 json_object
*json_last_update
= NULL
;
6865 json_object
*json_nexthop_global
= NULL
;
6866 json_object
*json_nexthop_ll
= NULL
;
6867 json_object
*json_nexthops
= NULL
;
6868 json_object
*json_path
= NULL
;
6869 json_object
*json_peer
= NULL
;
6870 json_object
*json_string
= NULL
;
6871 json_object
*json_adv_to
= NULL
;
6873 struct listnode
*node
, *nnode
;
6875 int addpath_capable
;
6877 unsigned int first_as
;
6881 json_path
= json_object_new_object();
6882 json_peer
= json_object_new_object();
6883 json_nexthop_global
= json_object_new_object();
6890 /* Line1 display AS-path, Aggregator */
6895 json_object_lock(attr
->aspath
->json
);
6896 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6900 if (attr
->aspath
->segments
)
6901 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6903 vty_out (vty
, " Local");
6907 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6910 json_object_boolean_true_add(json_path
, "removed");
6912 vty_out (vty
, ", (removed)");
6915 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6918 json_object_boolean_true_add(json_path
, "stale");
6920 vty_out (vty
, ", (stale)");
6923 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6927 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6928 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6932 vty_out (vty
, ", (aggregated by %u %s)",
6933 attr
->extra
->aggregator_as
,
6934 inet_ntoa (attr
->extra
->aggregator_addr
));
6938 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6941 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6943 vty_out (vty
, ", (Received from a RR-client)");
6946 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6949 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6951 vty_out (vty
, ", (Received from a RS-client)");
6954 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6957 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6959 vty_out (vty
, ", (history entry)");
6961 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6964 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6966 vty_out (vty
, ", (suppressed due to dampening)");
6970 vty_out (vty
, "%s", VTY_NEWLINE
);
6972 /* Line2 display Next-hop, Neighbor, Router-id */
6973 /* Display the nexthop */
6974 if (p
->family
== AF_INET
&&
6975 (safi
== SAFI_MPLS_VPN
||
6976 safi
== SAFI_ENCAP
||
6977 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6979 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6982 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6984 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6989 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6991 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6995 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6999 assert (attr
->extra
);
7002 json_object_string_add(json_nexthop_global
, "ip",
7003 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
7004 buf
, INET6_ADDRSTRLEN
));
7005 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
7006 json_object_string_add(json_nexthop_global
, "scope", "global");
7010 vty_out (vty
, " %s",
7011 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
7012 buf
, INET6_ADDRSTRLEN
));
7016 /* Display the IGP cost or 'inaccessible' */
7017 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7020 json_object_boolean_false_add(json_nexthop_global
, "accessible");
7022 vty_out (vty
, " (inaccessible)");
7026 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
7029 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
7031 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
7034 /* IGP cost is 0, display this only for json */
7038 json_object_int_add(json_nexthop_global
, "metric", 0);
7042 json_object_boolean_true_add(json_nexthop_global
, "accessible");
7045 /* Display peer "from" output */
7046 /* This path was originated locally */
7047 if (binfo
->peer
== bgp
->peer_self
)
7050 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
7053 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
7055 vty_out (vty
, " from 0.0.0.0 ");
7060 json_object_string_add(json_peer
, "peerId", "::");
7062 vty_out (vty
, " from :: ");
7066 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
7068 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
7071 /* We RXed this path from one of our peers */
7077 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7078 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7080 if (binfo
->peer
->hostname
)
7081 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
7083 if (binfo
->peer
->domainname
)
7084 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
7086 if (binfo
->peer
->conf_if
)
7087 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
7091 if (binfo
->peer
->conf_if
)
7093 if (binfo
->peer
->hostname
&&
7094 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7095 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7096 binfo
->peer
->conf_if
);
7098 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
7102 if (binfo
->peer
->hostname
&&
7103 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7104 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7107 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7110 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7111 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
7113 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7118 vty_out (vty
, "%s", VTY_NEWLINE
);
7120 /* display the link-local nexthop */
7121 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
7125 json_nexthop_ll
= json_object_new_object();
7126 json_object_string_add(json_nexthop_ll
, "ip",
7127 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7128 buf
, INET6_ADDRSTRLEN
));
7129 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
7130 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
7132 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
7134 if (!attr
->extra
->mp_nexthop_prefer_global
)
7135 json_object_boolean_true_add(json_nexthop_ll
, "used");
7137 json_object_boolean_true_add(json_nexthop_global
, "used");
7141 vty_out (vty
, " (%s) %s%s",
7142 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7143 buf
, INET6_ADDRSTRLEN
),
7144 attr
->extra
->mp_nexthop_prefer_global
?
7145 "(prefer-global)" : "(used)",
7149 /* If we do not have a link-local nexthop then we must flag the global as "used" */
7153 json_object_boolean_true_add(json_nexthop_global
, "used");
7156 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
7158 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
7160 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
7162 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
7165 json_object_int_add(json_path
, "med", attr
->med
);
7167 vty_out (vty
, ", metric %u", attr
->med
);
7170 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
7173 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
7175 vty_out (vty
, ", localpref %u", attr
->local_pref
);
7180 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
7182 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
7185 if (attr
->extra
&& attr
->extra
->weight
!= 0)
7188 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
7190 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
7193 if (attr
->extra
&& attr
->extra
->tag
!= 0)
7196 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
7198 vty_out (vty
, ", tag %"ROUTE_TAG_PRI
, attr
->extra
->tag
);
7201 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7204 json_object_boolean_false_add(json_path
, "valid");
7206 vty_out (vty
, ", invalid");
7208 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
7211 json_object_boolean_true_add(json_path
, "valid");
7213 vty_out (vty
, ", valid");
7216 if (binfo
->peer
!= bgp
->peer_self
)
7218 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
7220 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7223 json_object_string_add(json_peer
, "type", "confed-internal");
7225 vty_out (vty
, ", confed-internal");
7230 json_object_string_add(json_peer
, "type", "internal");
7232 vty_out (vty
, ", internal");
7237 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
7240 json_object_string_add(json_peer
, "type", "confed-external");
7242 vty_out (vty
, ", confed-external");
7247 json_object_string_add(json_peer
, "type", "external");
7249 vty_out (vty
, ", external");
7253 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
7257 json_object_boolean_true_add(json_path
, "aggregated");
7258 json_object_boolean_true_add(json_path
, "local");
7262 vty_out (vty
, ", aggregated, local");
7265 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
7268 json_object_boolean_true_add(json_path
, "sourced");
7270 vty_out (vty
, ", sourced");
7276 json_object_boolean_true_add(json_path
, "sourced");
7277 json_object_boolean_true_add(json_path
, "local");
7281 vty_out (vty
, ", sourced, local");
7285 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7288 json_object_boolean_true_add(json_path
, "atomicAggregate");
7290 vty_out (vty
, ", atomic-aggregate");
7293 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7294 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7295 bgp_info_mpath_count (binfo
)))
7298 json_object_boolean_true_add(json_path
, "multipath");
7300 vty_out (vty
, ", multipath");
7303 // Mark the bestpath(s)
7304 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7306 first_as
= aspath_get_first_as(attr
->aspath
);
7311 json_bestpath
= json_object_new_object();
7312 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7317 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7319 vty_out (vty
, ", bestpath-from-AS Local");
7323 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7328 json_bestpath
= json_object_new_object();
7329 json_object_boolean_true_add(json_bestpath
, "overall");
7332 vty_out (vty
, ", best");
7336 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7339 vty_out (vty
, "%s", VTY_NEWLINE
);
7341 /* Line 4 display Community */
7342 if (attr
->community
)
7346 json_object_lock(attr
->community
->json
);
7347 json_object_object_add(json_path
, "community", attr
->community
->json
);
7351 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7356 /* Line 5 display Extended-community */
7357 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7361 json_ext_community
= json_object_new_object();
7362 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7363 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7367 vty_out (vty
, " Extended Community: %s%s",
7368 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7372 /* Line 6 display Originator, Cluster-id */
7373 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7374 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7376 assert (attr
->extra
);
7377 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7380 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7382 vty_out (vty
, " Originator: %s",
7383 inet_ntoa (attr
->extra
->originator_id
));
7386 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7392 json_cluster_list
= json_object_new_object();
7393 json_cluster_list_list
= json_object_new_array();
7395 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7397 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7398 json_object_array_add(json_cluster_list_list
, json_string
);
7401 /* struct cluster_list does not have "str" variable like
7402 * aspath and community do. Add this someday if someone
7404 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7406 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7407 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7411 vty_out (vty
, ", Cluster list: ");
7413 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7415 vty_out (vty
, "%s ",
7416 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7422 vty_out (vty
, "%s", VTY_NEWLINE
);
7425 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7426 bgp_damp_info_vty (vty
, binfo
, json_path
);
7428 /* Line 7 display Addpath IDs */
7429 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7433 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7434 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7438 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7439 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7444 /* If we used addpath to TX a non-bestpath we need to display
7445 * "Advertised to" on a path-by-path basis */
7446 if (bgp
->addpath_tx_used
[afi
][safi
])
7450 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7452 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7453 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7455 if ((addpath_capable
&& has_adj
) ||
7456 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7458 if (json_path
&& !json_adv_to
)
7459 json_adv_to
= json_object_new_object();
7461 route_vty_out_advertised_to(vty
, peer
, &first
,
7471 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7478 vty_out (vty
, "%s", VTY_NEWLINE
);
7483 /* Line 8 display Uptime */
7484 #ifdef HAVE_CLOCK_MONOTONIC
7485 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7488 json_last_update
= json_object_new_object();
7489 json_object_int_add(json_last_update
, "epoch", tbuf
);
7490 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7491 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7494 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7498 json_last_update
= json_object_new_object();
7499 json_object_int_add(json_last_update
, "epoch", tbuf
);
7500 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7501 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7504 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7505 #endif /* HAVE_CLOCK_MONOTONIC */
7508 /* We've constructed the json object for this path, add it to the json
7513 if (json_nexthop_global
|| json_nexthop_ll
)
7515 json_nexthops
= json_object_new_array();
7517 if (json_nexthop_global
)
7518 json_object_array_add(json_nexthops
, json_nexthop_global
);
7520 if (json_nexthop_ll
)
7521 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7523 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7526 json_object_object_add(json_path
, "peer", json_peer
);
7527 json_object_array_add(json_paths
, json_path
);
7530 vty_out (vty
, "%s", VTY_NEWLINE
);
7533 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7534 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7535 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7539 bgp_show_type_normal
,
7540 bgp_show_type_regexp
,
7541 bgp_show_type_prefix_list
,
7542 bgp_show_type_filter_list
,
7543 bgp_show_type_route_map
,
7544 bgp_show_type_neighbor
,
7545 bgp_show_type_cidr_only
,
7546 bgp_show_type_prefix_longer
,
7547 bgp_show_type_community_all
,
7548 bgp_show_type_community
,
7549 bgp_show_type_community_exact
,
7550 bgp_show_type_community_list
,
7551 bgp_show_type_community_list_exact
,
7552 bgp_show_type_flap_statistics
,
7553 bgp_show_type_flap_address
,
7554 bgp_show_type_flap_prefix
,
7555 bgp_show_type_flap_cidr_only
,
7556 bgp_show_type_flap_regexp
,
7557 bgp_show_type_flap_filter_list
,
7558 bgp_show_type_flap_prefix_list
,
7559 bgp_show_type_flap_prefix_longer
,
7560 bgp_show_type_flap_route_map
,
7561 bgp_show_type_flap_neighbor
,
7562 bgp_show_type_dampend_paths
,
7563 bgp_show_type_damp_neighbor
7567 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7568 const char *prefix_list_str
, afi_t afi
,
7569 safi_t safi
, enum bgp_show_type type
);
7571 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7572 const char *filter
, afi_t afi
,
7573 safi_t safi
, enum bgp_show_type type
);
7575 bgp_show_route_map (struct vty
*vty
, const char *name
,
7576 const char *rmap_str
, afi_t afi
,
7577 safi_t safi
, enum bgp_show_type type
);
7579 bgp_show_community_list (struct vty
*vty
, const char *name
,
7580 const char *com
, int exact
,
7581 afi_t afi
, safi_t safi
);
7583 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7584 const char *prefix
, afi_t afi
,
7585 safi_t safi
, enum bgp_show_type type
);
7588 bgp_show_table (struct vty
*vty
, struct bgp
*bgp
, struct bgp_table
*table
,
7589 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7591 struct bgp_info
*ri
;
7592 struct bgp_node
*rn
;
7595 unsigned long output_count
;
7596 unsigned long total_count
;
7600 json_object
*json_paths
= NULL
;
7605 vty_out (vty
, "{ \"vrfId\": %d, \"vrfName\": \"%s\", \"tableVersion\": %" PRId64
", \"routerId\": \"%s\", \"routes\": { ",
7606 bgp
->vrf_id
== VRF_UNKNOWN
? -1 : bgp
->vrf_id
,
7607 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
? "Default" : bgp
->name
,
7608 table
->version
, inet_ntoa (bgp
->router_id
));
7609 json_paths
= json_object_new_object();
7612 /* This is first entry point, so reset total line. */
7616 /* Start processing of routes. */
7617 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7618 if (rn
->info
!= NULL
)
7621 if (!first
&& use_json
)
7626 json_paths
= json_object_new_array();
7630 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7633 if (type
== bgp_show_type_flap_statistics
7634 || type
== bgp_show_type_flap_address
7635 || type
== bgp_show_type_flap_prefix
7636 || type
== bgp_show_type_flap_cidr_only
7637 || type
== bgp_show_type_flap_regexp
7638 || type
== bgp_show_type_flap_filter_list
7639 || type
== bgp_show_type_flap_prefix_list
7640 || type
== bgp_show_type_flap_prefix_longer
7641 || type
== bgp_show_type_flap_route_map
7642 || type
== bgp_show_type_flap_neighbor
7643 || type
== bgp_show_type_dampend_paths
7644 || type
== bgp_show_type_damp_neighbor
)
7646 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7649 if (type
== bgp_show_type_regexp
7650 || type
== bgp_show_type_flap_regexp
)
7652 regex_t
*regex
= output_arg
;
7654 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7657 if (type
== bgp_show_type_prefix_list
7658 || type
== bgp_show_type_flap_prefix_list
)
7660 struct prefix_list
*plist
= output_arg
;
7662 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7665 if (type
== bgp_show_type_filter_list
7666 || type
== bgp_show_type_flap_filter_list
)
7668 struct as_list
*as_list
= output_arg
;
7670 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7673 if (type
== bgp_show_type_route_map
7674 || type
== bgp_show_type_flap_route_map
)
7676 struct route_map
*rmap
= output_arg
;
7677 struct bgp_info binfo
;
7678 struct attr dummy_attr
;
7679 struct attr_extra dummy_extra
;
7682 dummy_attr
.extra
= &dummy_extra
;
7683 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7685 binfo
.peer
= ri
->peer
;
7686 binfo
.attr
= &dummy_attr
;
7688 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7689 if (ret
== RMAP_DENYMATCH
)
7692 if (type
== bgp_show_type_neighbor
7693 || type
== bgp_show_type_flap_neighbor
7694 || type
== bgp_show_type_damp_neighbor
)
7696 union sockunion
*su
= output_arg
;
7698 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7701 if (type
== bgp_show_type_cidr_only
7702 || type
== bgp_show_type_flap_cidr_only
)
7704 u_int32_t destination
;
7706 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7707 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7709 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7711 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7714 if (type
== bgp_show_type_prefix_longer
7715 || type
== bgp_show_type_flap_prefix_longer
)
7717 struct prefix
*p
= output_arg
;
7719 if (! prefix_match (p
, &rn
->p
))
7722 if (type
== bgp_show_type_community_all
)
7724 if (! ri
->attr
->community
)
7727 if (type
== bgp_show_type_community
)
7729 struct community
*com
= output_arg
;
7731 if (! ri
->attr
->community
||
7732 ! community_match (ri
->attr
->community
, com
))
7735 if (type
== bgp_show_type_community_exact
)
7737 struct community
*com
= output_arg
;
7739 if (! ri
->attr
->community
||
7740 ! community_cmp (ri
->attr
->community
, com
))
7743 if (type
== bgp_show_type_community_list
)
7745 struct community_list
*list
= output_arg
;
7747 if (! community_list_match (ri
->attr
->community
, list
))
7750 if (type
== bgp_show_type_community_list_exact
)
7752 struct community_list
*list
= output_arg
;
7754 if (! community_list_exact_match (ri
->attr
->community
, list
))
7757 if (type
== bgp_show_type_flap_address
7758 || type
== bgp_show_type_flap_prefix
)
7760 struct prefix
*p
= output_arg
;
7762 if (! prefix_match (&rn
->p
, p
))
7765 if (type
== bgp_show_type_flap_prefix
)
7766 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7769 if (type
== bgp_show_type_dampend_paths
7770 || type
== bgp_show_type_damp_neighbor
)
7772 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7773 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7777 if (!use_json
&& header
)
7779 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
7780 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7781 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7782 if (type
== bgp_show_type_dampend_paths
7783 || type
== bgp_show_type_damp_neighbor
)
7784 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7785 else if (type
== bgp_show_type_flap_statistics
7786 || type
== bgp_show_type_flap_address
7787 || type
== bgp_show_type_flap_prefix
7788 || type
== bgp_show_type_flap_cidr_only
7789 || type
== bgp_show_type_flap_regexp
7790 || type
== bgp_show_type_flap_filter_list
7791 || type
== bgp_show_type_flap_prefix_list
7792 || type
== bgp_show_type_flap_prefix_longer
7793 || type
== bgp_show_type_flap_route_map
7794 || type
== bgp_show_type_flap_neighbor
)
7795 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7797 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7801 if (type
== bgp_show_type_dampend_paths
7802 || type
== bgp_show_type_damp_neighbor
)
7803 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7804 else if (type
== bgp_show_type_flap_statistics
7805 || type
== bgp_show_type_flap_address
7806 || type
== bgp_show_type_flap_prefix
7807 || type
== bgp_show_type_flap_cidr_only
7808 || type
== bgp_show_type_flap_regexp
7809 || type
== bgp_show_type_flap_filter_list
7810 || type
== bgp_show_type_flap_prefix_list
7811 || type
== bgp_show_type_flap_prefix_longer
7812 || type
== bgp_show_type_flap_route_map
7813 || type
== bgp_show_type_flap_neighbor
)
7814 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7816 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7826 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7827 vty_out (vty
, "\"%s\": ", buf2
);
7828 vty_out (vty
, "%s", json_object_to_json_string (json_paths
));
7829 json_object_free (json_paths
);
7838 json_object_free (json_paths
);
7839 vty_out (vty
, " } }%s", VTY_NEWLINE
);
7843 /* No route is displayed */
7844 if (output_count
== 0)
7846 if (type
== bgp_show_type_normal
)
7847 vty_out (vty
, "No BGP prefixes displayed, %ld exist%s", total_count
, VTY_NEWLINE
);
7850 vty_out (vty
, "%sDisplayed %ld routes and %ld total paths%s",
7851 VTY_NEWLINE
, output_count
, total_count
, VTY_NEWLINE
);
7858 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7859 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7861 struct bgp_table
*table
;
7865 bgp
= bgp_get_default ();
7871 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7875 table
= bgp
->rib
[afi
][safi
];
7877 return bgp_show_table (vty
, bgp
, table
, type
, output_arg
,
7882 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7885 struct listnode
*node
, *nnode
;
7887 struct bgp_table
*table
;
7891 vty_out (vty
, "{%s", VTY_NEWLINE
);
7893 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7898 vty_out (vty
, ",%s", VTY_NEWLINE
);
7902 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7903 ? "Default" : bgp
->name
);
7907 vty_out (vty
, "%sInstance %s:%s",
7909 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7910 ? "Default" : bgp
->name
,
7913 table
= bgp
->rib
[afi
][safi
];
7914 bgp_show_table (vty
, bgp
, table
,
7915 bgp_show_type_normal
, NULL
, use_json
);
7920 vty_out (vty
, "}%s", VTY_NEWLINE
);
7923 /* Header of detailed BGP route information */
7925 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7926 struct bgp_node
*rn
,
7927 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7930 struct bgp_info
*ri
;
7933 struct listnode
*node
, *nnode
;
7934 char buf1
[INET6_ADDRSTRLEN
];
7935 char buf2
[INET6_ADDRSTRLEN
];
7940 int no_advertise
= 0;
7943 json_object
*json_adv_to
= NULL
;
7949 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7950 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7954 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7955 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7956 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7957 safi
== SAFI_MPLS_VPN
? ":" : "",
7958 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7959 p
->prefixlen
, VTY_NEWLINE
);
7962 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7965 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7968 if (ri
->extra
&& ri
->extra
->suppress
)
7970 if (ri
->attr
->community
!= NULL
)
7972 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7974 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7976 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7984 vty_out (vty
, "Paths: (%d available", count
);
7987 vty_out (vty
, ", best #%d", best
);
7988 if (safi
== SAFI_UNICAST
)
7989 vty_out (vty
, ", table %s",
7990 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7991 ? "Default-IP-Routing-Table" : bgp
->name
);
7994 vty_out (vty
, ", no best path");
7997 vty_out (vty
, ", not advertised to any peer");
7999 vty_out (vty
, ", not advertised to EBGP peer");
8001 vty_out (vty
, ", not advertised outside local AS");
8004 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
8005 vty_out (vty
, ")%s", VTY_NEWLINE
);
8008 /* If we are not using addpath then we can display Advertised to and that will
8009 * show what peers we advertised the bestpath to. If we are using addpath
8010 * though then we must display Advertised to on a path-by-path basis. */
8011 if (!bgp
->addpath_tx_used
[afi
][safi
])
8013 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
8015 if (bgp_adj_out_lookup (peer
, rn
, 0))
8017 if (json
&& !json_adv_to
)
8018 json_adv_to
= json_object_new_object();
8020 route_vty_out_advertised_to(vty
, peer
, &first
,
8021 " Advertised to non peer-group peers:\n ",
8030 json_object_object_add(json
, "advertisedTo", json_adv_to
);
8036 vty_out (vty
, " Not advertised to any peer");
8037 vty_out (vty
, "%s", VTY_NEWLINE
);
8042 /* Display specified route of BGP table. */
8044 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
8045 struct bgp_table
*rib
, const char *ip_str
,
8046 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8047 int prefix_check
, enum bgp_path_type pathtype
,
8053 struct prefix match
;
8054 struct bgp_node
*rn
;
8055 struct bgp_node
*rm
;
8056 struct bgp_info
*ri
;
8057 struct bgp_table
*table
;
8058 json_object
*json
= NULL
;
8059 json_object
*json_paths
= NULL
;
8061 /* Check IP address argument. */
8062 ret
= str2prefix (ip_str
, &match
);
8065 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
8069 match
.family
= afi2family (afi
);
8073 json
= json_object_new_object();
8074 json_paths
= json_object_new_array();
8077 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
8079 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
8081 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
8084 if ((table
= rn
->info
) != NULL
)
8088 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
8090 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
8092 bgp_unlock_node (rm
);
8096 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
8100 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
8101 AFI_IP
, safi
, json
);
8106 if (pathtype
== BGP_PATH_ALL
||
8107 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8108 (pathtype
== BGP_PATH_MULTIPATH
&&
8109 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8110 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
8113 bgp_unlock_node (rm
);
8122 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
8124 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
8126 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8130 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
8135 if (pathtype
== BGP_PATH_ALL
||
8136 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8137 (pathtype
== BGP_PATH_MULTIPATH
&&
8138 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8139 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
8143 bgp_unlock_node (rn
);
8150 json_object_object_add(json
, "paths", json_paths
);
8152 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
8153 json_object_free(json
);
8159 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
8167 /* Display specified route of Main RIB */
8169 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
8170 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8171 int prefix_check
, enum bgp_path_type pathtype
,
8176 /* BGP structure lookup. */
8179 bgp
= bgp_lookup_by_name (view_name
);
8182 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
8188 bgp
= bgp_get_default ();
8191 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8196 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
8197 afi
, safi
, prd
, prefix_check
, pathtype
,
8201 /* BGP route print out function. */
8204 "show ip bgp {json}",
8208 "JavaScript Object Notation\n")
8210 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8215 "show bgp ipv4 {json}",
8220 "JavaScript Object Notation\n")
8222 DEFUN (show_ip_bgp_ipv4
,
8223 show_ip_bgp_ipv4_cmd
,
8224 "show ip bgp ipv4 (unicast|multicast) {json}",
8229 "Address Family modifier\n"
8230 "Address Family modifier\n"
8231 "JavaScript Object Notation\n")
8233 u_char uj
= use_json(argc
, argv
);
8235 return bgp_show (vty
, NULL
, AFI_IP
,
8236 bgp_vty_safi_from_arg(argv
[0]),
8237 bgp_show_type_normal
, NULL
, uj
);
8240 ALIAS (show_ip_bgp_ipv4
,
8241 show_bgp_ipv4_safi_cmd
,
8242 "show bgp ipv4 (unicast|multicast) {json}",
8246 "Address Family modifier\n"
8247 "Address Family modifier\n"
8248 "JavaScript Object Notation\n")
8250 DEFUN (show_ip_bgp_route
,
8251 show_ip_bgp_route_cmd
,
8252 "show ip bgp A.B.C.D {json}",
8256 "Network in the BGP routing table to display\n"
8257 "JavaScript Object Notation\n")
8259 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8262 DEFUN (show_ip_bgp_route_pathtype
,
8263 show_ip_bgp_route_pathtype_cmd
,
8264 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
8268 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8269 "Display only the bestpath\n"
8270 "Display only multipaths\n"
8271 "JavaScript Object Notation\n")
8273 u_char uj
= use_json(argc
, argv
);
8275 if (strncmp (argv
[1], "b", 1) == 0)
8276 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8278 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8281 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
8282 show_bgp_ipv4_safi_route_pathtype_cmd
,
8283 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D (bestpath|multipath) {json}",
8286 BGP_AFI_SAFI_HELP_STR
8287 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8288 "Display only the bestpath\n"
8289 "Display only multipaths\n"
8290 "JavaScript Object Notation\n")
8292 u_char uj
= use_json(argc
, argv
);
8294 if (strncmp (argv
[2], "b", 1) == 0)
8295 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8296 bgp_vty_safi_from_arg(argv
[0]),
8297 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8299 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8300 bgp_vty_safi_from_arg(argv
[0]),
8301 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8304 DEFUN (show_bgp_ipv4_prefix
,
8305 show_bgp_ipv4_prefix_cmd
,
8306 "show bgp ipv4 A.B.C.D/M {json}",
8310 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8313 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8316 DEFUN (show_bgp_ipv6_route
,
8317 show_bgp_ipv6_route_cmd
,
8318 "show bgp ipv6 X:X::X:X {json}",
8322 "Network in the BGP routing table to display\n"
8325 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8328 DEFUN (show_bgp_ipv6_prefix
,
8329 show_bgp_ipv6_prefix_cmd
,
8330 "show bgp ipv6 X:X::X:X/M {json}",
8334 "IPv6 prefix <network>/<length>\n"
8337 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
,argv
));
8340 DEFUN (show_ip_bgp_ipv4_route
,
8341 show_ip_bgp_ipv4_route_cmd
,
8342 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8346 BGP_AFI_SAFI_HELP_STR
8347 "Network in the BGP routing table to display\n"
8348 "JavaScript Object Notation\n")
8350 u_char uj
= use_json(argc
, argv
);
8352 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8353 bgp_vty_safi_from_arg(argv
[0]),
8354 NULL
, 0, BGP_PATH_ALL
, uj
);
8357 ALIAS (show_ip_bgp_ipv4_route
,
8358 show_bgp_ipv4_safi_route_cmd
,
8359 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8362 BGP_AFI_SAFI_HELP_STR
8363 "Network in the BGP routing table to display\n"
8364 "JavaScript Object Notation\n")
8366 DEFUN (show_bgp_ipv4_safi_rd_route
,
8367 show_bgp_ipv4_safi_rd_route_cmd
,
8368 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8372 "Address Family Modifier\n"
8373 "Address Family Modifier\n"
8374 "Display information for a route distinguisher\n"
8375 "ENCAP Route Distinguisher\n"
8376 "Network in the BGP routing table to display\n")
8379 struct prefix_rd prd
;
8382 if (bgp_parse_safi(argv
[0], &safi
)) {
8383 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8386 ret
= str2prefix_rd (argv
[1], &prd
);
8389 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8392 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8395 DEFUN (show_bgp_ipv6_safi_rd_route
,
8396 show_bgp_ipv6_safi_rd_route_cmd
,
8397 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
8401 "Address Family Modifier\n"
8402 "Address Family Modifier\n"
8403 "Display information for a route distinguisher\n"
8404 "ENCAP Route Distinguisher\n"
8405 "Network in the BGP routing table to display\n")
8408 struct prefix_rd prd
;
8411 if (bgp_parse_safi(argv
[0], &safi
)) {
8412 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8415 ret
= str2prefix_rd (argv
[1], &prd
);
8418 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8421 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, SAFI_ENCAP
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8425 DEFUN (show_bgp_ipv4_safi_rd_prefix
,
8426 show_bgp_ipv4_safi_rd_prefix_cmd
,
8427 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8431 "Address Family Modifier\n"
8432 "Address Family Modifier\n"
8433 "Display information for a route distinguisher\n"
8434 "ENCAP Route Distinguisher\n"
8435 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8438 struct prefix_rd prd
;
8441 if (bgp_parse_safi(argv
[0], &safi
)) {
8442 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8446 ret
= str2prefix_rd (argv
[1], &prd
);
8449 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8452 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8455 DEFUN (show_bgp_ipv6_safi_rd_prefix
,
8456 show_bgp_ipv6_safi_rd_prefix_cmd
,
8457 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M {json}",
8461 "Address Family Modifier\n"
8462 "Address Family Modifier\n"
8463 "Display information for a route distinguisher\n"
8464 "ENCAP Route Distinguisher\n"
8465 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8468 struct prefix_rd prd
;
8471 if (bgp_parse_safi(argv
[0], &safi
)) {
8472 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8476 ret
= str2prefix_rd (argv
[1], &prd
);
8479 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8482 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8485 DEFUN (show_ip_bgp_prefix
,
8486 show_ip_bgp_prefix_cmd
,
8487 "show ip bgp A.B.C.D/M {json}",
8491 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8492 "JavaScript Object Notation\n")
8494 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8497 DEFUN (show_ip_bgp_prefix_pathtype
,
8498 show_ip_bgp_prefix_pathtype_cmd
,
8499 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8503 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8504 "Display only the bestpath\n"
8505 "Display only multipaths\n"
8506 "JavaScript Object Notation\n")
8508 u_char uj
= use_json(argc
, argv
);
8509 if (strncmp (argv
[1], "b", 1) == 0)
8510 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8512 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8515 DEFUN (show_ip_bgp_ipv4_prefix
,
8516 show_ip_bgp_ipv4_prefix_cmd
,
8517 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8521 BGP_AFI_SAFI_HELP_STR
8522 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8523 "JavaScript Object Notation\n")
8525 u_char uj
= use_json(argc
, argv
);
8527 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8528 bgp_vty_safi_from_arg(argv
[0]),
8529 NULL
, 1, BGP_PATH_ALL
, uj
);
8532 ALIAS (show_ip_bgp_ipv4_prefix
,
8533 show_bgp_ipv4_safi_prefix_cmd
,
8534 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8537 BGP_AFI_SAFI_HELP_STR
8538 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8539 "JavaScript Object Notation\n")
8541 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8542 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8543 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8547 BGP_AFI_SAFI_HELP_STR
8548 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8549 "Display only the bestpath\n"
8550 "Display only multipaths\n"
8551 "JavaScript Object Notation\n")
8553 u_char uj
= use_json(argc
, argv
);
8555 if (strncmp (argv
[2], "b", 1) == 0)
8556 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8557 bgp_vty_safi_from_arg(argv
[0]),
8558 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8560 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8561 bgp_vty_safi_from_arg(argv
[0]),
8562 NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8565 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8566 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8567 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8570 BGP_AFI_SAFI_HELP_STR
8571 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8572 "Display only the bestpath\n"
8573 "Display only multipaths\n"
8574 "JavaScript Object Notation\n")
8577 DEFUN (show_ip_bgp_view
,
8578 show_ip_bgp_instance_cmd
,
8579 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8583 BGP_INSTANCE_HELP_STR
8584 "JavaScript Object Notation\n")
8588 /* BGP structure lookup. */
8589 bgp
= bgp_lookup_by_name (argv
[1]);
8592 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8596 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8599 DEFUN (show_ip_bgp_instance_all
,
8600 show_ip_bgp_instance_all_cmd
,
8601 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8605 BGP_INSTANCE_ALL_HELP_STR
8606 "JavaScript Object Notation\n")
8608 u_char uj
= use_json(argc
, argv
);
8610 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8614 DEFUN (show_ip_bgp_instance_route
,
8615 show_ip_bgp_instance_route_cmd
,
8616 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8620 BGP_INSTANCE_HELP_STR
8621 "Network in the BGP routing table to display\n"
8622 "JavaScript Object Notation\n")
8624 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8627 DEFUN (show_ip_bgp_instance_route_pathtype
,
8628 show_ip_bgp_instance_route_pathtype_cmd
,
8629 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8633 BGP_INSTANCE_HELP_STR
8634 "Network in the BGP routing table to display\n"
8635 "Display only the bestpath\n"
8636 "Display only multipaths\n"
8637 "JavaScript Object Notation\n")
8639 u_char uj
= use_json(argc
, argv
);
8641 if (strncmp (argv
[3], "b", 1) == 0)
8642 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8644 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8647 DEFUN (show_ip_bgp_instance_prefix
,
8648 show_ip_bgp_instance_prefix_cmd
,
8649 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8653 BGP_INSTANCE_HELP_STR
8654 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8655 "JavaScript Object Notation\n")
8657 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8660 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8661 show_ip_bgp_instance_prefix_pathtype_cmd
,
8662 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8666 BGP_INSTANCE_HELP_STR
8667 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8668 "Display only the bestpath\n"
8669 "Display only multipaths\n"
8670 "JavaScript Object Notation\n")
8672 u_char uj
= use_json(argc
, argv
);
8673 if (strncmp (argv
[3], "b", 1) == 0)
8674 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8676 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8685 "JavaScript Object Notation\n")
8687 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8688 NULL
, use_json(argc
, argv
));
8693 "show bgp ipv6 {json}",
8697 "JavaScript Object Notation\n")
8699 DEFUN (show_bgp_ipv6_safi
,
8700 show_bgp_ipv6_safi_cmd
,
8701 "show bgp ipv6 (unicast|multicast) {json}",
8705 "Address Family modifier\n"
8706 "Address Family modifier\n"
8707 "JavaScript Object Notation\n")
8709 u_char uj
= use_json(argc
, argv
);
8711 return bgp_show (vty
, NULL
, AFI_IP6
,
8712 bgp_vty_safi_from_arg(argv
[0]),
8713 bgp_show_type_normal
, NULL
, uj
);
8717 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8719 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8720 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8721 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8725 DEFUN (show_ipv6_bgp
,
8727 "show ipv6 bgp {json}",
8731 "JavaScript Object Notation\n")
8733 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8734 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8735 NULL
, use_json(argc
, argv
));
8738 DEFUN (show_bgp_route
,
8740 "show bgp X:X::X:X {json}",
8743 "Network in the BGP routing table to display\n"
8744 "JavaScript Object Notation\n")
8746 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8749 DEFUN (show_bgp_ipv6_safi_route
,
8750 show_bgp_ipv6_safi_route_cmd
,
8751 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X {json}",
8754 BGP_AFI_SAFI_HELP_STR
8755 "Network in the BGP routing table to display\n"
8756 "JavaScript Object Notation\n")
8758 u_char uj
= use_json(argc
, argv
);
8760 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8761 bgp_vty_safi_from_arg(argv
[0]),
8762 NULL
, 0, BGP_PATH_ALL
, uj
);
8765 DEFUN (show_bgp_route_pathtype
,
8766 show_bgp_route_pathtype_cmd
,
8767 "show bgp X:X::X:X (bestpath|multipath) {json}",
8770 "Network in the BGP routing table to display\n"
8771 "Display only the bestpath\n"
8772 "Display only multipaths\n"
8773 "JavaScript Object Notation\n")
8775 u_char uj
= use_json(argc
, argv
);
8776 if (strncmp (argv
[1], "b", 1) == 0)
8777 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8779 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8782 ALIAS (show_bgp_route_pathtype
,
8783 show_bgp_ipv6_route_pathtype_cmd
,
8784 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8788 "Network in the BGP routing table to display\n"
8789 "Display only the bestpath\n"
8790 "Display only multipaths\n"
8791 "JavaScript Object Notation\n")
8793 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8794 show_bgp_ipv6_safi_route_pathtype_cmd
,
8795 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X (bestpath|multipath) {json}",
8798 BGP_AFI_SAFI_HELP_STR
8799 "Network in the BGP routing table to display\n"
8800 "Display only the bestpath\n"
8801 "Display only multipaths\n"
8802 "JavaScript Object Notation\n")
8804 u_char uj
= use_json(argc
, argv
);
8805 if (strncmp (argv
[2], "b", 1) == 0)
8806 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8807 bgp_vty_safi_from_arg(argv
[0]),
8808 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8810 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8811 bgp_vty_safi_from_arg(argv
[0]),
8812 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8816 DEFUN (show_ipv6_bgp_route
,
8817 show_ipv6_bgp_route_cmd
,
8818 "show ipv6 bgp X:X::X:X {json}",
8822 "Network in the BGP routing table to display\n"
8823 "JavaScript Object Notation\n")
8825 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8826 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8829 DEFUN (show_bgp_prefix
,
8830 show_bgp_prefix_cmd
,
8831 "show bgp X:X::X:X/M {json}",
8834 "IPv6 prefix <network>/<length>\n"
8835 "JavaScript Object Notation\n")
8837 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8840 DEFUN (show_bgp_ipv6_safi_prefix
,
8841 show_bgp_ipv6_safi_prefix_cmd
,
8842 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M {json}",
8845 BGP_AFI_SAFI_HELP_STR
8846 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8847 "JavaScript Object Notation\n")
8849 u_char uj
= use_json(argc
, argv
);
8851 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8852 bgp_vty_safi_from_arg(argv
[0]),
8853 NULL
, 1, BGP_PATH_ALL
, uj
);
8856 DEFUN (show_bgp_prefix_pathtype
,
8857 show_bgp_prefix_pathtype_cmd
,
8858 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8861 "IPv6 prefix <network>/<length>\n"
8862 "Display only the bestpath\n"
8863 "Display only multipaths\n"
8864 "JavaScript Object Notation\n")
8866 u_char uj
= use_json(argc
, argv
);
8867 if (strncmp (argv
[1], "b", 1) == 0)
8868 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8870 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8873 ALIAS (show_bgp_prefix_pathtype
,
8874 show_bgp_ipv6_prefix_pathtype_cmd
,
8875 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8879 "IPv6 prefix <network>/<length>\n"
8880 "Display only the bestpath\n"
8881 "Display only multipaths\n"
8882 "JavaScript Object Notation\n")
8884 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8885 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8886 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M (bestpath|multipath) {json}",
8889 BGP_AFI_SAFI_HELP_STR
8890 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8891 "Display only the bestpath\n"
8892 "Display only multipaths\n"
8893 "JavaScript Object Notation\n")
8895 u_char uj
= use_json(argc
, argv
);
8896 if (strncmp (argv
[2], "b", 1) == 0)
8897 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8898 bgp_vty_safi_from_arg(argv
[0]),
8899 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8901 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8902 bgp_vty_safi_from_arg(argv
[0]), NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8906 DEFUN (show_ipv6_bgp_prefix
,
8907 show_ipv6_bgp_prefix_cmd
,
8908 "show ipv6 bgp X:X::X:X/M {json}",
8912 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8913 "JavaScript Object Notation\n")
8915 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8916 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8919 DEFUN (show_bgp_view
,
8920 show_bgp_instance_cmd
,
8921 "show bgp " BGP_INSTANCE_CMD
" {json}",
8924 BGP_INSTANCE_HELP_STR
8925 "JavaScript Object Notation\n")
8929 /* BGP structure lookup. */
8930 bgp
= bgp_lookup_by_name (argv
[1]);
8933 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8937 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8940 DEFUN (show_bgp_instance_all
,
8941 show_bgp_instance_all_cmd
,
8942 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8945 BGP_INSTANCE_ALL_HELP_STR
8946 "JavaScript Object Notation\n")
8948 u_char uj
= use_json(argc
, argv
);
8950 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8954 ALIAS (show_bgp_view
,
8955 show_bgp_instance_ipv6_cmd
,
8956 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8959 BGP_INSTANCE_HELP_STR
8961 "JavaScript Object Notation\n")
8963 DEFUN (show_bgp_instance_route
,
8964 show_bgp_instance_route_cmd
,
8965 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8968 BGP_INSTANCE_HELP_STR
8969 "Network in the BGP routing table to display\n"
8970 "JavaScript Object Notation\n")
8972 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8975 ALIAS (show_bgp_instance_route
,
8976 show_bgp_instance_ipv6_route_cmd
,
8977 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8980 BGP_INSTANCE_HELP_STR
8982 "Network in the BGP routing table to display\n"
8983 "JavaScript Object Notation\n")
8985 DEFUN (show_bgp_instance_route_pathtype
,
8986 show_bgp_instance_route_pathtype_cmd
,
8987 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8990 BGP_INSTANCE_HELP_STR
8991 "Network in the BGP routing table to display\n"
8992 "Display only the bestpath\n"
8993 "Display only multipaths\n"
8994 "JavaScript Object Notation\n")
8996 u_char uj
= use_json(argc
, argv
);
8997 if (strncmp (argv
[3], "b", 1) == 0)
8998 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
9000 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
9003 ALIAS (show_bgp_instance_route_pathtype
,
9004 show_bgp_instance_ipv6_route_pathtype_cmd
,
9005 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
9008 BGP_INSTANCE_HELP_STR
9010 "Network in the BGP routing table to display\n"
9011 "Display only the bestpath\n"
9012 "Display only multipaths\n"
9013 "JavaScript Object Notation\n")
9015 DEFUN (show_bgp_instance_prefix
,
9016 show_bgp_instance_prefix_cmd
,
9017 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
9020 BGP_INSTANCE_HELP_STR
9021 "IPv6 prefix <network>/<length>\n"
9022 "JavaScript Object Notation\n")
9024 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9027 ALIAS (show_bgp_instance_prefix
,
9028 show_bgp_instance_ipv6_prefix_cmd
,
9029 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
9032 BGP_INSTANCE_HELP_STR
9034 "IPv6 prefix <network>/<length>\n"
9035 "JavaScript Object Notation\n")
9037 DEFUN (show_bgp_instance_prefix_pathtype
,
9038 show_bgp_instance_prefix_pathtype_cmd
,
9039 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
9042 BGP_INSTANCE_HELP_STR
9043 "IPv6 prefix <network>/<length>\n"
9044 "Display only the bestpath\n"
9045 "Display only multipaths\n"
9046 "JavaScript Object Notation\n")
9048 u_char uj
= use_json(argc
, argv
);
9049 if (strncmp (argv
[3], "b", 1) == 0)
9050 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
9052 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
9055 ALIAS (show_bgp_instance_prefix_pathtype
,
9056 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
9057 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
9060 BGP_INSTANCE_HELP_STR
9062 "IPv6 prefix <network>/<length>\n"
9063 "Display only the bestpath\n"
9064 "Display only multipaths\n"
9065 "JavaScript Object Notation\n")
9067 DEFUN (show_bgp_instance_prefix_list
,
9068 show_bgp_instance_prefix_list_cmd
,
9069 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9072 BGP_INSTANCE_HELP_STR
9073 "Display routes conforming to the prefix-list\n"
9074 "IPv6 prefix-list name\n")
9076 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9077 bgp_show_type_prefix_list
);
9080 ALIAS (show_bgp_instance_prefix_list
,
9081 show_bgp_instance_ipv6_prefix_list_cmd
,
9082 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
9085 BGP_INSTANCE_HELP_STR
9087 "Display routes conforming to the prefix-list\n"
9088 "IPv6 prefix-list name\n")
9090 DEFUN (show_bgp_instance_filter_list
,
9091 show_bgp_instance_filter_list_cmd
,
9092 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9095 BGP_INSTANCE_HELP_STR
9096 "Display routes conforming to the filter-list\n"
9097 "Regular expression access list name\n")
9099 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9100 bgp_show_type_filter_list
);
9103 ALIAS (show_bgp_instance_filter_list
,
9104 show_bgp_instance_ipv6_filter_list_cmd
,
9105 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
9108 BGP_INSTANCE_HELP_STR
9110 "Display routes conforming to the filter-list\n"
9111 "Regular expression access list name\n")
9113 DEFUN (show_bgp_instance_route_map
,
9114 show_bgp_instance_route_map_cmd
,
9115 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
9118 BGP_INSTANCE_HELP_STR
9119 "Display routes matching the route-map\n"
9120 "A route-map to match on\n")
9122 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9123 bgp_show_type_route_map
);
9126 ALIAS (show_bgp_instance_route_map
,
9127 show_bgp_instance_ipv6_route_map_cmd
,
9128 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
9131 BGP_INSTANCE_HELP_STR
9133 "Display routes matching the route-map\n"
9134 "A route-map to match on\n")
9136 DEFUN (show_bgp_instance_community_list
,
9137 show_bgp_instance_community_list_cmd
,
9138 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
9141 BGP_INSTANCE_HELP_STR
9142 "Display routes matching the community-list\n"
9143 "community-list number\n"
9144 "community-list name\n")
9146 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
9149 ALIAS (show_bgp_instance_community_list
,
9150 show_bgp_instance_ipv6_community_list_cmd
,
9151 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
9154 BGP_INSTANCE_HELP_STR
9156 "Display routes matching the community-list\n"
9157 "community-list number\n"
9158 "community-list name\n")
9160 DEFUN (show_bgp_instance_prefix_longer
,
9161 show_bgp_instance_prefix_longer_cmd
,
9162 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
9165 BGP_INSTANCE_HELP_STR
9166 "IPv6 prefix <network>/<length>\n"
9167 "Display route and more specific routes\n")
9169 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9170 bgp_show_type_prefix_longer
);
9173 ALIAS (show_bgp_instance_prefix_longer
,
9174 show_bgp_instance_ipv6_prefix_longer_cmd
,
9175 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
9178 BGP_INSTANCE_HELP_STR
9180 "IPv6 prefix <network>/<length>\n"
9181 "Display route and more specific routes\n")
9184 DEFUN (show_ipv6_mbgp
,
9186 "show ipv6 mbgp {json}",
9190 "JavaScript Object Notation\n")
9192 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9193 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
9194 NULL
, use_json(argc
, argv
));
9198 DEFUN (show_ipv6_mbgp_route
,
9199 show_ipv6_mbgp_route_cmd
,
9200 "show ipv6 mbgp X:X::X:X {json}",
9204 "Network in the MBGP routing table to display\n"
9205 "JavaScript Object Notation\n")
9207 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9208 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9212 DEFUN (show_ipv6_mbgp_prefix
,
9213 show_ipv6_mbgp_prefix_cmd
,
9214 "show ipv6 mbgp X:X::X:X/M {json}",
9218 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9219 "JavaScript Object Notation\n")
9221 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9222 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9228 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
9229 safi_t safi
, enum bgp_show_type type
)
9239 b
= buffer_new (1024);
9240 for (i
= 0; i
< argc
; i
++)
9243 buffer_putc (b
, ' ');
9246 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9251 buffer_putstr (b
, argv
[i
]);
9253 buffer_putc (b
, '\0');
9255 regstr
= buffer_getstr (b
);
9258 regex
= bgp_regcomp (regstr
);
9259 XFREE(MTYPE_TMP
, regstr
);
9262 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
9267 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
9268 bgp_regex_free (regex
);
9272 DEFUN (show_ip_bgp_regexp
,
9273 show_ip_bgp_regexp_cmd
,
9274 "show ip bgp regexp .LINE",
9278 "Display routes matching the AS path regular expression\n"
9279 "A regular-expression to match the BGP AS paths\n")
9281 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9282 bgp_show_type_regexp
);
9285 DEFUN (show_ip_bgp_flap_regexp
,
9286 show_ip_bgp_flap_regexp_cmd
,
9287 "show ip bgp flap-statistics regexp .LINE",
9291 "Display flap statistics of routes\n"
9292 "Display routes matching the AS path regular expression\n"
9293 "A regular-expression to match the BGP AS paths\n")
9295 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9296 bgp_show_type_flap_regexp
);
9299 ALIAS (show_ip_bgp_flap_regexp
,
9300 show_ip_bgp_damp_flap_regexp_cmd
,
9301 "show ip bgp dampening flap-statistics regexp .LINE",
9305 "Display detailed information about dampening\n"
9306 "Display flap statistics of routes\n"
9307 "Display routes matching the AS path regular expression\n"
9308 "A regular-expression to match the BGP AS paths\n")
9310 DEFUN (show_ip_bgp_ipv4_regexp
,
9311 show_ip_bgp_ipv4_regexp_cmd
,
9312 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
9317 "Address Family modifier\n"
9318 "Address Family modifier\n"
9319 "Display routes matching the AS path regular expression\n"
9320 "A regular-expression to match the BGP AS paths\n")
9323 safi
= bgp_vty_safi_from_arg(argv
[0]);
9324 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, safi
,
9325 bgp_show_type_regexp
);
9329 DEFUN (show_bgp_regexp
,
9330 show_bgp_regexp_cmd
,
9331 "show bgp regexp .LINE",
9334 "Display routes matching the AS path regular expression\n"
9335 "A regular-expression to match the BGP AS paths\n")
9337 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9338 bgp_show_type_regexp
);
9341 ALIAS (show_bgp_regexp
,
9342 show_bgp_ipv6_regexp_cmd
,
9343 "show bgp ipv6 regexp .LINE",
9347 "Display routes matching the AS path regular expression\n"
9348 "A regular-expression to match the BGP AS paths\n")
9351 DEFUN (show_ipv6_bgp_regexp
,
9352 show_ipv6_bgp_regexp_cmd
,
9353 "show ipv6 bgp regexp .LINE",
9357 "Display routes matching the AS path regular expression\n"
9358 "A regular-expression to match the BGP AS paths\n")
9360 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9361 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9362 bgp_show_type_regexp
);
9366 DEFUN (show_ipv6_mbgp_regexp
,
9367 show_ipv6_mbgp_regexp_cmd
,
9368 "show ipv6 mbgp regexp .LINE",
9372 "Display routes matching the AS path regular expression\n"
9373 "A regular-expression to match the MBGP AS paths\n")
9375 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9376 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9377 bgp_show_type_regexp
);
9379 #endif /* HAVE_IPV6 */
9382 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9383 const char *prefix_list_str
, afi_t afi
,
9384 safi_t safi
, enum bgp_show_type type
)
9386 struct prefix_list
*plist
;
9387 struct bgp
*bgp
= NULL
;
9389 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9391 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9395 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9398 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9399 prefix_list_str
, VTY_NEWLINE
);
9403 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9406 DEFUN (show_ip_bgp_prefix_list
,
9407 show_ip_bgp_prefix_list_cmd
,
9408 "show ip bgp prefix-list WORD",
9412 "Display routes conforming to the prefix-list\n"
9413 "IP prefix-list name\n")
9415 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9416 bgp_show_type_prefix_list
);
9419 DEFUN (show_ip_bgp_instance_prefix_list
,
9420 show_ip_bgp_instance_prefix_list_cmd
,
9421 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9425 BGP_INSTANCE_HELP_STR
9426 "Display routes conforming to the prefix-list\n"
9427 "IP prefix-list name\n")
9429 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9430 bgp_show_type_prefix_list
);
9433 DEFUN (show_ip_bgp_flap_prefix_list
,
9434 show_ip_bgp_flap_prefix_list_cmd
,
9435 "show ip bgp flap-statistics prefix-list WORD",
9439 "Display flap statistics of routes\n"
9440 "Display routes conforming to the prefix-list\n"
9441 "IP prefix-list name\n")
9443 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9444 bgp_show_type_flap_prefix_list
);
9447 ALIAS (show_ip_bgp_flap_prefix_list
,
9448 show_ip_bgp_damp_flap_prefix_list_cmd
,
9449 "show ip bgp dampening flap-statistics prefix-list WORD",
9453 "Display detailed information about dampening\n"
9454 "Display flap statistics of routes\n"
9455 "Display routes conforming to the prefix-list\n"
9456 "IP prefix-list name\n")
9458 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9459 show_ip_bgp_ipv4_prefix_list_cmd
,
9460 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
9465 "Address Family modifier\n"
9466 "Address Family modifier\n"
9467 "Display routes conforming to the prefix-list\n"
9468 "IP prefix-list name\n")
9471 safi
= bgp_vty_safi_from_arg(argv
[0]);
9472 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9473 bgp_show_type_prefix_list
);
9477 DEFUN (show_bgp_prefix_list
,
9478 show_bgp_prefix_list_cmd
,
9479 "show bgp prefix-list WORD",
9482 "Display routes conforming to the prefix-list\n"
9483 "IPv6 prefix-list name\n")
9485 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9486 bgp_show_type_prefix_list
);
9489 ALIAS (show_bgp_prefix_list
,
9490 show_bgp_ipv6_prefix_list_cmd
,
9491 "show bgp ipv6 prefix-list WORD",
9495 "Display routes conforming to the prefix-list\n"
9496 "IPv6 prefix-list name\n")
9499 DEFUN (show_ipv6_bgp_prefix_list
,
9500 show_ipv6_bgp_prefix_list_cmd
,
9501 "show ipv6 bgp prefix-list WORD",
9505 "Display routes matching the prefix-list\n"
9506 "IPv6 prefix-list name\n")
9508 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9509 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9510 bgp_show_type_prefix_list
);
9514 DEFUN (show_ipv6_mbgp_prefix_list
,
9515 show_ipv6_mbgp_prefix_list_cmd
,
9516 "show ipv6 mbgp prefix-list WORD",
9520 "Display routes matching the prefix-list\n"
9521 "IPv6 prefix-list name\n")
9523 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9524 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9525 bgp_show_type_prefix_list
);
9527 #endif /* HAVE_IPV6 */
9530 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9531 const char *filter
, afi_t afi
,
9532 safi_t safi
, enum bgp_show_type type
)
9534 struct as_list
*as_list
;
9535 struct bgp
*bgp
= NULL
;
9537 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9539 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9543 as_list
= as_list_lookup (filter
);
9544 if (as_list
== NULL
)
9546 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9550 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9553 DEFUN (show_ip_bgp_filter_list
,
9554 show_ip_bgp_filter_list_cmd
,
9555 "show ip bgp filter-list WORD",
9559 "Display routes conforming to the filter-list\n"
9560 "Regular expression access list name\n")
9562 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9563 bgp_show_type_filter_list
);
9566 DEFUN (show_ip_bgp_instance_filter_list
,
9567 show_ip_bgp_instance_filter_list_cmd
,
9568 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9572 BGP_INSTANCE_HELP_STR
9573 "Display routes conforming to the filter-list\n"
9574 "Regular expression access list name\n")
9576 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9577 bgp_show_type_filter_list
);
9580 DEFUN (show_ip_bgp_flap_filter_list
,
9581 show_ip_bgp_flap_filter_list_cmd
,
9582 "show ip bgp flap-statistics filter-list WORD",
9586 "Display flap statistics of routes\n"
9587 "Display routes conforming to the filter-list\n"
9588 "Regular expression access list name\n")
9590 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9591 bgp_show_type_flap_filter_list
);
9594 ALIAS (show_ip_bgp_flap_filter_list
,
9595 show_ip_bgp_damp_flap_filter_list_cmd
,
9596 "show ip bgp dampening flap-statistics filter-list WORD",
9600 "Display detailed information about dampening\n"
9601 "Display flap statistics of routes\n"
9602 "Display routes conforming to the filter-list\n"
9603 "Regular expression access list name\n")
9605 DEFUN (show_ip_bgp_ipv4_filter_list
,
9606 show_ip_bgp_ipv4_filter_list_cmd
,
9607 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9612 "Address Family modifier\n"
9613 "Address Family modifier\n"
9614 "Display routes conforming to the filter-list\n"
9615 "Regular expression access list name\n")
9618 safi
= bgp_vty_safi_from_arg(argv
[0]);
9619 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9620 bgp_show_type_filter_list
);
9624 DEFUN (show_bgp_filter_list
,
9625 show_bgp_filter_list_cmd
,
9626 "show bgp filter-list WORD",
9629 "Display routes conforming to the filter-list\n"
9630 "Regular expression access list name\n")
9632 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9633 bgp_show_type_filter_list
);
9636 ALIAS (show_bgp_filter_list
,
9637 show_bgp_ipv6_filter_list_cmd
,
9638 "show bgp ipv6 filter-list WORD",
9642 "Display routes conforming to the filter-list\n"
9643 "Regular expression access list name\n")
9646 DEFUN (show_ipv6_bgp_filter_list
,
9647 show_ipv6_bgp_filter_list_cmd
,
9648 "show ipv6 bgp filter-list WORD",
9652 "Display routes conforming to the filter-list\n"
9653 "Regular expression access list name\n")
9655 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9656 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9657 bgp_show_type_filter_list
);
9661 DEFUN (show_ipv6_mbgp_filter_list
,
9662 show_ipv6_mbgp_filter_list_cmd
,
9663 "show ipv6 mbgp filter-list WORD",
9667 "Display routes conforming to the filter-list\n"
9668 "Regular expression access list name\n")
9670 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9671 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9672 bgp_show_type_filter_list
);
9674 #endif /* HAVE_IPV6 */
9676 DEFUN (show_ip_bgp_dampening_info
,
9677 show_ip_bgp_dampening_params_cmd
,
9678 "show ip bgp dampening parameters",
9682 "Display detailed information about dampening\n"
9683 "Display detail of configured dampening parameters\n")
9685 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9689 DEFUN (show_ip_bgp_ipv4_dampening_parameters
,
9690 show_ip_bgp_ipv4_dampening_parameters_cmd
,
9691 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
9696 "Address Family modifier\n"
9697 "Address Family modifier\n"
9698 "Display detailed information about dampening\n"
9699 "Display detail of configured dampening parameters\n")
9702 safi
= bgp_vty_safi_from_arg(argv
[0]);
9703 return bgp_show_dampening_parameters (vty
, AFI_IP
, safi
);
9707 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats
,
9708 show_ip_bgp_ipv4_dampening_flap_stats_cmd
,
9709 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
9714 "Address Family modifier\n"
9715 "Address Family modifier\n"
9716 "Display detailed information about dampening\n"
9717 "Display flap statistics of routes\n")
9720 safi
= bgp_vty_safi_from_arg(argv
[0]);
9721 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9722 bgp_show_type_flap_statistics
, NULL
, 0);
9725 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths
,
9726 show_ip_bgp_ipv4_dampening_dampd_paths_cmd
,
9727 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
9732 "Address Family modifier\n"
9733 "Address Family modifier\n"
9734 "Display detailed information about dampening\n"
9735 "Display paths suppressed due to dampening\n")
9738 safi
= bgp_vty_safi_from_arg(argv
[0]);
9739 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9740 bgp_show_type_dampend_paths
, NULL
, 0);
9744 bgp_show_route_map (struct vty
*vty
, const char *name
,
9745 const char *rmap_str
, afi_t afi
,
9746 safi_t safi
, enum bgp_show_type type
)
9748 struct route_map
*rmap
;
9749 struct bgp
*bgp
= NULL
;
9751 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9753 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9757 rmap
= route_map_lookup_by_name (rmap_str
);
9760 vty_out (vty
, "%% %s is not a valid route-map name%s",
9761 rmap_str
, VTY_NEWLINE
);
9765 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9768 DEFUN (show_ip_bgp_route_map
,
9769 show_ip_bgp_route_map_cmd
,
9770 "show ip bgp route-map WORD",
9774 "Display routes matching the route-map\n"
9775 "A route-map to match on\n")
9777 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9778 bgp_show_type_route_map
);
9781 DEFUN (show_ip_bgp_instance_route_map
,
9782 show_ip_bgp_instance_route_map_cmd
,
9783 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9787 BGP_INSTANCE_HELP_STR
9788 "Display routes matching the route-map\n"
9789 "A route-map to match on\n")
9791 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9792 bgp_show_type_route_map
);
9795 DEFUN (show_ip_bgp_flap_route_map
,
9796 show_ip_bgp_flap_route_map_cmd
,
9797 "show ip bgp flap-statistics route-map WORD",
9801 "Display flap statistics of routes\n"
9802 "Display routes matching the route-map\n"
9803 "A route-map to match on\n")
9805 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9806 bgp_show_type_flap_route_map
);
9809 ALIAS (show_ip_bgp_flap_route_map
,
9810 show_ip_bgp_damp_flap_route_map_cmd
,
9811 "show ip bgp dampening flap-statistics route-map WORD",
9815 "Display detailed information about dampening\n"
9816 "Display flap statistics of routes\n"
9817 "Display routes matching the route-map\n"
9818 "A route-map to match on\n")
9820 DEFUN (show_ip_bgp_ipv4_route_map
,
9821 show_ip_bgp_ipv4_route_map_cmd
,
9822 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9827 "Address Family modifier\n"
9828 "Address Family modifier\n"
9829 "Display routes matching the route-map\n"
9830 "A route-map to match on\n")
9833 safi
= bgp_vty_safi_from_arg(argv
[0]);
9834 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9835 bgp_show_type_route_map
);
9838 DEFUN (show_bgp_route_map
,
9839 show_bgp_route_map_cmd
,
9840 "show bgp route-map WORD",
9843 "Display routes matching the route-map\n"
9844 "A route-map to match on\n")
9846 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9847 bgp_show_type_route_map
);
9850 ALIAS (show_bgp_route_map
,
9851 show_bgp_ipv6_route_map_cmd
,
9852 "show bgp ipv6 route-map WORD",
9856 "Display routes matching the route-map\n"
9857 "A route-map to match on\n")
9859 DEFUN (show_ip_bgp_cidr_only
,
9860 show_ip_bgp_cidr_only_cmd
,
9861 "show ip bgp cidr-only",
9865 "Display only routes with non-natural netmasks\n")
9867 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9868 bgp_show_type_cidr_only
, NULL
, 0);
9871 DEFUN (show_ip_bgp_flap_cidr_only
,
9872 show_ip_bgp_flap_cidr_only_cmd
,
9873 "show ip bgp flap-statistics cidr-only",
9877 "Display flap statistics of routes\n"
9878 "Display only routes with non-natural netmasks\n")
9880 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9881 bgp_show_type_flap_cidr_only
, NULL
, 0);
9884 ALIAS (show_ip_bgp_flap_cidr_only
,
9885 show_ip_bgp_damp_flap_cidr_only_cmd
,
9886 "show ip bgp dampening flap-statistics cidr-only",
9890 "Display detailed information about dampening\n"
9891 "Display flap statistics of routes\n"
9892 "Display only routes with non-natural netmasks\n")
9894 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9895 show_ip_bgp_ipv4_cidr_only_cmd
,
9896 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9901 "Address Family modifier\n"
9902 "Address Family modifier\n"
9903 "Display only routes with non-natural netmasks\n")
9906 safi
= bgp_vty_safi_from_arg(argv
[0]);
9907 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9908 bgp_show_type_cidr_only
, NULL
, 0);
9911 DEFUN (show_ip_bgp_community_all
,
9912 show_ip_bgp_community_all_cmd
,
9913 "show ip bgp community",
9917 "Display routes matching the communities\n")
9919 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9920 bgp_show_type_community_all
, NULL
, 0);
9923 DEFUN (show_ip_bgp_ipv4_community_all
,
9924 show_ip_bgp_ipv4_community_all_cmd
,
9925 "show ip bgp ipv4 (unicast|multicast) community",
9930 "Address Family modifier\n"
9931 "Address Family modifier\n"
9932 "Display routes matching the communities\n")
9935 safi
= bgp_vty_safi_from_arg(argv
[0]);
9936 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9937 bgp_show_type_community_all
, NULL
, 0);
9941 DEFUN (show_bgp_community_all
,
9942 show_bgp_community_all_cmd
,
9943 "show bgp community",
9946 "Display routes matching the communities\n")
9948 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9949 bgp_show_type_community_all
, NULL
, 0);
9952 ALIAS (show_bgp_community_all
,
9953 show_bgp_ipv6_community_all_cmd
,
9954 "show bgp ipv6 community",
9958 "Display routes matching the communities\n")
9961 DEFUN (show_ipv6_bgp_community_all
,
9962 show_ipv6_bgp_community_all_cmd
,
9963 "show ipv6 bgp community",
9967 "Display routes matching the communities\n")
9969 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9970 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9971 bgp_show_type_community_all
, NULL
, 0);
9975 DEFUN (show_ipv6_mbgp_community_all
,
9976 show_ipv6_mbgp_community_all_cmd
,
9977 "show ipv6 mbgp community",
9981 "Display routes matching the communities\n")
9983 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9984 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9985 bgp_show_type_community_all
, NULL
, 0);
9987 #endif /* HAVE_IPV6 */
9990 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9991 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9993 struct community
*com
;
10000 /* BGP structure lookup */
10003 bgp
= bgp_lookup_by_name (view_name
);
10006 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
10007 return CMD_WARNING
;
10012 bgp
= bgp_get_default ();
10015 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10016 return CMD_WARNING
;
10020 b
= buffer_new (1024);
10021 for (i
= 0; i
< argc
; i
++)
10024 buffer_putc (b
, ' ');
10027 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
10032 buffer_putstr (b
, argv
[i
]);
10034 buffer_putc (b
, '\0');
10036 str
= buffer_getstr (b
);
10039 com
= community_str2com (str
);
10040 XFREE (MTYPE_TMP
, str
);
10043 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
10044 return CMD_WARNING
;
10047 return bgp_show (vty
, bgp
, afi
, safi
,
10048 (exact
? bgp_show_type_community_exact
:
10049 bgp_show_type_community
), com
, 0);
10052 DEFUN (show_ip_bgp_community
,
10053 show_ip_bgp_community_cmd
,
10054 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
10058 "Display routes matching the communities\n"
10060 "Do not send outside local AS (well-known community)\n"
10061 "Do not advertise to any peer (well-known community)\n"
10062 "Do not export to next AS (well-known community)\n")
10064 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
10067 ALIAS (show_ip_bgp_community
,
10068 show_ip_bgp_community2_cmd
,
10069 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10073 "Display routes matching the communities\n"
10075 "Do not send outside local AS (well-known community)\n"
10076 "Do not advertise to any peer (well-known community)\n"
10077 "Do not export to next AS (well-known community)\n"
10079 "Do not send outside local AS (well-known community)\n"
10080 "Do not advertise to any peer (well-known community)\n"
10081 "Do not export to next AS (well-known community)\n")
10083 ALIAS (show_ip_bgp_community
,
10084 show_ip_bgp_community3_cmd
,
10085 "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)",
10089 "Display routes matching the communities\n"
10091 "Do not send outside local AS (well-known community)\n"
10092 "Do not advertise to any peer (well-known community)\n"
10093 "Do not export to next AS (well-known community)\n"
10095 "Do not send outside local AS (well-known community)\n"
10096 "Do not advertise to any peer (well-known community)\n"
10097 "Do not export to next AS (well-known community)\n"
10099 "Do not send outside local AS (well-known community)\n"
10100 "Do not advertise to any peer (well-known community)\n"
10101 "Do not export to next AS (well-known community)\n")
10103 ALIAS (show_ip_bgp_community
,
10104 show_ip_bgp_community4_cmd
,
10105 "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)",
10109 "Display routes matching the communities\n"
10111 "Do not send outside local AS (well-known community)\n"
10112 "Do not advertise to any peer (well-known community)\n"
10113 "Do not export to next AS (well-known community)\n"
10115 "Do not send outside local AS (well-known community)\n"
10116 "Do not advertise to any peer (well-known community)\n"
10117 "Do not export to next AS (well-known community)\n"
10119 "Do not send outside local AS (well-known community)\n"
10120 "Do not advertise to any peer (well-known community)\n"
10121 "Do not export to next AS (well-known community)\n"
10123 "Do not send outside local AS (well-known community)\n"
10124 "Do not advertise to any peer (well-known community)\n"
10125 "Do not export to next AS (well-known community)\n")
10127 DEFUN (show_ip_bgp_ipv4_community
,
10128 show_ip_bgp_ipv4_community_cmd
,
10129 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10134 "Address Family modifier\n"
10135 "Address Family modifier\n"
10136 "Display routes matching the communities\n"
10138 "Do not send outside local AS (well-known community)\n"
10139 "Do not advertise to any peer (well-known community)\n"
10140 "Do not export to next AS (well-known community)\n")
10143 safi
= bgp_vty_safi_from_arg(argv
[0]);
10144 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, safi
);
10147 ALIAS (show_ip_bgp_ipv4_community
,
10148 show_ip_bgp_ipv4_community2_cmd
,
10149 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10154 "Address Family modifier\n"
10155 "Address Family modifier\n"
10156 "Display routes matching the communities\n"
10158 "Do not send outside local AS (well-known community)\n"
10159 "Do not advertise to any peer (well-known community)\n"
10160 "Do not export to next AS (well-known community)\n"
10162 "Do not send outside local AS (well-known community)\n"
10163 "Do not advertise to any peer (well-known community)\n"
10164 "Do not export to next AS (well-known community)\n")
10166 ALIAS (show_ip_bgp_ipv4_community
,
10167 show_ip_bgp_ipv4_community3_cmd
,
10168 "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)",
10173 "Address Family modifier\n"
10174 "Address Family modifier\n"
10175 "Display routes matching the communities\n"
10177 "Do not send outside local AS (well-known community)\n"
10178 "Do not advertise to any peer (well-known community)\n"
10179 "Do not export to next AS (well-known community)\n"
10181 "Do not send outside local AS (well-known community)\n"
10182 "Do not advertise to any peer (well-known community)\n"
10183 "Do not export to next AS (well-known community)\n"
10185 "Do not send outside local AS (well-known community)\n"
10186 "Do not advertise to any peer (well-known community)\n"
10187 "Do not export to next AS (well-known community)\n")
10189 ALIAS (show_ip_bgp_ipv4_community
,
10190 show_ip_bgp_ipv4_community4_cmd
,
10191 "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)",
10196 "Address Family modifier\n"
10197 "Address Family modifier\n"
10198 "Display routes matching the communities\n"
10200 "Do not send outside local AS (well-known community)\n"
10201 "Do not advertise to any peer (well-known community)\n"
10202 "Do not export to next AS (well-known community)\n"
10204 "Do not send outside local AS (well-known community)\n"
10205 "Do not advertise to any peer (well-known community)\n"
10206 "Do not export to next AS (well-known community)\n"
10208 "Do not send outside local AS (well-known community)\n"
10209 "Do not advertise to any peer (well-known community)\n"
10210 "Do not export to next AS (well-known community)\n"
10212 "Do not send outside local AS (well-known community)\n"
10213 "Do not advertise to any peer (well-known community)\n"
10214 "Do not export to next AS (well-known community)\n")
10216 DEFUN (show_bgp_instance_afi_safi_community_all
,
10217 show_bgp_instance_afi_safi_community_all_cmd
,
10218 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
10221 BGP_INSTANCE_HELP_STR
10224 "Address Family modifier\n"
10225 "Address Family modifier\n"
10226 "Display routes matching the communities\n")
10232 /* BGP structure lookup. */
10233 bgp
= bgp_lookup_by_name (argv
[1]);
10236 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
10237 return CMD_WARNING
;
10240 afi
= bgp_vty_safi_from_arg(argv
[2]);
10241 safi
= bgp_vty_safi_from_arg(argv
[3]);
10242 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
10245 DEFUN (show_bgp_instance_afi_safi_community
,
10246 show_bgp_instance_afi_safi_community_cmd
,
10247 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10250 BGP_INSTANCE_HELP_STR
10253 "Address family modifier\n"
10254 "Address family modifier\n"
10255 "Display routes matching the communities\n"
10257 "Do not send outside local AS (well-known community)\n"
10258 "Do not advertise to any peer (well-known community)\n"
10259 "Do not export to next AS (well-known community)\n")
10264 afi
= bgp_vty_safi_from_arg(argv
[2]);
10265 safi
= bgp_vty_safi_from_arg(argv
[3]);
10266 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
10269 ALIAS (show_bgp_instance_afi_safi_community
,
10270 show_bgp_instance_afi_safi_community2_cmd
,
10271 "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)",
10274 BGP_INSTANCE_HELP_STR
10277 "Address family modifier\n"
10278 "Address family modifier\n"
10279 "Display routes matching the communities\n"
10281 "Do not send outside local AS (well-known community)\n"
10282 "Do not advertise to any peer (well-known community)\n"
10283 "Do not export to next AS (well-known community)\n"
10285 "Do not send outside local AS (well-known community)\n"
10286 "Do not advertise to any peer (well-known community)\n"
10287 "Do not export to next AS (well-known community)\n")
10289 ALIAS (show_bgp_instance_afi_safi_community
,
10290 show_bgp_instance_afi_safi_community3_cmd
,
10291 "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)",
10294 BGP_INSTANCE_HELP_STR
10297 "Address family modifier\n"
10298 "Address family modifier\n"
10299 "Display routes matching the communities\n"
10301 "Do not send outside local AS (well-known community)\n"
10302 "Do not advertise to any peer (well-known community)\n"
10303 "Do not export to next AS (well-known community)\n"
10305 "Do not send outside local AS (well-known community)\n"
10306 "Do not advertise to any peer (well-known community)\n"
10307 "Do not export to next AS (well-known community)\n"
10309 "Do not send outside local AS (well-known community)\n"
10310 "Do not advertise to any peer (well-known community)\n"
10311 "Do not export to next AS (well-known community)\n")
10313 ALIAS (show_bgp_instance_afi_safi_community
,
10314 show_bgp_instance_afi_safi_community4_cmd
,
10315 "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)",
10318 BGP_INSTANCE_HELP_STR
10321 "Address family modifier\n"
10322 "Address family modifier\n"
10323 "Display routes matching the communities\n"
10325 "Do not send outside local AS (well-known community)\n"
10326 "Do not advertise to any peer (well-known community)\n"
10327 "Do not export to next AS (well-known community)\n"
10329 "Do not send outside local AS (well-known community)\n"
10330 "Do not advertise to any peer (well-known community)\n"
10331 "Do not export to next AS (well-known community)\n"
10333 "Do not send outside local AS (well-known community)\n"
10334 "Do not advertise to any peer (well-known community)\n"
10335 "Do not export to next AS (well-known community)\n"
10337 "Do not send outside local AS (well-known community)\n"
10338 "Do not advertise to any peer (well-known community)\n"
10339 "Do not export to next AS (well-known community)\n")
10341 DEFUN (show_ip_bgp_community_exact
,
10342 show_ip_bgp_community_exact_cmd
,
10343 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10347 "Display routes matching the communities\n"
10349 "Do not send outside local AS (well-known community)\n"
10350 "Do not advertise to any peer (well-known community)\n"
10351 "Do not export to next AS (well-known community)\n"
10352 "Exact match of the communities")
10354 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10357 ALIAS (show_ip_bgp_community_exact
,
10358 show_ip_bgp_community2_exact_cmd
,
10359 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10363 "Display routes matching the communities\n"
10365 "Do not send outside local AS (well-known community)\n"
10366 "Do not advertise to any peer (well-known community)\n"
10367 "Do not export to next AS (well-known community)\n"
10369 "Do not send outside local AS (well-known community)\n"
10370 "Do not advertise to any peer (well-known community)\n"
10371 "Do not export to next AS (well-known community)\n"
10372 "Exact match of the communities")
10374 ALIAS (show_ip_bgp_community_exact
,
10375 show_ip_bgp_community3_exact_cmd
,
10376 "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",
10380 "Display routes matching the communities\n"
10382 "Do not send outside local AS (well-known community)\n"
10383 "Do not advertise to any peer (well-known community)\n"
10384 "Do not export to next AS (well-known community)\n"
10386 "Do not send outside local AS (well-known community)\n"
10387 "Do not advertise to any peer (well-known community)\n"
10388 "Do not export to next AS (well-known community)\n"
10390 "Do not send outside local AS (well-known community)\n"
10391 "Do not advertise to any peer (well-known community)\n"
10392 "Do not export to next AS (well-known community)\n"
10393 "Exact match of the communities")
10395 ALIAS (show_ip_bgp_community_exact
,
10396 show_ip_bgp_community4_exact_cmd
,
10397 "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",
10401 "Display routes matching the communities\n"
10403 "Do not send outside local AS (well-known community)\n"
10404 "Do not advertise to any peer (well-known community)\n"
10405 "Do not export to next AS (well-known community)\n"
10407 "Do not send outside local AS (well-known community)\n"
10408 "Do not advertise to any peer (well-known community)\n"
10409 "Do not export to next AS (well-known community)\n"
10411 "Do not send outside local AS (well-known community)\n"
10412 "Do not advertise to any peer (well-known community)\n"
10413 "Do not export to next AS (well-known community)\n"
10415 "Do not send outside local AS (well-known community)\n"
10416 "Do not advertise to any peer (well-known community)\n"
10417 "Do not export to next AS (well-known community)\n"
10418 "Exact match of the communities")
10420 DEFUN (show_ip_bgp_ipv4_community_exact
,
10421 show_ip_bgp_ipv4_community_exact_cmd
,
10422 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10427 "Address Family modifier\n"
10428 "Address Family modifier\n"
10429 "Display routes matching the communities\n"
10431 "Do not send outside local AS (well-known community)\n"
10432 "Do not advertise to any peer (well-known community)\n"
10433 "Do not export to next AS (well-known community)\n"
10434 "Exact match of the communities")
10437 safi
= bgp_vty_safi_from_arg(argv
[0]);
10438 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, safi
);
10441 ALIAS (show_ip_bgp_ipv4_community_exact
,
10442 show_ip_bgp_ipv4_community2_exact_cmd
,
10443 "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",
10448 "Address Family modifier\n"
10449 "Address Family modifier\n"
10450 "Display routes matching the communities\n"
10452 "Do not send outside local AS (well-known community)\n"
10453 "Do not advertise to any peer (well-known community)\n"
10454 "Do not export to next AS (well-known community)\n"
10456 "Do not send outside local AS (well-known community)\n"
10457 "Do not advertise to any peer (well-known community)\n"
10458 "Do not export to next AS (well-known community)\n"
10459 "Exact match of the communities")
10461 ALIAS (show_ip_bgp_ipv4_community_exact
,
10462 show_ip_bgp_ipv4_community3_exact_cmd
,
10463 "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",
10468 "Address Family modifier\n"
10469 "Address Family modifier\n"
10470 "Display routes matching the communities\n"
10472 "Do not send outside local AS (well-known community)\n"
10473 "Do not advertise to any peer (well-known community)\n"
10474 "Do not export to next AS (well-known community)\n"
10476 "Do not send outside local AS (well-known community)\n"
10477 "Do not advertise to any peer (well-known community)\n"
10478 "Do not export to next AS (well-known community)\n"
10480 "Do not send outside local AS (well-known community)\n"
10481 "Do not advertise to any peer (well-known community)\n"
10482 "Do not export to next AS (well-known community)\n"
10483 "Exact match of the communities")
10485 ALIAS (show_ip_bgp_ipv4_community_exact
,
10486 show_ip_bgp_ipv4_community4_exact_cmd
,
10487 "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",
10492 "Address Family modifier\n"
10493 "Address Family modifier\n"
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")
10514 DEFUN (show_bgp_community
,
10515 show_bgp_community_cmd
,
10516 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10519 "Display routes matching the communities\n"
10521 "Do not send outside local AS (well-known community)\n"
10522 "Do not advertise to any peer (well-known community)\n"
10523 "Do not export to next AS (well-known community)\n")
10525 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10528 ALIAS (show_bgp_community
,
10529 show_bgp_ipv6_community_cmd
,
10530 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10534 "Display routes matching the communities\n"
10536 "Do not send outside local AS (well-known community)\n"
10537 "Do not advertise to any peer (well-known community)\n"
10538 "Do not export to next AS (well-known community)\n")
10540 ALIAS (show_bgp_community
,
10541 show_bgp_community2_cmd
,
10542 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10545 "Display routes matching the communities\n"
10547 "Do not send outside local AS (well-known community)\n"
10548 "Do not advertise to any peer (well-known community)\n"
10549 "Do not export to next AS (well-known community)\n"
10551 "Do not send outside local AS (well-known community)\n"
10552 "Do not advertise to any peer (well-known community)\n"
10553 "Do not export to next AS (well-known community)\n")
10555 ALIAS (show_bgp_community
,
10556 show_bgp_ipv6_community2_cmd
,
10557 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10561 "Display routes matching the communities\n"
10563 "Do not send outside local AS (well-known community)\n"
10564 "Do not advertise to any peer (well-known community)\n"
10565 "Do not export to next AS (well-known community)\n"
10567 "Do not send outside local AS (well-known community)\n"
10568 "Do not advertise to any peer (well-known community)\n"
10569 "Do not export to next AS (well-known community)\n")
10571 ALIAS (show_bgp_community
,
10572 show_bgp_community3_cmd
,
10573 "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)",
10576 "Display routes matching the communities\n"
10578 "Do not send outside local AS (well-known community)\n"
10579 "Do not advertise to any peer (well-known community)\n"
10580 "Do not export to next AS (well-known community)\n"
10582 "Do not send outside local AS (well-known community)\n"
10583 "Do not advertise to any peer (well-known community)\n"
10584 "Do not export to next AS (well-known community)\n"
10586 "Do not send outside local AS (well-known community)\n"
10587 "Do not advertise to any peer (well-known community)\n"
10588 "Do not export to next AS (well-known community)\n")
10590 ALIAS (show_bgp_community
,
10591 show_bgp_ipv6_community3_cmd
,
10592 "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)",
10596 "Display routes matching the communities\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"
10606 "Do not send outside local AS (well-known community)\n"
10607 "Do not advertise to any peer (well-known community)\n"
10608 "Do not export to next AS (well-known community)\n")
10610 ALIAS (show_bgp_community
,
10611 show_bgp_community4_cmd
,
10612 "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)",
10615 "Display routes matching the communities\n"
10617 "Do not send outside local AS (well-known community)\n"
10618 "Do not advertise to any peer (well-known community)\n"
10619 "Do not export to next AS (well-known community)\n"
10621 "Do not send outside local AS (well-known community)\n"
10622 "Do not advertise to any peer (well-known community)\n"
10623 "Do not export to next AS (well-known community)\n"
10625 "Do not send outside local AS (well-known community)\n"
10626 "Do not advertise to any peer (well-known community)\n"
10627 "Do not export to next AS (well-known community)\n"
10629 "Do not send outside local AS (well-known community)\n"
10630 "Do not advertise to any peer (well-known community)\n"
10631 "Do not export to next AS (well-known community)\n")
10633 ALIAS (show_bgp_community
,
10634 show_bgp_ipv6_community4_cmd
,
10635 "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)",
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 "Do not send outside local AS (well-known community)\n"
10650 "Do not advertise to any peer (well-known community)\n"
10651 "Do not export to next AS (well-known community)\n"
10653 "Do not send outside local AS (well-known community)\n"
10654 "Do not advertise to any peer (well-known community)\n"
10655 "Do not export to next AS (well-known community)\n")
10658 DEFUN (show_ipv6_bgp_community
,
10659 show_ipv6_bgp_community_cmd
,
10660 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10664 "Display routes matching the communities\n"
10666 "Do not send outside local AS (well-known community)\n"
10667 "Do not advertise to any peer (well-known community)\n"
10668 "Do not export to next AS (well-known community)\n")
10670 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10671 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10675 ALIAS (show_ipv6_bgp_community
,
10676 show_ipv6_bgp_community2_cmd
,
10677 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10681 "Display routes matching the communities\n"
10683 "Do not send outside local AS (well-known community)\n"
10684 "Do not advertise to any peer (well-known community)\n"
10685 "Do not export to next AS (well-known community)\n"
10687 "Do not send outside local AS (well-known community)\n"
10688 "Do not advertise to any peer (well-known community)\n"
10689 "Do not export to next AS (well-known community)\n")
10692 ALIAS (show_ipv6_bgp_community
,
10693 show_ipv6_bgp_community3_cmd
,
10694 "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)",
10698 "Display routes matching the communities\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 "Do not send outside local AS (well-known community)\n"
10705 "Do not advertise to any peer (well-known community)\n"
10706 "Do not export to next AS (well-known community)\n"
10708 "Do not send outside local AS (well-known community)\n"
10709 "Do not advertise to any peer (well-known community)\n"
10710 "Do not export to next AS (well-known community)\n")
10713 ALIAS (show_ipv6_bgp_community
,
10714 show_ipv6_bgp_community4_cmd
,
10715 "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)",
10719 "Display routes matching the communities\n"
10721 "Do not send outside local AS (well-known community)\n"
10722 "Do not advertise to any peer (well-known community)\n"
10723 "Do not export to next AS (well-known community)\n"
10725 "Do not send outside local AS (well-known community)\n"
10726 "Do not advertise to any peer (well-known community)\n"
10727 "Do not export to next AS (well-known community)\n"
10729 "Do not send outside local AS (well-known community)\n"
10730 "Do not advertise to any peer (well-known community)\n"
10731 "Do not export to next AS (well-known community)\n"
10733 "Do not send outside local AS (well-known community)\n"
10734 "Do not advertise to any peer (well-known community)\n"
10735 "Do not export to next AS (well-known community)\n")
10737 DEFUN (show_bgp_community_exact
,
10738 show_bgp_community_exact_cmd
,
10739 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10742 "Display routes matching the communities\n"
10744 "Do not send outside local AS (well-known community)\n"
10745 "Do not advertise to any peer (well-known community)\n"
10746 "Do not export to next AS (well-known community)\n"
10747 "Exact match of the communities")
10749 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10752 ALIAS (show_bgp_community_exact
,
10753 show_bgp_ipv6_community_exact_cmd
,
10754 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
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"
10763 "Exact match of the communities")
10765 ALIAS (show_bgp_community_exact
,
10766 show_bgp_community2_exact_cmd
,
10767 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10770 "Display routes matching the communities\n"
10772 "Do not send outside local AS (well-known community)\n"
10773 "Do not advertise to any peer (well-known community)\n"
10774 "Do not export to next AS (well-known community)\n"
10776 "Do not send outside local AS (well-known community)\n"
10777 "Do not advertise to any peer (well-known community)\n"
10778 "Do not export to next AS (well-known community)\n"
10779 "Exact match of the communities")
10781 ALIAS (show_bgp_community_exact
,
10782 show_bgp_ipv6_community2_exact_cmd
,
10783 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10787 "Display routes matching the communities\n"
10789 "Do not send outside local AS (well-known community)\n"
10790 "Do not advertise to any peer (well-known community)\n"
10791 "Do not export to next AS (well-known community)\n"
10793 "Do not send outside local AS (well-known community)\n"
10794 "Do not advertise to any peer (well-known community)\n"
10795 "Do not export to next AS (well-known community)\n"
10796 "Exact match of the communities")
10798 ALIAS (show_bgp_community_exact
,
10799 show_bgp_community3_exact_cmd
,
10800 "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",
10803 "Display routes matching the communities\n"
10805 "Do not send outside local AS (well-known community)\n"
10806 "Do not advertise to any peer (well-known community)\n"
10807 "Do not export to next AS (well-known community)\n"
10809 "Do not send outside local AS (well-known community)\n"
10810 "Do not advertise to any peer (well-known community)\n"
10811 "Do not export to next AS (well-known community)\n"
10813 "Do not send outside local AS (well-known community)\n"
10814 "Do not advertise to any peer (well-known community)\n"
10815 "Do not export to next AS (well-known community)\n"
10816 "Exact match of the communities")
10818 ALIAS (show_bgp_community_exact
,
10819 show_bgp_ipv6_community3_exact_cmd
,
10820 "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",
10824 "Display routes matching the communities\n"
10826 "Do not send outside local AS (well-known community)\n"
10827 "Do not advertise to any peer (well-known community)\n"
10828 "Do not export to next AS (well-known community)\n"
10830 "Do not send outside local AS (well-known community)\n"
10831 "Do not advertise to any peer (well-known community)\n"
10832 "Do not export to next AS (well-known community)\n"
10834 "Do not send outside local AS (well-known community)\n"
10835 "Do not advertise to any peer (well-known community)\n"
10836 "Do not export to next AS (well-known community)\n"
10837 "Exact match of the communities")
10839 ALIAS (show_bgp_community_exact
,
10840 show_bgp_community4_exact_cmd
,
10841 "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",
10844 "Display routes matching the communities\n"
10846 "Do not send outside local AS (well-known community)\n"
10847 "Do not advertise to any peer (well-known community)\n"
10848 "Do not export to next AS (well-known community)\n"
10850 "Do not send outside local AS (well-known community)\n"
10851 "Do not advertise to any peer (well-known community)\n"
10852 "Do not export to next AS (well-known community)\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"
10858 "Do not send outside local AS (well-known community)\n"
10859 "Do not advertise to any peer (well-known community)\n"
10860 "Do not export to next AS (well-known community)\n"
10861 "Exact match of the communities")
10863 ALIAS (show_bgp_community_exact
,
10864 show_bgp_ipv6_community4_exact_cmd
,
10865 "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",
10869 "Display routes matching the communities\n"
10871 "Do not send outside local AS (well-known community)\n"
10872 "Do not advertise to any peer (well-known community)\n"
10873 "Do not export to next AS (well-known community)\n"
10875 "Do not send outside local AS (well-known community)\n"
10876 "Do not advertise to any peer (well-known community)\n"
10877 "Do not export to next AS (well-known community)\n"
10879 "Do not send outside local AS (well-known community)\n"
10880 "Do not advertise to any peer (well-known community)\n"
10881 "Do not export to next AS (well-known community)\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"
10886 "Exact match of the communities")
10889 DEFUN (show_ipv6_bgp_community_exact
,
10890 show_ipv6_bgp_community_exact_cmd
,
10891 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10895 "Display routes matching the communities\n"
10897 "Do not send outside local AS (well-known community)\n"
10898 "Do not advertise to any peer (well-known community)\n"
10899 "Do not export to next AS (well-known community)\n"
10900 "Exact match of the communities")
10902 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10903 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10907 ALIAS (show_ipv6_bgp_community_exact
,
10908 show_ipv6_bgp_community2_exact_cmd
,
10909 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10913 "Display routes matching the communities\n"
10915 "Do not send outside local AS (well-known community)\n"
10916 "Do not advertise to any peer (well-known community)\n"
10917 "Do not export to next AS (well-known community)\n"
10919 "Do not send outside local AS (well-known community)\n"
10920 "Do not advertise to any peer (well-known community)\n"
10921 "Do not export to next AS (well-known community)\n"
10922 "Exact match of the communities")
10925 ALIAS (show_ipv6_bgp_community_exact
,
10926 show_ipv6_bgp_community3_exact_cmd
,
10927 "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",
10931 "Display routes matching the communities\n"
10933 "Do not send outside local AS (well-known community)\n"
10934 "Do not advertise to any peer (well-known community)\n"
10935 "Do not export to next AS (well-known community)\n"
10937 "Do not send outside local AS (well-known community)\n"
10938 "Do not advertise to any peer (well-known community)\n"
10939 "Do not export to next AS (well-known community)\n"
10941 "Do not send outside local AS (well-known community)\n"
10942 "Do not advertise to any peer (well-known community)\n"
10943 "Do not export to next AS (well-known community)\n"
10944 "Exact match of the communities")
10947 ALIAS (show_ipv6_bgp_community_exact
,
10948 show_ipv6_bgp_community4_exact_cmd
,
10949 "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",
10953 "Display routes matching the communities\n"
10955 "Do not send outside local AS (well-known community)\n"
10956 "Do not advertise to any peer (well-known community)\n"
10957 "Do not export to next AS (well-known community)\n"
10959 "Do not send outside local AS (well-known community)\n"
10960 "Do not advertise to any peer (well-known community)\n"
10961 "Do not export to next AS (well-known community)\n"
10963 "Do not send outside local AS (well-known community)\n"
10964 "Do not advertise to any peer (well-known community)\n"
10965 "Do not export to next AS (well-known community)\n"
10967 "Do not send outside local AS (well-known community)\n"
10968 "Do not advertise to any peer (well-known community)\n"
10969 "Do not export to next AS (well-known community)\n"
10970 "Exact match of the communities")
10973 DEFUN (show_ipv6_mbgp_community
,
10974 show_ipv6_mbgp_community_cmd
,
10975 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10979 "Display routes matching the communities\n"
10981 "Do not send outside local AS (well-known community)\n"
10982 "Do not advertise to any peer (well-known community)\n"
10983 "Do not export to next AS (well-known community)\n")
10985 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10986 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10990 ALIAS (show_ipv6_mbgp_community
,
10991 show_ipv6_mbgp_community2_cmd
,
10992 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10996 "Display routes matching the communities\n"
10998 "Do not send outside local AS (well-known community)\n"
10999 "Do not advertise to any peer (well-known community)\n"
11000 "Do not export to next AS (well-known community)\n"
11002 "Do not send outside local AS (well-known community)\n"
11003 "Do not advertise to any peer (well-known community)\n"
11004 "Do not export to next AS (well-known community)\n")
11007 ALIAS (show_ipv6_mbgp_community
,
11008 show_ipv6_mbgp_community3_cmd
,
11009 "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)",
11013 "Display routes matching the communities\n"
11015 "Do not send outside local AS (well-known community)\n"
11016 "Do not advertise to any peer (well-known community)\n"
11017 "Do not export to next AS (well-known community)\n"
11019 "Do not send outside local AS (well-known community)\n"
11020 "Do not advertise to any peer (well-known community)\n"
11021 "Do not export to next AS (well-known community)\n"
11023 "Do not send outside local AS (well-known community)\n"
11024 "Do not advertise to any peer (well-known community)\n"
11025 "Do not export to next AS (well-known community)\n")
11028 ALIAS (show_ipv6_mbgp_community
,
11029 show_ipv6_mbgp_community4_cmd
,
11030 "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)",
11034 "Display routes matching the communities\n"
11036 "Do not send outside local AS (well-known community)\n"
11037 "Do not advertise to any peer (well-known community)\n"
11038 "Do not export to next AS (well-known community)\n"
11040 "Do not send outside local AS (well-known community)\n"
11041 "Do not advertise to any peer (well-known community)\n"
11042 "Do not export to next AS (well-known community)\n"
11044 "Do not send outside local AS (well-known community)\n"
11045 "Do not advertise to any peer (well-known community)\n"
11046 "Do not export to next AS (well-known community)\n"
11048 "Do not send outside local AS (well-known community)\n"
11049 "Do not advertise to any peer (well-known community)\n"
11050 "Do not export to next AS (well-known community)\n")
11053 DEFUN (show_ipv6_mbgp_community_exact
,
11054 show_ipv6_mbgp_community_exact_cmd
,
11055 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
11059 "Display routes matching the communities\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")
11066 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11067 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
11071 ALIAS (show_ipv6_mbgp_community_exact
,
11072 show_ipv6_mbgp_community2_exact_cmd
,
11073 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11077 "Display routes matching the communities\n"
11079 "Do not send outside local AS (well-known community)\n"
11080 "Do not advertise to any peer (well-known community)\n"
11081 "Do not export to next AS (well-known community)\n"
11083 "Do not send outside local AS (well-known community)\n"
11084 "Do not advertise to any peer (well-known community)\n"
11085 "Do not export to next AS (well-known community)\n"
11086 "Exact match of the communities")
11089 ALIAS (show_ipv6_mbgp_community_exact
,
11090 show_ipv6_mbgp_community3_exact_cmd
,
11091 "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",
11095 "Display routes matching the communities\n"
11097 "Do not send outside local AS (well-known community)\n"
11098 "Do not advertise to any peer (well-known community)\n"
11099 "Do not export to next AS (well-known community)\n"
11101 "Do not send outside local AS (well-known community)\n"
11102 "Do not advertise to any peer (well-known community)\n"
11103 "Do not export to next AS (well-known community)\n"
11105 "Do not send outside local AS (well-known community)\n"
11106 "Do not advertise to any peer (well-known community)\n"
11107 "Do not export to next AS (well-known community)\n"
11108 "Exact match of the communities")
11111 ALIAS (show_ipv6_mbgp_community_exact
,
11112 show_ipv6_mbgp_community4_exact_cmd
,
11113 "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",
11117 "Display routes matching the communities\n"
11119 "Do not send outside local AS (well-known community)\n"
11120 "Do not advertise to any peer (well-known community)\n"
11121 "Do not export to next AS (well-known community)\n"
11123 "Do not send outside local AS (well-known community)\n"
11124 "Do not advertise to any peer (well-known community)\n"
11125 "Do not export to next AS (well-known community)\n"
11127 "Do not send outside local AS (well-known community)\n"
11128 "Do not advertise to any peer (well-known community)\n"
11129 "Do not export to next AS (well-known community)\n"
11131 "Do not send outside local AS (well-known community)\n"
11132 "Do not advertise to any peer (well-known community)\n"
11133 "Do not export to next AS (well-known community)\n"
11134 "Exact match of the communities")
11135 #endif /* HAVE_IPV6 */
11138 bgp_show_community_list (struct vty
*vty
, const char *name
,
11139 const char *com
, int exact
,
11140 afi_t afi
, safi_t safi
)
11142 struct community_list
*list
;
11143 struct bgp
*bgp
= NULL
;
11145 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11147 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11148 return CMD_WARNING
;
11151 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
11154 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
11156 return CMD_WARNING
;
11159 return bgp_show (vty
, bgp
, afi
, safi
,
11160 (exact
? bgp_show_type_community_list_exact
:
11161 bgp_show_type_community_list
), list
, 0);
11164 DEFUN (show_ip_bgp_community_list
,
11165 show_ip_bgp_community_list_cmd
,
11166 "show ip bgp community-list (<1-500>|WORD)",
11170 "Display routes matching the community-list\n"
11171 "community-list number\n"
11172 "community-list name\n")
11174 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
11177 DEFUN (show_ip_bgp_instance_community_list
,
11178 show_ip_bgp_instance_community_list_cmd
,
11179 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
11183 BGP_INSTANCE_HELP_STR
11184 "Display routes matching the community-list\n"
11185 "community-list number\n"
11186 "community-list name\n")
11188 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
11191 DEFUN (show_ip_bgp_ipv4_community_list
,
11192 show_ip_bgp_ipv4_community_list_cmd
,
11193 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11198 "Address Family modifier\n"
11199 "Address Family modifier\n"
11200 "Display routes matching the community-list\n"
11201 "community-list number\n"
11202 "community-list name\n")
11205 safi
= bgp_vty_safi_from_arg(argv
[0]);
11206 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, safi
);
11209 DEFUN (show_ip_bgp_community_list_exact
,
11210 show_ip_bgp_community_list_exact_cmd
,
11211 "show ip bgp community-list (<1-500>|WORD) exact-match",
11215 "Display routes matching the community-list\n"
11216 "community-list number\n"
11217 "community-list name\n"
11218 "Exact match of the communities\n")
11220 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
11223 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
11224 show_ip_bgp_ipv4_community_list_exact_cmd
,
11225 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11230 "Address Family modifier\n"
11231 "Address Family modifier\n"
11232 "Display routes matching the community-list\n"
11233 "community-list number\n"
11234 "community-list name\n"
11235 "Exact match of the communities\n")
11238 safi
= bgp_vty_safi_from_arg(argv
[0]);
11239 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, safi
);
11243 DEFUN (show_bgp_community_list
,
11244 show_bgp_community_list_cmd
,
11245 "show bgp community-list (<1-500>|WORD)",
11248 "Display routes matching the community-list\n"
11249 "community-list number\n"
11250 "community-list name\n")
11252 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11255 ALIAS (show_bgp_community_list
,
11256 show_bgp_ipv6_community_list_cmd
,
11257 "show bgp ipv6 community-list (<1-500>|WORD)",
11261 "Display routes matching the community-list\n"
11262 "community-list number\n"
11263 "community-list name\n")
11266 DEFUN (show_ipv6_bgp_community_list
,
11267 show_ipv6_bgp_community_list_cmd
,
11268 "show ipv6 bgp community-list WORD",
11272 "Display routes matching the community-list\n"
11273 "community-list name\n")
11275 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11276 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11280 DEFUN (show_ipv6_mbgp_community_list
,
11281 show_ipv6_mbgp_community_list_cmd
,
11282 "show ipv6 mbgp community-list WORD",
11286 "Display routes matching the community-list\n"
11287 "community-list name\n")
11289 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11290 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
11293 DEFUN (show_bgp_community_list_exact
,
11294 show_bgp_community_list_exact_cmd
,
11295 "show bgp community-list (<1-500>|WORD) exact-match",
11298 "Display routes matching the community-list\n"
11299 "community-list number\n"
11300 "community-list name\n"
11301 "Exact match of the communities\n")
11303 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11306 ALIAS (show_bgp_community_list_exact
,
11307 show_bgp_ipv6_community_list_exact_cmd
,
11308 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11312 "Display routes matching the community-list\n"
11313 "community-list number\n"
11314 "community-list name\n"
11315 "Exact match of the communities\n")
11318 DEFUN (show_ipv6_bgp_community_list_exact
,
11319 show_ipv6_bgp_community_list_exact_cmd
,
11320 "show ipv6 bgp community-list WORD exact-match",
11324 "Display routes matching the community-list\n"
11325 "community-list name\n"
11326 "Exact match of the communities\n")
11328 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11329 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11333 DEFUN (show_ipv6_mbgp_community_list_exact
,
11334 show_ipv6_mbgp_community_list_exact_cmd
,
11335 "show ipv6 mbgp community-list WORD exact-match",
11339 "Display routes matching the community-list\n"
11340 "community-list name\n"
11341 "Exact match of the communities\n")
11343 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11344 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
11346 #endif /* HAVE_IPV6 */
11349 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11350 const char *prefix
, afi_t afi
,
11351 safi_t safi
, enum bgp_show_type type
)
11355 struct bgp
*bgp
= NULL
;
11357 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11359 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11360 return CMD_WARNING
;
11365 ret
= str2prefix (prefix
, p
);
11368 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11369 return CMD_WARNING
;
11372 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11377 DEFUN (show_ip_bgp_prefix_longer
,
11378 show_ip_bgp_prefix_longer_cmd
,
11379 "show ip bgp A.B.C.D/M longer-prefixes",
11383 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11384 "Display route and more specific routes\n")
11386 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11387 bgp_show_type_prefix_longer
);
11390 DEFUN (show_ip_bgp_instance_prefix_longer
,
11391 show_ip_bgp_instance_prefix_longer_cmd
,
11392 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11396 BGP_INSTANCE_HELP_STR
11397 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11398 "Display route and more specific routes\n")
11400 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
11401 bgp_show_type_prefix_longer
);
11404 DEFUN (show_ip_bgp_flap_prefix_longer
,
11405 show_ip_bgp_flap_prefix_longer_cmd
,
11406 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11410 "Display flap statistics of routes\n"
11411 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11412 "Display route and more specific routes\n")
11414 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11415 bgp_show_type_flap_prefix_longer
);
11418 ALIAS (show_ip_bgp_flap_prefix_longer
,
11419 show_ip_bgp_damp_flap_prefix_longer_cmd
,
11420 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11424 "Display detailed information about dampening\n"
11425 "Display flap statistics of routes\n"
11426 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11427 "Display route and more specific routes\n")
11429 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11430 show_ip_bgp_ipv4_prefix_longer_cmd
,
11431 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11436 "Address Family modifier\n"
11437 "Address Family modifier\n"
11438 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11439 "Display route and more specific routes\n")
11442 safi
= bgp_vty_safi_from_arg(argv
[0]);
11443 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, safi
,
11444 bgp_show_type_prefix_longer
);
11447 DEFUN (show_ip_bgp_flap_address
,
11448 show_ip_bgp_flap_address_cmd
,
11449 "show ip bgp flap-statistics A.B.C.D",
11453 "Display flap statistics of routes\n"
11454 "Network in the BGP routing table to display\n")
11456 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11457 bgp_show_type_flap_address
);
11460 ALIAS (show_ip_bgp_flap_address
,
11461 show_ip_bgp_damp_flap_address_cmd
,
11462 "show ip bgp dampening flap-statistics A.B.C.D",
11466 "Display detailed information about dampening\n"
11467 "Display flap statistics of routes\n"
11468 "Network in the BGP routing table to display\n")
11470 DEFUN (show_ip_bgp_flap_prefix
,
11471 show_ip_bgp_flap_prefix_cmd
,
11472 "show ip bgp flap-statistics A.B.C.D/M",
11476 "Display flap statistics of routes\n"
11477 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11479 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11480 bgp_show_type_flap_prefix
);
11483 ALIAS (show_ip_bgp_flap_prefix
,
11484 show_ip_bgp_damp_flap_prefix_cmd
,
11485 "show ip bgp dampening flap-statistics A.B.C.D/M",
11489 "Display detailed information about dampening\n"
11490 "Display flap statistics of routes\n"
11491 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11494 DEFUN (show_bgp_prefix_longer
,
11495 show_bgp_prefix_longer_cmd
,
11496 "show bgp X:X::X:X/M longer-prefixes",
11499 "IPv6 prefix <network>/<length>\n"
11500 "Display route and more specific routes\n")
11502 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11503 bgp_show_type_prefix_longer
);
11506 ALIAS (show_bgp_prefix_longer
,
11507 show_bgp_ipv6_prefix_longer_cmd
,
11508 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11512 "IPv6 prefix <network>/<length>\n"
11513 "Display route and more specific routes\n")
11516 DEFUN (show_ipv6_bgp_prefix_longer
,
11517 show_ipv6_bgp_prefix_longer_cmd
,
11518 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11522 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11523 "Display route and more specific routes\n")
11525 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11526 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11527 bgp_show_type_prefix_longer
);
11531 DEFUN (show_ipv6_mbgp_prefix_longer
,
11532 show_ipv6_mbgp_prefix_longer_cmd
,
11533 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11537 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11538 "Display route and more specific routes\n")
11540 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11541 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11542 bgp_show_type_prefix_longer
);
11544 #endif /* HAVE_IPV6 */
11546 static struct peer
*
11547 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11548 const char *ip_str
, u_char use_json
)
11553 union sockunion su
;
11555 /* BGP structure lookup. */
11558 bgp
= bgp_lookup_by_name (view_name
);
11563 json_object
*json_no
= NULL
;
11564 json_no
= json_object_new_object();
11565 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11566 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11567 json_object_free(json_no
);
11570 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11576 bgp
= bgp_get_default ();
11581 json_object
*json_no
= NULL
;
11582 json_no
= json_object_new_object();
11583 json_object_string_add(json_no
, "warning", "No BGP process configured");
11584 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11585 json_object_free(json_no
);
11588 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11593 /* Get peer sockunion. */
11594 ret
= str2sockunion (ip_str
, &su
);
11597 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11600 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11606 json_object
*json_no
= NULL
;
11607 json_no
= json_object_new_object();
11608 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11609 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11610 json_object_free(json_no
);
11613 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11620 /* Peer structure lookup. */
11621 peer
= peer_lookup (bgp
, &su
);
11626 json_object
*json_no
= NULL
;
11627 json_no
= json_object_new_object();
11628 json_object_string_add(json_no
, "warning","No such neighbor");
11629 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11630 json_object_free(json_no
);
11633 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11642 BGP_STATS_MAXBITLEN
= 0,
11644 BGP_STATS_PREFIXES
,
11646 BGP_STATS_UNAGGREGATEABLE
,
11647 BGP_STATS_MAX_AGGREGATEABLE
,
11648 BGP_STATS_AGGREGATES
,
11650 BGP_STATS_ASPATH_COUNT
,
11651 BGP_STATS_ASPATH_MAXHOPS
,
11652 BGP_STATS_ASPATH_TOTHOPS
,
11653 BGP_STATS_ASPATH_MAXSIZE
,
11654 BGP_STATS_ASPATH_TOTSIZE
,
11655 BGP_STATS_ASN_HIGHEST
,
11659 static const char *table_stats_strs
[] =
11661 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11662 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11663 [BGP_STATS_RIB
] = "Total Advertisements",
11664 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11665 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11666 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11667 [BGP_STATS_SPACE
] = "Address space advertised",
11668 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11669 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11670 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11671 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11672 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11673 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11674 [BGP_STATS_MAX
] = NULL
,
11677 struct bgp_table_stats
11679 struct bgp_table
*table
;
11680 unsigned long long counts
[BGP_STATS_MAX
];
11684 #define TALLY_SIGFIG 100000
11685 static unsigned long
11686 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11688 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11689 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11690 unsigned long ret
= newtot
/ count
;
11692 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11700 bgp_table_stats_walker (struct thread
*t
)
11702 struct bgp_node
*rn
;
11703 struct bgp_node
*top
;
11704 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11705 unsigned int space
= 0;
11707 if (!(top
= bgp_table_top (ts
->table
)))
11710 switch (top
->p
.family
)
11713 space
= IPV4_MAX_BITLEN
;
11716 space
= IPV6_MAX_BITLEN
;
11720 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11722 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11724 struct bgp_info
*ri
;
11725 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11726 unsigned int rinum
= 0;
11734 ts
->counts
[BGP_STATS_PREFIXES
]++;
11735 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11738 ts
->counts
[BGP_STATS_AVGPLEN
]
11739 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11740 ts
->counts
[BGP_STATS_AVGPLEN
],
11744 /* check if the prefix is included by any other announcements */
11745 while (prn
&& !prn
->info
)
11746 prn
= bgp_node_parent_nolock (prn
);
11748 if (prn
== NULL
|| prn
== top
)
11750 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11751 /* announced address space */
11753 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11755 else if (prn
->info
)
11756 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11758 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11761 ts
->counts
[BGP_STATS_RIB
]++;
11764 (CHECK_FLAG (ri
->attr
->flag
,
11765 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11766 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11768 /* as-path stats */
11769 if (ri
->attr
&& ri
->attr
->aspath
)
11771 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11772 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11773 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11775 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11777 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11778 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11780 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11781 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11783 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11784 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11786 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11787 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11788 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11790 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11791 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11792 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11795 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11796 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11804 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11806 struct bgp_table_stats ts
;
11809 if (!bgp
->rib
[afi
][safi
])
11811 vty_out (vty
, "%% No RIB exists for the AFI(%d)/SAFI(%d)%s",
11812 afi
, safi
, VTY_NEWLINE
);
11813 return CMD_WARNING
;
11816 memset (&ts
, 0, sizeof (ts
));
11817 ts
.table
= bgp
->rib
[afi
][safi
];
11818 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11820 vty_out (vty
, "BGP %s RIB statistics%s%s",
11821 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11823 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11825 if (!table_stats_strs
[i
])
11831 case BGP_STATS_ASPATH_AVGHOPS
:
11832 case BGP_STATS_ASPATH_AVGSIZE
:
11833 case BGP_STATS_AVGPLEN
:
11834 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11835 vty_out (vty
, "%12.2f",
11836 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11839 case BGP_STATS_ASPATH_TOTHOPS
:
11840 case BGP_STATS_ASPATH_TOTSIZE
:
11841 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11842 vty_out (vty
, "%12.2f",
11844 (float)ts
.counts
[i
] /
11845 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11848 case BGP_STATS_TOTPLEN
:
11849 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11850 vty_out (vty
, "%12.2f",
11852 (float)ts
.counts
[i
] /
11853 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11856 case BGP_STATS_SPACE
:
11857 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11858 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11859 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11861 vty_out (vty
, "%30s: ", "%% announced ");
11862 vty_out (vty
, "%12.2f%s",
11863 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11864 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11866 vty_out (vty
, "%30s: ", "/8 equivalent ");
11867 vty_out (vty
, "%12.2f%s",
11868 (float)ts
.counts
[BGP_STATS_SPACE
] /
11869 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11871 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11873 vty_out (vty
, "%30s: ", "/24 equivalent ");
11874 vty_out (vty
, "%12.2f",
11875 (float)ts
.counts
[BGP_STATS_SPACE
] /
11876 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11879 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11880 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11883 vty_out (vty
, "%s", VTY_NEWLINE
);
11885 return CMD_SUCCESS
;
11889 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11890 const char *afi_str
, const char *safi_str
)
11897 bgp
= bgp_lookup_by_name (name
);
11899 bgp
= bgp_get_default ();
11903 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11904 return CMD_WARNING
;
11906 afi
= bgp_vty_afi_from_arg(afi_str
);
11907 if (afi
== AFI_MAX
)
11909 vty_out (vty
, "%% Invalid address family \"%s\"%s",
11910 afi_str
, VTY_NEWLINE
);
11911 return CMD_WARNING
;
11913 safi
= bgp_vty_safi_from_arg(safi_str
);
11914 if (safi
== SAFI_MAX
)
11916 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11917 safi_str
, VTY_NEWLINE
);
11918 return CMD_WARNING
;
11921 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11924 DEFUN (show_bgp_statistics
,
11925 show_bgp_statistics_cmd
,
11926 "show bgp "BGP_AFI_SAFI_CMD_STR
" statistics",
11929 BGP_AFI_SAFI_HELP_STR
11930 "BGP RIB advertisement statistics\n")
11932 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11935 DEFUN (show_bgp_statistics_view
,
11936 show_bgp_statistics_view_cmd
,
11937 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" statistics",
11940 BGP_INSTANCE_HELP_STR
11941 BGP_AFI_SAFI_HELP_STR
11942 "BGP RIB advertisement statistics\n")
11944 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11957 PCOUNT_PFCNT
, /* the figure we display to users */
11961 static const char *pcount_strs
[] =
11963 [PCOUNT_ADJ_IN
] = "Adj-in",
11964 [PCOUNT_DAMPED
] = "Damped",
11965 [PCOUNT_REMOVED
] = "Removed",
11966 [PCOUNT_HISTORY
] = "History",
11967 [PCOUNT_STALE
] = "Stale",
11968 [PCOUNT_VALID
] = "Valid",
11969 [PCOUNT_ALL
] = "All RIB",
11970 [PCOUNT_COUNTED
] = "PfxCt counted",
11971 [PCOUNT_PFCNT
] = "Useable",
11972 [PCOUNT_MAX
] = NULL
,
11975 struct peer_pcounts
11977 unsigned int count
[PCOUNT_MAX
];
11978 const struct peer
*peer
;
11979 const struct bgp_table
*table
;
11983 bgp_peer_count_walker (struct thread
*t
)
11985 struct bgp_node
*rn
;
11986 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11987 const struct peer
*peer
= pc
->peer
;
11989 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11991 struct bgp_adj_in
*ain
;
11992 struct bgp_info
*ri
;
11994 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11995 if (ain
->peer
== peer
)
11996 pc
->count
[PCOUNT_ADJ_IN
]++;
11998 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
12000 char buf
[SU_ADDRSTRLEN
];
12002 if (ri
->peer
!= peer
)
12005 pc
->count
[PCOUNT_ALL
]++;
12007 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
12008 pc
->count
[PCOUNT_DAMPED
]++;
12009 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
12010 pc
->count
[PCOUNT_HISTORY
]++;
12011 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
12012 pc
->count
[PCOUNT_REMOVED
]++;
12013 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
12014 pc
->count
[PCOUNT_STALE
]++;
12015 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
12016 pc
->count
[PCOUNT_VALID
]++;
12017 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12018 pc
->count
[PCOUNT_PFCNT
]++;
12020 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
12022 pc
->count
[PCOUNT_COUNTED
]++;
12023 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12024 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
12026 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12027 buf
, SU_ADDRSTRLEN
),
12033 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12034 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
12036 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12037 buf
, SU_ADDRSTRLEN
),
12047 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
12049 struct peer_pcounts pcounts
= { .peer
= peer
};
12051 json_object
*json
= NULL
;
12052 json_object
*json_loop
= NULL
;
12056 json
= json_object_new_object();
12057 json_loop
= json_object_new_object();
12060 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
12061 || !peer
->bgp
->rib
[afi
][safi
])
12065 json_object_string_add(json
, "warning", "No such neighbor or address family");
12066 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12067 json_object_free(json
);
12070 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12072 return CMD_WARNING
;
12075 memset (&pcounts
, 0, sizeof(pcounts
));
12076 pcounts
.peer
= peer
;
12077 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
12079 /* in-place call via thread subsystem so as to record execution time
12080 * * stats for the thread-walk (i.e. ensure this can't be blamed on
12081 * * on just vty_read()).
12083 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
12087 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
12088 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
12089 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
12091 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12092 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
12094 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
12096 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12098 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
12099 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
12101 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12102 json_object_free(json
);
12107 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
12109 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
12110 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
12115 vty_out (vty
, "Prefix counts for %s, %s%s",
12116 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
12119 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
12120 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
12121 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
12123 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12124 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
12126 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12128 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
12129 peer
->host
, VTY_NEWLINE
);
12130 vty_out (vty
, "Please report this bug, with the above command output%s",
12135 return CMD_SUCCESS
;
12138 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
12139 show_ip_bgp_neighbor_prefix_counts_cmd
,
12140 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12144 "Detailed information on TCP and BGP neighbor connections\n"
12145 "Neighbor to display information about\n"
12146 "Neighbor to display information about\n"
12147 "Neighbor on bgp configured interface\n"
12148 "Display detailed prefix count information\n"
12149 "JavaScript Object Notation\n")
12152 u_char uj
= use_json(argc
, argv
);
12154 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12156 return CMD_WARNING
;
12158 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12161 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
12162 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
12163 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12167 BGP_INSTANCE_HELP_STR
12168 "Detailed information on TCP and BGP neighbor connections\n"
12169 "Neighbor to display information about\n"
12170 "Neighbor to display information about\n"
12171 "Neighbor on bgp configured interface\n"
12172 "Display detailed prefix count information\n"
12173 "JavaScript Object Notation\n")
12176 u_char uj
= use_json(argc
, argv
);
12178 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12180 return CMD_WARNING
;
12182 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12185 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
12186 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
12187 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12191 "Detailed information on TCP and BGP neighbor connections\n"
12192 "Neighbor to display information about\n"
12193 "Neighbor to display information about\n"
12194 "Neighbor on bgp configured interface\n"
12195 "Display detailed prefix count information\n"
12196 "JavaScript Object Notation\n")
12199 u_char uj
= use_json(argc
, argv
);
12201 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12203 return CMD_WARNING
;
12205 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12208 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
12209 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
12210 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12213 BGP_INSTANCE_HELP_STR
12215 "Detailed information on TCP and BGP neighbor connections\n"
12216 "Neighbor to display information about\n"
12217 "Neighbor to display information about\n"
12218 "Neighbor on bgp configured interface\n"
12219 "Display detailed prefix count information\n"
12220 "JavaScript Object Notation\n")
12223 u_char uj
= use_json(argc
, argv
);
12225 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12227 return CMD_WARNING
;
12229 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12232 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
12233 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
12234 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12239 "Address Family modifier\n"
12240 "Address Family modifier\n"
12241 "Detailed information on TCP and BGP neighbor connections\n"
12242 "Neighbor to display information about\n"
12243 "Neighbor to display information about\n"
12244 "Neighbor on bgp configured interface\n"
12245 "Display detailed prefix count information\n"
12246 "JavaScript Object Notation\n")
12249 u_char uj
= use_json(argc
, argv
);
12251 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12253 return CMD_WARNING
;
12256 safi
= bgp_vty_safi_from_arg(argv
[0]);
12257 return bgp_peer_counts (vty
, peer
, AFI_IP
, safi
, uj
);
12261 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12262 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
12264 struct bgp_table
*table
;
12265 struct bgp_adj_in
*ain
;
12266 struct bgp_adj_out
*adj
;
12267 unsigned long output_count
;
12268 unsigned long filtered_count
;
12269 struct bgp_node
*rn
;
12274 struct attr_extra extra
;
12276 struct update_subgroup
*subgrp
;
12277 json_object
*json_scode
= NULL
;
12278 json_object
*json_ocode
= NULL
;
12279 json_object
*json_ar
= NULL
;
12280 struct peer_af
*paf
;
12284 json_scode
= json_object_new_object();
12285 json_ocode
= json_object_new_object();
12286 json_ar
= json_object_new_object();
12288 json_object_string_add(json_scode
, "suppressed", "s");
12289 json_object_string_add(json_scode
, "damped", "d");
12290 json_object_string_add(json_scode
, "history", "h");
12291 json_object_string_add(json_scode
, "valid", "*");
12292 json_object_string_add(json_scode
, "best", ">");
12293 json_object_string_add(json_scode
, "multipath", "=");
12294 json_object_string_add(json_scode
, "internal", "i");
12295 json_object_string_add(json_scode
, "ribFailure", "r");
12296 json_object_string_add(json_scode
, "stale", "S");
12297 json_object_string_add(json_scode
, "removed", "R");
12299 json_object_string_add(json_ocode
, "igp", "i");
12300 json_object_string_add(json_ocode
, "egp", "e");
12301 json_object_string_add(json_ocode
, "incomplete", "?");
12310 json_object_string_add(json
, "alert", "no BGP");
12311 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12312 json_object_free(json
);
12315 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12319 table
= bgp
->rib
[afi
][safi
];
12321 output_count
= filtered_count
= 0;
12322 subgrp
= peer_subgroup(peer
, afi
, safi
);
12324 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12328 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12329 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12330 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12331 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12332 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12336 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12337 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12338 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12340 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12341 VTY_NEWLINE
, VTY_NEWLINE
);
12346 attr
.extra
= &extra
;
12347 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12351 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12353 if (ain
->peer
== peer
)
12359 json_object_int_add(json
, "bgpTableVersion", 0);
12360 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12361 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12362 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12366 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12367 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12368 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12375 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12380 bgp_attr_dup(&attr
, ain
->attr
);
12381 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12383 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12394 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12395 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12396 if (paf
->peer
== peer
)
12402 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12403 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12404 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12405 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12409 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12410 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12411 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12412 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12420 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12426 bgp_attr_dup(&attr
, adj
->attr
);
12427 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12428 if (ret
!= RMAP_DENY
)
12430 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12440 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12442 if (output_count
!= 0)
12445 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12447 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12448 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12452 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12453 json_object_free(json
);
12459 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12460 int in
, const char *rmap_name
, u_char use_json
)
12462 json_object
*json
= NULL
;
12465 json
= json_object_new_object();
12467 if (!peer
|| !peer
->afc
[afi
][safi
])
12471 json_object_string_add(json
, "warning", "No such neighbor or address family");
12472 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12473 json_object_free(json
);
12476 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12478 return CMD_WARNING
;
12481 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12485 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12486 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12487 json_object_free(json
);
12490 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12492 return CMD_WARNING
;
12495 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12497 return CMD_SUCCESS
;
12500 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12501 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12502 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12506 BGP_INSTANCE_HELP_STR
12507 "Detailed information on TCP and BGP neighbor connections\n"
12508 "Neighbor to display information about\n"
12509 "Neighbor to display information about\n"
12510 "Display the routes advertised to a BGP neighbor\n"
12511 "JavaScript Object Notation\n")
12514 u_char uj
= use_json(argc
, argv
);
12516 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12517 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12519 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12522 return CMD_WARNING
;
12524 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12527 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12528 show_ip_bgp_neighbor_advertised_route_cmd
,
12529 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12533 "Detailed information on TCP and BGP neighbor connections\n"
12534 "Neighbor to display information about\n"
12535 "Neighbor to display information about\n"
12536 "Neighbor on bgp configured interface\n"
12537 "Display the routes advertised to a BGP neighbor\n"
12538 "JavaScript Object Notation\n")
12542 const char *rmap_name
= NULL
;
12543 u_char uj
= use_json(argc
, argv
);
12545 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12548 return CMD_WARNING
;
12550 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12552 rmap_name
= argv
[1];
12554 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12557 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12558 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12559 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12563 "Detailed information on TCP and BGP neighbor connections\n"
12564 "Neighbor to display information about\n"
12565 "Neighbor to display information about\n"
12566 "Neighbor on bgp configured interface\n"
12567 "Display the routes advertised to a BGP neighbor\n"
12568 "JavaScript Object Notation\n")
12570 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12571 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12572 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12576 BGP_INSTANCE_HELP_STR
12577 "Detailed information on TCP and BGP neighbor connections\n"
12578 "Neighbor to display information about\n"
12579 "Neighbor to display information about\n"
12580 "Neighbor on bgp configured interface\n"
12581 "Display the routes advertised to a BGP neighbor\n"
12582 "JavaScript Object Notation\n")
12583 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12584 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12585 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12590 "Address Family modifier\n"
12591 "Address Family modifier\n"
12592 "Detailed information on TCP and BGP neighbor connections\n"
12593 "Neighbor to display information about\n"
12594 "Neighbor to display information about\n"
12595 "Neighbor on bgp configured interface\n"
12596 "Display the routes advertised to a BGP neighbor\n"
12597 "JavaScript Object Notation\n")
12600 const char *rmap_name
= NULL
;
12603 u_char uj
= use_json(argc
, argv
);
12605 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12607 return CMD_WARNING
;
12609 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12610 rmap_name
= argv
[2];
12612 safi
= bgp_vty_safi_from_arg(argv
[0]);
12613 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 0, rmap_name
, uj
);
12616 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12617 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12618 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12623 "Address Family modifier\n"
12624 "Address Family modifier\n"
12625 "Detailed information on TCP and BGP neighbor connections\n"
12626 "Neighbor to display information about\n"
12627 "Neighbor to display information about\n"
12628 "Neighbor on bgp configured interface\n"
12629 "Display the routes advertised to a BGP neighbor\n"
12630 "Route-map to control what is displayed\n"
12631 "JavaScript Object Notation\n")
12634 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12635 show_bgp_instance_neighbor_advertised_route_cmd
,
12636 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12639 BGP_INSTANCE_HELP_STR
12640 "Detailed information on TCP and BGP neighbor connections\n"
12641 "Neighbor to display information about\n"
12642 "Neighbor to display information about\n"
12643 "Neighbor on bgp configured interface\n"
12644 "Display the routes advertised to a BGP neighbor\n"
12645 "JavaScript Object Notation\n")
12648 u_char uj
= use_json(argc
, argv
);
12650 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12651 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12653 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12656 return CMD_WARNING
;
12658 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12661 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12662 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12663 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12666 BGP_INSTANCE_HELP_STR
12668 "Detailed information on TCP and BGP neighbor connections\n"
12669 "Neighbor to display information about\n"
12670 "Neighbor to display information about\n"
12671 "Neighbor on bgp configured interface\n"
12672 "Display the routes advertised to a BGP neighbor\n"
12673 "JavaScript Object Notation\n")
12675 DEFUN (show_bgp_neighbor_advertised_route
,
12676 show_bgp_neighbor_advertised_route_cmd
,
12677 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12680 "Detailed information on TCP and BGP neighbor connections\n"
12681 "Neighbor to display information about\n"
12682 "Neighbor to display information about\n"
12683 "Neighbor on bgp configured interface\n"
12684 "Display the routes advertised to a BGP neighbor\n"
12685 "JavaScript Object Notation\n")
12689 const char *rmap_name
= NULL
;
12690 u_char uj
= use_json(argc
, argv
);
12692 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12695 return CMD_WARNING
;
12697 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12698 rmap_name
= argv
[1];
12700 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12703 ALIAS (show_bgp_neighbor_advertised_route
,
12704 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12705 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12709 "Detailed information on TCP and BGP neighbor connections\n"
12710 "Neighbor to display information about\n"
12711 "Neighbor to display information about\n"
12712 "Neighbor on bgp configured interface\n"
12713 "Display the routes advertised to a BGP neighbor\n"
12714 "JavaScript Object Notation\n")
12717 ALIAS (show_bgp_neighbor_advertised_route
,
12718 ipv6_bgp_neighbor_advertised_route_cmd
,
12719 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12723 "Detailed information on TCP and BGP neighbor connections\n"
12724 "Neighbor to display information about\n"
12725 "Neighbor to display information about\n"
12726 "Neighbor on bgp configured interface\n"
12727 "Display the routes advertised to a BGP neighbor\n"
12728 "JavaScript Object Notation\n")
12731 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12732 ipv6_mbgp_neighbor_advertised_route_cmd
,
12733 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12737 "Detailed information on TCP and BGP neighbor connections\n"
12738 "Neighbor to display information about\n"
12739 "Neighbor to display information about\n"
12740 "Neighbor on bgp configured interface\n"
12741 "Neighbor on bgp configured interface\n"
12742 "Display the routes advertised to a BGP neighbor\n"
12743 "JavaScript Object Notation\n")
12746 u_char uj
= use_json(argc
, argv
);
12748 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12750 return CMD_WARNING
;
12752 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12753 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12755 #endif /* HAVE_IPV6 */
12757 DEFUN (show_bgp_instance_neighbor_received_routes
,
12758 show_bgp_instance_neighbor_received_routes_cmd
,
12759 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12762 BGP_INSTANCE_HELP_STR
12763 "Detailed information on TCP and BGP neighbor connections\n"
12764 "Neighbor to display information about\n"
12765 "Neighbor to display information about\n"
12766 "Neighbor on bgp configured interface\n"
12767 "Display the received routes from neighbor\n"
12768 "JavaScript Object Notation\n")
12771 u_char uj
= use_json(argc
, argv
);
12773 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12775 return CMD_WARNING
;
12777 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12780 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12781 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12782 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12786 BGP_INSTANCE_HELP_STR
12787 "Detailed information on TCP and BGP neighbor connections\n"
12788 "Neighbor to display information about\n"
12789 "Neighbor to display information about\n"
12790 "Neighbor on bgp configured interface\n"
12791 "Display the received routes from neighbor\n"
12792 "JavaScript Object Notation\n")
12795 u_char uj
= use_json(argc
, argv
);
12797 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12799 return CMD_WARNING
;
12801 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12804 ALIAS (show_bgp_instance_neighbor_received_routes
,
12805 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12806 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12809 BGP_INSTANCE_HELP_STR
12811 "Detailed information on TCP and BGP neighbor connections\n"
12812 "Neighbor to display information about\n"
12813 "Neighbor to display information about\n"
12814 "Neighbor on bgp configured interface\n"
12815 "Display the received routes from neighbor\n"
12816 "JavaScript Object Notation\n")
12818 DEFUN (show_ip_bgp_neighbor_received_routes
,
12819 show_ip_bgp_neighbor_received_routes_cmd
,
12820 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12824 "Detailed information on TCP and BGP neighbor connections\n"
12825 "Neighbor to display information about\n"
12826 "Neighbor to display information about\n"
12827 "Neighbor on bgp configured interface\n"
12828 "Display the received routes from neighbor\n"
12829 "JavaScript Object Notation\n")
12833 const char *rmap_name
= NULL
;
12834 u_char uj
= use_json(argc
, argv
);
12836 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12839 return CMD_WARNING
;
12841 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12842 rmap_name
= argv
[1];
12844 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12847 ALIAS (show_ip_bgp_neighbor_received_routes
,
12848 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12849 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12853 "Detailed information on TCP and BGP neighbor connections\n"
12854 "Neighbor to display information about\n"
12855 "Neighbor to display information about\n"
12856 "Neighbor on bgp configured interface\n"
12857 "Display the received routes from neighbor\n"
12858 "JavaScript Object Notation\n")
12860 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12861 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12862 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12866 BGP_INSTANCE_HELP_STR
12867 "Detailed information on TCP and BGP neighbor connections\n"
12868 "Neighbor to display information about\n"
12869 "Neighbor to display information about\n"
12870 "Neighbor on bgp configured interface\n"
12871 "Display the received routes from neighbor\n"
12872 "JavaScript Object Notation\n")
12874 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12875 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12876 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12881 "Address Family modifier\n"
12882 "Address Family modifier\n"
12883 "Detailed information on TCP and BGP neighbor connections\n"
12884 "Neighbor to display information about\n"
12885 "Neighbor to display information about\n"
12886 "Neighbor on bgp configured interface\n"
12887 "Display the received routes from neighbor\n"
12888 "JavaScript Object Notation\n")
12891 const char *rmap_name
= NULL
;
12893 u_char uj
= use_json(argc
, argv
);
12895 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12897 return CMD_WARNING
;
12899 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12900 rmap_name
= argv
[2];
12902 safi
= bgp_vty_safi_from_arg(argv
[0]);
12903 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 1, rmap_name
, uj
);
12906 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12907 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12908 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12913 "Address Family modifier\n"
12914 "Address Family modifier\n"
12915 "Detailed information on TCP and BGP neighbor connections\n"
12916 "Neighbor to display information about\n"
12917 "Neighbor to display information about\n"
12918 "Neighbor on bgp configured interface\n"
12919 "Display the received routes from neighbor\n"
12920 "JavaScript Object Notation\n")
12922 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12923 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12924 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12927 BGP_INSTANCE_HELP_STR
12930 "Address family modifier\n"
12931 "Address family modifier\n"
12932 "Detailed information on TCP and BGP neighbor connections\n"
12933 "Neighbor to display information about\n"
12934 "Neighbor to display information about\n"
12935 "Neighbor on bgp configured interface\n"
12936 "Display the advertised routes to neighbor\n"
12937 "Display the received routes from neighbor\n"
12938 "JavaScript Object Notation\n")
12944 u_char uj
= use_json(argc
, argv
);
12946 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12949 return CMD_WARNING
;
12951 afi
= bgp_vty_safi_from_arg(argv
[2]);
12952 safi
= bgp_vty_safi_from_arg(argv
[3]);
12953 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12955 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12958 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12959 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12960 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12964 "Detailed information on TCP and BGP neighbor connections\n"
12965 "Neighbor to display information about\n"
12966 "Neighbor to display information about\n"
12967 "Neighbor on bgp configured interface\n"
12968 "Display information received from a BGP neighbor\n"
12969 "Display the prefixlist filter\n"
12970 "JavaScript Object Notation\n")
12973 union sockunion su
;
12976 u_char uj
= use_json(argc
, argv
);
12978 ret
= str2sockunion (argv
[0], &su
);
12981 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12986 json_object
*json_no
= NULL
;
12987 json_object
*json_sub
= NULL
;
12988 json_no
= json_object_new_object();
12989 json_sub
= json_object_new_object();
12990 json_object_string_add(json_no
, "warning", "Malformed address or name");
12991 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12992 json_object_object_add(json_no
, "detail", json_sub
);
12993 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12994 json_object_free(json_no
);
12997 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12998 return CMD_WARNING
;
13003 peer
= peer_lookup (NULL
, &su
);
13008 json_object
*json_no
= NULL
;
13009 json_no
= json_object_new_object();
13010 json_object_string_add(json_no
, "warning", "Peer not found");
13011 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13012 json_object_free(json_no
);
13015 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13016 return CMD_WARNING
;
13020 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
13021 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13025 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
13026 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13032 json_object
*json_no
= NULL
;
13033 json_no
= json_object_new_object();
13034 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13035 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13036 json_object_free(json_no
);
13039 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13042 return CMD_SUCCESS
;
13045 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
13046 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
13047 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13052 "Address Family modifier\n"
13053 "Address Family modifier\n"
13054 "Detailed information on TCP and BGP neighbor connections\n"
13055 "Neighbor to display information about\n"
13056 "Neighbor to display information about\n"
13057 "Neighbor on bgp configured interface\n"
13058 "Display information received from a BGP neighbor\n"
13059 "Display the prefixlist filter\n"
13060 "JavaScript Object Notation\n")
13063 union sockunion su
;
13066 u_char uj
= use_json(argc
, argv
);
13068 ret
= str2sockunion (argv
[1], &su
);
13071 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
13076 json_object
*json_no
= NULL
;
13077 json_object
*json_sub
= NULL
;
13078 json_no
= json_object_new_object();
13079 json_sub
= json_object_new_object();
13080 json_object_string_add(json_no
, "warning", "Malformed address or name");
13081 json_object_string_add(json_sub
, "warningCause", argv
[1]);
13082 json_object_object_add(json_no
, "detail", json_sub
);
13083 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13084 json_object_free(json_no
);
13087 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
13088 return CMD_WARNING
;
13093 peer
= peer_lookup (NULL
, &su
);
13098 json_object
*json_no
= NULL
;
13099 json_no
= json_object_new_object();
13100 json_object_string_add(json_no
, "warning", "Peer not found");
13101 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13102 json_object_free(json_no
);
13105 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13106 return CMD_WARNING
;
13112 safi
= bgp_vty_safi_from_arg(argv
[0]);
13113 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, safi
);
13114 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13118 vty_out (vty
, "Address family: %s%s",
13119 afi_safi_print (AFI_IP
, safi
), VTY_NEWLINE
);
13120 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13126 json_object
*json_no
= NULL
;
13127 json_no
= json_object_new_object();
13128 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13129 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13130 json_object_free(json_no
);
13133 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13137 return CMD_SUCCESS
;
13140 DEFUN (show_bgp_neighbor_received_routes
,
13141 show_bgp_neighbor_received_routes_cmd
,
13142 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13145 "Detailed information on TCP and BGP neighbor connections\n"
13146 "Neighbor to display information about\n"
13147 "Neighbor to display information about\n"
13148 "Neighbor on bgp configured interface\n"
13149 "Display the received routes from neighbor\n"
13150 "JavaScript Object Notation\n")
13153 const char *rmap_name
= NULL
;
13154 u_char uj
= use_json(argc
, argv
);
13156 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13159 return CMD_WARNING
;
13161 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
13162 rmap_name
= argv
[1];
13164 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13167 ALIAS (show_bgp_neighbor_received_routes
,
13168 show_bgp_ipv6_neighbor_received_routes_cmd
,
13169 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13173 "Detailed information on TCP and BGP neighbor connections\n"
13174 "Neighbor to display information about\n"
13175 "Neighbor to display information about\n"
13176 "Neighbor on bgp configured interface\n"
13177 "Display the received routes from neighbor\n"
13178 "JavaScript Object Notation\n")
13180 DEFUN (show_bgp_neighbor_received_prefix_filter
,
13181 show_bgp_neighbor_received_prefix_filter_cmd
,
13182 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13185 "Detailed information on TCP and BGP neighbor connections\n"
13186 "Neighbor to display information about\n"
13187 "Neighbor to display information about\n"
13188 "Neighbor on bgp configured interface\n"
13189 "Display information received from a BGP neighbor\n"
13190 "Display the prefixlist filter\n"
13191 "JavaScript Object Notation\n")
13194 union sockunion su
;
13197 u_char uj
= use_json(argc
, argv
);
13199 ret
= str2sockunion (argv
[0], &su
);
13202 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13207 json_object
*json_no
= NULL
;
13208 json_object
*json_sub
= NULL
;
13209 json_no
= json_object_new_object();
13210 json_sub
= json_object_new_object();
13211 json_object_string_add(json_no
, "warning", "Malformed address or name");
13212 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13213 json_object_object_add(json_no
, "detail", json_sub
);
13214 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13215 json_object_free(json_no
);
13218 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13219 return CMD_WARNING
;
13224 peer
= peer_lookup (NULL
, &su
);
13229 json_object
*json_no
= NULL
;
13230 json_no
= json_object_new_object();
13231 json_object_string_add(json_no
, "warning", "No Peer");
13232 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13233 json_object_free(json_no
);
13236 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13237 return CMD_WARNING
;
13241 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13242 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13246 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13247 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13253 json_object
*json_no
= NULL
;
13254 json_no
= json_object_new_object();
13255 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
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 functional output%s", VTY_NEWLINE
);
13263 return CMD_SUCCESS
;
13266 ALIAS (show_bgp_neighbor_received_prefix_filter
,
13267 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
13268 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13272 "Detailed information on TCP and BGP neighbor connections\n"
13273 "Neighbor to display information about\n"
13274 "Neighbor to display information about\n"
13275 "Neighbor on bgp configured interface\n"
13276 "Display information received from a BGP neighbor\n"
13277 "Display the prefixlist filter\n"
13278 "JavaScript Object Notation\n")
13281 ALIAS (show_bgp_neighbor_received_routes
,
13282 ipv6_bgp_neighbor_received_routes_cmd
,
13283 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13287 "Detailed information on TCP and BGP neighbor connections\n"
13288 "Neighbor to display information about\n"
13289 "Neighbor to display information about\n"
13290 "Neighbor on bgp configured interface\n"
13291 "Display the received routes from neighbor\n"
13292 "JavaScript Object Notation\n")
13295 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13296 ipv6_mbgp_neighbor_received_routes_cmd
,
13297 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13301 "Detailed information on TCP and BGP neighbor connections\n"
13302 "Neighbor to display information about\n"
13303 "Neighbor to display information about\n"
13304 "Neighbor on bgp configured interface\n"
13305 "Display the received routes from neighbor\n"
13306 "JavaScript Object Notation\n")
13309 u_char uj
= use_json(argc
, argv
);
13311 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13313 return CMD_WARNING
;
13315 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13316 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13319 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13320 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13321 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13324 BGP_INSTANCE_HELP_STR
13325 "Detailed information on TCP and BGP neighbor connections\n"
13326 "Neighbor to display information about\n"
13327 "Neighbor to display information about\n"
13328 "Neighbor on bgp configured interface\n"
13329 "Display information received from a BGP neighbor\n"
13330 "Display the prefixlist filter\n"
13331 "JavaScript Object Notation\n")
13334 union sockunion su
;
13338 u_char uj
= use_json(argc
, argv
);
13340 /* BGP structure lookup. */
13341 bgp
= bgp_lookup_by_name (argv
[1]);
13346 json_object
*json_no
= NULL
;
13347 json_no
= json_object_new_object();
13348 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13349 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13350 json_object_free(json_no
);
13353 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13354 return CMD_WARNING
;
13357 ret
= str2sockunion (argv
[2], &su
);
13360 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13365 json_object
*json_no
= NULL
;
13366 json_object
*json_sub
= NULL
;
13367 json_no
= json_object_new_object();
13368 json_sub
= json_object_new_object();
13369 json_object_string_add(json_no
, "warning", "Malformed address or name");
13370 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13371 json_object_object_add(json_no
, "detail", json_sub
);
13372 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13373 json_object_free(json_no
);
13376 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13377 return CMD_WARNING
;
13382 peer
= peer_lookup (bgp
, &su
);
13387 json_object
*json_no
= NULL
;
13388 json_no
= json_object_new_object();
13389 json_object_boolean_true_add(json_no
, "noPeer");
13390 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13391 json_object_free(json_no
);
13394 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13395 return CMD_WARNING
;
13400 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13401 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13405 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13406 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13409 return CMD_SUCCESS
;
13411 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13412 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13413 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13416 BGP_INSTANCE_HELP_STR
13418 "Detailed information on TCP and BGP neighbor connections\n"
13419 "Neighbor to display information about\n"
13420 "Neighbor to display information about\n"
13421 "Neighbor on bgp configured interface\n"
13422 "Display information received from a BGP neighbor\n"
13423 "Display the prefixlist filter\n"
13424 "JavaScript Object NOtation\n")
13425 #endif /* HAVE_IPV6 */
13428 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13429 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13431 if (! peer
|| ! peer
->afc
[afi
][safi
])
13435 json_object
*json_no
= NULL
;
13436 json_no
= json_object_new_object();
13437 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13438 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13439 json_object_free(json_no
);
13442 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13443 return CMD_WARNING
;
13446 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13449 DEFUN (show_ip_bgp_neighbor_routes
,
13450 show_ip_bgp_neighbor_routes_cmd
,
13451 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13455 "Detailed information on TCP and BGP neighbor connections\n"
13456 "Neighbor to display information about\n"
13457 "Neighbor to display information about\n"
13458 "Neighbor on bgp configured interface\n"
13459 "Display routes learned from neighbor\n"
13460 "JavaScript Object Notation\n")
13463 u_char uj
= use_json(argc
, argv
);
13465 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13467 return CMD_WARNING
;
13469 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13470 bgp_show_type_neighbor
, uj
);
13473 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13474 show_ip_bgp_instance_neighbor_routes_cmd
,
13475 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13479 BGP_INSTANCE_HELP_STR
13480 "Detailed information on TCP and BGP neighbor connections\n"
13481 "Neighbor to display information about\n"
13482 "Neighbor to display information about\n"
13483 "Neighbor on bgp configured interface\n"
13484 "Display routes learned from neighbor\n"
13485 "JavaScript Object Notation\n")
13488 u_char uj
= use_json(argc
, argv
);
13490 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13492 return CMD_WARNING
;
13494 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13495 bgp_show_type_neighbor
, uj
);
13498 DEFUN (show_ip_bgp_neighbor_flap
,
13499 show_ip_bgp_neighbor_flap_cmd
,
13500 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13504 "Detailed information on TCP and BGP neighbor connections\n"
13505 "Neighbor to display information about\n"
13506 "Neighbor to display information about\n"
13507 "Neighbor on bgp configured interface\n"
13508 "Display flap statistics of the routes learned from neighbor\n"
13509 "JavaScript Object Notation\n")
13512 u_char uj
= use_json(argc
, argv
);
13514 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13516 return CMD_WARNING
;
13518 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13519 bgp_show_type_flap_neighbor
, uj
);
13522 DEFUN (show_ip_bgp_neighbor_damp
,
13523 show_ip_bgp_neighbor_damp_cmd
,
13524 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13528 "Detailed information on TCP and BGP neighbor connections\n"
13529 "Neighbor to display information about\n"
13530 "Neighbor to display information about\n"
13531 "Neighbor on bgp configured interface\n"
13532 "Display the dampened routes received from neighbor\n"
13533 "JavaScript Object Notation\n")
13536 u_char uj
= use_json(argc
, argv
);
13538 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13540 return CMD_WARNING
;
13542 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13543 bgp_show_type_damp_neighbor
, uj
);
13546 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13547 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13548 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13553 "Address Family modifier\n"
13554 "Address Family modifier\n"
13555 "Detailed information on TCP and BGP neighbor connections\n"
13556 "Neighbor to display information about\n"
13557 "Neighbor to display information about\n"
13558 "Neighbor on bgp configured interface\n"
13559 "Display routes learned from neighbor\n"
13560 "JavaScript Object Notation\n")
13564 u_char uj
= use_json(argc
, argv
);
13566 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13568 return CMD_WARNING
;
13570 safi
= bgp_vty_safi_from_arg(argv
[0]);
13571 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, safi
,
13572 bgp_show_type_neighbor
, uj
);
13576 DEFUN (show_bgp_instance_neighbor_routes
,
13577 show_bgp_instance_neighbor_routes_cmd
,
13578 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13581 BGP_INSTANCE_HELP_STR
13582 "Detailed information on TCP and BGP neighbor connections\n"
13583 "Neighbor to display information about\n"
13584 "Neighbor to display information about\n"
13585 "Neighbor on bgp configured interface\n"
13586 "Display routes learned from neighbor\n"
13587 "JavaScript Object Notation\n")
13590 u_char uj
= use_json(argc
, argv
);
13592 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13594 return CMD_WARNING
;
13596 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13597 bgp_show_type_neighbor
, uj
);
13600 ALIAS (show_bgp_instance_neighbor_routes
,
13601 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13602 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13605 BGP_INSTANCE_HELP_STR
13607 "Detailed information on TCP and BGP neighbor connections\n"
13608 "Neighbor to display information about\n"
13609 "Neighbor to display information about\n"
13610 "Neighbor on bgp configured interface\n"
13611 "Display routes learned from neighbor\n"
13612 "JavaScript Object Notation\n")
13614 DEFUN (show_bgp_instance_neighbor_damp
,
13615 show_bgp_instance_neighbor_damp_cmd
,
13616 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13619 BGP_INSTANCE_HELP_STR
13620 "Detailed information on TCP and BGP neighbor connections\n"
13621 "Neighbor to display information about\n"
13622 "Neighbor to display information about\n"
13623 "Neighbor on bgp configured interface\n"
13624 "Display the dampened routes received from neighbor\n"
13625 "JavaScript Object Notation\n")
13628 u_char uj
= use_json(argc
, argv
);
13630 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13631 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13632 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13634 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13637 return CMD_WARNING
;
13639 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13640 bgp_show_type_damp_neighbor
, uj
);
13643 ALIAS (show_bgp_instance_neighbor_damp
,
13644 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13645 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13648 BGP_INSTANCE_HELP_STR
13650 "Detailed information on TCP and BGP neighbor connections\n"
13651 "Neighbor to display information about\n"
13652 "Neighbor to display information about\n"
13653 "Neighbor on bgp configured interface\n"
13654 "Display the dampened routes received from neighbor\n"
13655 "JavaScript Object Notation\n")
13657 DEFUN (show_bgp_instance_neighbor_flap
,
13658 show_bgp_instance_neighbor_flap_cmd
,
13659 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13662 BGP_INSTANCE_HELP_STR
13663 "Detailed information on TCP and BGP neighbor connections\n"
13664 "Neighbor to display information about\n"
13665 "Neighbor to display information about\n"
13666 "Neighbor on bgp configured interface\n"
13667 "Display flap statistics of the routes learned from neighbor\n"
13668 "JavaScript Object Notation\n")
13671 u_char uj
= use_json(argc
, argv
);
13673 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13674 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13675 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13677 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13680 return CMD_WARNING
;
13682 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13683 bgp_show_type_flap_neighbor
, uj
);
13686 ALIAS (show_bgp_instance_neighbor_flap
,
13687 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13688 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13691 BGP_INSTANCE_HELP_STR
13693 "Detailed information on TCP and BGP neighbor connections\n"
13694 "Neighbor to display information about\n"
13695 "Neighbor to display information about\n"
13696 "Neighbor on bgp configured interface\n"
13697 "Display flap statistics of the routes learned from neighbor\n"
13698 "JavaScript Object Notation\n")
13700 DEFUN (show_bgp_neighbor_routes
,
13701 show_bgp_neighbor_routes_cmd
,
13702 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) 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 routes learned 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_IP6
, SAFI_UNICAST
,
13720 bgp_show_type_neighbor
, uj
);
13724 ALIAS (show_bgp_neighbor_routes
,
13725 show_bgp_ipv6_neighbor_routes_cmd
,
13726 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13730 "Detailed information on TCP and BGP neighbor connections\n"
13731 "Neighbor to display information about\n"
13732 "Neighbor to display information about\n"
13733 "Neighbor on bgp configured interface\n"
13734 "Display routes learned from neighbor\n"
13735 "JavaScript Object Notation\n")
13738 ALIAS (show_bgp_neighbor_routes
,
13739 ipv6_bgp_neighbor_routes_cmd
,
13740 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13744 "Detailed information on TCP and BGP neighbor connections\n"
13745 "Neighbor to display information about\n"
13746 "Neighbor to display information about\n"
13747 "Neighbor on bgp configured interface\n"
13748 "Display routes learned from neighbor\n"
13749 "JavaScript Object Notation\n")
13752 DEFUN (ipv6_mbgp_neighbor_routes
,
13753 ipv6_mbgp_neighbor_routes_cmd
,
13754 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13758 "Detailed information on TCP and BGP neighbor connections\n"
13759 "Neighbor to display information about\n"
13760 "Neighbor to display information about\n"
13761 "Neighbor on bgp configured interface\n"
13762 "Display routes learned from neighbor\n"
13763 "JavaScript Object Notation\n")
13766 u_char uj
= use_json(argc
, argv
);
13768 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13770 return CMD_WARNING
;
13772 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13773 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13774 bgp_show_type_neighbor
, uj
);
13777 ALIAS (show_bgp_instance_neighbor_flap
,
13778 show_bgp_neighbor_flap_cmd
,
13779 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13782 "Detailed information on TCP and BGP neighbor connections\n"
13783 "Neighbor to display information about\n"
13784 "Neighbor to display information about\n"
13785 "Neighbor on bgp configured interface\n"
13786 "Display flap statistics of the routes learned from neighbor\n"
13787 "JavaScript Object Notation\n")
13789 ALIAS (show_bgp_instance_neighbor_flap
,
13790 show_bgp_ipv6_neighbor_flap_cmd
,
13791 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13795 "Detailed information on TCP and BGP neighbor connections\n"
13796 "Neighbor to display information about\n"
13797 "Neighbor to display information about\n"
13798 "Neighbor on bgp configured interface\n"
13799 "Display flap statistics of the routes learned from neighbor\n"
13800 "JavaScript Object Notation\n")
13802 ALIAS (show_bgp_instance_neighbor_damp
,
13803 show_bgp_neighbor_damp_cmd
,
13804 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13807 "Detailed information on TCP and BGP neighbor connections\n"
13808 "Neighbor to display information about\n"
13809 "Neighbor to display information about\n"
13810 "Neighbor on bgp configured interface\n"
13811 "Display the dampened routes received from neighbor\n"
13812 "JavaScript Object Notation\n")
13814 ALIAS (show_bgp_instance_neighbor_damp
,
13815 show_bgp_ipv6_neighbor_damp_cmd
,
13816 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13820 "Detailed information on TCP and BGP neighbor connections\n"
13821 "Neighbor to display information about\n"
13822 "Neighbor to display information about\n"
13823 "Neighbor on bgp configured interface\n"
13824 "Display the dampened routes received from neighbor\n"
13825 "JavaScript Object Notation\n")
13827 #endif /* HAVE_IPV6 */
13829 struct bgp_table
*bgp_distance_table
[AFI_MAX
][SAFI_MAX
];
13831 struct bgp_distance
13833 /* Distance value for the IP source prefix. */
13836 /* Name of the access-list to be matched. */
13840 static struct bgp_distance
*
13841 bgp_distance_new (void)
13843 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13847 bgp_distance_free (struct bgp_distance
*bdistance
)
13849 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13853 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13854 const char *ip_str
, const char *access_list_str
)
13861 struct bgp_node
*rn
;
13862 struct bgp_distance
*bdistance
;
13864 afi
= bgp_node_afi (vty
);
13865 safi
= bgp_node_safi (vty
);
13867 ret
= str2prefix (ip_str
, &p
);
13870 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13871 return CMD_WARNING
;
13874 distance
= atoi (distance_str
);
13876 /* Get BGP distance node. */
13877 rn
= bgp_node_get (bgp_distance_table
[afi
][safi
], (struct prefix
*) &p
);
13880 bdistance
= rn
->info
;
13881 bgp_unlock_node (rn
);
13885 bdistance
= bgp_distance_new ();
13886 rn
->info
= bdistance
;
13889 /* Set distance value. */
13890 bdistance
->distance
= distance
;
13892 /* Reset access-list configuration. */
13893 if (bdistance
->access_list
)
13895 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13896 bdistance
->access_list
= NULL
;
13898 if (access_list_str
)
13899 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13901 return CMD_SUCCESS
;
13905 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13906 const char *ip_str
, const char *access_list_str
)
13913 struct bgp_node
*rn
;
13914 struct bgp_distance
*bdistance
;
13916 afi
= bgp_node_afi (vty
);
13917 safi
= bgp_node_safi (vty
);
13919 ret
= str2prefix (ip_str
, &p
);
13922 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13923 return CMD_WARNING
;
13926 rn
= bgp_node_lookup (bgp_distance_table
[afi
][safi
], (struct prefix
*)&p
);
13929 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13930 return CMD_WARNING
;
13933 bdistance
= rn
->info
;
13934 distance
= atoi(distance_str
);
13936 if (bdistance
->distance
!= distance
)
13938 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13939 return CMD_WARNING
;
13942 if (bdistance
->access_list
)
13943 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13944 bgp_distance_free (bdistance
);
13947 bgp_unlock_node (rn
);
13948 bgp_unlock_node (rn
);
13950 return CMD_SUCCESS
;
13953 /* Apply BGP information to distance method. */
13955 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, afi_t afi
,
13956 safi_t safi
, struct bgp
*bgp
)
13958 struct bgp_node
*rn
;
13961 struct bgp_distance
*bdistance
;
13962 struct access_list
*alist
;
13963 struct bgp_static
*bgp_static
;
13968 peer
= rinfo
->peer
;
13970 /* Check source address. */
13971 sockunion2hostprefix (&peer
->su
, &q
);
13972 rn
= bgp_node_match (bgp_distance_table
[afi
][safi
], &q
);
13975 bdistance
= rn
->info
;
13976 bgp_unlock_node (rn
);
13978 if (bdistance
->access_list
)
13980 alist
= access_list_lookup (afi
, bdistance
->access_list
);
13981 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13982 return bdistance
->distance
;
13985 return bdistance
->distance
;
13988 /* Backdoor check. */
13989 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], p
);
13992 bgp_static
= rn
->info
;
13993 bgp_unlock_node (rn
);
13995 if (bgp_static
->backdoor
)
13997 if (bgp
->distance_local
[afi
][safi
])
13998 return bgp
->distance_local
[afi
][safi
];
14000 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
14004 if (peer
->sort
== BGP_PEER_EBGP
)
14006 if (bgp
->distance_ebgp
[afi
][safi
])
14007 return bgp
->distance_ebgp
[afi
][safi
];
14008 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
14012 if (bgp
->distance_ibgp
[afi
][safi
])
14013 return bgp
->distance_ibgp
[afi
][safi
];
14014 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
14018 DEFUN (bgp_distance
,
14020 "distance bgp <1-255> <1-255> <1-255>",
14021 "Define an administrative distance\n"
14023 "Distance for routes external to the AS\n"
14024 "Distance for routes internal to the AS\n"
14025 "Distance for local routes\n")
14032 afi
= bgp_node_afi (vty
);
14033 safi
= bgp_node_safi (vty
);
14035 bgp
->distance_ebgp
[afi
][safi
] = atoi (argv
[0]);
14036 bgp
->distance_ibgp
[afi
][safi
] = atoi (argv
[1]);
14037 bgp
->distance_local
[afi
][safi
] = atoi (argv
[2]);
14038 return CMD_SUCCESS
;
14041 DEFUN (no_bgp_distance
,
14042 no_bgp_distance_cmd
,
14043 "no distance bgp <1-255> <1-255> <1-255>",
14045 "Define an administrative distance\n"
14047 "Distance for routes external to the AS\n"
14048 "Distance for routes internal to the AS\n"
14049 "Distance for local routes\n")
14056 afi
= bgp_node_afi (vty
);
14057 safi
= bgp_node_safi (vty
);
14059 bgp
->distance_ebgp
[afi
][safi
] = 0;
14060 bgp
->distance_ibgp
[afi
][safi
] = 0;
14061 bgp
->distance_local
[afi
][safi
] = 0;
14062 return CMD_SUCCESS
;
14065 ALIAS (no_bgp_distance
,
14066 no_bgp_distance2_cmd
,
14069 "Define an administrative distance\n"
14072 DEFUN (bgp_distance_source
,
14073 bgp_distance_source_cmd
,
14074 "distance <1-255> A.B.C.D/M",
14075 "Define an administrative distance\n"
14076 "Administrative distance\n"
14077 "IP source prefix\n")
14079 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14080 return CMD_SUCCESS
;
14083 DEFUN (no_bgp_distance_source
,
14084 no_bgp_distance_source_cmd
,
14085 "no distance <1-255> A.B.C.D/M",
14087 "Define an administrative distance\n"
14088 "Administrative distance\n"
14089 "IP source prefix\n")
14091 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14092 return CMD_SUCCESS
;
14095 DEFUN (bgp_distance_source_access_list
,
14096 bgp_distance_source_access_list_cmd
,
14097 "distance <1-255> A.B.C.D/M WORD",
14098 "Define an administrative distance\n"
14099 "Administrative distance\n"
14100 "IP source prefix\n"
14101 "Access list name\n")
14103 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14104 return CMD_SUCCESS
;
14107 DEFUN (no_bgp_distance_source_access_list
,
14108 no_bgp_distance_source_access_list_cmd
,
14109 "no distance <1-255> A.B.C.D/M WORD",
14111 "Define an administrative distance\n"
14112 "Administrative distance\n"
14113 "IP source prefix\n"
14114 "Access list name\n")
14116 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14117 return CMD_SUCCESS
;
14120 DEFUN (ipv6_bgp_distance_source
,
14121 ipv6_bgp_distance_source_cmd
,
14122 "distance <1-255> X:X::X:X/M",
14123 "Define an administrative distance\n"
14124 "Administrative distance\n"
14125 "IP source prefix\n")
14127 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14128 return CMD_SUCCESS
;
14131 DEFUN (no_ipv6_bgp_distance_source
,
14132 no_ipv6_bgp_distance_source_cmd
,
14133 "no distance <1-255> X:X::X:X/M",
14135 "Define an administrative distance\n"
14136 "Administrative distance\n"
14137 "IP source prefix\n")
14139 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14140 return CMD_SUCCESS
;
14143 DEFUN (ipv6_bgp_distance_source_access_list
,
14144 ipv6_bgp_distance_source_access_list_cmd
,
14145 "distance <1-255> X:X::X:X/M WORD",
14146 "Define an administrative distance\n"
14147 "Administrative distance\n"
14148 "IP source prefix\n"
14149 "Access list name\n")
14151 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14152 return CMD_SUCCESS
;
14155 DEFUN (no_ipv6_bgp_distance_source_access_list
,
14156 no_ipv6_bgp_distance_source_access_list_cmd
,
14157 "no distance <1-255> X:X::X:X/M WORD",
14159 "Define an administrative distance\n"
14160 "Administrative distance\n"
14161 "IP source prefix\n"
14162 "Access list name\n")
14164 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14165 return CMD_SUCCESS
;
14168 DEFUN (bgp_damp_set
,
14170 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14171 "BGP Specific commands\n"
14172 "Enable route-flap dampening\n"
14173 "Half-life time for the penalty\n"
14174 "Value to start reusing a route\n"
14175 "Value to start suppressing a route\n"
14176 "Maximum duration to suppress a stable route\n")
14179 int half
= DEFAULT_HALF_LIFE
* 60;
14180 int reuse
= DEFAULT_REUSE
;
14181 int suppress
= DEFAULT_SUPPRESS
;
14182 int max
= 4 * half
;
14186 half
= atoi (argv
[0]) * 60;
14187 reuse
= atoi (argv
[1]);
14188 suppress
= atoi (argv
[2]);
14189 max
= atoi (argv
[3]) * 60;
14191 else if (argc
== 1)
14193 half
= atoi (argv
[0]) * 60;
14199 if (suppress
< reuse
)
14201 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
14206 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
14207 half
, reuse
, suppress
, max
);
14210 ALIAS (bgp_damp_set
,
14212 "bgp dampening <1-45>",
14213 "BGP Specific commands\n"
14214 "Enable route-flap dampening\n"
14215 "Half-life time for the penalty\n")
14217 ALIAS (bgp_damp_set
,
14220 "BGP Specific commands\n"
14221 "Enable route-flap dampening\n")
14223 DEFUN (bgp_damp_unset
,
14224 bgp_damp_unset_cmd
,
14225 "no bgp dampening",
14227 "BGP Specific commands\n"
14228 "Enable route-flap dampening\n")
14233 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
14236 ALIAS (bgp_damp_unset
,
14237 bgp_damp_unset2_cmd
,
14238 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14240 "BGP Specific commands\n"
14241 "Enable route-flap dampening\n"
14242 "Half-life time for the penalty\n"
14243 "Value to start reusing a route\n"
14244 "Value to start suppressing a route\n"
14245 "Maximum duration to suppress a stable route\n")
14247 ALIAS (bgp_damp_unset
,
14248 bgp_damp_unset3_cmd
,
14249 "no bgp dampening <1-45>",
14251 "BGP Specific commands\n"
14252 "Enable route-flap dampening\n"
14253 "Half-life time for the penalty\n")
14255 DEFUN (show_ip_bgp_dampened_paths
,
14256 show_ip_bgp_dampened_paths_cmd
,
14257 "show ip bgp dampened-paths",
14261 "Display paths suppressed due to dampening\n")
14263 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
14267 ALIAS (show_ip_bgp_dampened_paths
,
14268 show_ip_bgp_damp_dampened_paths_cmd
,
14269 "show ip bgp dampening dampened-paths",
14273 "Display detailed information about dampening\n"
14274 "Display paths suppressed due to dampening\n")
14276 DEFUN (show_ip_bgp_flap_statistics
,
14277 show_ip_bgp_flap_statistics_cmd
,
14278 "show ip bgp flap-statistics",
14282 "Display flap statistics of routes\n")
14284 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
14285 bgp_show_type_flap_statistics
, NULL
, 0);
14288 ALIAS (show_ip_bgp_flap_statistics
,
14289 show_ip_bgp_damp_flap_statistics_cmd
,
14290 "show ip bgp dampening flap-statistics",
14294 "Display detailed information about dampening\n"
14295 "Display flap statistics of routes\n")
14297 /* Display specified route of BGP table. */
14299 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
14300 const char *ip_str
, afi_t afi
, safi_t safi
,
14301 struct prefix_rd
*prd
, int prefix_check
)
14304 struct prefix match
;
14305 struct bgp_node
*rn
;
14306 struct bgp_node
*rm
;
14307 struct bgp_info
*ri
;
14308 struct bgp_info
*ri_temp
;
14310 struct bgp_table
*table
;
14312 /* BGP structure lookup. */
14315 bgp
= bgp_lookup_by_name (view_name
);
14318 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
14319 return CMD_WARNING
;
14324 bgp
= bgp_get_default ();
14327 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14328 return CMD_WARNING
;
14332 /* Check IP address argument. */
14333 ret
= str2prefix (ip_str
, &match
);
14336 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14337 return CMD_WARNING
;
14340 match
.family
= afi2family (afi
);
14342 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14344 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14346 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14349 if ((table
= rn
->info
) != NULL
)
14350 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14352 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14357 if (ri
->extra
&& ri
->extra
->damp_info
)
14359 ri_temp
= ri
->next
;
14360 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14368 bgp_unlock_node (rm
);
14374 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14376 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14381 if (ri
->extra
&& ri
->extra
->damp_info
)
14383 ri_temp
= ri
->next
;
14384 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14392 bgp_unlock_node (rn
);
14396 return CMD_SUCCESS
;
14399 DEFUN (clear_ip_bgp_dampening
,
14400 clear_ip_bgp_dampening_cmd
,
14401 "clear ip bgp dampening",
14405 "Clear route flap dampening information\n")
14407 bgp_damp_info_clean ();
14408 return CMD_SUCCESS
;
14411 DEFUN (clear_ip_bgp_dampening_prefix
,
14412 clear_ip_bgp_dampening_prefix_cmd
,
14413 "clear ip bgp dampening A.B.C.D/M",
14417 "Clear route flap dampening information\n"
14418 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14420 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14421 SAFI_UNICAST
, NULL
, 1);
14424 DEFUN (clear_ip_bgp_dampening_address
,
14425 clear_ip_bgp_dampening_address_cmd
,
14426 "clear ip bgp dampening A.B.C.D",
14430 "Clear route flap dampening information\n"
14431 "Network to clear damping information\n")
14433 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14434 SAFI_UNICAST
, NULL
, 0);
14437 DEFUN (clear_ip_bgp_dampening_address_mask
,
14438 clear_ip_bgp_dampening_address_mask_cmd
,
14439 "clear ip bgp dampening A.B.C.D A.B.C.D",
14443 "Clear route flap dampening information\n"
14444 "Network to clear damping information\n"
14448 char prefix_str
[BUFSIZ
];
14450 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14453 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14454 return CMD_WARNING
;
14457 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14458 SAFI_UNICAST
, NULL
, 0);
14461 /* also used for encap safi */
14463 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14464 afi_t afi
, safi_t safi
, int *write
)
14466 struct bgp_node
*prn
;
14467 struct bgp_node
*rn
;
14468 struct bgp_table
*table
;
14470 struct prefix_rd
*prd
;
14471 struct bgp_static
*bgp_static
;
14473 char buf
[SU_ADDRSTRLEN
];
14474 char rdbuf
[RD_ADDRSTRLEN
];
14476 /* Network configuration. */
14477 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14478 if ((table
= prn
->info
) != NULL
)
14479 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14480 if ((bgp_static
= rn
->info
) != NULL
)
14483 prd
= (struct prefix_rd
*) &prn
->p
;
14485 /* "address-family" display. */
14486 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14488 /* "network" configuration display. */
14489 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14490 label
= decode_label (bgp_static
->tag
);
14492 vty_out (vty
, " network %s/%d rd %s tag %d",
14493 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14496 vty_out (vty
, "%s", VTY_NEWLINE
);
14501 /* Configuration of static route announcement and aggregate
14504 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14505 afi_t afi
, safi_t safi
, int *write
)
14507 struct bgp_node
*rn
;
14509 struct bgp_static
*bgp_static
;
14510 struct bgp_aggregate
*bgp_aggregate
;
14511 char buf
[SU_ADDRSTRLEN
];
14513 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14514 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14516 /* Network configuration. */
14517 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14518 if ((bgp_static
= rn
->info
) != NULL
)
14522 /* "address-family" display. */
14523 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14525 /* "network" configuration display. */
14526 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14528 u_int32_t destination
;
14529 struct in_addr netmask
;
14531 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14532 masklen2ip (p
->prefixlen
, &netmask
);
14533 vty_out (vty
, " network %s",
14534 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14536 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14537 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14538 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14539 || p
->u
.prefix4
.s_addr
== 0)
14541 /* Natural mask is not display. */
14544 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14548 vty_out (vty
, " network %s/%d",
14549 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14553 if (bgp_static
->rmap
.name
)
14554 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14557 if (bgp_static
->backdoor
)
14558 vty_out (vty
, " backdoor");
14561 vty_out (vty
, "%s", VTY_NEWLINE
);
14564 /* Aggregate-address configuration. */
14565 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14566 if ((bgp_aggregate
= rn
->info
) != NULL
)
14570 /* "address-family" display. */
14571 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14573 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14575 struct in_addr netmask
;
14577 masklen2ip (p
->prefixlen
, &netmask
);
14578 vty_out (vty
, " aggregate-address %s %s",
14579 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14580 inet_ntoa (netmask
));
14584 vty_out (vty
, " aggregate-address %s/%d",
14585 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14589 if (bgp_aggregate
->as_set
)
14590 vty_out (vty
, " as-set");
14592 if (bgp_aggregate
->summary_only
)
14593 vty_out (vty
, " summary-only");
14595 vty_out (vty
, "%s", VTY_NEWLINE
);
14602 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
14603 safi_t safi
, int *write
)
14605 struct bgp_node
*rn
;
14606 struct bgp_distance
*bdistance
;
14608 /* Distance configuration. */
14609 if (bgp
->distance_ebgp
[afi
][safi
]
14610 && bgp
->distance_ibgp
[afi
][safi
]
14611 && bgp
->distance_local
[afi
][safi
]
14612 && (bgp
->distance_ebgp
[afi
][safi
] != ZEBRA_EBGP_DISTANCE_DEFAULT
14613 || bgp
->distance_ibgp
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
14614 || bgp
->distance_local
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
))
14616 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14617 vty_out (vty
, " distance bgp %d %d %d%s",
14618 bgp
->distance_ebgp
[afi
][safi
], bgp
->distance_ibgp
[afi
][safi
],
14619 bgp
->distance_local
[afi
][safi
], VTY_NEWLINE
);
14622 for (rn
= bgp_table_top (bgp_distance_table
[afi
][safi
]); rn
;
14623 rn
= bgp_route_next (rn
))
14624 if ((bdistance
= rn
->info
) != NULL
)
14626 char buf
[PREFIX_STRLEN
];
14628 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14629 vty_out (vty
, " distance %d %s %s%s", bdistance
->distance
,
14630 prefix2str (&rn
->p
, buf
, sizeof (buf
)),
14631 bdistance
->access_list
? bdistance
->access_list
: "",
14638 /* Allocate routing table structure and install commands. */
14640 bgp_route_init (void)
14645 /* Init BGP distance table. */
14646 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
14647 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
14648 bgp_distance_table
[afi
][safi
] = bgp_table_init (afi
, safi
);
14650 /* IPv4 BGP commands. */
14651 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14652 install_element (BGP_NODE
, &bgp_network_cmd
);
14653 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14654 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14655 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14656 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14657 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14658 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14659 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14660 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14661 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14662 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14663 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14664 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14665 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14666 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14667 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14668 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14669 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14670 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14672 install_element (BGP_NODE
, &aggregate_address_cmd
);
14673 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14674 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14675 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14676 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14677 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14678 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14679 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14680 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14681 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14682 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14683 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14684 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14685 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14686 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14687 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14688 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14689 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14690 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14691 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14693 /* IPv4 unicast configuration. */
14694 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14695 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14696 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14697 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14698 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14699 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14700 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14701 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14702 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14703 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14704 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14705 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14706 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14707 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14709 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14710 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14711 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14712 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14713 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14714 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14715 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14716 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14717 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14718 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14719 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14720 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14721 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14722 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14723 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14724 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14725 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14726 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14727 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14728 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14730 /* IPv4 multicast configuration. */
14731 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14732 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14733 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14734 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14735 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14736 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14737 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14738 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14739 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14740 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14741 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14742 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14743 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14744 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14745 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14746 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14747 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14748 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14749 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14750 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14751 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14752 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14753 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14754 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14755 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14756 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14757 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14758 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14759 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14760 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14761 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14762 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14763 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14764 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14766 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14767 install_element (VIEW_NODE
, &show_bgp_ipv4_cmd
);
14768 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14769 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14770 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14771 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14772 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14773 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14774 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14775 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14776 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14777 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14778 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14779 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14780 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14781 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14782 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14783 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14784 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14785 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14786 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14788 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14789 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14790 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14791 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14792 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14793 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14794 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14795 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14796 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14797 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14798 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14799 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14800 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14801 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14802 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14803 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14804 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14805 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14806 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14807 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14808 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14809 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14810 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14811 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14812 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14813 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14814 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14815 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14816 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14817 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14818 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14819 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14820 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14821 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14822 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14823 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14824 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14825 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14826 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14827 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14828 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14829 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14830 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14831 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14832 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14833 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14834 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14835 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14836 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14837 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14838 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14839 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14840 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14841 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14842 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14843 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14844 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14845 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14846 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14847 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14848 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14849 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14850 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14851 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
14852 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14853 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
14854 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
14855 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14856 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14857 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14858 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14859 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14860 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14861 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14862 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14863 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14864 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14865 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14866 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14867 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14868 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14869 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14870 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14871 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14872 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14873 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14875 install_element (VIEW_NODE
, &show_bgp_ipv4_prefix_cmd
);
14876 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_route_cmd
);
14877 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_route_cmd
);
14878 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_prefix_cmd
);
14879 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_prefix_cmd
);
14881 /* BGP dampening clear commands */
14882 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14883 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14884 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14885 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14888 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14889 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14890 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14892 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14893 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14895 /* New config IPv6 BGP commands. */
14896 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14897 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14898 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14899 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14900 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14901 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14903 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14904 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14905 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14906 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14908 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14909 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14911 /* Old config IPv6 BGP commands. */
14912 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14913 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14915 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14916 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14917 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14918 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14920 install_element (VIEW_NODE
, &show_bgp_cmd
);
14921 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14922 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14923 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14924 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14925 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14926 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14927 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14928 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14929 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14930 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14931 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14932 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14933 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14934 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14935 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14936 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14937 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14938 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14939 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14940 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14941 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14942 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14943 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14944 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14945 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14946 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14947 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14948 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14949 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14950 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14951 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14952 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14953 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14954 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14955 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14956 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14957 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14958 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14959 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14960 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14961 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14962 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14963 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14964 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14965 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14966 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14967 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14968 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14969 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14970 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14971 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14972 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14973 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14974 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14975 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14976 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14977 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14978 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14979 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14980 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14981 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14982 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14983 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14984 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14985 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14986 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14987 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14988 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14989 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14990 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14991 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14992 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14993 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14994 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14995 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14996 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14997 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14998 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14999 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
15000 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
15001 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
15002 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
15003 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
15004 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
15005 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
15006 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
15007 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
15008 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
15009 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
15010 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
15011 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
15014 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
15015 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
15016 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
15017 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
15020 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
15021 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
15022 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
15023 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
15024 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
15025 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
15026 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
15027 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
15028 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
15029 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
15030 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
15031 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
15032 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
15033 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
15034 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
15035 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
15036 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15037 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15038 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
15039 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
15040 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15041 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15042 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15043 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15044 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15045 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
15046 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
15047 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
15048 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
15049 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15050 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
15051 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
15052 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
15053 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15054 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15055 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15058 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
15059 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15062 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
15063 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15066 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
15067 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15068 #endif /* HAVE_IPV6 */
15070 install_element (BGP_NODE
, &bgp_distance_cmd
);
15071 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
15072 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
15073 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
15074 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
15075 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
15076 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
15077 install_element (BGP_IPV4_NODE
, &bgp_distance_cmd
);
15078 install_element (BGP_IPV4_NODE
, &no_bgp_distance_cmd
);
15079 install_element (BGP_IPV4_NODE
, &no_bgp_distance2_cmd
);
15080 install_element (BGP_IPV4_NODE
, &bgp_distance_source_cmd
);
15081 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_cmd
);
15082 install_element (BGP_IPV4_NODE
, &bgp_distance_source_access_list_cmd
);
15083 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_access_list_cmd
);
15084 install_element (BGP_IPV4M_NODE
, &bgp_distance_cmd
);
15085 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_cmd
);
15086 install_element (BGP_IPV4M_NODE
, &no_bgp_distance2_cmd
);
15087 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_cmd
);
15088 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_cmd
);
15089 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_access_list_cmd
);
15090 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_access_list_cmd
);
15091 install_element (BGP_IPV6_NODE
, &bgp_distance_cmd
);
15092 install_element (BGP_IPV6_NODE
, &no_bgp_distance_cmd
);
15093 install_element (BGP_IPV6_NODE
, &no_bgp_distance2_cmd
);
15094 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_cmd
);
15095 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15096 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15097 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15098 install_element (BGP_IPV6M_NODE
, &bgp_distance_cmd
);
15099 install_element (BGP_IPV6M_NODE
, &no_bgp_distance_cmd
);
15100 install_element (BGP_IPV6M_NODE
, &no_bgp_distance2_cmd
);
15101 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_cmd
);
15102 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15103 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15104 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15106 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15107 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15108 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15109 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15110 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15111 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15112 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15113 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15114 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15115 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15116 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15117 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15119 /* IPv4 Multicast Mode */
15120 install_element (BGP_IPV4M_NODE
, &bgp_damp_set_cmd
);
15121 install_element (BGP_IPV4M_NODE
, &bgp_damp_set2_cmd
);
15122 install_element (BGP_IPV4M_NODE
, &bgp_damp_set3_cmd
);
15123 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset_cmd
);
15124 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset2_cmd
);
15128 bgp_route_finish (void)
15133 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
15134 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
15136 bgp_table_unlock (bgp_distance_table
[afi
][safi
]);
15137 bgp_distance_table
[afi
][safi
] = NULL
;