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
)
2065 bgp_process_queue_init ();
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
)
2090 bgp_process_queue_init ();
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
);
2287 /* Check if received nexthop is valid or not. */
2289 bgp_update_martian_nexthop (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct attr
*attr
)
2291 struct attr_extra
*attre
= attr
->extra
;
2294 /* Only validated for unicast and multicast currently. */
2295 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2298 /* If NEXT_HOP is present, validate it. */
2299 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2301 if (attr
->nexthop
.s_addr
== 0 ||
2302 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2303 bgp_nexthop_self (bgp
, attr
))
2307 /* If MP_NEXTHOP is present, validate it. */
2308 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2309 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2310 * it is not an IPv6 link-local address.
2312 if (attre
&& attre
->mp_nexthop_len
)
2314 switch (attre
->mp_nexthop_len
)
2316 case BGP_ATTR_NHLEN_IPV4
:
2317 case BGP_ATTR_NHLEN_VPNV4
:
2318 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2319 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2323 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2324 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2325 case BGP_ATTR_NHLEN_VPNV6_GLOBAL
:
2326 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2327 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2328 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2330 #endif /* HAVE_IPV6 */
2342 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2343 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2344 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2348 int aspath_loop_count
= 0;
2349 struct bgp_node
*rn
;
2351 struct attr new_attr
;
2352 struct attr_extra new_extra
;
2353 struct attr
*attr_new
;
2354 struct bgp_info
*ri
;
2355 struct bgp_info
*new;
2357 char buf
[SU_ADDRSTRLEN
];
2360 int do_loop_check
= 1;
2362 int vnc_implicit_withdraw
= 0;
2365 memset (&new_attr
, 0, sizeof(struct attr
));
2366 memset (&new_extra
, 0, sizeof(struct attr_extra
));
2369 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2371 /* When peer's soft reconfiguration enabled. Record input packet in
2373 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2374 && peer
!= bgp
->peer_self
)
2375 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2377 /* Check previously received route. */
2378 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2379 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2380 ri
->addpath_rx_id
== addpath_id
)
2383 /* AS path local-as loop check. */
2384 if (peer
->change_local_as
)
2386 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2387 aspath_loop_count
= 1;
2389 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2391 reason
= "as-path contains our own AS;";
2396 /* If the peer is configured for "allowas-in origin" and the last ASN in the
2397 * as-path is our ASN then we do not need to call aspath_loop_check
2399 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN_ORIGIN
))
2400 if (aspath_get_last_as(attr
->aspath
) == bgp
->as
)
2403 /* AS path loop check. */
2406 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2407 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2408 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
) > peer
->allowas_in
[afi
][safi
]))
2410 reason
= "as-path contains our own AS;";
2415 /* Route reflector originator ID check. */
2416 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2417 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2419 reason
= "originator is us;";
2423 /* Route reflector cluster ID check. */
2424 if (bgp_cluster_filter (peer
, attr
))
2426 reason
= "reflected from the same cluster;";
2430 /* Apply incoming filter. */
2431 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2437 new_attr
.extra
= &new_extra
;
2438 bgp_attr_dup (&new_attr
, attr
);
2440 /* Apply incoming route-map.
2441 * NB: new_attr may now contain newly allocated values from route-map "set"
2442 * commands, so we need bgp_attr_flush in the error paths, until we intern
2443 * the attr (which takes over the memory references) */
2444 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2446 reason
= "route-map;";
2447 bgp_attr_flush (&new_attr
);
2451 /* next hop check. */
2452 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2454 reason
= "martian or self next-hop;";
2455 bgp_attr_flush (&new_attr
);
2459 attr_new
= bgp_attr_intern (&new_attr
);
2461 /* If the update is implicit withdraw. */
2464 ri
->uptime
= bgp_clock ();
2466 /* Same attribute comes in. */
2467 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2468 && attrhash_cmp (ri
->attr
, attr_new
))
2470 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2471 && peer
->sort
== BGP_PEER_EBGP
2472 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2474 if (bgp_debug_update(peer
, p
, NULL
, 1))
2476 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2477 zlog_debug ("%s rcvd %s/%d%s",
2479 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2480 p
->prefixlen
, buf2
);
2483 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2485 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2486 bgp_process (bgp
, rn
, afi
, safi
);
2489 else /* Duplicate - odd */
2491 if (bgp_debug_update(peer
, p
, NULL
, 1))
2493 if (!peer
->rcvd_attr_printed
)
2495 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2496 peer
->rcvd_attr_printed
= 1;
2499 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2500 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2502 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2503 p
->prefixlen
, buf2
);
2506 /* graceful restart STALE flag unset. */
2507 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2509 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2510 bgp_process (bgp
, rn
, afi
, safi
);
2514 bgp_unlock_node (rn
);
2515 bgp_attr_unintern (&attr_new
);
2520 /* Withdraw/Announce before we fully processed the withdraw */
2521 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2523 if (bgp_debug_update(peer
, p
, NULL
, 1))
2525 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2526 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2528 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2529 p
->prefixlen
, buf2
);
2531 bgp_info_restore (rn
, ri
);
2534 /* Received Logging. */
2535 if (bgp_debug_update(peer
, p
, NULL
, 1))
2537 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2538 zlog_debug ("%s rcvd %s/%d%s",
2540 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2541 p
->prefixlen
, buf2
);
2544 /* graceful restart STALE flag unset. */
2545 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2546 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2548 /* The attribute is changed. */
2549 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2551 /* implicit withdraw, decrement aggregate and pcount here.
2552 * only if update is accepted, they'll increment below.
2554 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2556 /* Update bgp route dampening information. */
2557 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2558 && peer
->sort
== BGP_PEER_EBGP
)
2560 /* This is implicit withdraw so we should update dampening
2562 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2563 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2566 if (safi
== SAFI_MPLS_VPN
) {
2567 struct bgp_node
*prn
= NULL
;
2568 struct bgp_table
*table
= NULL
;
2570 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2572 table
= (struct bgp_table
*)(prn
->info
);
2574 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2581 bgp_unlock_node(prn
);
2583 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2584 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2586 * Implicit withdraw case.
2588 ++vnc_implicit_withdraw
;
2589 vnc_import_bgp_del_route(bgp
, p
, ri
);
2590 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
2595 /* Update to new attribute. */
2596 bgp_attr_unintern (&ri
->attr
);
2597 ri
->attr
= attr_new
;
2599 /* Update MPLS tag. */
2600 if (safi
== SAFI_MPLS_VPN
)
2601 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2604 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
2606 if (vnc_implicit_withdraw
)
2609 * Add back the route with its new attributes (e.g., nexthop).
2610 * The route is still selected, until the route selection
2611 * queued by bgp_process actually runs. We have to make this
2612 * update to the VNC side immediately to avoid racing against
2613 * configuration changes (e.g., route-map changes) which
2614 * trigger re-importation of the entire RIB.
2616 vnc_import_bgp_add_route(bgp
, p
, ri
);
2617 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
2622 /* Update bgp route dampening information. */
2623 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2624 && peer
->sort
== BGP_PEER_EBGP
)
2626 /* Now we do normal update dampening. */
2627 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2628 if (ret
== BGP_DAMP_SUPPRESSED
)
2630 bgp_unlock_node (rn
);
2635 /* Nexthop reachability check. */
2636 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2638 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2639 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2640 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2645 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2646 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2649 if (BGP_DEBUG(nht
, NHT
))
2651 char buf1
[INET6_ADDRSTRLEN
];
2652 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2653 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2655 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2659 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2662 if (safi
== SAFI_MPLS_VPN
)
2664 struct bgp_node
*prn
= NULL
;
2665 struct bgp_table
*table
= NULL
;
2667 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2670 table
= (struct bgp_table
*)(prn
->info
);
2672 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2679 bgp_unlock_node(prn
);
2683 /* Process change. */
2684 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2686 bgp_process (bgp
, rn
, afi
, safi
);
2687 bgp_unlock_node (rn
);
2690 if (SAFI_MPLS_VPN
== safi
)
2692 uint32_t label
= decode_label(tag
);
2694 rfapiProcessUpdate(peer
, NULL
, p
, prd
, attr
, afi
, safi
, type
, sub_type
,
2697 if (SAFI_ENCAP
== safi
)
2699 rfapiProcessUpdate(peer
, NULL
, p
, prd
, attr
, afi
, safi
, type
, sub_type
,
2705 } // End of implicit withdraw
2707 /* Received Logging. */
2708 if (bgp_debug_update(peer
, p
, NULL
, 1))
2710 if (!peer
->rcvd_attr_printed
)
2712 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2713 peer
->rcvd_attr_printed
= 1;
2716 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2717 zlog_debug ("%s rcvd %s/%d%s",
2719 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2720 p
->prefixlen
, buf2
);
2723 /* Make new BGP info. */
2724 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2726 /* Update MPLS tag. */
2727 if (safi
== SAFI_MPLS_VPN
)
2728 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2730 /* Nexthop reachability check. */
2731 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2733 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2734 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2735 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2740 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2741 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2744 if (BGP_DEBUG(nht
, NHT
))
2746 char buf1
[INET6_ADDRSTRLEN
];
2747 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2748 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2750 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2754 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2757 new->addpath_rx_id
= addpath_id
;
2759 /* Increment prefix */
2760 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2762 /* Register new BGP information. */
2763 bgp_info_add (rn
, new);
2765 /* route_node_get lock */
2766 bgp_unlock_node (rn
);
2769 if (safi
== SAFI_MPLS_VPN
)
2771 struct bgp_node
*prn
= NULL
;
2772 struct bgp_table
*table
= NULL
;
2774 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2777 table
= (struct bgp_table
*)(prn
->info
);
2779 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2786 bgp_unlock_node(prn
);
2790 /* If maximum prefix count is configured and current prefix
2792 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2795 /* Process change. */
2796 bgp_process (bgp
, rn
, afi
, safi
);
2799 if (SAFI_MPLS_VPN
== safi
)
2801 uint32_t label
= decode_label(tag
);
2803 rfapiProcessUpdate(peer
, NULL
, p
, prd
, attr
, afi
, safi
, type
, sub_type
,
2806 if (SAFI_ENCAP
== safi
)
2808 rfapiProcessUpdate(peer
, NULL
, p
, prd
, attr
, afi
, safi
, type
, sub_type
,
2815 /* This BGP update is filtered. Log the reason then update BGP
2818 if (bgp_debug_update(peer
, p
, NULL
, 1))
2820 if (!peer
->rcvd_attr_printed
)
2822 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2823 peer
->rcvd_attr_printed
= 1;
2826 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2827 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2829 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2830 p
->prefixlen
, buf2
, reason
);
2834 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2836 bgp_unlock_node (rn
);
2840 * Filtered update is treated as an implicit withdrawal (see bgp_rib_remove()
2841 * a few lines above)
2843 if ((SAFI_MPLS_VPN
== safi
) || (SAFI_ENCAP
== safi
))
2845 rfapiProcessWithdraw(peer
, NULL
, p
, prd
, NULL
, afi
, safi
, type
, 0);
2853 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2854 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2855 struct prefix_rd
*prd
, u_char
*tag
)
2858 char buf
[SU_ADDRSTRLEN
];
2860 struct bgp_node
*rn
;
2861 struct bgp_info
*ri
;
2864 if ((SAFI_MPLS_VPN
== safi
) || (SAFI_ENCAP
== safi
))
2866 rfapiProcessWithdraw(peer
, NULL
, p
, prd
, NULL
, afi
, safi
, type
, 0);
2873 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2875 /* If peer is soft reconfiguration enabled. Record input packet for
2876 * further calculation.
2878 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2879 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2880 * the iteration over all RS clients.
2881 * Since we need to remove the entry from adj_in anyway, do that first and
2882 * if there was no entry, we don't need to do anything more.
2884 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2885 && peer
!= bgp
->peer_self
)
2886 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2888 if (bgp_debug_update (peer
, p
, NULL
, 1))
2889 zlog_debug ("%s withdrawing route %s/%d "
2890 "not in adj-in", peer
->host
,
2891 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2893 bgp_unlock_node (rn
);
2897 /* Lookup withdrawn route. */
2898 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2899 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2900 ri
->addpath_rx_id
== addpath_id
)
2904 if (bgp_debug_update(peer
, p
, NULL
, 1))
2906 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2907 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2909 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2910 p
->prefixlen
, buf2
);
2913 /* Withdraw specified route from routing table. */
2914 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2915 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
, prd
);
2916 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2917 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2918 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2921 /* Unlock bgp_node_get() lock. */
2922 bgp_unlock_node (rn
);
2928 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2930 struct update_subgroup
*subgrp
;
2931 subgrp
= peer_subgroup(peer
, afi
, safi
);
2932 subgroup_default_originate(subgrp
, withdraw
);
2937 * bgp_stop_announce_route_timer
2940 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2942 if (!paf
->t_announce_route
)
2945 THREAD_TIMER_OFF (paf
->t_announce_route
);
2949 * bgp_announce_route_timer_expired
2951 * Callback that is invoked when the route announcement timer for a
2955 bgp_announce_route_timer_expired (struct thread
*t
)
2957 struct peer_af
*paf
;
2960 paf
= THREAD_ARG (t
);
2963 assert (paf
->t_announce_route
);
2964 paf
->t_announce_route
= NULL
;
2966 if (peer
->status
!= Established
)
2969 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2972 peer_af_announce_route (paf
, 1);
2977 * bgp_announce_route
2979 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2982 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2984 struct peer_af
*paf
;
2985 struct update_subgroup
*subgrp
;
2987 paf
= peer_af_find (peer
, afi
, safi
);
2990 subgrp
= PAF_SUBGRP(paf
);
2993 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2994 * or a refresh has already been triggered.
2996 if (!subgrp
|| paf
->t_announce_route
)
3000 * Start a timer to stagger/delay the announce. This serves
3001 * two purposes - announcement can potentially be combined for
3002 * multiple peers and the announcement doesn't happen in the
3005 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
3006 bgp_announce_route_timer_expired
, paf
,
3007 (subgrp
->peer_count
== 1) ?
3008 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
3009 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
3013 * Announce routes from all AF tables to a peer.
3015 * This should ONLY be called when there is a need to refresh the
3016 * routes to the peer based on a policy change for this peer alone
3017 * or a route refresh request received from the peer.
3018 * The operation will result in splitting the peer from its existing
3019 * subgroups and putting it in new subgroups.
3022 bgp_announce_route_all (struct peer
*peer
)
3027 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3028 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3029 bgp_announce_route (peer
, afi
, safi
);
3033 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3034 struct bgp_table
*table
, struct prefix_rd
*prd
)
3037 struct bgp_node
*rn
;
3038 struct bgp_adj_in
*ain
;
3041 table
= peer
->bgp
->rib
[afi
][safi
];
3043 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3044 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
3046 if (ain
->peer
== peer
)
3048 struct bgp_info
*ri
= rn
->info
;
3049 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
3051 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
3052 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
3057 bgp_unlock_node (rn
);
3065 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3067 struct bgp_node
*rn
;
3068 struct bgp_table
*table
;
3070 if (peer
->status
!= Established
)
3073 if ((safi
!= SAFI_MPLS_VPN
) && (safi
!= SAFI_ENCAP
))
3074 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
3076 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3077 rn
= bgp_route_next (rn
))
3078 if ((table
= rn
->info
) != NULL
)
3080 struct prefix_rd prd
;
3081 prd
.family
= AF_UNSPEC
;
3083 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
3085 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
3090 struct bgp_clear_node_queue
3092 struct bgp_node
*rn
;
3095 static wq_item_status
3096 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
3098 struct bgp_clear_node_queue
*cnq
= data
;
3099 struct bgp_node
*rn
= cnq
->rn
;
3100 struct peer
*peer
= wq
->spec
.data
;
3101 struct bgp_info
*ri
;
3102 afi_t afi
= bgp_node_table (rn
)->afi
;
3103 safi_t safi
= bgp_node_table (rn
)->safi
;
3105 assert (rn
&& peer
);
3107 /* It is possible that we have multiple paths for a prefix from a peer
3108 * if that peer is using AddPath.
3110 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3111 if (ri
->peer
== peer
)
3113 /* graceful restart STALE flag set. */
3114 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
3115 && peer
->nsf
[afi
][safi
]
3116 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
3117 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
3118 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
3120 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3126 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
3128 struct bgp_clear_node_queue
*cnq
= data
;
3129 struct bgp_node
*rn
= cnq
->rn
;
3130 struct bgp_table
*table
= bgp_node_table (rn
);
3132 bgp_unlock_node (rn
);
3133 bgp_table_unlock (table
);
3134 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
3138 bgp_clear_node_complete (struct work_queue
*wq
)
3140 struct peer
*peer
= wq
->spec
.data
;
3142 /* Tickle FSM to start moving again */
3143 BGP_EVENT_ADD (peer
, Clearing_Completed
);
3145 peer_unlock (peer
); /* bgp_clear_route */
3149 bgp_clear_node_queue_init (struct peer
*peer
)
3151 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
3153 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
3154 #undef CLEAR_QUEUE_NAME_LEN
3156 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
3158 zlog_err ("%s: Failed to allocate work queue", __func__
);
3161 peer
->clear_node_queue
->spec
.hold
= 10;
3162 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
3163 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
3164 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
3165 peer
->clear_node_queue
->spec
.max_retries
= 0;
3167 /* we only 'lock' this peer reference when the queue is actually active */
3168 peer
->clear_node_queue
->spec
.data
= peer
;
3172 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3173 struct bgp_table
*table
)
3175 struct bgp_node
*rn
;
3176 int force
= bm
->process_main_queue
? 0 : 1;
3179 table
= peer
->bgp
->rib
[afi
][safi
];
3181 /* If still no table => afi/safi isn't configured at all or smth. */
3185 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3187 struct bgp_info
*ri
, *next
;
3188 struct bgp_adj_in
*ain
;
3189 struct bgp_adj_in
*ain_next
;
3191 /* XXX:TODO: This is suboptimal, every non-empty route_node is
3192 * queued for every clearing peer, regardless of whether it is
3193 * relevant to the peer at hand.
3195 * Overview: There are 3 different indices which need to be
3196 * scrubbed, potentially, when a peer is removed:
3198 * 1 peer's routes visible via the RIB (ie accepted routes)
3199 * 2 peer's routes visible by the (optional) peer's adj-in index
3200 * 3 other routes visible by the peer's adj-out index
3202 * 3 there is no hurry in scrubbing, once the struct peer is
3203 * removed from bgp->peer, we could just GC such deleted peer's
3204 * adj-outs at our leisure.
3206 * 1 and 2 must be 'scrubbed' in some way, at least made
3207 * invisible via RIB index before peer session is allowed to be
3208 * brought back up. So one needs to know when such a 'search' is
3213 * - there'd be a single global queue or a single RIB walker
3214 * - rather than tracking which route_nodes still need to be
3215 * examined on a peer basis, we'd track which peers still
3218 * Given that our per-peer prefix-counts now should be reliable,
3219 * this may actually be achievable. It doesn't seem to be a huge
3220 * problem at this time,
3222 * It is possible that we have multiple paths for a prefix from a peer
3223 * if that peer is using AddPath.
3228 ain_next
= ain
->next
;
3230 if (ain
->peer
== peer
)
3232 bgp_adj_in_remove (rn
, ain
);
3233 bgp_unlock_node (rn
);
3239 for (ri
= rn
->info
; ri
; ri
= next
)
3242 if (ri
->peer
!= peer
)
3246 bgp_info_reap (rn
, ri
);
3249 struct bgp_clear_node_queue
*cnq
;
3251 /* both unlocked in bgp_clear_node_queue_del */
3252 bgp_table_lock (bgp_node_table (rn
));
3254 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
3255 sizeof (struct bgp_clear_node_queue
));
3257 work_queue_add (peer
->clear_node_queue
, cnq
);
3266 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3268 struct bgp_node
*rn
;
3269 struct bgp_table
*table
;
3271 if (peer
->clear_node_queue
== NULL
)
3272 bgp_clear_node_queue_init (peer
);
3274 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3275 * Idle until it receives a Clearing_Completed event. This protects
3276 * against peers which flap faster than we can we clear, which could
3279 * a) race with routes from the new session being installed before
3280 * clear_route_node visits the node (to delete the route of that
3282 * b) resource exhaustion, clear_route_node likely leads to an entry
3283 * on the process_main queue. Fast-flapping could cause that queue
3287 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3288 * the unlock will happen upon work-queue completion; other wise, the
3289 * unlock happens at the end of this function.
3291 if (!peer
->clear_node_queue
->thread
)
3294 if (safi
!= SAFI_MPLS_VPN
&& safi
!= SAFI_ENCAP
)
3295 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
3297 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3298 rn
= bgp_route_next (rn
))
3299 if ((table
= rn
->info
) != NULL
)
3300 bgp_clear_route_table (peer
, afi
, safi
, table
);
3302 /* unlock if no nodes got added to the clear-node-queue. */
3303 if (!peer
->clear_node_queue
->thread
)
3309 bgp_clear_route_all (struct peer
*peer
)
3314 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3315 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3316 bgp_clear_route (peer
, afi
, safi
);
3319 rfapiProcessPeerDown(peer
);
3324 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3326 struct bgp_table
*table
;
3327 struct bgp_node
*rn
;
3328 struct bgp_adj_in
*ain
;
3329 struct bgp_adj_in
*ain_next
;
3331 table
= peer
->bgp
->rib
[afi
][safi
];
3333 /* It is possible that we have multiple paths for a prefix from a peer
3334 * if that peer is using AddPath.
3336 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3342 ain_next
= ain
->next
;
3344 if (ain
->peer
== peer
)
3346 bgp_adj_in_remove (rn
, ain
);
3347 bgp_unlock_node (rn
);
3356 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3358 struct bgp_node
*rn
;
3359 struct bgp_info
*ri
;
3360 struct bgp_table
*table
;
3362 table
= peer
->bgp
->rib
[afi
][safi
];
3364 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3366 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3367 if (ri
->peer
== peer
)
3369 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3370 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3377 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3379 struct bgp_node
*rn
;
3380 struct bgp_info
*ri
;
3381 struct bgp_info
*next
;
3383 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3384 for (ri
= rn
->info
; ri
; ri
= next
)
3387 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3388 && ri
->type
== ZEBRA_ROUTE_BGP
3389 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3390 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3393 if (table
->owner
&& table
->owner
->bgp
)
3394 vnc_import_bgp_del_route(table
->owner
->bgp
, &rn
->p
, ri
);
3396 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3397 bgp_info_reap (rn
, ri
);
3402 /* Delete all kernel routes. */
3404 bgp_cleanup_routes (struct bgp
*bgp
)
3408 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3410 struct bgp_node
*rn
;
3412 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3415 * VPN and ENCAP tables are two-level (RD is top level)
3417 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3418 rn
= bgp_route_next (rn
))
3422 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3423 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3425 bgp_unlock_node(rn
);
3429 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_ENCAP
]); rn
;
3430 rn
= bgp_route_next (rn
))
3434 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_ENCAP
);
3435 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3437 bgp_unlock_node(rn
);
3447 bgp_zclient_reset ();
3448 access_list_reset ();
3449 prefix_list_reset ();
3453 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3455 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3456 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3459 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3462 bgp_nlri_parse_ip (struct peer
*peer
, struct attr
*attr
,
3463 struct bgp_nlri
*packet
)
3472 int addpath_encoded
;
3473 u_int32_t addpath_id
;
3475 /* Check peer status. */
3476 if (peer
->status
!= Established
)
3480 lim
= pnt
+ packet
->length
;
3482 safi
= packet
->safi
;
3484 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3486 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3487 syntactic validity. If the field is syntactically incorrect,
3488 then the Error Subcode is set to Invalid Network Field. */
3489 for (; pnt
< lim
; pnt
+= psize
)
3491 /* Clear prefix structure. */
3492 memset (&p
, 0, sizeof (struct prefix
));
3494 if (addpath_encoded
)
3497 /* When packet overflow occurs return immediately. */
3498 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3501 addpath_id
= ntohl(*((uint32_t*) pnt
));
3502 pnt
+= BGP_ADDPATH_ID_LEN
;
3505 /* Fetch prefix length. */
3506 p
.prefixlen
= *pnt
++;
3507 /* afi/safi validity already verified by caller, bgp_update_receive */
3508 p
.family
= afi2family (afi
);
3510 /* Prefix length check. */
3511 if (p
.prefixlen
> prefix_blen (&p
) * 8)
3513 zlog_err("%s [Error] Update packet error (wrong perfix length %d for afi %u)",
3514 peer
->host
, p
.prefixlen
, packet
->afi
);
3518 /* Packet size overflow check. */
3519 psize
= PSIZE (p
.prefixlen
);
3521 /* When packet overflow occur return immediately. */
3522 if (pnt
+ psize
> lim
)
3524 zlog_err("%s [Error] Update packet error (prefix length %d overflows packet)",
3525 peer
->host
, p
.prefixlen
);
3529 /* Defensive coding, double-check the psize fits in a struct prefix */
3530 if (psize
> (ssize_t
) sizeof(p
.u
))
3532 zlog_err("%s [Error] Update packet error (prefix length %d too large for prefix storage %zu)",
3533 peer
->host
, p
.prefixlen
, sizeof(p
.u
));
3537 /* Fetch prefix from NLRI packet. */
3538 memcpy (&p
.u
.prefix
, pnt
, psize
);
3540 /* Check address. */
3541 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3543 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3545 /* From RFC4271 Section 6.3:
3547 * If a prefix in the NLRI field is semantically incorrect
3548 * (e.g., an unexpected multicast IP address), an error SHOULD
3549 * be logged locally, and the prefix SHOULD be ignored.
3551 zlog_err ("%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3552 peer
->host
, inet_ntoa (p
.u
.prefix4
));
3558 /* Check address. */
3559 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3561 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3565 zlog_err ("%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3566 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3570 if (IN6_IS_ADDR_MULTICAST (&p
.u
.prefix6
))
3574 zlog_err ("%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3575 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3580 #endif /* HAVE_IPV6 */
3582 /* Normal process. */
3584 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3585 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3587 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3588 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3590 /* Address family configuration mismatch or maximum-prefix count
3596 /* Packet length consistency check. */
3599 zlog_err ("%s [Error] Update packet error (prefix length mismatch with total length)",
3607 static struct bgp_static
*
3608 bgp_static_new (void)
3610 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3614 bgp_static_free (struct bgp_static
*bgp_static
)
3616 if (bgp_static
->rmap
.name
)
3617 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3618 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3622 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3623 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3625 struct bgp_node
*rn
;
3626 struct bgp_info
*ri
;
3627 struct bgp_info
*new;
3628 struct bgp_info info
;
3630 struct attr
*attr_new
;
3633 int vnc_implicit_withdraw
= 0;
3636 assert (bgp_static
);
3640 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3642 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3644 attr
.nexthop
= bgp_static
->igpnexthop
;
3645 attr
.med
= bgp_static
->igpmetric
;
3646 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3648 if (bgp_static
->atomic
)
3649 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3651 /* Apply route-map. */
3652 if (bgp_static
->rmap
.name
)
3654 struct attr attr_tmp
= attr
;
3655 info
.peer
= bgp
->peer_self
;
3656 info
.attr
= &attr_tmp
;
3658 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3660 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3662 bgp
->peer_self
->rmap_type
= 0;
3664 if (ret
== RMAP_DENYMATCH
)
3666 /* Free uninterned attribute. */
3667 bgp_attr_flush (&attr_tmp
);
3669 /* Unintern original. */
3670 aspath_unintern (&attr
.aspath
);
3671 bgp_attr_extra_free (&attr
);
3672 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3675 attr_new
= bgp_attr_intern (&attr_tmp
);
3678 attr_new
= bgp_attr_intern (&attr
);
3680 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3681 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3682 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3687 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3688 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3689 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3691 bgp_unlock_node (rn
);
3692 bgp_attr_unintern (&attr_new
);
3693 aspath_unintern (&attr
.aspath
);
3694 bgp_attr_extra_free (&attr
);
3699 /* The attribute is changed. */
3700 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3702 /* Rewrite BGP route information. */
3703 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3704 bgp_info_restore(rn
, ri
);
3706 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3708 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3710 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
3713 * Implicit withdraw case.
3714 * We have to do this before ri is changed
3716 ++vnc_implicit_withdraw
;
3717 vnc_import_bgp_del_route(bgp
, p
, ri
);
3718 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
3722 bgp_attr_unintern (&ri
->attr
);
3723 ri
->attr
= attr_new
;
3724 ri
->uptime
= bgp_clock ();
3726 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3728 if (vnc_implicit_withdraw
)
3730 vnc_import_bgp_add_route(bgp
, p
, ri
);
3731 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
3736 /* Nexthop reachability check. */
3737 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3739 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3740 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3743 if (BGP_DEBUG(nht
, NHT
))
3745 char buf1
[INET6_ADDRSTRLEN
];
3746 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3748 zlog_debug("%s(%s): Route not in table, not advertising",
3749 __FUNCTION__
, buf1
);
3751 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3756 /* Delete the NHT structure if any, if we're toggling between
3757 * enabling/disabling import check. We deregister the route
3758 * from NHT to avoid overloading NHT and the process interaction
3760 bgp_unlink_nexthop(ri
);
3761 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3763 /* Process change. */
3764 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3765 bgp_process (bgp
, rn
, afi
, safi
);
3766 bgp_unlock_node (rn
);
3767 aspath_unintern (&attr
.aspath
);
3768 bgp_attr_extra_free (&attr
);
3773 /* Make new BGP info. */
3774 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3776 /* Nexthop reachability check. */
3777 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3779 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3780 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3783 if (BGP_DEBUG(nht
, NHT
))
3785 char buf1
[INET6_ADDRSTRLEN
];
3786 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3788 zlog_debug("%s(%s): Route not in table, not advertising",
3789 __FUNCTION__
, buf1
);
3791 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3796 /* Delete the NHT structure if any, if we're toggling between
3797 * enabling/disabling import check. We deregister the route
3798 * from NHT to avoid overloading NHT and the process interaction
3800 bgp_unlink_nexthop(new);
3802 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3805 /* Aggregate address increment. */
3806 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3808 /* Register new BGP information. */
3809 bgp_info_add (rn
, new);
3811 /* route_node_get lock */
3812 bgp_unlock_node (rn
);
3814 /* Process change. */
3815 bgp_process (bgp
, rn
, afi
, safi
);
3817 /* Unintern original. */
3818 aspath_unintern (&attr
.aspath
);
3819 bgp_attr_extra_free (&attr
);
3823 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3824 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3826 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3830 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3833 struct bgp_node
*rn
;
3834 struct bgp_info
*ri
;
3836 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3838 /* Check selected route and self inserted route. */
3839 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3840 if (ri
->peer
== bgp
->peer_self
3841 && ri
->type
== ZEBRA_ROUTE_BGP
3842 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3845 /* Withdraw static BGP route from routing table. */
3848 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3849 bgp_unlink_nexthop(ri
);
3850 bgp_info_delete (rn
, ri
);
3851 bgp_process (bgp
, rn
, afi
, safi
);
3854 /* Unlock bgp_node_lookup. */
3855 bgp_unlock_node (rn
);
3859 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3862 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3863 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3865 struct bgp_node
*rn
;
3866 struct bgp_info
*ri
;
3868 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3870 /* Check selected route and self inserted route. */
3871 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3872 if (ri
->peer
== bgp
->peer_self
3873 && ri
->type
== ZEBRA_ROUTE_BGP
3874 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3877 /* Withdraw static BGP route from routing table. */
3881 rfapiProcessWithdraw(
3890 1); /* Kill, since it is an administrative change */
3892 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3893 bgp_info_delete (rn
, ri
);
3894 bgp_process (bgp
, rn
, afi
, safi
);
3897 /* Unlock bgp_node_lookup. */
3898 bgp_unlock_node (rn
);
3902 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3903 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3905 struct bgp_node
*rn
;
3906 struct bgp_info
*new;
3907 struct attr
*attr_new
;
3908 struct attr attr
= { 0 };
3909 struct bgp_info
*ri
;
3911 u_int32_t label
= 0;
3914 assert (bgp_static
);
3916 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3918 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3920 attr
.nexthop
= bgp_static
->igpnexthop
;
3921 attr
.med
= bgp_static
->igpmetric
;
3922 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3924 /* Apply route-map. */
3925 if (bgp_static
->rmap
.name
)
3927 struct attr attr_tmp
= attr
;
3928 struct bgp_info info
;
3931 info
.peer
= bgp
->peer_self
;
3932 info
.attr
= &attr_tmp
;
3934 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3936 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3938 bgp
->peer_self
->rmap_type
= 0;
3940 if (ret
== RMAP_DENYMATCH
)
3942 /* Free uninterned attribute. */
3943 bgp_attr_flush (&attr_tmp
);
3945 /* Unintern original. */
3946 aspath_unintern (&attr
.aspath
);
3947 bgp_attr_extra_free (&attr
);
3948 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3953 attr_new
= bgp_attr_intern (&attr_tmp
);
3957 attr_new
= bgp_attr_intern (&attr
);
3960 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3961 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3962 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3967 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3968 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3970 bgp_unlock_node (rn
);
3971 bgp_attr_unintern (&attr_new
);
3972 aspath_unintern (&attr
.aspath
);
3973 bgp_attr_extra_free (&attr
);
3978 /* The attribute is changed. */
3979 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3981 /* Rewrite BGP route information. */
3982 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3983 bgp_info_restore(rn
, ri
);
3985 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3986 bgp_attr_unintern (&ri
->attr
);
3987 ri
->attr
= attr_new
;
3988 ri
->uptime
= bgp_clock ();
3991 label
= decode_label (ri
->extra
->tag
);
3994 /* Process change. */
3995 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3996 bgp_process (bgp
, rn
, afi
, safi
);
3998 rfapiProcessUpdate(ri
->peer
, NULL
, p
, &bgp_static
->prd
,
3999 ri
->attr
, afi
, safi
,
4000 ri
->type
, ri
->sub_type
, &label
);
4002 bgp_unlock_node (rn
);
4003 aspath_unintern (&attr
.aspath
);
4004 bgp_attr_extra_free (&attr
);
4010 /* Make new BGP info. */
4011 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
4013 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4014 new->extra
= bgp_info_extra_new();
4015 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
4017 label
= decode_label (bgp_static
->tag
);
4020 /* Aggregate address increment. */
4021 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
4023 /* Register new BGP information. */
4024 bgp_info_add (rn
, new);
4026 /* route_node_get lock */
4027 bgp_unlock_node (rn
);
4029 /* Process change. */
4030 bgp_process (bgp
, rn
, afi
, safi
);
4033 rfapiProcessUpdate(new->peer
, NULL
, p
, &bgp_static
->prd
,
4034 new->attr
, afi
, safi
,
4035 new->type
, new->sub_type
, &label
);
4038 /* Unintern original. */
4039 aspath_unintern (&attr
.aspath
);
4040 bgp_attr_extra_free (&attr
);
4043 /* Configure static BGP network. When user don't run zebra, static
4044 route should be installed as valid. */
4046 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4047 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
4051 struct bgp_static
*bgp_static
;
4052 struct bgp_node
*rn
;
4053 u_char need_update
= 0;
4055 /* Convert IP prefix string to struct prefix. */
4056 ret
= str2prefix (ip_str
, &p
);
4059 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4063 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4065 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4069 #endif /* HAVE_IPV6 */
4073 /* Set BGP static route configuration. */
4074 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
4078 /* Configuration change. */
4079 bgp_static
= rn
->info
;
4081 /* Check previous routes are installed into BGP. */
4082 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
4085 bgp_static
->backdoor
= backdoor
;
4089 if (bgp_static
->rmap
.name
)
4090 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4091 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4092 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4096 if (bgp_static
->rmap
.name
)
4097 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4098 bgp_static
->rmap
.name
= NULL
;
4099 bgp_static
->rmap
.map
= NULL
;
4100 bgp_static
->valid
= 0;
4102 bgp_unlock_node (rn
);
4106 /* New configuration. */
4107 bgp_static
= bgp_static_new ();
4108 bgp_static
->backdoor
= backdoor
;
4109 bgp_static
->valid
= 0;
4110 bgp_static
->igpmetric
= 0;
4111 bgp_static
->igpnexthop
.s_addr
= 0;
4115 if (bgp_static
->rmap
.name
)
4116 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4117 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4118 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4120 rn
->info
= bgp_static
;
4123 bgp_static
->valid
= 1;
4125 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4127 if (! bgp_static
->backdoor
)
4128 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
4133 /* Configure static BGP network. */
4135 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4136 afi_t afi
, safi_t safi
)
4140 struct bgp_static
*bgp_static
;
4141 struct bgp_node
*rn
;
4143 /* Convert IP prefix string to struct prefix. */
4144 ret
= str2prefix (ip_str
, &p
);
4147 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4151 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4153 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4157 #endif /* HAVE_IPV6 */
4161 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
4164 vty_out (vty
, "%% Can't find specified static route configuration.%s",
4169 bgp_static
= rn
->info
;
4171 /* Update BGP RIB. */
4172 if (! bgp_static
->backdoor
)
4173 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4175 /* Clear configuration. */
4176 bgp_static_free (bgp_static
);
4178 bgp_unlock_node (rn
);
4179 bgp_unlock_node (rn
);
4185 bgp_static_add (struct bgp
*bgp
)
4189 struct bgp_node
*rn
;
4190 struct bgp_node
*rm
;
4191 struct bgp_table
*table
;
4192 struct bgp_static
*bgp_static
;
4194 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4195 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4196 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4197 if (rn
->info
!= NULL
)
4199 if (safi
== SAFI_MPLS_VPN
)
4203 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4205 bgp_static
= rn
->info
;
4206 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
4211 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
4216 /* Called from bgp_delete(). Delete all static routes from the BGP
4219 bgp_static_delete (struct bgp
*bgp
)
4223 struct bgp_node
*rn
;
4224 struct bgp_node
*rm
;
4225 struct bgp_table
*table
;
4226 struct bgp_static
*bgp_static
;
4228 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4229 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4230 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4231 if (rn
->info
!= NULL
)
4233 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4237 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4239 bgp_static
= rn
->info
;
4240 bgp_static_withdraw_safi (bgp
, &rm
->p
,
4242 (struct prefix_rd
*)&rn
->p
,
4244 bgp_static_free (bgp_static
);
4246 bgp_unlock_node (rn
);
4251 bgp_static
= rn
->info
;
4252 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
4253 bgp_static_free (bgp_static
);
4255 bgp_unlock_node (rn
);
4261 bgp_static_redo_import_check (struct bgp
*bgp
)
4265 struct bgp_node
*rn
;
4266 struct bgp_static
*bgp_static
;
4268 /* Use this flag to force reprocessing of the route */
4269 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4270 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4271 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4272 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4273 if (rn
->info
!= NULL
)
4275 bgp_static
= rn
->info
;
4276 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
4278 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4282 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
4284 struct bgp_table
*table
;
4285 struct bgp_node
*rn
;
4286 struct bgp_info
*ri
;
4288 table
= bgp
->rib
[afi
][safi
];
4289 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
4291 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4293 if (ri
->peer
== bgp
->peer_self
&&
4294 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
4295 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
4296 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
4297 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
4299 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4300 bgp_unlink_nexthop(ri
);
4301 bgp_info_delete (rn
, ri
);
4302 bgp_process (bgp
, rn
, afi
, safi
);
4309 * Purge all networks and redistributed routes from routing table.
4310 * Invoked upon the instance going down.
4313 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4318 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4319 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4320 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4325 * Currently this is used to set static routes for VPN and ENCAP.
4326 * I think it can probably be factored with bgp_static_set.
4329 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4330 const char *rd_str
, const char *tag_str
,
4331 const char *rmap_str
)
4335 struct prefix_rd prd
;
4337 struct bgp_node
*prn
;
4338 struct bgp_node
*rn
;
4339 struct bgp_table
*table
;
4340 struct bgp_static
*bgp_static
;
4345 ret
= str2prefix (ip_str
, &p
);
4348 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4353 ret
= str2prefix_rd (rd_str
, &prd
);
4356 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4360 ret
= str2tag (tag_str
, tag
);
4363 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4367 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4368 (struct prefix
*)&prd
);
4369 if (prn
->info
== NULL
)
4370 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4372 bgp_unlock_node (prn
);
4375 rn
= bgp_node_get (table
, &p
);
4379 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4380 bgp_unlock_node (rn
);
4384 /* New configuration. */
4385 bgp_static
= bgp_static_new ();
4386 bgp_static
->backdoor
= 0;
4387 bgp_static
->valid
= 0;
4388 bgp_static
->igpmetric
= 0;
4389 bgp_static
->igpnexthop
.s_addr
= 0;
4390 memcpy(bgp_static
->tag
, tag
, 3);
4391 bgp_static
->prd
= prd
;
4395 if (bgp_static
->rmap
.name
)
4396 free (bgp_static
->rmap
.name
);
4397 bgp_static
->rmap
.name
= strdup (rmap_str
);
4398 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4400 rn
->info
= bgp_static
;
4402 bgp_static
->valid
= 1;
4403 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4409 /* Configure static BGP network. */
4411 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4412 const char *rd_str
, const char *tag_str
)
4417 struct prefix_rd prd
;
4418 struct bgp_node
*prn
;
4419 struct bgp_node
*rn
;
4420 struct bgp_table
*table
;
4421 struct bgp_static
*bgp_static
;
4426 /* Convert IP prefix string to struct prefix. */
4427 ret
= str2prefix (ip_str
, &p
);
4430 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4435 ret
= str2prefix_rd (rd_str
, &prd
);
4438 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4442 ret
= str2tag (tag_str
, tag
);
4445 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4449 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4450 (struct prefix
*)&prd
);
4451 if (prn
->info
== NULL
)
4452 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4454 bgp_unlock_node (prn
);
4457 rn
= bgp_node_lookup (table
, &p
);
4461 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4463 bgp_static
= rn
->info
;
4464 bgp_static_free (bgp_static
);
4466 bgp_unlock_node (rn
);
4467 bgp_unlock_node (rn
);
4470 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4476 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4477 const char *rmap_name
)
4479 struct bgp_rmap
*rmap
;
4481 rmap
= &bgp
->table_map
[afi
][safi
];
4485 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4486 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4487 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4492 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4497 bgp_zebra_announce_table(bgp
, afi
, safi
);
4503 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4504 const char *rmap_name
)
4506 struct bgp_rmap
*rmap
;
4508 rmap
= &bgp
->table_map
[afi
][safi
];
4510 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4514 bgp_zebra_announce_table(bgp
, afi
, safi
);
4520 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4521 safi_t safi
, int *write
)
4523 if (bgp
->table_map
[afi
][safi
].name
)
4525 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4526 vty_out (vty
, " table-map %s%s",
4527 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4533 DEFUN (bgp_table_map
,
4536 "BGP table to RIB route download filter\n"
4537 "Name of the route map\n")
4539 return bgp_table_map_set (vty
, vty
->index
,
4540 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4542 DEFUN (no_bgp_table_map
,
4543 no_bgp_table_map_cmd
,
4544 "no table-map WORD",
4545 "BGP table to RIB route download filter\n"
4546 "Name of the route map\n")
4548 return bgp_table_map_unset (vty
, vty
->index
,
4549 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4554 "network A.B.C.D/M",
4555 "Specify a network to announce via BGP\n"
4556 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4558 return bgp_static_set (vty
, vty
->index
, argv
[0],
4559 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4562 DEFUN (bgp_network_route_map
,
4563 bgp_network_route_map_cmd
,
4564 "network A.B.C.D/M route-map WORD",
4565 "Specify a network to announce via BGP\n"
4566 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4567 "Route-map to modify the attributes\n"
4568 "Name of the route map\n")
4570 return bgp_static_set (vty
, vty
->index
, argv
[0],
4571 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4574 DEFUN (bgp_network_backdoor
,
4575 bgp_network_backdoor_cmd
,
4576 "network A.B.C.D/M backdoor",
4577 "Specify a network to announce via BGP\n"
4578 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4579 "Specify a BGP backdoor route\n")
4581 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4585 DEFUN (bgp_network_mask
,
4586 bgp_network_mask_cmd
,
4587 "network A.B.C.D mask A.B.C.D",
4588 "Specify a network to announce via BGP\n"
4594 char prefix_str
[BUFSIZ
];
4596 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4599 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4603 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4604 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4607 DEFUN (bgp_network_mask_route_map
,
4608 bgp_network_mask_route_map_cmd
,
4609 "network A.B.C.D mask A.B.C.D route-map WORD",
4610 "Specify a network to announce via BGP\n"
4614 "Route-map to modify the attributes\n"
4615 "Name of the route map\n")
4618 char prefix_str
[BUFSIZ
];
4620 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4623 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4627 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4628 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4631 DEFUN (bgp_network_mask_backdoor
,
4632 bgp_network_mask_backdoor_cmd
,
4633 "network A.B.C.D mask A.B.C.D backdoor",
4634 "Specify a network to announce via BGP\n"
4638 "Specify a BGP backdoor route\n")
4641 char prefix_str
[BUFSIZ
];
4643 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4646 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4650 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4654 DEFUN (bgp_network_mask_natural
,
4655 bgp_network_mask_natural_cmd
,
4657 "Specify a network to announce via BGP\n"
4661 char prefix_str
[BUFSIZ
];
4663 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4666 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4670 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4671 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4674 DEFUN (bgp_network_mask_natural_route_map
,
4675 bgp_network_mask_natural_route_map_cmd
,
4676 "network A.B.C.D route-map WORD",
4677 "Specify a network to announce via BGP\n"
4679 "Route-map to modify the attributes\n"
4680 "Name of the route map\n")
4683 char prefix_str
[BUFSIZ
];
4685 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4688 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4692 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4693 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4696 DEFUN (bgp_network_mask_natural_backdoor
,
4697 bgp_network_mask_natural_backdoor_cmd
,
4698 "network A.B.C.D backdoor",
4699 "Specify a network to announce via BGP\n"
4701 "Specify a BGP backdoor route\n")
4704 char prefix_str
[BUFSIZ
];
4706 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4709 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4713 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4717 DEFUN (no_bgp_network
,
4719 "no network A.B.C.D/M",
4721 "Specify a network to announce via BGP\n"
4722 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4724 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4725 bgp_node_safi (vty
));
4728 ALIAS (no_bgp_network
,
4729 no_bgp_network_route_map_cmd
,
4730 "no network A.B.C.D/M route-map WORD",
4732 "Specify a network to announce via BGP\n"
4733 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4734 "Route-map to modify the attributes\n"
4735 "Name of the route map\n")
4737 ALIAS (no_bgp_network
,
4738 no_bgp_network_backdoor_cmd
,
4739 "no network A.B.C.D/M backdoor",
4741 "Specify a network to announce via BGP\n"
4742 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4743 "Specify a BGP backdoor route\n")
4745 DEFUN (no_bgp_network_mask
,
4746 no_bgp_network_mask_cmd
,
4747 "no network A.B.C.D mask A.B.C.D",
4749 "Specify a network to announce via BGP\n"
4755 char prefix_str
[BUFSIZ
];
4757 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4760 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4764 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4765 bgp_node_safi (vty
));
4768 ALIAS (no_bgp_network_mask
,
4769 no_bgp_network_mask_route_map_cmd
,
4770 "no network A.B.C.D mask A.B.C.D route-map WORD",
4772 "Specify a network to announce via BGP\n"
4776 "Route-map to modify the attributes\n"
4777 "Name of the route map\n")
4779 ALIAS (no_bgp_network_mask
,
4780 no_bgp_network_mask_backdoor_cmd
,
4781 "no network A.B.C.D mask A.B.C.D backdoor",
4783 "Specify a network to announce via BGP\n"
4787 "Specify a BGP backdoor route\n")
4789 DEFUN (no_bgp_network_mask_natural
,
4790 no_bgp_network_mask_natural_cmd
,
4791 "no network A.B.C.D",
4793 "Specify a network to announce via BGP\n"
4797 char prefix_str
[BUFSIZ
];
4799 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4802 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4806 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4807 bgp_node_safi (vty
));
4810 ALIAS (no_bgp_network_mask_natural
,
4811 no_bgp_network_mask_natural_route_map_cmd
,
4812 "no network A.B.C.D route-map WORD",
4814 "Specify a network to announce via BGP\n"
4816 "Route-map to modify the attributes\n"
4817 "Name of the route map\n")
4819 ALIAS (no_bgp_network_mask_natural
,
4820 no_bgp_network_mask_natural_backdoor_cmd
,
4821 "no network A.B.C.D backdoor",
4823 "Specify a network to announce via BGP\n"
4825 "Specify a BGP backdoor route\n")
4828 DEFUN (ipv6_bgp_network
,
4829 ipv6_bgp_network_cmd
,
4830 "network X:X::X:X/M",
4831 "Specify a network to announce via BGP\n"
4832 "IPv6 prefix <network>/<length>\n")
4834 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4838 DEFUN (ipv6_bgp_network_route_map
,
4839 ipv6_bgp_network_route_map_cmd
,
4840 "network X:X::X:X/M route-map WORD",
4841 "Specify a network to announce via BGP\n"
4842 "IPv6 prefix <network>/<length>\n"
4843 "Route-map to modify the attributes\n"
4844 "Name of the route map\n")
4846 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4847 bgp_node_safi (vty
), argv
[1], 0);
4850 DEFUN (no_ipv6_bgp_network
,
4851 no_ipv6_bgp_network_cmd
,
4852 "no network X:X::X:X/M",
4854 "Specify a network to announce via BGP\n"
4855 "IPv6 prefix <network>/<length>\n")
4857 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4860 ALIAS (no_ipv6_bgp_network
,
4861 no_ipv6_bgp_network_route_map_cmd
,
4862 "no network X:X::X:X/M route-map WORD",
4864 "Specify a network to announce via BGP\n"
4865 "IPv6 prefix <network>/<length>\n"
4866 "Route-map to modify the attributes\n"
4867 "Name of the route map\n")
4869 ALIAS (ipv6_bgp_network
,
4870 old_ipv6_bgp_network_cmd
,
4871 "ipv6 bgp network X:X::X:X/M",
4874 "Specify a network to announce via BGP\n"
4875 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4877 ALIAS (no_ipv6_bgp_network
,
4878 old_no_ipv6_bgp_network_cmd
,
4879 "no ipv6 bgp network X:X::X:X/M",
4883 "Specify a network to announce via BGP\n"
4884 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4885 #endif /* HAVE_IPV6 */
4887 /* Aggreagete address:
4889 advertise-map Set condition to advertise attribute
4890 as-set Generate AS set path information
4891 attribute-map Set attributes of aggregate
4892 route-map Set parameters of aggregate
4893 summary-only Filter more specific routes from updates
4894 suppress-map Conditionally filter more specific routes from updates
4897 struct bgp_aggregate
4899 /* Summary-only flag. */
4900 u_char summary_only
;
4902 /* AS set generation. */
4905 /* Route-map for aggregated route. */
4906 struct route_map
*map
;
4908 /* Suppress-count. */
4909 unsigned long count
;
4911 /* SAFI configuration. */
4915 static struct bgp_aggregate
*
4916 bgp_aggregate_new (void)
4918 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4922 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4924 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4927 /* Update an aggregate as routes are added/removed from the BGP table */
4929 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4930 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4931 struct bgp_aggregate
*aggregate
)
4933 struct bgp_table
*table
;
4934 struct bgp_node
*top
;
4935 struct bgp_node
*rn
;
4937 struct aspath
*aspath
= NULL
;
4938 struct aspath
*asmerge
= NULL
;
4939 struct community
*community
= NULL
;
4940 struct community
*commerge
= NULL
;
4941 #if defined(AGGREGATE_NEXTHOP_CHECK)
4942 struct in_addr nexthop
;
4945 struct bgp_info
*ri
;
4946 struct bgp_info
*new;
4948 unsigned long match
= 0;
4949 u_char atomic_aggregate
= 0;
4951 /* Record adding route's nexthop and med. */
4954 #if defined(AGGREGATE_NEXTHOP_CHECK)
4955 nexthop
= rinew
->attr
->nexthop
;
4956 med
= rinew
->attr
->med
;
4960 /* ORIGIN attribute: If at least one route among routes that are
4961 aggregated has ORIGIN with the value INCOMPLETE, then the
4962 aggregated route must have the ORIGIN attribute with the value
4963 INCOMPLETE. Otherwise, if at least one route among routes that
4964 are aggregated has ORIGIN with the value EGP, then the aggregated
4965 route must have the origin attribute with the value EGP. In all
4966 other case the value of the ORIGIN attribute of the aggregated
4967 route is INTERNAL. */
4968 origin
= BGP_ORIGIN_IGP
;
4970 table
= bgp
->rib
[afi
][safi
];
4972 top
= bgp_node_get (table
, p
);
4973 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4974 if (rn
->p
.prefixlen
> p
->prefixlen
)
4978 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4980 if (BGP_INFO_HOLDDOWN (ri
))
4983 if (del
&& ri
== del
)
4986 if (! rinew
&& first
)
4988 #if defined(AGGREGATE_NEXTHOP_CHECK)
4989 nexthop
= ri
->attr
->nexthop
;
4990 med
= ri
->attr
->med
;
4995 #ifdef AGGREGATE_NEXTHOP_CHECK
4996 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4997 || ri
->attr
->med
!= med
)
5000 aspath_free (aspath
);
5002 community_free (community
);
5003 bgp_unlock_node (rn
);
5004 bgp_unlock_node (top
);
5007 #endif /* AGGREGATE_NEXTHOP_CHECK */
5009 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5010 atomic_aggregate
= 1;
5012 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5014 if (aggregate
->summary_only
)
5016 (bgp_info_extra_get (ri
))->suppress
++;
5017 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5023 if (origin
< ri
->attr
->origin
)
5024 origin
= ri
->attr
->origin
;
5026 if (aggregate
->as_set
)
5030 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5031 aspath_free (aspath
);
5035 aspath
= aspath_dup (ri
->attr
->aspath
);
5037 if (ri
->attr
->community
)
5041 commerge
= community_merge (community
,
5042 ri
->attr
->community
);
5043 community
= community_uniq_sort (commerge
);
5044 community_free (commerge
);
5047 community
= community_dup (ri
->attr
->community
);
5053 bgp_process (bgp
, rn
, afi
, safi
);
5055 bgp_unlock_node (top
);
5061 if (aggregate
->summary_only
)
5062 (bgp_info_extra_get (rinew
))->suppress
++;
5064 if (origin
< rinew
->attr
->origin
)
5065 origin
= rinew
->attr
->origin
;
5067 if (aggregate
->as_set
)
5071 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
5072 aspath_free (aspath
);
5076 aspath
= aspath_dup (rinew
->attr
->aspath
);
5078 if (rinew
->attr
->community
)
5082 commerge
= community_merge (community
,
5083 rinew
->attr
->community
);
5084 community
= community_uniq_sort (commerge
);
5085 community_free (commerge
);
5088 community
= community_dup (rinew
->attr
->community
);
5093 if (aggregate
->count
> 0)
5095 rn
= bgp_node_get (table
, p
);
5096 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5097 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5099 atomic_aggregate
), rn
);
5100 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5102 bgp_info_add (rn
, new);
5103 bgp_unlock_node (rn
);
5104 bgp_process (bgp
, rn
, afi
, safi
);
5109 aspath_free (aspath
);
5111 community_free (community
);
5115 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
5116 struct bgp_aggregate
*);
5119 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
5120 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
5122 struct bgp_node
*child
;
5123 struct bgp_node
*rn
;
5124 struct bgp_aggregate
*aggregate
;
5125 struct bgp_table
*table
;
5127 /* MPLS-VPN aggregation is not yet supported. */
5128 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5131 table
= bgp
->aggregate
[afi
][safi
];
5133 /* No aggregates configured. */
5134 if (bgp_table_top_nolock (table
) == NULL
)
5137 if (p
->prefixlen
== 0)
5140 if (BGP_INFO_HOLDDOWN (ri
))
5143 child
= bgp_node_get (table
, p
);
5145 /* Aggregate address configuration check. */
5146 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5147 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5149 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5150 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
5152 bgp_unlock_node (child
);
5156 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
5157 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
5159 struct bgp_node
*child
;
5160 struct bgp_node
*rn
;
5161 struct bgp_aggregate
*aggregate
;
5162 struct bgp_table
*table
;
5164 /* MPLS-VPN aggregation is not yet supported. */
5165 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5168 table
= bgp
->aggregate
[afi
][safi
];
5170 /* No aggregates configured. */
5171 if (bgp_table_top_nolock (table
) == NULL
)
5174 if (p
->prefixlen
== 0)
5177 child
= bgp_node_get (table
, p
);
5179 /* Aggregate address configuration check. */
5180 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5181 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5183 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5184 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
5186 bgp_unlock_node (child
);
5189 /* Called via bgp_aggregate_set when the user configures aggregate-address */
5191 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
5192 struct bgp_aggregate
*aggregate
)
5194 struct bgp_table
*table
;
5195 struct bgp_node
*top
;
5196 struct bgp_node
*rn
;
5197 struct bgp_info
*new;
5198 struct bgp_info
*ri
;
5199 unsigned long match
;
5200 u_char origin
= BGP_ORIGIN_IGP
;
5201 struct aspath
*aspath
= NULL
;
5202 struct aspath
*asmerge
= NULL
;
5203 struct community
*community
= NULL
;
5204 struct community
*commerge
= NULL
;
5205 u_char atomic_aggregate
= 0;
5207 table
= bgp
->rib
[afi
][safi
];
5210 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5212 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5215 /* If routes exists below this node, generate aggregate routes. */
5216 top
= bgp_node_get (table
, p
);
5217 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5218 if (rn
->p
.prefixlen
> p
->prefixlen
)
5222 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5224 if (BGP_INFO_HOLDDOWN (ri
))
5227 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5228 atomic_aggregate
= 1;
5230 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5232 /* summary-only aggregate route suppress aggregated
5233 route announcement. */
5234 if (aggregate
->summary_only
)
5236 (bgp_info_extra_get (ri
))->suppress
++;
5237 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5241 /* If at least one route among routes that are aggregated has
5242 * ORIGIN with the value INCOMPLETE, then the aggregated route
5243 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5244 * Otherwise, if at least one route among routes that are
5245 * aggregated has ORIGIN with the value EGP, then the aggregated
5246 * route MUST have the ORIGIN attribute with the value EGP.
5248 if (origin
< ri
->attr
->origin
)
5249 origin
= ri
->attr
->origin
;
5251 /* as-set aggregate route generate origin, as path,
5252 community aggregation. */
5253 if (aggregate
->as_set
)
5257 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5258 aspath_free (aspath
);
5262 aspath
= aspath_dup (ri
->attr
->aspath
);
5264 if (ri
->attr
->community
)
5268 commerge
= community_merge (community
,
5269 ri
->attr
->community
);
5270 community
= community_uniq_sort (commerge
);
5271 community_free (commerge
);
5274 community
= community_dup (ri
->attr
->community
);
5281 /* If this node is suppressed, process the change. */
5283 bgp_process (bgp
, rn
, afi
, safi
);
5285 bgp_unlock_node (top
);
5287 /* Add aggregate route to BGP table. */
5288 if (aggregate
->count
)
5290 rn
= bgp_node_get (table
, p
);
5291 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5292 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5294 atomic_aggregate
), rn
);
5295 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5297 bgp_info_add (rn
, new);
5298 bgp_unlock_node (rn
);
5300 /* Process change. */
5301 bgp_process (bgp
, rn
, afi
, safi
);
5306 aspath_free (aspath
);
5308 community_free (community
);
5313 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5314 safi_t safi
, struct bgp_aggregate
*aggregate
)
5316 struct bgp_table
*table
;
5317 struct bgp_node
*top
;
5318 struct bgp_node
*rn
;
5319 struct bgp_info
*ri
;
5320 unsigned long match
;
5322 table
= bgp
->rib
[afi
][safi
];
5324 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5326 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5329 /* If routes exists below this node, generate aggregate routes. */
5330 top
= bgp_node_get (table
, p
);
5331 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5332 if (rn
->p
.prefixlen
> p
->prefixlen
)
5336 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5338 if (BGP_INFO_HOLDDOWN (ri
))
5341 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5343 if (aggregate
->summary_only
&& ri
->extra
)
5345 ri
->extra
->suppress
--;
5347 if (ri
->extra
->suppress
== 0)
5349 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5357 /* If this node was suppressed, process the change. */
5359 bgp_process (bgp
, rn
, afi
, safi
);
5361 bgp_unlock_node (top
);
5363 /* Delete aggregate route from BGP table. */
5364 rn
= bgp_node_get (table
, p
);
5366 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5367 if (ri
->peer
== bgp
->peer_self
5368 && ri
->type
== ZEBRA_ROUTE_BGP
5369 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5372 /* Withdraw static BGP route from routing table. */
5375 bgp_info_delete (rn
, ri
);
5376 bgp_process (bgp
, rn
, afi
, safi
);
5379 /* Unlock bgp_node_lookup. */
5380 bgp_unlock_node (rn
);
5383 /* Aggregate route attribute. */
5384 #define AGGREGATE_SUMMARY_ONLY 1
5385 #define AGGREGATE_AS_SET 1
5388 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5389 afi_t afi
, safi_t safi
)
5393 struct bgp_node
*rn
;
5395 struct bgp_aggregate
*aggregate
;
5397 /* Convert string to prefix structure. */
5398 ret
= str2prefix (prefix_str
, &p
);
5401 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5406 /* Get BGP structure. */
5409 /* Old configuration check. */
5410 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5413 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5418 aggregate
= rn
->info
;
5419 if (aggregate
->safi
& SAFI_UNICAST
)
5420 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5421 if (aggregate
->safi
& SAFI_MULTICAST
)
5422 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5424 /* Unlock aggregate address configuration. */
5426 bgp_aggregate_free (aggregate
);
5427 bgp_unlock_node (rn
);
5428 bgp_unlock_node (rn
);
5434 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5435 afi_t afi
, safi_t safi
,
5436 u_char summary_only
, u_char as_set
)
5440 struct bgp_node
*rn
;
5442 struct bgp_aggregate
*aggregate
;
5444 /* Convert string to prefix structure. */
5445 ret
= str2prefix (prefix_str
, &p
);
5448 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5453 /* Get BGP structure. */
5456 /* Old configuration check. */
5457 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5461 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5462 /* try to remove the old entry */
5463 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5466 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5467 bgp_unlock_node (rn
);
5472 /* Make aggregate address structure. */
5473 aggregate
= bgp_aggregate_new ();
5474 aggregate
->summary_only
= summary_only
;
5475 aggregate
->as_set
= as_set
;
5476 aggregate
->safi
= safi
;
5477 rn
->info
= aggregate
;
5479 /* Aggregate address insert into BGP routing table. */
5480 if (safi
& SAFI_UNICAST
)
5481 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5482 if (safi
& SAFI_MULTICAST
)
5483 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5488 DEFUN (aggregate_address
,
5489 aggregate_address_cmd
,
5490 "aggregate-address A.B.C.D/M",
5491 "Configure BGP aggregate entries\n"
5492 "Aggregate prefix\n")
5494 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5497 DEFUN (aggregate_address_mask
,
5498 aggregate_address_mask_cmd
,
5499 "aggregate-address A.B.C.D A.B.C.D",
5500 "Configure BGP aggregate entries\n"
5501 "Aggregate address\n"
5505 char prefix_str
[BUFSIZ
];
5507 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5511 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5515 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5519 DEFUN (aggregate_address_summary_only
,
5520 aggregate_address_summary_only_cmd
,
5521 "aggregate-address A.B.C.D/M summary-only",
5522 "Configure BGP aggregate entries\n"
5523 "Aggregate prefix\n"
5524 "Filter more specific routes from updates\n")
5526 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5527 AGGREGATE_SUMMARY_ONLY
, 0);
5530 DEFUN (aggregate_address_mask_summary_only
,
5531 aggregate_address_mask_summary_only_cmd
,
5532 "aggregate-address A.B.C.D A.B.C.D summary-only",
5533 "Configure BGP aggregate entries\n"
5534 "Aggregate address\n"
5536 "Filter more specific routes from updates\n")
5539 char prefix_str
[BUFSIZ
];
5541 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5545 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5549 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5550 AGGREGATE_SUMMARY_ONLY
, 0);
5553 DEFUN (aggregate_address_as_set
,
5554 aggregate_address_as_set_cmd
,
5555 "aggregate-address A.B.C.D/M as-set",
5556 "Configure BGP aggregate entries\n"
5557 "Aggregate prefix\n"
5558 "Generate AS set path information\n")
5560 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5561 0, AGGREGATE_AS_SET
);
5564 DEFUN (aggregate_address_mask_as_set
,
5565 aggregate_address_mask_as_set_cmd
,
5566 "aggregate-address A.B.C.D A.B.C.D as-set",
5567 "Configure BGP aggregate entries\n"
5568 "Aggregate address\n"
5570 "Generate AS set path information\n")
5573 char prefix_str
[BUFSIZ
];
5575 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5579 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5583 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5584 0, AGGREGATE_AS_SET
);
5588 DEFUN (aggregate_address_as_set_summary
,
5589 aggregate_address_as_set_summary_cmd
,
5590 "aggregate-address A.B.C.D/M as-set summary-only",
5591 "Configure BGP aggregate entries\n"
5592 "Aggregate prefix\n"
5593 "Generate AS set path information\n"
5594 "Filter more specific routes from updates\n")
5596 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5597 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5600 ALIAS (aggregate_address_as_set_summary
,
5601 aggregate_address_summary_as_set_cmd
,
5602 "aggregate-address A.B.C.D/M summary-only as-set",
5603 "Configure BGP aggregate entries\n"
5604 "Aggregate prefix\n"
5605 "Filter more specific routes from updates\n"
5606 "Generate AS set path information\n")
5608 DEFUN (aggregate_address_mask_as_set_summary
,
5609 aggregate_address_mask_as_set_summary_cmd
,
5610 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5611 "Configure BGP aggregate entries\n"
5612 "Aggregate address\n"
5614 "Generate AS set path information\n"
5615 "Filter more specific routes from updates\n")
5618 char prefix_str
[BUFSIZ
];
5620 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5624 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5628 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5629 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5632 ALIAS (aggregate_address_mask_as_set_summary
,
5633 aggregate_address_mask_summary_as_set_cmd
,
5634 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5635 "Configure BGP aggregate entries\n"
5636 "Aggregate address\n"
5638 "Filter more specific routes from updates\n"
5639 "Generate AS set path information\n")
5641 DEFUN (no_aggregate_address
,
5642 no_aggregate_address_cmd
,
5643 "no aggregate-address A.B.C.D/M",
5645 "Configure BGP aggregate entries\n"
5646 "Aggregate prefix\n")
5648 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5651 ALIAS (no_aggregate_address
,
5652 no_aggregate_address_summary_only_cmd
,
5653 "no aggregate-address A.B.C.D/M summary-only",
5655 "Configure BGP aggregate entries\n"
5656 "Aggregate prefix\n"
5657 "Filter more specific routes from updates\n")
5659 ALIAS (no_aggregate_address
,
5660 no_aggregate_address_as_set_cmd
,
5661 "no aggregate-address A.B.C.D/M as-set",
5663 "Configure BGP aggregate entries\n"
5664 "Aggregate prefix\n"
5665 "Generate AS set path information\n")
5667 ALIAS (no_aggregate_address
,
5668 no_aggregate_address_as_set_summary_cmd
,
5669 "no aggregate-address A.B.C.D/M as-set summary-only",
5671 "Configure BGP aggregate entries\n"
5672 "Aggregate prefix\n"
5673 "Generate AS set path information\n"
5674 "Filter more specific routes from updates\n")
5676 ALIAS (no_aggregate_address
,
5677 no_aggregate_address_summary_as_set_cmd
,
5678 "no aggregate-address A.B.C.D/M summary-only as-set",
5680 "Configure BGP aggregate entries\n"
5681 "Aggregate prefix\n"
5682 "Filter more specific routes from updates\n"
5683 "Generate AS set path information\n")
5685 DEFUN (no_aggregate_address_mask
,
5686 no_aggregate_address_mask_cmd
,
5687 "no aggregate-address A.B.C.D A.B.C.D",
5689 "Configure BGP aggregate entries\n"
5690 "Aggregate address\n"
5694 char prefix_str
[BUFSIZ
];
5696 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5700 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5704 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5707 ALIAS (no_aggregate_address_mask
,
5708 no_aggregate_address_mask_summary_only_cmd
,
5709 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5711 "Configure BGP aggregate entries\n"
5712 "Aggregate address\n"
5714 "Filter more specific routes from updates\n")
5716 ALIAS (no_aggregate_address_mask
,
5717 no_aggregate_address_mask_as_set_cmd
,
5718 "no aggregate-address A.B.C.D A.B.C.D as-set",
5720 "Configure BGP aggregate entries\n"
5721 "Aggregate address\n"
5723 "Generate AS set path information\n")
5725 ALIAS (no_aggregate_address_mask
,
5726 no_aggregate_address_mask_as_set_summary_cmd
,
5727 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5729 "Configure BGP aggregate entries\n"
5730 "Aggregate address\n"
5732 "Generate AS set path information\n"
5733 "Filter more specific routes from updates\n")
5735 ALIAS (no_aggregate_address_mask
,
5736 no_aggregate_address_mask_summary_as_set_cmd
,
5737 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5739 "Configure BGP aggregate entries\n"
5740 "Aggregate address\n"
5742 "Filter more specific routes from updates\n"
5743 "Generate AS set path information\n")
5746 DEFUN (ipv6_aggregate_address
,
5747 ipv6_aggregate_address_cmd
,
5748 "aggregate-address X:X::X:X/M",
5749 "Configure BGP aggregate entries\n"
5750 "Aggregate prefix\n")
5752 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5755 DEFUN (ipv6_aggregate_address_summary_only
,
5756 ipv6_aggregate_address_summary_only_cmd
,
5757 "aggregate-address X:X::X:X/M summary-only",
5758 "Configure BGP aggregate entries\n"
5759 "Aggregate prefix\n"
5760 "Filter more specific routes from updates\n")
5762 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5763 AGGREGATE_SUMMARY_ONLY
, 0);
5766 DEFUN (no_ipv6_aggregate_address
,
5767 no_ipv6_aggregate_address_cmd
,
5768 "no aggregate-address X:X::X:X/M",
5770 "Configure BGP aggregate entries\n"
5771 "Aggregate prefix\n")
5773 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5776 DEFUN (no_ipv6_aggregate_address_summary_only
,
5777 no_ipv6_aggregate_address_summary_only_cmd
,
5778 "no aggregate-address X:X::X:X/M summary-only",
5780 "Configure BGP aggregate entries\n"
5781 "Aggregate prefix\n"
5782 "Filter more specific routes from updates\n")
5784 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5787 ALIAS (ipv6_aggregate_address
,
5788 old_ipv6_aggregate_address_cmd
,
5789 "ipv6 bgp aggregate-address X:X::X:X/M",
5792 "Configure BGP aggregate entries\n"
5793 "Aggregate prefix\n")
5795 ALIAS (ipv6_aggregate_address_summary_only
,
5796 old_ipv6_aggregate_address_summary_only_cmd
,
5797 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5800 "Configure BGP aggregate entries\n"
5801 "Aggregate prefix\n"
5802 "Filter more specific routes from updates\n")
5804 ALIAS (no_ipv6_aggregate_address
,
5805 old_no_ipv6_aggregate_address_cmd
,
5806 "no ipv6 bgp aggregate-address X:X::X:X/M",
5810 "Configure BGP aggregate entries\n"
5811 "Aggregate prefix\n")
5813 ALIAS (no_ipv6_aggregate_address_summary_only
,
5814 old_no_ipv6_aggregate_address_summary_only_cmd
,
5815 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5819 "Configure BGP aggregate entries\n"
5820 "Aggregate prefix\n"
5821 "Filter more specific routes from updates\n")
5822 #endif /* HAVE_IPV6 */
5824 /* Redistribute route treatment. */
5826 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5827 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5828 u_int32_t metric
, u_char type
, u_short instance
, route_tag_t tag
)
5830 struct bgp_info
*new;
5831 struct bgp_info
*bi
;
5832 struct bgp_info info
;
5833 struct bgp_node
*bn
;
5835 struct attr
*new_attr
;
5838 struct bgp_redist
*red
;
5840 /* Make default attribute. */
5841 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5843 attr
.nexthop
= *nexthop
;
5844 attr
.nh_ifindex
= ifindex
;
5849 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5850 extra
->mp_nexthop_global
= *nexthop6
;
5851 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5856 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5857 attr
.extra
->tag
= tag
;
5859 afi
= family2afi (p
->family
);
5861 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5864 struct attr attr_new
;
5865 struct attr_extra extra_new
;
5867 /* Copy attribute for modification. */
5868 attr_new
.extra
= &extra_new
;
5869 bgp_attr_dup (&attr_new
, &attr
);
5871 if (red
->redist_metric_flag
)
5872 attr_new
.med
= red
->redist_metric
;
5874 /* Apply route-map. */
5877 info
.peer
= bgp
->peer_self
;
5878 info
.attr
= &attr_new
;
5880 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5882 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5884 bgp
->peer_self
->rmap_type
= 0;
5886 if (ret
== RMAP_DENYMATCH
)
5888 /* Free uninterned attribute. */
5889 bgp_attr_flush (&attr_new
);
5891 /* Unintern original. */
5892 aspath_unintern (&attr
.aspath
);
5893 bgp_attr_extra_free (&attr
);
5894 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5899 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5900 afi
, SAFI_UNICAST
, p
, NULL
);
5902 new_attr
= bgp_attr_intern (&attr_new
);
5904 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5905 if (bi
->peer
== bgp
->peer_self
5906 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5911 /* Ensure the (source route) type is updated. */
5913 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5914 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5916 bgp_attr_unintern (&new_attr
);
5917 aspath_unintern (&attr
.aspath
);
5918 bgp_attr_extra_free (&attr
);
5919 bgp_unlock_node (bn
);
5924 /* The attribute is changed. */
5925 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5927 /* Rewrite BGP route information. */
5928 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5929 bgp_info_restore(bn
, bi
);
5931 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5932 bgp_attr_unintern (&bi
->attr
);
5933 bi
->attr
= new_attr
;
5934 bi
->uptime
= bgp_clock ();
5936 /* Process change. */
5937 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5938 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5939 bgp_unlock_node (bn
);
5940 aspath_unintern (&attr
.aspath
);
5941 bgp_attr_extra_free (&attr
);
5946 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5948 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5950 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5951 bgp_info_add (bn
, new);
5952 bgp_unlock_node (bn
);
5953 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5956 /* Unintern original. */
5957 aspath_unintern (&attr
.aspath
);
5958 bgp_attr_extra_free (&attr
);
5962 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5965 struct bgp_node
*rn
;
5966 struct bgp_info
*ri
;
5967 struct bgp_redist
*red
;
5969 afi
= family2afi (p
->family
);
5971 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5974 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5976 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5977 if (ri
->peer
== bgp
->peer_self
5978 && ri
->type
== type
)
5983 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5984 bgp_info_delete (rn
, ri
);
5985 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5987 bgp_unlock_node (rn
);
5991 /* Withdraw specified route type's route. */
5993 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5995 struct bgp_node
*rn
;
5996 struct bgp_info
*ri
;
5997 struct bgp_table
*table
;
5999 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
6001 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
6003 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
6004 if (ri
->peer
== bgp
->peer_self
6006 && ri
->instance
== instance
)
6011 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
6012 bgp_info_delete (rn
, ri
);
6013 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
6018 /* Static function to display route. */
6020 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
6023 u_int32_t destination
;
6026 if (p
->family
== AF_INET
)
6028 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
6029 destination
= ntohl (p
->u
.prefix4
.s_addr
);
6031 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
6032 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
6033 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
6034 || p
->u
.prefix4
.s_addr
== 0)
6036 /* When mask is natural, mask is not displayed. */
6039 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
6042 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
6047 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
6049 vty_out (vty
, "%*s", len
, " ");
6052 enum bgp_display_type
6057 /* Print the short form route status for a bgp_info */
6059 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
6060 json_object
*json_path
)
6065 /* Route status display. */
6066 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6067 json_object_boolean_true_add(json_path
, "removed");
6069 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6070 json_object_boolean_true_add(json_path
, "stale");
6072 if (binfo
->extra
&& binfo
->extra
->suppress
)
6073 json_object_boolean_true_add(json_path
, "suppressed");
6075 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6076 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6077 json_object_boolean_true_add(json_path
, "valid");
6080 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6081 json_object_boolean_true_add(json_path
, "history");
6083 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6084 json_object_boolean_true_add(json_path
, "damped");
6086 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6087 json_object_boolean_true_add(json_path
, "bestpath");
6089 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6090 json_object_boolean_true_add(json_path
, "multipath");
6092 /* Internal route. */
6093 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6094 json_object_string_add(json_path
, "pathFrom", "internal");
6096 json_object_string_add(json_path
, "pathFrom", "external");
6101 /* Route status display. */
6102 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6104 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6106 else if (binfo
->extra
&& binfo
->extra
->suppress
)
6108 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6109 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6115 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6117 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6119 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6121 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6126 /* Internal route. */
6127 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6133 /* called from terminal list command */
6135 route_vty_out (struct vty
*vty
, struct prefix
*p
,
6136 struct bgp_info
*binfo
, int display
, safi_t safi
,
6137 json_object
*json_paths
)
6140 json_object
*json_path
= NULL
;
6141 json_object
*json_nexthops
= NULL
;
6142 json_object
*json_nexthop_global
= NULL
;
6143 json_object
*json_nexthop_ll
= NULL
;
6146 json_path
= json_object_new_object();
6148 /* short status lead text */
6149 route_vty_short_status_out (vty
, binfo
, json_path
);
6153 /* print prefix and mask */
6155 route_vty_out_route (p
, vty
);
6157 vty_out (vty
, "%*s", 17, " ");
6160 /* Print attribute */
6165 * For ENCAP routes, nexthop address family is not
6166 * neccessarily the same as the prefix address family.
6167 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
6169 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
6174 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
6179 vty_out (vty
, "%s", inet_ntop(af
,
6180 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
6184 vty_out (vty
, "%s", inet_ntop(af
,
6185 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
6197 else if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6201 json_nexthop_global
= json_object_new_object();
6203 if (safi
== SAFI_MPLS_VPN
)
6204 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6206 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6208 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6209 json_object_boolean_true_add(json_nexthop_global
, "used");
6213 if (safi
== SAFI_MPLS_VPN
)
6214 vty_out (vty
, "%-16s",
6215 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6217 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6222 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6229 json_nexthop_global
= json_object_new_object();
6230 json_object_string_add(json_nexthop_global
, "ip",
6231 inet_ntop (AF_INET6
,
6232 &attr
->extra
->mp_nexthop_global
,
6234 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6235 json_object_string_add(json_nexthop_global
, "scope", "global");
6237 /* We display both LL & GL if both have been received */
6238 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
6240 json_nexthop_ll
= json_object_new_object();
6241 json_object_string_add(json_nexthop_ll
, "ip",
6242 inet_ntop (AF_INET6
,
6243 &attr
->extra
->mp_nexthop_local
,
6245 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6246 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6248 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
6249 &attr
->extra
->mp_nexthop_local
) != 0) &&
6250 !attr
->extra
->mp_nexthop_prefer_global
)
6251 json_object_boolean_true_add(json_nexthop_ll
, "used");
6253 json_object_boolean_true_add(json_nexthop_global
, "used");
6256 json_object_boolean_true_add(json_nexthop_global
, "used");
6260 /* Display LL if LL/Global both in table unless prefer-global is set */
6261 if (((attr
->extra
->mp_nexthop_len
== 32) &&
6262 !attr
->extra
->mp_nexthop_prefer_global
) ||
6263 (binfo
->peer
->conf_if
))
6265 if (binfo
->peer
->conf_if
)
6267 len
= vty_out (vty
, "%s",
6268 binfo
->peer
->conf_if
);
6269 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6272 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6274 vty_out (vty
, "%*s", len
, " ");
6278 len
= vty_out (vty
, "%s",
6279 inet_ntop (AF_INET6
,
6280 &attr
->extra
->mp_nexthop_local
,
6285 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6287 vty_out (vty
, "%*s", len
, " ");
6292 len
= vty_out (vty
, "%s",
6293 inet_ntop (AF_INET6
,
6294 &attr
->extra
->mp_nexthop_global
,
6299 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6301 vty_out (vty
, "%*s", len
, " ");
6307 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6309 json_object_int_add(json_path
, "med", attr
->med
);
6311 vty_out (vty
, "%10u", attr
->med
);
6317 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6319 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6321 vty_out (vty
, "%7u", attr
->local_pref
);
6329 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6331 json_object_int_add(json_path
, "weight", 0);
6334 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6338 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6345 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6347 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6352 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6354 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6359 json_object_string_add(json_path
, "alert", "No attributes");
6361 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6366 if (json_nexthop_global
|| json_nexthop_ll
)
6368 json_nexthops
= json_object_new_array();
6370 if (json_nexthop_global
)
6371 json_object_array_add(json_nexthops
, json_nexthop_global
);
6373 if (json_nexthop_ll
)
6374 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6376 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6379 json_object_array_add(json_paths
, json_path
);
6383 vty_out (vty
, "%s", VTY_NEWLINE
);
6385 /* prints an additional line, indented, with VNC info, if present */
6386 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
6387 rfapi_vty_out_vncinfo(vty
, p
, binfo
, safi
);
6392 /* called from terminal list command */
6394 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6395 u_char use_json
, json_object
*json_ar
)
6397 json_object
*json_status
= NULL
;
6398 json_object
*json_net
= NULL
;
6400 /* Route status display. */
6403 json_status
= json_object_new_object();
6404 json_net
= json_object_new_object();
6413 /* print prefix and mask */
6415 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6417 route_vty_out_route (p
, vty
);
6419 /* Print attribute */
6424 if (p
->family
== AF_INET
&&
6425 (safi
== SAFI_MPLS_VPN
||
6426 safi
== SAFI_ENCAP
||
6427 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6429 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6430 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6432 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6435 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6439 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6442 #endif /* HAVE_IPV6 */
6444 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6445 json_object_int_add(json_net
, "metric", attr
->med
);
6447 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6448 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6451 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6453 json_object_int_add(json_net
, "weight", 0);
6457 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6460 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6464 if (p
->family
== AF_INET
&&
6465 (safi
== SAFI_MPLS_VPN
||
6466 safi
== SAFI_ENCAP
||
6467 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6470 (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
))
6471 vty_out (vty
, "%-16s",
6472 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6474 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6477 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6483 len
= vty_out (vty
, "%s",
6484 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6491 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6493 vty_out (vty
, "%*s", len
, " ");
6495 #endif /* HAVE_IPV6 */
6496 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6497 vty_out (vty
, "%10u", attr
->med
);
6501 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6502 vty_out (vty
, "%7u", attr
->local_pref
);
6506 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6510 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6513 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6518 json_object_boolean_true_add(json_status
, "*");
6519 json_object_boolean_true_add(json_status
, ">");
6520 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6521 char buf_cut
[BUFSIZ
];
6522 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6525 vty_out (vty
, "%s", VTY_NEWLINE
);
6529 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6530 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6532 json_object
*json_out
= NULL
;
6534 u_int32_t label
= 0;
6540 json_out
= json_object_new_object();
6542 /* short status lead text */
6543 route_vty_short_status_out (vty
, binfo
, json_out
);
6545 /* print prefix and mask */
6549 route_vty_out_route (p
, vty
);
6551 vty_out (vty
, "%*s", 17, " ");
6554 /* Print attribute */
6558 if (p
->family
== AF_INET
6559 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6561 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6564 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6566 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6571 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6573 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6577 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6579 assert (attr
->extra
);
6583 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6586 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6587 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6590 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6593 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6597 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6599 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6601 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6602 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6605 vty_out (vty
, "%s(%s)",
6606 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6608 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6613 #endif /* HAVE_IPV6 */
6616 label
= decode_label (binfo
->extra
->tag
);
6621 json_object_int_add(json_out
, "notag", label
);
6622 json_object_array_add(json
, json_out
);
6626 vty_out (vty
, "notag/%d", label
);
6627 vty_out (vty
, "%s", VTY_NEWLINE
);
6631 /* dampening route */
6633 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6634 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6638 char timebuf
[BGP_UPTIME_LEN
];
6640 /* short status lead text */
6641 route_vty_short_status_out (vty
, binfo
, json
);
6643 /* print prefix and mask */
6647 route_vty_out_route (p
, vty
);
6649 vty_out (vty
, "%*s", 17, " ");
6652 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6657 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6662 json_object_int_add(json
, "peerHost", len
);
6664 vty_out (vty
, "%*s", len
, " ");
6668 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6670 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6672 /* Print attribute */
6680 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6682 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6687 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6689 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6692 vty_out (vty
, "%s", VTY_NEWLINE
);
6697 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6698 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6701 struct bgp_damp_info
*bdi
;
6702 char timebuf
[BGP_UPTIME_LEN
];
6708 bdi
= binfo
->extra
->damp_info
;
6710 /* short status lead text */
6711 route_vty_short_status_out (vty
, binfo
, json
);
6713 /* print prefix and mask */
6717 route_vty_out_route (p
, vty
);
6719 vty_out (vty
, "%*s", 17, " ");
6722 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6727 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6732 json_object_int_add(json
, "peerHost", len
);
6734 vty_out (vty
, "%*s", len
, " ");
6737 len
= vty_out (vty
, "%d", bdi
->flap
);
6747 json_object_int_add(json
, "bdiFlap", len
);
6749 vty_out (vty
, "%*s", len
, " ");
6753 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6755 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6756 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6758 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6759 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6762 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6764 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6769 vty_out (vty
, "%*s ", 8, " ");
6772 /* Print attribute */
6780 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6782 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6787 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6789 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6792 vty_out (vty
, "%s", VTY_NEWLINE
);
6796 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6797 const char *header
, json_object
*json_adv_to
)
6799 char buf1
[INET6_ADDRSTRLEN
];
6800 json_object
*json_peer
= NULL
;
6804 /* 'advertised-to' is a dictionary of peers we have advertised this
6805 * prefix too. The key is the peer's IP or swpX, the value is the
6806 * hostname if we know it and "" if not.
6808 json_peer
= json_object_new_object();
6811 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6814 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6816 json_object_object_add(json_adv_to
,
6817 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6824 vty_out (vty
, "%s", header
);
6828 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6831 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6833 vty_out (vty
, " %s(%s)", peer
->hostname
,
6834 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6839 vty_out (vty
, " %s", peer
->conf_if
);
6841 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6847 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6848 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6849 json_object
*json_paths
)
6851 char buf
[INET6_ADDRSTRLEN
];
6854 int sockunion_vty_out (struct vty
*, union sockunion
*);
6855 #ifdef HAVE_CLOCK_MONOTONIC
6858 json_object
*json_bestpath
= NULL
;
6859 json_object
*json_cluster_list
= NULL
;
6860 json_object
*json_cluster_list_list
= NULL
;
6861 json_object
*json_ext_community
= NULL
;
6862 json_object
*json_last_update
= NULL
;
6863 json_object
*json_nexthop_global
= NULL
;
6864 json_object
*json_nexthop_ll
= NULL
;
6865 json_object
*json_nexthops
= NULL
;
6866 json_object
*json_path
= NULL
;
6867 json_object
*json_peer
= NULL
;
6868 json_object
*json_string
= NULL
;
6869 json_object
*json_adv_to
= NULL
;
6871 struct listnode
*node
, *nnode
;
6873 int addpath_capable
;
6875 unsigned int first_as
;
6879 json_path
= json_object_new_object();
6880 json_peer
= json_object_new_object();
6881 json_nexthop_global
= json_object_new_object();
6888 /* Line1 display AS-path, Aggregator */
6893 json_object_lock(attr
->aspath
->json
);
6894 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6898 if (attr
->aspath
->segments
)
6899 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6901 vty_out (vty
, " Local");
6905 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6908 json_object_boolean_true_add(json_path
, "removed");
6910 vty_out (vty
, ", (removed)");
6913 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6916 json_object_boolean_true_add(json_path
, "stale");
6918 vty_out (vty
, ", (stale)");
6921 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6925 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6926 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6930 vty_out (vty
, ", (aggregated by %u %s)",
6931 attr
->extra
->aggregator_as
,
6932 inet_ntoa (attr
->extra
->aggregator_addr
));
6936 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6939 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6941 vty_out (vty
, ", (Received from a RR-client)");
6944 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6947 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6949 vty_out (vty
, ", (Received from a RS-client)");
6952 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6955 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6957 vty_out (vty
, ", (history entry)");
6959 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6962 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6964 vty_out (vty
, ", (suppressed due to dampening)");
6968 vty_out (vty
, "%s", VTY_NEWLINE
);
6970 /* Line2 display Next-hop, Neighbor, Router-id */
6971 /* Display the nexthop */
6972 if (p
->family
== AF_INET
&&
6973 (safi
== SAFI_MPLS_VPN
||
6974 safi
== SAFI_ENCAP
||
6975 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6977 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6980 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6982 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6987 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6989 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6993 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6997 assert (attr
->extra
);
7000 json_object_string_add(json_nexthop_global
, "ip",
7001 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
7002 buf
, INET6_ADDRSTRLEN
));
7003 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
7004 json_object_string_add(json_nexthop_global
, "scope", "global");
7008 vty_out (vty
, " %s",
7009 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
7010 buf
, INET6_ADDRSTRLEN
));
7014 /* Display the IGP cost or 'inaccessible' */
7015 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7018 json_object_boolean_false_add(json_nexthop_global
, "accessible");
7020 vty_out (vty
, " (inaccessible)");
7024 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
7027 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
7029 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
7032 /* IGP cost is 0, display this only for json */
7036 json_object_int_add(json_nexthop_global
, "metric", 0);
7040 json_object_boolean_true_add(json_nexthop_global
, "accessible");
7043 /* Display peer "from" output */
7044 /* This path was originated locally */
7045 if (binfo
->peer
== bgp
->peer_self
)
7048 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
7051 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
7053 vty_out (vty
, " from 0.0.0.0 ");
7058 json_object_string_add(json_peer
, "peerId", "::");
7060 vty_out (vty
, " from :: ");
7064 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
7066 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
7069 /* We RXed this path from one of our peers */
7075 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7076 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7078 if (binfo
->peer
->hostname
)
7079 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
7081 if (binfo
->peer
->domainname
)
7082 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
7084 if (binfo
->peer
->conf_if
)
7085 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
7089 if (binfo
->peer
->conf_if
)
7091 if (binfo
->peer
->hostname
&&
7092 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7093 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7094 binfo
->peer
->conf_if
);
7096 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
7100 if (binfo
->peer
->hostname
&&
7101 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7102 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7105 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7108 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7109 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
7111 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7116 vty_out (vty
, "%s", VTY_NEWLINE
);
7118 /* display the link-local nexthop */
7119 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
7123 json_nexthop_ll
= json_object_new_object();
7124 json_object_string_add(json_nexthop_ll
, "ip",
7125 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7126 buf
, INET6_ADDRSTRLEN
));
7127 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
7128 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
7130 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
7132 if (!attr
->extra
->mp_nexthop_prefer_global
)
7133 json_object_boolean_true_add(json_nexthop_ll
, "used");
7135 json_object_boolean_true_add(json_nexthop_global
, "used");
7139 vty_out (vty
, " (%s) %s%s",
7140 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7141 buf
, INET6_ADDRSTRLEN
),
7142 attr
->extra
->mp_nexthop_prefer_global
?
7143 "(prefer-global)" : "(used)",
7147 /* If we do not have a link-local nexthop then we must flag the global as "used" */
7151 json_object_boolean_true_add(json_nexthop_global
, "used");
7154 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
7156 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
7158 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
7160 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
7163 json_object_int_add(json_path
, "med", attr
->med
);
7165 vty_out (vty
, ", metric %u", attr
->med
);
7168 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
7171 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
7173 vty_out (vty
, ", localpref %u", attr
->local_pref
);
7178 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
7180 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
7183 if (attr
->extra
&& attr
->extra
->weight
!= 0)
7186 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
7188 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
7191 if (attr
->extra
&& attr
->extra
->tag
!= 0)
7194 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
7196 vty_out (vty
, ", tag %"ROUTE_TAG_PRI
, attr
->extra
->tag
);
7199 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7202 json_object_boolean_false_add(json_path
, "valid");
7204 vty_out (vty
, ", invalid");
7206 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
7209 json_object_boolean_true_add(json_path
, "valid");
7211 vty_out (vty
, ", valid");
7214 if (binfo
->peer
!= bgp
->peer_self
)
7216 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
7218 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7221 json_object_string_add(json_peer
, "type", "confed-internal");
7223 vty_out (vty
, ", confed-internal");
7228 json_object_string_add(json_peer
, "type", "internal");
7230 vty_out (vty
, ", internal");
7235 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
7238 json_object_string_add(json_peer
, "type", "confed-external");
7240 vty_out (vty
, ", confed-external");
7245 json_object_string_add(json_peer
, "type", "external");
7247 vty_out (vty
, ", external");
7251 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
7255 json_object_boolean_true_add(json_path
, "aggregated");
7256 json_object_boolean_true_add(json_path
, "local");
7260 vty_out (vty
, ", aggregated, local");
7263 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
7266 json_object_boolean_true_add(json_path
, "sourced");
7268 vty_out (vty
, ", sourced");
7274 json_object_boolean_true_add(json_path
, "sourced");
7275 json_object_boolean_true_add(json_path
, "local");
7279 vty_out (vty
, ", sourced, local");
7283 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7286 json_object_boolean_true_add(json_path
, "atomicAggregate");
7288 vty_out (vty
, ", atomic-aggregate");
7291 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7292 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7293 bgp_info_mpath_count (binfo
)))
7296 json_object_boolean_true_add(json_path
, "multipath");
7298 vty_out (vty
, ", multipath");
7301 // Mark the bestpath(s)
7302 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7304 first_as
= aspath_get_first_as(attr
->aspath
);
7309 json_bestpath
= json_object_new_object();
7310 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7315 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7317 vty_out (vty
, ", bestpath-from-AS Local");
7321 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7326 json_bestpath
= json_object_new_object();
7327 json_object_boolean_true_add(json_bestpath
, "overall");
7330 vty_out (vty
, ", best");
7334 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7337 vty_out (vty
, "%s", VTY_NEWLINE
);
7339 /* Line 4 display Community */
7340 if (attr
->community
)
7344 json_object_lock(attr
->community
->json
);
7345 json_object_object_add(json_path
, "community", attr
->community
->json
);
7349 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7354 /* Line 5 display Extended-community */
7355 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7359 json_ext_community
= json_object_new_object();
7360 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7361 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7365 vty_out (vty
, " Extended Community: %s%s",
7366 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7370 /* Line 6 display Originator, Cluster-id */
7371 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7372 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7374 assert (attr
->extra
);
7375 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7378 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7380 vty_out (vty
, " Originator: %s",
7381 inet_ntoa (attr
->extra
->originator_id
));
7384 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7390 json_cluster_list
= json_object_new_object();
7391 json_cluster_list_list
= json_object_new_array();
7393 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7395 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7396 json_object_array_add(json_cluster_list_list
, json_string
);
7399 /* struct cluster_list does not have "str" variable like
7400 * aspath and community do. Add this someday if someone
7402 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7404 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7405 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7409 vty_out (vty
, ", Cluster list: ");
7411 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7413 vty_out (vty
, "%s ",
7414 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7420 vty_out (vty
, "%s", VTY_NEWLINE
);
7423 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7424 bgp_damp_info_vty (vty
, binfo
, json_path
);
7426 /* Line 7 display Addpath IDs */
7427 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7431 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7432 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7436 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7437 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7442 /* If we used addpath to TX a non-bestpath we need to display
7443 * "Advertised to" on a path-by-path basis */
7444 if (bgp
->addpath_tx_used
[afi
][safi
])
7448 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7450 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7451 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7453 if ((addpath_capable
&& has_adj
) ||
7454 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7456 if (json_path
&& !json_adv_to
)
7457 json_adv_to
= json_object_new_object();
7459 route_vty_out_advertised_to(vty
, peer
, &first
,
7469 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7476 vty_out (vty
, "%s", VTY_NEWLINE
);
7481 /* Line 8 display Uptime */
7482 #ifdef HAVE_CLOCK_MONOTONIC
7483 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7486 json_last_update
= json_object_new_object();
7487 json_object_int_add(json_last_update
, "epoch", tbuf
);
7488 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7489 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7492 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7496 json_last_update
= json_object_new_object();
7497 json_object_int_add(json_last_update
, "epoch", tbuf
);
7498 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7499 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7502 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7503 #endif /* HAVE_CLOCK_MONOTONIC */
7506 /* We've constructed the json object for this path, add it to the json
7511 if (json_nexthop_global
|| json_nexthop_ll
)
7513 json_nexthops
= json_object_new_array();
7515 if (json_nexthop_global
)
7516 json_object_array_add(json_nexthops
, json_nexthop_global
);
7518 if (json_nexthop_ll
)
7519 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7521 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7524 json_object_object_add(json_path
, "peer", json_peer
);
7525 json_object_array_add(json_paths
, json_path
);
7528 vty_out (vty
, "%s", VTY_NEWLINE
);
7531 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7532 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7533 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7537 bgp_show_type_normal
,
7538 bgp_show_type_regexp
,
7539 bgp_show_type_prefix_list
,
7540 bgp_show_type_filter_list
,
7541 bgp_show_type_route_map
,
7542 bgp_show_type_neighbor
,
7543 bgp_show_type_cidr_only
,
7544 bgp_show_type_prefix_longer
,
7545 bgp_show_type_community_all
,
7546 bgp_show_type_community
,
7547 bgp_show_type_community_exact
,
7548 bgp_show_type_community_list
,
7549 bgp_show_type_community_list_exact
,
7550 bgp_show_type_flap_statistics
,
7551 bgp_show_type_flap_address
,
7552 bgp_show_type_flap_prefix
,
7553 bgp_show_type_flap_cidr_only
,
7554 bgp_show_type_flap_regexp
,
7555 bgp_show_type_flap_filter_list
,
7556 bgp_show_type_flap_prefix_list
,
7557 bgp_show_type_flap_prefix_longer
,
7558 bgp_show_type_flap_route_map
,
7559 bgp_show_type_flap_neighbor
,
7560 bgp_show_type_dampend_paths
,
7561 bgp_show_type_damp_neighbor
7565 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7566 const char *prefix_list_str
, afi_t afi
,
7567 safi_t safi
, enum bgp_show_type type
);
7569 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7570 const char *filter
, afi_t afi
,
7571 safi_t safi
, enum bgp_show_type type
);
7573 bgp_show_route_map (struct vty
*vty
, const char *name
,
7574 const char *rmap_str
, afi_t afi
,
7575 safi_t safi
, enum bgp_show_type type
);
7577 bgp_show_community_list (struct vty
*vty
, const char *name
,
7578 const char *com
, int exact
,
7579 afi_t afi
, safi_t safi
);
7581 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7582 const char *prefix
, afi_t afi
,
7583 safi_t safi
, enum bgp_show_type type
);
7586 bgp_show_table (struct vty
*vty
, struct bgp
*bgp
, struct bgp_table
*table
,
7587 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7589 struct bgp_info
*ri
;
7590 struct bgp_node
*rn
;
7593 unsigned long output_count
;
7594 unsigned long total_count
;
7598 json_object
*json_paths
= NULL
;
7603 vty_out (vty
, "{ \"vrfId\": %d, \"vrfName\": \"%s\", \"tableVersion\": %" PRId64
", \"routerId\": \"%s\", \"routes\": { ",
7604 bgp
->vrf_id
== VRF_UNKNOWN
? -1 : bgp
->vrf_id
,
7605 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
? "Default" : bgp
->name
,
7606 table
->version
, inet_ntoa (bgp
->router_id
));
7607 json_paths
= json_object_new_object();
7610 /* This is first entry point, so reset total line. */
7614 /* Start processing of routes. */
7615 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7616 if (rn
->info
!= NULL
)
7619 if (!first
&& use_json
)
7624 json_paths
= json_object_new_array();
7628 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7631 if (type
== bgp_show_type_flap_statistics
7632 || type
== bgp_show_type_flap_address
7633 || type
== bgp_show_type_flap_prefix
7634 || type
== bgp_show_type_flap_cidr_only
7635 || type
== bgp_show_type_flap_regexp
7636 || type
== bgp_show_type_flap_filter_list
7637 || type
== bgp_show_type_flap_prefix_list
7638 || type
== bgp_show_type_flap_prefix_longer
7639 || type
== bgp_show_type_flap_route_map
7640 || type
== bgp_show_type_flap_neighbor
7641 || type
== bgp_show_type_dampend_paths
7642 || type
== bgp_show_type_damp_neighbor
)
7644 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7647 if (type
== bgp_show_type_regexp
7648 || type
== bgp_show_type_flap_regexp
)
7650 regex_t
*regex
= output_arg
;
7652 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7655 if (type
== bgp_show_type_prefix_list
7656 || type
== bgp_show_type_flap_prefix_list
)
7658 struct prefix_list
*plist
= output_arg
;
7660 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7663 if (type
== bgp_show_type_filter_list
7664 || type
== bgp_show_type_flap_filter_list
)
7666 struct as_list
*as_list
= output_arg
;
7668 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7671 if (type
== bgp_show_type_route_map
7672 || type
== bgp_show_type_flap_route_map
)
7674 struct route_map
*rmap
= output_arg
;
7675 struct bgp_info binfo
;
7676 struct attr dummy_attr
;
7677 struct attr_extra dummy_extra
;
7680 dummy_attr
.extra
= &dummy_extra
;
7681 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7683 binfo
.peer
= ri
->peer
;
7684 binfo
.attr
= &dummy_attr
;
7686 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7687 if (ret
== RMAP_DENYMATCH
)
7690 if (type
== bgp_show_type_neighbor
7691 || type
== bgp_show_type_flap_neighbor
7692 || type
== bgp_show_type_damp_neighbor
)
7694 union sockunion
*su
= output_arg
;
7696 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7699 if (type
== bgp_show_type_cidr_only
7700 || type
== bgp_show_type_flap_cidr_only
)
7702 u_int32_t destination
;
7704 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7705 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7707 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7709 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7712 if (type
== bgp_show_type_prefix_longer
7713 || type
== bgp_show_type_flap_prefix_longer
)
7715 struct prefix
*p
= output_arg
;
7717 if (! prefix_match (p
, &rn
->p
))
7720 if (type
== bgp_show_type_community_all
)
7722 if (! ri
->attr
->community
)
7725 if (type
== bgp_show_type_community
)
7727 struct community
*com
= output_arg
;
7729 if (! ri
->attr
->community
||
7730 ! community_match (ri
->attr
->community
, com
))
7733 if (type
== bgp_show_type_community_exact
)
7735 struct community
*com
= output_arg
;
7737 if (! ri
->attr
->community
||
7738 ! community_cmp (ri
->attr
->community
, com
))
7741 if (type
== bgp_show_type_community_list
)
7743 struct community_list
*list
= output_arg
;
7745 if (! community_list_match (ri
->attr
->community
, list
))
7748 if (type
== bgp_show_type_community_list_exact
)
7750 struct community_list
*list
= output_arg
;
7752 if (! community_list_exact_match (ri
->attr
->community
, list
))
7755 if (type
== bgp_show_type_flap_address
7756 || type
== bgp_show_type_flap_prefix
)
7758 struct prefix
*p
= output_arg
;
7760 if (! prefix_match (&rn
->p
, p
))
7763 if (type
== bgp_show_type_flap_prefix
)
7764 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7767 if (type
== bgp_show_type_dampend_paths
7768 || type
== bgp_show_type_damp_neighbor
)
7770 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7771 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7775 if (!use_json
&& header
)
7777 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
7778 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7779 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7780 if (type
== bgp_show_type_dampend_paths
7781 || type
== bgp_show_type_damp_neighbor
)
7782 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7783 else if (type
== bgp_show_type_flap_statistics
7784 || type
== bgp_show_type_flap_address
7785 || type
== bgp_show_type_flap_prefix
7786 || type
== bgp_show_type_flap_cidr_only
7787 || type
== bgp_show_type_flap_regexp
7788 || type
== bgp_show_type_flap_filter_list
7789 || type
== bgp_show_type_flap_prefix_list
7790 || type
== bgp_show_type_flap_prefix_longer
7791 || type
== bgp_show_type_flap_route_map
7792 || type
== bgp_show_type_flap_neighbor
)
7793 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7795 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7799 if (type
== bgp_show_type_dampend_paths
7800 || type
== bgp_show_type_damp_neighbor
)
7801 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7802 else if (type
== bgp_show_type_flap_statistics
7803 || type
== bgp_show_type_flap_address
7804 || type
== bgp_show_type_flap_prefix
7805 || type
== bgp_show_type_flap_cidr_only
7806 || type
== bgp_show_type_flap_regexp
7807 || type
== bgp_show_type_flap_filter_list
7808 || type
== bgp_show_type_flap_prefix_list
7809 || type
== bgp_show_type_flap_prefix_longer
7810 || type
== bgp_show_type_flap_route_map
7811 || type
== bgp_show_type_flap_neighbor
)
7812 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7814 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7824 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7825 vty_out (vty
, "\"%s\": ", buf2
);
7826 vty_out (vty
, "%s", json_object_to_json_string (json_paths
));
7827 json_object_free (json_paths
);
7836 json_object_free (json_paths
);
7837 vty_out (vty
, " } }%s", VTY_NEWLINE
);
7841 /* No route is displayed */
7842 if (output_count
== 0)
7844 if (type
== bgp_show_type_normal
)
7845 vty_out (vty
, "No BGP prefixes displayed, %ld exist%s", total_count
, VTY_NEWLINE
);
7848 vty_out (vty
, "%sDisplayed %ld routes and %ld total paths%s",
7849 VTY_NEWLINE
, output_count
, total_count
, VTY_NEWLINE
);
7856 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7857 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7859 struct bgp_table
*table
;
7863 bgp
= bgp_get_default ();
7869 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7873 table
= bgp
->rib
[afi
][safi
];
7875 return bgp_show_table (vty
, bgp
, table
, type
, output_arg
,
7880 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7883 struct listnode
*node
, *nnode
;
7885 struct bgp_table
*table
;
7889 vty_out (vty
, "{%s", VTY_NEWLINE
);
7891 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7896 vty_out (vty
, ",%s", VTY_NEWLINE
);
7900 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7901 ? "Default" : bgp
->name
);
7905 vty_out (vty
, "%sInstance %s:%s",
7907 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7908 ? "Default" : bgp
->name
,
7911 table
= bgp
->rib
[afi
][safi
];
7912 bgp_show_table (vty
, bgp
, table
,
7913 bgp_show_type_normal
, NULL
, use_json
);
7918 vty_out (vty
, "}%s", VTY_NEWLINE
);
7921 /* Header of detailed BGP route information */
7923 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7924 struct bgp_node
*rn
,
7925 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7928 struct bgp_info
*ri
;
7931 struct listnode
*node
, *nnode
;
7932 char buf1
[INET6_ADDRSTRLEN
];
7933 char buf2
[INET6_ADDRSTRLEN
];
7938 int no_advertise
= 0;
7941 json_object
*json_adv_to
= NULL
;
7947 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7948 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7952 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7953 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7954 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7955 safi
== SAFI_MPLS_VPN
? ":" : "",
7956 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7957 p
->prefixlen
, VTY_NEWLINE
);
7960 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7963 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7966 if (ri
->extra
&& ri
->extra
->suppress
)
7968 if (ri
->attr
->community
!= NULL
)
7970 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7972 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7974 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7982 vty_out (vty
, "Paths: (%d available", count
);
7985 vty_out (vty
, ", best #%d", best
);
7986 if (safi
== SAFI_UNICAST
)
7987 vty_out (vty
, ", table %s",
7988 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7989 ? "Default-IP-Routing-Table" : bgp
->name
);
7992 vty_out (vty
, ", no best path");
7995 vty_out (vty
, ", not advertised to any peer");
7997 vty_out (vty
, ", not advertised to EBGP peer");
7999 vty_out (vty
, ", not advertised outside local AS");
8002 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
8003 vty_out (vty
, ")%s", VTY_NEWLINE
);
8006 /* If we are not using addpath then we can display Advertised to and that will
8007 * show what peers we advertised the bestpath to. If we are using addpath
8008 * though then we must display Advertised to on a path-by-path basis. */
8009 if (!bgp
->addpath_tx_used
[afi
][safi
])
8011 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
8013 if (bgp_adj_out_lookup (peer
, rn
, 0))
8015 if (json
&& !json_adv_to
)
8016 json_adv_to
= json_object_new_object();
8018 route_vty_out_advertised_to(vty
, peer
, &first
,
8019 " Advertised to non peer-group peers:\n ",
8028 json_object_object_add(json
, "advertisedTo", json_adv_to
);
8034 vty_out (vty
, " Not advertised to any peer");
8035 vty_out (vty
, "%s", VTY_NEWLINE
);
8040 /* Display specified route of BGP table. */
8042 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
8043 struct bgp_table
*rib
, const char *ip_str
,
8044 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8045 int prefix_check
, enum bgp_path_type pathtype
,
8051 struct prefix match
;
8052 struct bgp_node
*rn
;
8053 struct bgp_node
*rm
;
8054 struct bgp_info
*ri
;
8055 struct bgp_table
*table
;
8056 json_object
*json
= NULL
;
8057 json_object
*json_paths
= NULL
;
8059 /* Check IP address argument. */
8060 ret
= str2prefix (ip_str
, &match
);
8063 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
8067 match
.family
= afi2family (afi
);
8071 json
= json_object_new_object();
8072 json_paths
= json_object_new_array();
8075 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
8077 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
8079 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
8082 if ((table
= rn
->info
) != NULL
)
8086 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
8088 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
8090 bgp_unlock_node (rm
);
8094 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
8098 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
8099 AFI_IP
, safi
, json
);
8104 if (pathtype
== BGP_PATH_ALL
||
8105 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8106 (pathtype
== BGP_PATH_MULTIPATH
&&
8107 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8108 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
8111 bgp_unlock_node (rm
);
8120 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
8122 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
8124 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8128 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
8133 if (pathtype
== BGP_PATH_ALL
||
8134 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8135 (pathtype
== BGP_PATH_MULTIPATH
&&
8136 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8137 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
8141 bgp_unlock_node (rn
);
8148 json_object_object_add(json
, "paths", json_paths
);
8150 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
8151 json_object_free(json
);
8157 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
8165 /* Display specified route of Main RIB */
8167 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
8168 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8169 int prefix_check
, enum bgp_path_type pathtype
,
8174 /* BGP structure lookup. */
8177 bgp
= bgp_lookup_by_name (view_name
);
8180 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
8186 bgp
= bgp_get_default ();
8189 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8194 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
8195 afi
, safi
, prd
, prefix_check
, pathtype
,
8199 /* BGP route print out function. */
8202 "show ip bgp {json}",
8206 "JavaScript Object Notation\n")
8208 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8211 DEFUN (show_ip_bgp_ipv4
,
8212 show_ip_bgp_ipv4_cmd
,
8213 "show ip bgp ipv4 (unicast|multicast) {json}",
8218 "Address Family modifier\n"
8219 "Address Family modifier\n"
8220 "JavaScript Object Notation\n")
8222 u_char uj
= use_json(argc
, argv
);
8224 return bgp_show (vty
, NULL
, AFI_IP
,
8225 bgp_vty_safi_from_arg(argv
[0]),
8226 bgp_show_type_normal
, NULL
, uj
);
8229 ALIAS (show_ip_bgp_ipv4
,
8230 show_bgp_ipv4_safi_cmd
,
8231 "show bgp ipv4 (unicast|multicast) {json}",
8235 "Address Family modifier\n"
8236 "Address Family modifier\n"
8237 "JavaScript Object Notation\n")
8239 DEFUN (show_ip_bgp_route
,
8240 show_ip_bgp_route_cmd
,
8241 "show ip bgp A.B.C.D {json}",
8245 "Network in the BGP routing table to display\n"
8246 "JavaScript Object Notation\n")
8248 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8251 DEFUN (show_ip_bgp_route_pathtype
,
8252 show_ip_bgp_route_pathtype_cmd
,
8253 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
8257 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8258 "Display only the bestpath\n"
8259 "Display only multipaths\n"
8260 "JavaScript Object Notation\n")
8262 u_char uj
= use_json(argc
, argv
);
8264 if (strncmp (argv
[1], "b", 1) == 0)
8265 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8267 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8270 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
8271 show_bgp_ipv4_safi_route_pathtype_cmd
,
8272 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D (bestpath|multipath) {json}",
8275 BGP_AFI_SAFI_HELP_STR
8276 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8277 "Display only the bestpath\n"
8278 "Display only multipaths\n"
8279 "JavaScript Object Notation\n")
8281 u_char uj
= use_json(argc
, argv
);
8283 if (strncmp (argv
[2], "b", 1) == 0)
8284 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8285 bgp_vty_safi_from_arg(argv
[0]),
8286 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8288 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8289 bgp_vty_safi_from_arg(argv
[0]),
8290 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8293 DEFUN (show_bgp_ipv4_prefix
,
8294 show_bgp_ipv4_prefix_cmd
,
8295 "show bgp ipv4 A.B.C.D/M {json}",
8299 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8302 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8305 DEFUN (show_bgp_ipv6_route
,
8306 show_bgp_ipv6_route_cmd
,
8307 "show bgp ipv6 X:X::X:X {json}",
8311 "Network in the BGP routing table to display\n"
8314 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8317 DEFUN (show_bgp_ipv6_prefix
,
8318 show_bgp_ipv6_prefix_cmd
,
8319 "show bgp ipv6 X:X::X:X/M {json}",
8323 "IPv6 prefix <network>/<length>\n"
8326 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
,argv
));
8329 DEFUN (show_ip_bgp_ipv4_route
,
8330 show_ip_bgp_ipv4_route_cmd
,
8331 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8335 BGP_AFI_SAFI_HELP_STR
8336 "Network in the BGP routing table to display\n"
8337 "JavaScript Object Notation\n")
8339 u_char uj
= use_json(argc
, argv
);
8341 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8342 bgp_vty_safi_from_arg(argv
[0]),
8343 NULL
, 0, BGP_PATH_ALL
, uj
);
8346 ALIAS (show_ip_bgp_ipv4_route
,
8347 show_bgp_ipv4_safi_route_cmd
,
8348 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8351 BGP_AFI_SAFI_HELP_STR
8352 "Network in the BGP routing table to display\n"
8353 "JavaScript Object Notation\n")
8355 DEFUN (show_bgp_ipv4_safi_rd_route
,
8356 show_bgp_ipv4_safi_rd_route_cmd
,
8357 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8361 "Address Family Modifier\n"
8362 "Address Family Modifier\n"
8363 "Display information for a route distinguisher\n"
8364 "ENCAP Route Distinguisher\n"
8365 "Network in the BGP routing table to display\n")
8368 struct prefix_rd prd
;
8371 if (bgp_parse_safi(argv
[0], &safi
)) {
8372 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8375 ret
= str2prefix_rd (argv
[1], &prd
);
8378 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8381 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8384 DEFUN (show_bgp_ipv6_safi_rd_route
,
8385 show_bgp_ipv6_safi_rd_route_cmd
,
8386 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
8390 "Address Family Modifier\n"
8391 "Address Family Modifier\n"
8392 "Display information for a route distinguisher\n"
8393 "ENCAP Route Distinguisher\n"
8394 "Network in the BGP routing table to display\n")
8397 struct prefix_rd prd
;
8400 if (bgp_parse_safi(argv
[0], &safi
)) {
8401 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8404 ret
= str2prefix_rd (argv
[1], &prd
);
8407 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8410 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, SAFI_ENCAP
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8414 DEFUN (show_bgp_ipv4_safi_rd_prefix
,
8415 show_bgp_ipv4_safi_rd_prefix_cmd
,
8416 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8420 "Address Family Modifier\n"
8421 "Address Family Modifier\n"
8422 "Display information for a route distinguisher\n"
8423 "ENCAP Route Distinguisher\n"
8424 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8427 struct prefix_rd prd
;
8430 if (bgp_parse_safi(argv
[0], &safi
)) {
8431 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8435 ret
= str2prefix_rd (argv
[1], &prd
);
8438 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8441 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8444 DEFUN (show_bgp_ipv6_safi_rd_prefix
,
8445 show_bgp_ipv6_safi_rd_prefix_cmd
,
8446 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M {json}",
8450 "Address Family Modifier\n"
8451 "Address Family Modifier\n"
8452 "Display information for a route distinguisher\n"
8453 "ENCAP Route Distinguisher\n"
8454 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8457 struct prefix_rd prd
;
8460 if (bgp_parse_safi(argv
[0], &safi
)) {
8461 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8465 ret
= str2prefix_rd (argv
[1], &prd
);
8468 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8471 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8474 DEFUN (show_ip_bgp_prefix
,
8475 show_ip_bgp_prefix_cmd
,
8476 "show ip bgp A.B.C.D/M {json}",
8480 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8481 "JavaScript Object Notation\n")
8483 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8486 DEFUN (show_ip_bgp_prefix_pathtype
,
8487 show_ip_bgp_prefix_pathtype_cmd
,
8488 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8492 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8493 "Display only the bestpath\n"
8494 "Display only multipaths\n"
8495 "JavaScript Object Notation\n")
8497 u_char uj
= use_json(argc
, argv
);
8498 if (strncmp (argv
[1], "b", 1) == 0)
8499 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8501 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8504 DEFUN (show_ip_bgp_ipv4_prefix
,
8505 show_ip_bgp_ipv4_prefix_cmd
,
8506 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8510 BGP_AFI_SAFI_HELP_STR
8511 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8512 "JavaScript Object Notation\n")
8514 u_char uj
= use_json(argc
, argv
);
8516 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8517 bgp_vty_safi_from_arg(argv
[0]),
8518 NULL
, 1, BGP_PATH_ALL
, uj
);
8521 ALIAS (show_ip_bgp_ipv4_prefix
,
8522 show_bgp_ipv4_safi_prefix_cmd
,
8523 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8526 BGP_AFI_SAFI_HELP_STR
8527 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8528 "JavaScript Object Notation\n")
8530 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8531 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8532 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8536 BGP_AFI_SAFI_HELP_STR
8537 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8538 "Display only the bestpath\n"
8539 "Display only multipaths\n"
8540 "JavaScript Object Notation\n")
8542 u_char uj
= use_json(argc
, argv
);
8544 if (strncmp (argv
[2], "b", 1) == 0)
8545 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8546 bgp_vty_safi_from_arg(argv
[0]),
8547 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8549 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8550 bgp_vty_safi_from_arg(argv
[0]),
8551 NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8554 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8555 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8556 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8559 BGP_AFI_SAFI_HELP_STR
8560 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8561 "Display only the bestpath\n"
8562 "Display only multipaths\n"
8563 "JavaScript Object Notation\n")
8566 DEFUN (show_ip_bgp_view
,
8567 show_ip_bgp_instance_cmd
,
8568 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8572 BGP_INSTANCE_HELP_STR
8573 "JavaScript Object Notation\n")
8577 /* BGP structure lookup. */
8578 bgp
= bgp_lookup_by_name (argv
[1]);
8581 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8585 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8588 DEFUN (show_ip_bgp_instance_all
,
8589 show_ip_bgp_instance_all_cmd
,
8590 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8594 BGP_INSTANCE_ALL_HELP_STR
8595 "JavaScript Object Notation\n")
8597 u_char uj
= use_json(argc
, argv
);
8599 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8603 DEFUN (show_ip_bgp_instance_route
,
8604 show_ip_bgp_instance_route_cmd
,
8605 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8609 BGP_INSTANCE_HELP_STR
8610 "Network in the BGP routing table to display\n"
8611 "JavaScript Object Notation\n")
8613 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8616 DEFUN (show_ip_bgp_instance_route_pathtype
,
8617 show_ip_bgp_instance_route_pathtype_cmd
,
8618 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8622 BGP_INSTANCE_HELP_STR
8623 "Network in the BGP routing table to display\n"
8624 "Display only the bestpath\n"
8625 "Display only multipaths\n"
8626 "JavaScript Object Notation\n")
8628 u_char uj
= use_json(argc
, argv
);
8630 if (strncmp (argv
[3], "b", 1) == 0)
8631 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8633 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8636 DEFUN (show_ip_bgp_instance_prefix
,
8637 show_ip_bgp_instance_prefix_cmd
,
8638 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8642 BGP_INSTANCE_HELP_STR
8643 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8644 "JavaScript Object Notation\n")
8646 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8649 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8650 show_ip_bgp_instance_prefix_pathtype_cmd
,
8651 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8655 BGP_INSTANCE_HELP_STR
8656 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8657 "Display only the bestpath\n"
8658 "Display only multipaths\n"
8659 "JavaScript Object Notation\n")
8661 u_char uj
= use_json(argc
, argv
);
8662 if (strncmp (argv
[3], "b", 1) == 0)
8663 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8665 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8674 "JavaScript Object Notation\n")
8676 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8677 NULL
, use_json(argc
, argv
));
8682 "show bgp ipv6 {json}",
8686 "JavaScript Object Notation\n")
8688 DEFUN (show_bgp_ipv6_safi
,
8689 show_bgp_ipv6_safi_cmd
,
8690 "show bgp ipv6 (unicast|multicast) {json}",
8694 "Address Family modifier\n"
8695 "Address Family modifier\n"
8696 "JavaScript Object Notation\n")
8698 u_char uj
= use_json(argc
, argv
);
8700 return bgp_show (vty
, NULL
, AFI_IP6
,
8701 bgp_vty_safi_from_arg(argv
[0]),
8702 bgp_show_type_normal
, NULL
, uj
);
8706 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8708 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8709 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8710 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8714 DEFUN (show_ipv6_bgp
,
8716 "show ipv6 bgp {json}",
8720 "JavaScript Object Notation\n")
8722 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8723 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8724 NULL
, use_json(argc
, argv
));
8727 DEFUN (show_bgp_route
,
8729 "show bgp X:X::X:X {json}",
8732 "Network in the BGP routing table to display\n"
8733 "JavaScript Object Notation\n")
8735 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8738 DEFUN (show_bgp_ipv6_safi_route
,
8739 show_bgp_ipv6_safi_route_cmd
,
8740 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X {json}",
8743 BGP_AFI_SAFI_HELP_STR
8744 "Network in the BGP routing table to display\n"
8745 "JavaScript Object Notation\n")
8747 u_char uj
= use_json(argc
, argv
);
8749 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8750 bgp_vty_safi_from_arg(argv
[0]),
8751 NULL
, 0, BGP_PATH_ALL
, uj
);
8754 DEFUN (show_bgp_route_pathtype
,
8755 show_bgp_route_pathtype_cmd
,
8756 "show bgp X:X::X:X (bestpath|multipath) {json}",
8759 "Network in the BGP routing table to display\n"
8760 "Display only the bestpath\n"
8761 "Display only multipaths\n"
8762 "JavaScript Object Notation\n")
8764 u_char uj
= use_json(argc
, argv
);
8765 if (strncmp (argv
[1], "b", 1) == 0)
8766 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8768 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8771 ALIAS (show_bgp_route_pathtype
,
8772 show_bgp_ipv6_route_pathtype_cmd
,
8773 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8777 "Network in the BGP routing table to display\n"
8778 "Display only the bestpath\n"
8779 "Display only multipaths\n"
8780 "JavaScript Object Notation\n")
8782 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8783 show_bgp_ipv6_safi_route_pathtype_cmd
,
8784 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X (bestpath|multipath) {json}",
8787 BGP_AFI_SAFI_HELP_STR
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 u_char uj
= use_json(argc
, argv
);
8794 if (strncmp (argv
[2], "b", 1) == 0)
8795 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8796 bgp_vty_safi_from_arg(argv
[0]),
8797 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8799 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8800 bgp_vty_safi_from_arg(argv
[0]),
8801 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8805 DEFUN (show_ipv6_bgp_route
,
8806 show_ipv6_bgp_route_cmd
,
8807 "show ipv6 bgp X:X::X:X {json}",
8811 "Network in the BGP routing table to display\n"
8812 "JavaScript Object Notation\n")
8814 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8815 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8818 DEFUN (show_bgp_prefix
,
8819 show_bgp_prefix_cmd
,
8820 "show bgp X:X::X:X/M {json}",
8823 "IPv6 prefix <network>/<length>\n"
8824 "JavaScript Object Notation\n")
8826 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8829 DEFUN (show_bgp_ipv6_safi_prefix
,
8830 show_bgp_ipv6_safi_prefix_cmd
,
8831 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M {json}",
8834 BGP_AFI_SAFI_HELP_STR
8835 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8836 "JavaScript Object Notation\n")
8838 u_char uj
= use_json(argc
, argv
);
8840 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8841 bgp_vty_safi_from_arg(argv
[0]),
8842 NULL
, 1, BGP_PATH_ALL
, uj
);
8845 DEFUN (show_bgp_prefix_pathtype
,
8846 show_bgp_prefix_pathtype_cmd
,
8847 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8850 "IPv6 prefix <network>/<length>\n"
8851 "Display only the bestpath\n"
8852 "Display only multipaths\n"
8853 "JavaScript Object Notation\n")
8855 u_char uj
= use_json(argc
, argv
);
8856 if (strncmp (argv
[1], "b", 1) == 0)
8857 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8859 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8862 ALIAS (show_bgp_prefix_pathtype
,
8863 show_bgp_ipv6_prefix_pathtype_cmd
,
8864 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8868 "IPv6 prefix <network>/<length>\n"
8869 "Display only the bestpath\n"
8870 "Display only multipaths\n"
8871 "JavaScript Object Notation\n")
8873 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8874 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8875 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M (bestpath|multipath) {json}",
8878 BGP_AFI_SAFI_HELP_STR
8879 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8880 "Display only the bestpath\n"
8881 "Display only multipaths\n"
8882 "JavaScript Object Notation\n")
8884 u_char uj
= use_json(argc
, argv
);
8885 if (strncmp (argv
[2], "b", 1) == 0)
8886 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8887 bgp_vty_safi_from_arg(argv
[0]),
8888 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8890 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8891 bgp_vty_safi_from_arg(argv
[0]), NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8895 DEFUN (show_ipv6_bgp_prefix
,
8896 show_ipv6_bgp_prefix_cmd
,
8897 "show ipv6 bgp X:X::X:X/M {json}",
8901 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8902 "JavaScript Object Notation\n")
8904 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8905 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8908 DEFUN (show_bgp_view
,
8909 show_bgp_instance_cmd
,
8910 "show bgp " BGP_INSTANCE_CMD
" {json}",
8913 BGP_INSTANCE_HELP_STR
8914 "JavaScript Object Notation\n")
8918 /* BGP structure lookup. */
8919 bgp
= bgp_lookup_by_name (argv
[1]);
8922 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8926 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8929 DEFUN (show_bgp_instance_all
,
8930 show_bgp_instance_all_cmd
,
8931 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8934 BGP_INSTANCE_ALL_HELP_STR
8935 "JavaScript Object Notation\n")
8937 u_char uj
= use_json(argc
, argv
);
8939 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8943 ALIAS (show_bgp_view
,
8944 show_bgp_instance_ipv6_cmd
,
8945 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8948 BGP_INSTANCE_HELP_STR
8950 "JavaScript Object Notation\n")
8952 DEFUN (show_bgp_instance_route
,
8953 show_bgp_instance_route_cmd
,
8954 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8957 BGP_INSTANCE_HELP_STR
8958 "Network in the BGP routing table to display\n"
8959 "JavaScript Object Notation\n")
8961 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8964 ALIAS (show_bgp_instance_route
,
8965 show_bgp_instance_ipv6_route_cmd
,
8966 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8969 BGP_INSTANCE_HELP_STR
8971 "Network in the BGP routing table to display\n"
8972 "JavaScript Object Notation\n")
8974 DEFUN (show_bgp_instance_route_pathtype
,
8975 show_bgp_instance_route_pathtype_cmd
,
8976 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8979 BGP_INSTANCE_HELP_STR
8980 "Network in the BGP routing table to display\n"
8981 "Display only the bestpath\n"
8982 "Display only multipaths\n"
8983 "JavaScript Object Notation\n")
8985 u_char uj
= use_json(argc
, argv
);
8986 if (strncmp (argv
[3], "b", 1) == 0)
8987 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8989 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8992 ALIAS (show_bgp_instance_route_pathtype
,
8993 show_bgp_instance_ipv6_route_pathtype_cmd
,
8994 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
8997 BGP_INSTANCE_HELP_STR
8999 "Network in the BGP routing table to display\n"
9000 "Display only the bestpath\n"
9001 "Display only multipaths\n"
9002 "JavaScript Object Notation\n")
9004 DEFUN (show_bgp_instance_prefix
,
9005 show_bgp_instance_prefix_cmd
,
9006 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
9009 BGP_INSTANCE_HELP_STR
9010 "IPv6 prefix <network>/<length>\n"
9011 "JavaScript Object Notation\n")
9013 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9016 ALIAS (show_bgp_instance_prefix
,
9017 show_bgp_instance_ipv6_prefix_cmd
,
9018 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
9021 BGP_INSTANCE_HELP_STR
9023 "IPv6 prefix <network>/<length>\n"
9024 "JavaScript Object Notation\n")
9026 DEFUN (show_bgp_instance_prefix_pathtype
,
9027 show_bgp_instance_prefix_pathtype_cmd
,
9028 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
9031 BGP_INSTANCE_HELP_STR
9032 "IPv6 prefix <network>/<length>\n"
9033 "Display only the bestpath\n"
9034 "Display only multipaths\n"
9035 "JavaScript Object Notation\n")
9037 u_char uj
= use_json(argc
, argv
);
9038 if (strncmp (argv
[3], "b", 1) == 0)
9039 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
9041 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
9044 ALIAS (show_bgp_instance_prefix_pathtype
,
9045 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
9046 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
9049 BGP_INSTANCE_HELP_STR
9051 "IPv6 prefix <network>/<length>\n"
9052 "Display only the bestpath\n"
9053 "Display only multipaths\n"
9054 "JavaScript Object Notation\n")
9056 DEFUN (show_bgp_instance_prefix_list
,
9057 show_bgp_instance_prefix_list_cmd
,
9058 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9061 BGP_INSTANCE_HELP_STR
9062 "Display routes conforming to the prefix-list\n"
9063 "IPv6 prefix-list name\n")
9065 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9066 bgp_show_type_prefix_list
);
9069 ALIAS (show_bgp_instance_prefix_list
,
9070 show_bgp_instance_ipv6_prefix_list_cmd
,
9071 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
9074 BGP_INSTANCE_HELP_STR
9076 "Display routes conforming to the prefix-list\n"
9077 "IPv6 prefix-list name\n")
9079 DEFUN (show_bgp_instance_filter_list
,
9080 show_bgp_instance_filter_list_cmd
,
9081 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9084 BGP_INSTANCE_HELP_STR
9085 "Display routes conforming to the filter-list\n"
9086 "Regular expression access list name\n")
9088 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9089 bgp_show_type_filter_list
);
9092 ALIAS (show_bgp_instance_filter_list
,
9093 show_bgp_instance_ipv6_filter_list_cmd
,
9094 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
9097 BGP_INSTANCE_HELP_STR
9099 "Display routes conforming to the filter-list\n"
9100 "Regular expression access list name\n")
9102 DEFUN (show_bgp_instance_route_map
,
9103 show_bgp_instance_route_map_cmd
,
9104 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
9107 BGP_INSTANCE_HELP_STR
9108 "Display routes matching the route-map\n"
9109 "A route-map to match on\n")
9111 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9112 bgp_show_type_route_map
);
9115 ALIAS (show_bgp_instance_route_map
,
9116 show_bgp_instance_ipv6_route_map_cmd
,
9117 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
9120 BGP_INSTANCE_HELP_STR
9122 "Display routes matching the route-map\n"
9123 "A route-map to match on\n")
9125 DEFUN (show_bgp_instance_community_list
,
9126 show_bgp_instance_community_list_cmd
,
9127 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
9130 BGP_INSTANCE_HELP_STR
9131 "Display routes matching the community-list\n"
9132 "community-list number\n"
9133 "community-list name\n")
9135 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
9138 ALIAS (show_bgp_instance_community_list
,
9139 show_bgp_instance_ipv6_community_list_cmd
,
9140 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
9143 BGP_INSTANCE_HELP_STR
9145 "Display routes matching the community-list\n"
9146 "community-list number\n"
9147 "community-list name\n")
9149 DEFUN (show_bgp_instance_prefix_longer
,
9150 show_bgp_instance_prefix_longer_cmd
,
9151 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
9154 BGP_INSTANCE_HELP_STR
9155 "IPv6 prefix <network>/<length>\n"
9156 "Display route and more specific routes\n")
9158 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9159 bgp_show_type_prefix_longer
);
9162 ALIAS (show_bgp_instance_prefix_longer
,
9163 show_bgp_instance_ipv6_prefix_longer_cmd
,
9164 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
9167 BGP_INSTANCE_HELP_STR
9169 "IPv6 prefix <network>/<length>\n"
9170 "Display route and more specific routes\n")
9173 DEFUN (show_ipv6_mbgp
,
9175 "show ipv6 mbgp {json}",
9179 "JavaScript Object Notation\n")
9181 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9182 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
9183 NULL
, use_json(argc
, argv
));
9187 DEFUN (show_ipv6_mbgp_route
,
9188 show_ipv6_mbgp_route_cmd
,
9189 "show ipv6 mbgp X:X::X:X {json}",
9193 "Network in the MBGP routing table to display\n"
9194 "JavaScript Object Notation\n")
9196 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9197 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9201 DEFUN (show_ipv6_mbgp_prefix
,
9202 show_ipv6_mbgp_prefix_cmd
,
9203 "show ipv6 mbgp X:X::X:X/M {json}",
9207 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9208 "JavaScript Object Notation\n")
9210 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9211 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9217 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
9218 safi_t safi
, enum bgp_show_type type
)
9228 b
= buffer_new (1024);
9229 for (i
= 0; i
< argc
; i
++)
9232 buffer_putc (b
, ' ');
9235 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9240 buffer_putstr (b
, argv
[i
]);
9242 buffer_putc (b
, '\0');
9244 regstr
= buffer_getstr (b
);
9247 regex
= bgp_regcomp (regstr
);
9248 XFREE(MTYPE_TMP
, regstr
);
9251 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
9256 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
9257 bgp_regex_free (regex
);
9261 DEFUN (show_ip_bgp_regexp
,
9262 show_ip_bgp_regexp_cmd
,
9263 "show ip bgp regexp .LINE",
9267 "Display routes matching the AS path regular expression\n"
9268 "A regular-expression to match the BGP AS paths\n")
9270 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9271 bgp_show_type_regexp
);
9274 DEFUN (show_ip_bgp_flap_regexp
,
9275 show_ip_bgp_flap_regexp_cmd
,
9276 "show ip bgp flap-statistics regexp .LINE",
9280 "Display flap statistics of routes\n"
9281 "Display routes matching the AS path regular expression\n"
9282 "A regular-expression to match the BGP AS paths\n")
9284 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9285 bgp_show_type_flap_regexp
);
9288 ALIAS (show_ip_bgp_flap_regexp
,
9289 show_ip_bgp_damp_flap_regexp_cmd
,
9290 "show ip bgp dampening flap-statistics regexp .LINE",
9294 "Display detailed information about dampening\n"
9295 "Display flap statistics of routes\n"
9296 "Display routes matching the AS path regular expression\n"
9297 "A regular-expression to match the BGP AS paths\n")
9299 DEFUN (show_ip_bgp_ipv4_regexp
,
9300 show_ip_bgp_ipv4_regexp_cmd
,
9301 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
9306 "Address Family modifier\n"
9307 "Address Family modifier\n"
9308 "Display routes matching the AS path regular expression\n"
9309 "A regular-expression to match the BGP AS paths\n")
9312 safi
= bgp_vty_safi_from_arg(argv
[0]);
9313 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, safi
,
9314 bgp_show_type_regexp
);
9318 DEFUN (show_bgp_regexp
,
9319 show_bgp_regexp_cmd
,
9320 "show bgp regexp .LINE",
9323 "Display routes matching the AS path regular expression\n"
9324 "A regular-expression to match the BGP AS paths\n")
9326 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9327 bgp_show_type_regexp
);
9330 ALIAS (show_bgp_regexp
,
9331 show_bgp_ipv6_regexp_cmd
,
9332 "show bgp ipv6 regexp .LINE",
9336 "Display routes matching the AS path regular expression\n"
9337 "A regular-expression to match the BGP AS paths\n")
9340 DEFUN (show_ipv6_bgp_regexp
,
9341 show_ipv6_bgp_regexp_cmd
,
9342 "show ipv6 bgp regexp .LINE",
9346 "Display routes matching the AS path regular expression\n"
9347 "A regular-expression to match the BGP AS paths\n")
9349 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9350 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9351 bgp_show_type_regexp
);
9355 DEFUN (show_ipv6_mbgp_regexp
,
9356 show_ipv6_mbgp_regexp_cmd
,
9357 "show ipv6 mbgp regexp .LINE",
9361 "Display routes matching the AS path regular expression\n"
9362 "A regular-expression to match the MBGP AS paths\n")
9364 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9365 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9366 bgp_show_type_regexp
);
9368 #endif /* HAVE_IPV6 */
9371 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9372 const char *prefix_list_str
, afi_t afi
,
9373 safi_t safi
, enum bgp_show_type type
)
9375 struct prefix_list
*plist
;
9376 struct bgp
*bgp
= NULL
;
9378 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9380 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9384 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9387 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9388 prefix_list_str
, VTY_NEWLINE
);
9392 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9395 DEFUN (show_ip_bgp_prefix_list
,
9396 show_ip_bgp_prefix_list_cmd
,
9397 "show ip bgp prefix-list WORD",
9401 "Display routes conforming to the prefix-list\n"
9402 "IP prefix-list name\n")
9404 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9405 bgp_show_type_prefix_list
);
9408 DEFUN (show_ip_bgp_instance_prefix_list
,
9409 show_ip_bgp_instance_prefix_list_cmd
,
9410 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9414 BGP_INSTANCE_HELP_STR
9415 "Display routes conforming to the prefix-list\n"
9416 "IP prefix-list name\n")
9418 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9419 bgp_show_type_prefix_list
);
9422 DEFUN (show_ip_bgp_flap_prefix_list
,
9423 show_ip_bgp_flap_prefix_list_cmd
,
9424 "show ip bgp flap-statistics prefix-list WORD",
9428 "Display flap statistics of routes\n"
9429 "Display routes conforming to the prefix-list\n"
9430 "IP prefix-list name\n")
9432 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9433 bgp_show_type_flap_prefix_list
);
9436 ALIAS (show_ip_bgp_flap_prefix_list
,
9437 show_ip_bgp_damp_flap_prefix_list_cmd
,
9438 "show ip bgp dampening flap-statistics prefix-list WORD",
9442 "Display detailed information about dampening\n"
9443 "Display flap statistics of routes\n"
9444 "Display routes conforming to the prefix-list\n"
9445 "IP prefix-list name\n")
9447 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9448 show_ip_bgp_ipv4_prefix_list_cmd
,
9449 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
9454 "Address Family modifier\n"
9455 "Address Family modifier\n"
9456 "Display routes conforming to the prefix-list\n"
9457 "IP prefix-list name\n")
9460 safi
= bgp_vty_safi_from_arg(argv
[0]);
9461 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9462 bgp_show_type_prefix_list
);
9466 DEFUN (show_bgp_prefix_list
,
9467 show_bgp_prefix_list_cmd
,
9468 "show bgp prefix-list WORD",
9471 "Display routes conforming to the prefix-list\n"
9472 "IPv6 prefix-list name\n")
9474 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9475 bgp_show_type_prefix_list
);
9478 ALIAS (show_bgp_prefix_list
,
9479 show_bgp_ipv6_prefix_list_cmd
,
9480 "show bgp ipv6 prefix-list WORD",
9484 "Display routes conforming to the prefix-list\n"
9485 "IPv6 prefix-list name\n")
9488 DEFUN (show_ipv6_bgp_prefix_list
,
9489 show_ipv6_bgp_prefix_list_cmd
,
9490 "show ipv6 bgp prefix-list WORD",
9494 "Display routes matching the prefix-list\n"
9495 "IPv6 prefix-list name\n")
9497 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9498 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9499 bgp_show_type_prefix_list
);
9503 DEFUN (show_ipv6_mbgp_prefix_list
,
9504 show_ipv6_mbgp_prefix_list_cmd
,
9505 "show ipv6 mbgp prefix-list WORD",
9509 "Display routes matching the prefix-list\n"
9510 "IPv6 prefix-list name\n")
9512 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9513 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9514 bgp_show_type_prefix_list
);
9516 #endif /* HAVE_IPV6 */
9519 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9520 const char *filter
, afi_t afi
,
9521 safi_t safi
, enum bgp_show_type type
)
9523 struct as_list
*as_list
;
9524 struct bgp
*bgp
= NULL
;
9526 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9528 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9532 as_list
= as_list_lookup (filter
);
9533 if (as_list
== NULL
)
9535 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9539 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9542 DEFUN (show_ip_bgp_filter_list
,
9543 show_ip_bgp_filter_list_cmd
,
9544 "show ip bgp filter-list WORD",
9548 "Display routes conforming to the filter-list\n"
9549 "Regular expression access list name\n")
9551 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9552 bgp_show_type_filter_list
);
9555 DEFUN (show_ip_bgp_instance_filter_list
,
9556 show_ip_bgp_instance_filter_list_cmd
,
9557 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9561 BGP_INSTANCE_HELP_STR
9562 "Display routes conforming to the filter-list\n"
9563 "Regular expression access list name\n")
9565 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9566 bgp_show_type_filter_list
);
9569 DEFUN (show_ip_bgp_flap_filter_list
,
9570 show_ip_bgp_flap_filter_list_cmd
,
9571 "show ip bgp flap-statistics filter-list WORD",
9575 "Display flap statistics of routes\n"
9576 "Display routes conforming to the filter-list\n"
9577 "Regular expression access list name\n")
9579 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9580 bgp_show_type_flap_filter_list
);
9583 ALIAS (show_ip_bgp_flap_filter_list
,
9584 show_ip_bgp_damp_flap_filter_list_cmd
,
9585 "show ip bgp dampening flap-statistics filter-list WORD",
9589 "Display detailed information about dampening\n"
9590 "Display flap statistics of routes\n"
9591 "Display routes conforming to the filter-list\n"
9592 "Regular expression access list name\n")
9594 DEFUN (show_ip_bgp_ipv4_filter_list
,
9595 show_ip_bgp_ipv4_filter_list_cmd
,
9596 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9601 "Address Family modifier\n"
9602 "Address Family modifier\n"
9603 "Display routes conforming to the filter-list\n"
9604 "Regular expression access list name\n")
9607 safi
= bgp_vty_safi_from_arg(argv
[0]);
9608 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9609 bgp_show_type_filter_list
);
9613 DEFUN (show_bgp_filter_list
,
9614 show_bgp_filter_list_cmd
,
9615 "show bgp filter-list WORD",
9618 "Display routes conforming to the filter-list\n"
9619 "Regular expression access list name\n")
9621 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9622 bgp_show_type_filter_list
);
9625 ALIAS (show_bgp_filter_list
,
9626 show_bgp_ipv6_filter_list_cmd
,
9627 "show bgp ipv6 filter-list WORD",
9631 "Display routes conforming to the filter-list\n"
9632 "Regular expression access list name\n")
9635 DEFUN (show_ipv6_bgp_filter_list
,
9636 show_ipv6_bgp_filter_list_cmd
,
9637 "show ipv6 bgp filter-list WORD",
9641 "Display routes conforming to the filter-list\n"
9642 "Regular expression access list name\n")
9644 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9645 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9646 bgp_show_type_filter_list
);
9650 DEFUN (show_ipv6_mbgp_filter_list
,
9651 show_ipv6_mbgp_filter_list_cmd
,
9652 "show ipv6 mbgp filter-list WORD",
9656 "Display routes conforming to the filter-list\n"
9657 "Regular expression access list name\n")
9659 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9660 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9661 bgp_show_type_filter_list
);
9663 #endif /* HAVE_IPV6 */
9665 DEFUN (show_ip_bgp_dampening_info
,
9666 show_ip_bgp_dampening_params_cmd
,
9667 "show ip bgp dampening parameters",
9671 "Display detailed information about dampening\n"
9672 "Display detail of configured dampening parameters\n")
9674 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9678 DEFUN (show_ip_bgp_ipv4_dampening_parameters
,
9679 show_ip_bgp_ipv4_dampening_parameters_cmd
,
9680 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
9685 "Address Family modifier\n"
9686 "Address Family modifier\n"
9687 "Display detailed information about dampening\n"
9688 "Display detail of configured dampening parameters\n")
9691 safi
= bgp_vty_safi_from_arg(argv
[0]);
9692 return bgp_show_dampening_parameters (vty
, AFI_IP
, safi
);
9696 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats
,
9697 show_ip_bgp_ipv4_dampening_flap_stats_cmd
,
9698 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
9703 "Address Family modifier\n"
9704 "Address Family modifier\n"
9705 "Display detailed information about dampening\n"
9706 "Display flap statistics of routes\n")
9709 safi
= bgp_vty_safi_from_arg(argv
[0]);
9710 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9711 bgp_show_type_flap_statistics
, NULL
, 0);
9714 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths
,
9715 show_ip_bgp_ipv4_dampening_dampd_paths_cmd
,
9716 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
9721 "Address Family modifier\n"
9722 "Address Family modifier\n"
9723 "Display detailed information about dampening\n"
9724 "Display paths suppressed due to dampening\n")
9727 safi
= bgp_vty_safi_from_arg(argv
[0]);
9728 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9729 bgp_show_type_dampend_paths
, NULL
, 0);
9733 bgp_show_route_map (struct vty
*vty
, const char *name
,
9734 const char *rmap_str
, afi_t afi
,
9735 safi_t safi
, enum bgp_show_type type
)
9737 struct route_map
*rmap
;
9738 struct bgp
*bgp
= NULL
;
9740 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9742 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9746 rmap
= route_map_lookup_by_name (rmap_str
);
9749 vty_out (vty
, "%% %s is not a valid route-map name%s",
9750 rmap_str
, VTY_NEWLINE
);
9754 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9757 DEFUN (show_ip_bgp_route_map
,
9758 show_ip_bgp_route_map_cmd
,
9759 "show ip bgp route-map WORD",
9763 "Display routes matching the route-map\n"
9764 "A route-map to match on\n")
9766 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9767 bgp_show_type_route_map
);
9770 DEFUN (show_ip_bgp_instance_route_map
,
9771 show_ip_bgp_instance_route_map_cmd
,
9772 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9776 BGP_INSTANCE_HELP_STR
9777 "Display routes matching the route-map\n"
9778 "A route-map to match on\n")
9780 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9781 bgp_show_type_route_map
);
9784 DEFUN (show_ip_bgp_flap_route_map
,
9785 show_ip_bgp_flap_route_map_cmd
,
9786 "show ip bgp flap-statistics route-map WORD",
9790 "Display flap statistics of routes\n"
9791 "Display routes matching the route-map\n"
9792 "A route-map to match on\n")
9794 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9795 bgp_show_type_flap_route_map
);
9798 ALIAS (show_ip_bgp_flap_route_map
,
9799 show_ip_bgp_damp_flap_route_map_cmd
,
9800 "show ip bgp dampening flap-statistics route-map WORD",
9804 "Display detailed information about dampening\n"
9805 "Display flap statistics of routes\n"
9806 "Display routes matching the route-map\n"
9807 "A route-map to match on\n")
9809 DEFUN (show_ip_bgp_ipv4_route_map
,
9810 show_ip_bgp_ipv4_route_map_cmd
,
9811 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9816 "Address Family modifier\n"
9817 "Address Family modifier\n"
9818 "Display routes matching the route-map\n"
9819 "A route-map to match on\n")
9822 safi
= bgp_vty_safi_from_arg(argv
[0]);
9823 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9824 bgp_show_type_route_map
);
9827 DEFUN (show_bgp_route_map
,
9828 show_bgp_route_map_cmd
,
9829 "show bgp route-map WORD",
9832 "Display routes matching the route-map\n"
9833 "A route-map to match on\n")
9835 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9836 bgp_show_type_route_map
);
9839 ALIAS (show_bgp_route_map
,
9840 show_bgp_ipv6_route_map_cmd
,
9841 "show bgp ipv6 route-map WORD",
9845 "Display routes matching the route-map\n"
9846 "A route-map to match on\n")
9848 DEFUN (show_ip_bgp_cidr_only
,
9849 show_ip_bgp_cidr_only_cmd
,
9850 "show ip bgp cidr-only",
9854 "Display only routes with non-natural netmasks\n")
9856 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9857 bgp_show_type_cidr_only
, NULL
, 0);
9860 DEFUN (show_ip_bgp_flap_cidr_only
,
9861 show_ip_bgp_flap_cidr_only_cmd
,
9862 "show ip bgp flap-statistics cidr-only",
9866 "Display flap statistics of routes\n"
9867 "Display only routes with non-natural netmasks\n")
9869 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9870 bgp_show_type_flap_cidr_only
, NULL
, 0);
9873 ALIAS (show_ip_bgp_flap_cidr_only
,
9874 show_ip_bgp_damp_flap_cidr_only_cmd
,
9875 "show ip bgp dampening flap-statistics cidr-only",
9879 "Display detailed information about dampening\n"
9880 "Display flap statistics of routes\n"
9881 "Display only routes with non-natural netmasks\n")
9883 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9884 show_ip_bgp_ipv4_cidr_only_cmd
,
9885 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9890 "Address Family modifier\n"
9891 "Address Family modifier\n"
9892 "Display only routes with non-natural netmasks\n")
9895 safi
= bgp_vty_safi_from_arg(argv
[0]);
9896 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9897 bgp_show_type_cidr_only
, NULL
, 0);
9900 DEFUN (show_ip_bgp_community_all
,
9901 show_ip_bgp_community_all_cmd
,
9902 "show ip bgp community",
9906 "Display routes matching the communities\n")
9908 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9909 bgp_show_type_community_all
, NULL
, 0);
9912 DEFUN (show_ip_bgp_ipv4_community_all
,
9913 show_ip_bgp_ipv4_community_all_cmd
,
9914 "show ip bgp ipv4 (unicast|multicast) community",
9919 "Address Family modifier\n"
9920 "Address Family modifier\n"
9921 "Display routes matching the communities\n")
9924 safi
= bgp_vty_safi_from_arg(argv
[0]);
9925 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9926 bgp_show_type_community_all
, NULL
, 0);
9930 DEFUN (show_bgp_community_all
,
9931 show_bgp_community_all_cmd
,
9932 "show bgp community",
9935 "Display routes matching the communities\n")
9937 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9938 bgp_show_type_community_all
, NULL
, 0);
9941 ALIAS (show_bgp_community_all
,
9942 show_bgp_ipv6_community_all_cmd
,
9943 "show bgp ipv6 community",
9947 "Display routes matching the communities\n")
9950 DEFUN (show_ipv6_bgp_community_all
,
9951 show_ipv6_bgp_community_all_cmd
,
9952 "show ipv6 bgp community",
9956 "Display routes matching the communities\n")
9958 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9959 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9960 bgp_show_type_community_all
, NULL
, 0);
9964 DEFUN (show_ipv6_mbgp_community_all
,
9965 show_ipv6_mbgp_community_all_cmd
,
9966 "show ipv6 mbgp community",
9970 "Display routes matching the communities\n")
9972 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9973 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9974 bgp_show_type_community_all
, NULL
, 0);
9976 #endif /* HAVE_IPV6 */
9979 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9980 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9982 struct community
*com
;
9989 /* BGP structure lookup */
9992 bgp
= bgp_lookup_by_name (view_name
);
9995 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
10001 bgp
= bgp_get_default ();
10004 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
10005 return CMD_WARNING
;
10009 b
= buffer_new (1024);
10010 for (i
= 0; i
< argc
; i
++)
10013 buffer_putc (b
, ' ');
10016 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
10021 buffer_putstr (b
, argv
[i
]);
10023 buffer_putc (b
, '\0');
10025 str
= buffer_getstr (b
);
10028 com
= community_str2com (str
);
10029 XFREE (MTYPE_TMP
, str
);
10032 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
10033 return CMD_WARNING
;
10036 return bgp_show (vty
, bgp
, afi
, safi
,
10037 (exact
? bgp_show_type_community_exact
:
10038 bgp_show_type_community
), com
, 0);
10041 DEFUN (show_ip_bgp_community
,
10042 show_ip_bgp_community_cmd
,
10043 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
10047 "Display routes matching the communities\n"
10049 "Do not send outside local AS (well-known community)\n"
10050 "Do not advertise to any peer (well-known community)\n"
10051 "Do not export to next AS (well-known community)\n")
10053 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
10056 ALIAS (show_ip_bgp_community
,
10057 show_ip_bgp_community2_cmd
,
10058 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10062 "Display routes matching the communities\n"
10064 "Do not send outside local AS (well-known community)\n"
10065 "Do not advertise to any peer (well-known community)\n"
10066 "Do not export to next AS (well-known community)\n"
10068 "Do not send outside local AS (well-known community)\n"
10069 "Do not advertise to any peer (well-known community)\n"
10070 "Do not export to next AS (well-known community)\n")
10072 ALIAS (show_ip_bgp_community
,
10073 show_ip_bgp_community3_cmd
,
10074 "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)",
10078 "Display routes matching the communities\n"
10080 "Do not send outside local AS (well-known community)\n"
10081 "Do not advertise to any peer (well-known community)\n"
10082 "Do not export to next AS (well-known community)\n"
10084 "Do not send outside local AS (well-known community)\n"
10085 "Do not advertise to any peer (well-known community)\n"
10086 "Do not export to next AS (well-known community)\n"
10088 "Do not send outside local AS (well-known community)\n"
10089 "Do not advertise to any peer (well-known community)\n"
10090 "Do not export to next AS (well-known community)\n")
10092 ALIAS (show_ip_bgp_community
,
10093 show_ip_bgp_community4_cmd
,
10094 "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)",
10098 "Display routes matching the communities\n"
10100 "Do not send outside local AS (well-known community)\n"
10101 "Do not advertise to any peer (well-known community)\n"
10102 "Do not export to next AS (well-known community)\n"
10104 "Do not send outside local AS (well-known community)\n"
10105 "Do not advertise to any peer (well-known community)\n"
10106 "Do not export to next AS (well-known community)\n"
10108 "Do not send outside local AS (well-known community)\n"
10109 "Do not advertise to any peer (well-known community)\n"
10110 "Do not export to next AS (well-known community)\n"
10112 "Do not send outside local AS (well-known community)\n"
10113 "Do not advertise to any peer (well-known community)\n"
10114 "Do not export to next AS (well-known community)\n")
10116 DEFUN (show_ip_bgp_ipv4_community
,
10117 show_ip_bgp_ipv4_community_cmd
,
10118 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10123 "Address Family modifier\n"
10124 "Address Family modifier\n"
10125 "Display routes matching the communities\n"
10127 "Do not send outside local AS (well-known community)\n"
10128 "Do not advertise to any peer (well-known community)\n"
10129 "Do not export to next AS (well-known community)\n")
10132 safi
= bgp_vty_safi_from_arg(argv
[0]);
10133 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, safi
);
10136 ALIAS (show_ip_bgp_ipv4_community
,
10137 show_ip_bgp_ipv4_community2_cmd
,
10138 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10143 "Address Family modifier\n"
10144 "Address Family modifier\n"
10145 "Display routes matching the communities\n"
10147 "Do not send outside local AS (well-known community)\n"
10148 "Do not advertise to any peer (well-known community)\n"
10149 "Do not export to next AS (well-known community)\n"
10151 "Do not send outside local AS (well-known community)\n"
10152 "Do not advertise to any peer (well-known community)\n"
10153 "Do not export to next AS (well-known community)\n")
10155 ALIAS (show_ip_bgp_ipv4_community
,
10156 show_ip_bgp_ipv4_community3_cmd
,
10157 "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)",
10162 "Address Family modifier\n"
10163 "Address Family modifier\n"
10164 "Display routes matching the communities\n"
10166 "Do not send outside local AS (well-known community)\n"
10167 "Do not advertise to any peer (well-known community)\n"
10168 "Do not export to next AS (well-known community)\n"
10170 "Do not send outside local AS (well-known community)\n"
10171 "Do not advertise to any peer (well-known community)\n"
10172 "Do not export to next AS (well-known community)\n"
10174 "Do not send outside local AS (well-known community)\n"
10175 "Do not advertise to any peer (well-known community)\n"
10176 "Do not export to next AS (well-known community)\n")
10178 ALIAS (show_ip_bgp_ipv4_community
,
10179 show_ip_bgp_ipv4_community4_cmd
,
10180 "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)",
10185 "Address Family modifier\n"
10186 "Address Family modifier\n"
10187 "Display routes matching the communities\n"
10189 "Do not send outside local AS (well-known community)\n"
10190 "Do not advertise to any peer (well-known community)\n"
10191 "Do not export to next AS (well-known community)\n"
10193 "Do not send outside local AS (well-known community)\n"
10194 "Do not advertise to any peer (well-known community)\n"
10195 "Do not export to next AS (well-known community)\n"
10197 "Do not send outside local AS (well-known community)\n"
10198 "Do not advertise to any peer (well-known community)\n"
10199 "Do not export to next AS (well-known community)\n"
10201 "Do not send outside local AS (well-known community)\n"
10202 "Do not advertise to any peer (well-known community)\n"
10203 "Do not export to next AS (well-known community)\n")
10205 DEFUN (show_bgp_instance_afi_safi_community_all
,
10206 show_bgp_instance_afi_safi_community_all_cmd
,
10207 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
10210 BGP_INSTANCE_HELP_STR
10213 "Address Family modifier\n"
10214 "Address Family modifier\n"
10215 "Display routes matching the communities\n")
10221 /* BGP structure lookup. */
10222 bgp
= bgp_lookup_by_name (argv
[1]);
10225 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
10226 return CMD_WARNING
;
10229 afi
= bgp_vty_safi_from_arg(argv
[2]);
10230 safi
= bgp_vty_safi_from_arg(argv
[3]);
10231 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
10234 DEFUN (show_bgp_instance_afi_safi_community
,
10235 show_bgp_instance_afi_safi_community_cmd
,
10236 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10239 BGP_INSTANCE_HELP_STR
10242 "Address family modifier\n"
10243 "Address family modifier\n"
10244 "Display routes matching the communities\n"
10246 "Do not send outside local AS (well-known community)\n"
10247 "Do not advertise to any peer (well-known community)\n"
10248 "Do not export to next AS (well-known community)\n")
10253 afi
= bgp_vty_safi_from_arg(argv
[2]);
10254 safi
= bgp_vty_safi_from_arg(argv
[3]);
10255 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
10258 ALIAS (show_bgp_instance_afi_safi_community
,
10259 show_bgp_instance_afi_safi_community2_cmd
,
10260 "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)",
10263 BGP_INSTANCE_HELP_STR
10266 "Address family modifier\n"
10267 "Address family modifier\n"
10268 "Display routes matching the communities\n"
10270 "Do not send outside local AS (well-known community)\n"
10271 "Do not advertise to any peer (well-known community)\n"
10272 "Do not export to next AS (well-known community)\n"
10274 "Do not send outside local AS (well-known community)\n"
10275 "Do not advertise to any peer (well-known community)\n"
10276 "Do not export to next AS (well-known community)\n")
10278 ALIAS (show_bgp_instance_afi_safi_community
,
10279 show_bgp_instance_afi_safi_community3_cmd
,
10280 "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)",
10283 BGP_INSTANCE_HELP_STR
10286 "Address family modifier\n"
10287 "Address family modifier\n"
10288 "Display routes matching the communities\n"
10290 "Do not send outside local AS (well-known community)\n"
10291 "Do not advertise to any peer (well-known community)\n"
10292 "Do not export to next AS (well-known community)\n"
10294 "Do not send outside local AS (well-known community)\n"
10295 "Do not advertise to any peer (well-known community)\n"
10296 "Do not export to next AS (well-known community)\n"
10298 "Do not send outside local AS (well-known community)\n"
10299 "Do not advertise to any peer (well-known community)\n"
10300 "Do not export to next AS (well-known community)\n")
10302 ALIAS (show_bgp_instance_afi_safi_community
,
10303 show_bgp_instance_afi_safi_community4_cmd
,
10304 "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)",
10307 BGP_INSTANCE_HELP_STR
10310 "Address family modifier\n"
10311 "Address family modifier\n"
10312 "Display routes matching the communities\n"
10314 "Do not send outside local AS (well-known community)\n"
10315 "Do not advertise to any peer (well-known community)\n"
10316 "Do not export to next AS (well-known community)\n"
10318 "Do not send outside local AS (well-known community)\n"
10319 "Do not advertise to any peer (well-known community)\n"
10320 "Do not export to next AS (well-known community)\n"
10322 "Do not send outside local AS (well-known community)\n"
10323 "Do not advertise to any peer (well-known community)\n"
10324 "Do not export to next AS (well-known community)\n"
10326 "Do not send outside local AS (well-known community)\n"
10327 "Do not advertise to any peer (well-known community)\n"
10328 "Do not export to next AS (well-known community)\n")
10330 DEFUN (show_ip_bgp_community_exact
,
10331 show_ip_bgp_community_exact_cmd
,
10332 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10336 "Display routes matching the communities\n"
10338 "Do not send outside local AS (well-known community)\n"
10339 "Do not advertise to any peer (well-known community)\n"
10340 "Do not export to next AS (well-known community)\n"
10341 "Exact match of the communities")
10343 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10346 ALIAS (show_ip_bgp_community_exact
,
10347 show_ip_bgp_community2_exact_cmd
,
10348 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10352 "Display routes matching the communities\n"
10354 "Do not send outside local AS (well-known community)\n"
10355 "Do not advertise to any peer (well-known community)\n"
10356 "Do not export to next AS (well-known community)\n"
10358 "Do not send outside local AS (well-known community)\n"
10359 "Do not advertise to any peer (well-known community)\n"
10360 "Do not export to next AS (well-known community)\n"
10361 "Exact match of the communities")
10363 ALIAS (show_ip_bgp_community_exact
,
10364 show_ip_bgp_community3_exact_cmd
,
10365 "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",
10369 "Display routes matching the communities\n"
10371 "Do not send outside local AS (well-known community)\n"
10372 "Do not advertise to any peer (well-known community)\n"
10373 "Do not export to next AS (well-known community)\n"
10375 "Do not send outside local AS (well-known community)\n"
10376 "Do not advertise to any peer (well-known community)\n"
10377 "Do not export to next AS (well-known community)\n"
10379 "Do not send outside local AS (well-known community)\n"
10380 "Do not advertise to any peer (well-known community)\n"
10381 "Do not export to next AS (well-known community)\n"
10382 "Exact match of the communities")
10384 ALIAS (show_ip_bgp_community_exact
,
10385 show_ip_bgp_community4_exact_cmd
,
10386 "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",
10390 "Display routes matching the communities\n"
10392 "Do not send outside local AS (well-known community)\n"
10393 "Do not advertise to any peer (well-known community)\n"
10394 "Do not export to next AS (well-known community)\n"
10396 "Do not send outside local AS (well-known community)\n"
10397 "Do not advertise to any peer (well-known community)\n"
10398 "Do not export to next AS (well-known community)\n"
10400 "Do not send outside local AS (well-known community)\n"
10401 "Do not advertise to any peer (well-known community)\n"
10402 "Do not export to next AS (well-known community)\n"
10404 "Do not send outside local AS (well-known community)\n"
10405 "Do not advertise to any peer (well-known community)\n"
10406 "Do not export to next AS (well-known community)\n"
10407 "Exact match of the communities")
10409 DEFUN (show_ip_bgp_ipv4_community_exact
,
10410 show_ip_bgp_ipv4_community_exact_cmd
,
10411 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10416 "Address Family modifier\n"
10417 "Address Family modifier\n"
10418 "Display routes matching the communities\n"
10420 "Do not send outside local AS (well-known community)\n"
10421 "Do not advertise to any peer (well-known community)\n"
10422 "Do not export to next AS (well-known community)\n"
10423 "Exact match of the communities")
10426 safi
= bgp_vty_safi_from_arg(argv
[0]);
10427 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, safi
);
10430 ALIAS (show_ip_bgp_ipv4_community_exact
,
10431 show_ip_bgp_ipv4_community2_exact_cmd
,
10432 "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",
10437 "Address Family modifier\n"
10438 "Address Family modifier\n"
10439 "Display routes matching the communities\n"
10441 "Do not send outside local AS (well-known community)\n"
10442 "Do not advertise to any peer (well-known community)\n"
10443 "Do not export to next AS (well-known community)\n"
10445 "Do not send outside local AS (well-known community)\n"
10446 "Do not advertise to any peer (well-known community)\n"
10447 "Do not export to next AS (well-known community)\n"
10448 "Exact match of the communities")
10450 ALIAS (show_ip_bgp_ipv4_community_exact
,
10451 show_ip_bgp_ipv4_community3_exact_cmd
,
10452 "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",
10457 "Address Family modifier\n"
10458 "Address Family modifier\n"
10459 "Display routes matching the communities\n"
10461 "Do not send outside local AS (well-known community)\n"
10462 "Do not advertise to any peer (well-known community)\n"
10463 "Do not export to next AS (well-known community)\n"
10465 "Do not send outside local AS (well-known community)\n"
10466 "Do not advertise to any peer (well-known community)\n"
10467 "Do not export to next AS (well-known community)\n"
10469 "Do not send outside local AS (well-known community)\n"
10470 "Do not advertise to any peer (well-known community)\n"
10471 "Do not export to next AS (well-known community)\n"
10472 "Exact match of the communities")
10474 ALIAS (show_ip_bgp_ipv4_community_exact
,
10475 show_ip_bgp_ipv4_community4_exact_cmd
,
10476 "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",
10481 "Address Family modifier\n"
10482 "Address Family modifier\n"
10483 "Display routes matching the communities\n"
10485 "Do not send outside local AS (well-known community)\n"
10486 "Do not advertise to any peer (well-known community)\n"
10487 "Do not export to next AS (well-known community)\n"
10489 "Do not send outside local AS (well-known community)\n"
10490 "Do not advertise to any peer (well-known community)\n"
10491 "Do not export to next AS (well-known community)\n"
10493 "Do not send outside local AS (well-known community)\n"
10494 "Do not advertise to any peer (well-known community)\n"
10495 "Do not export to next AS (well-known community)\n"
10497 "Do not send outside local AS (well-known community)\n"
10498 "Do not advertise to any peer (well-known community)\n"
10499 "Do not export to next AS (well-known community)\n"
10500 "Exact match of the communities")
10503 DEFUN (show_bgp_community
,
10504 show_bgp_community_cmd
,
10505 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10508 "Display routes matching the communities\n"
10510 "Do not send outside local AS (well-known community)\n"
10511 "Do not advertise to any peer (well-known community)\n"
10512 "Do not export to next AS (well-known community)\n")
10514 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10517 ALIAS (show_bgp_community
,
10518 show_bgp_ipv6_community_cmd
,
10519 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10523 "Display routes matching the communities\n"
10525 "Do not send outside local AS (well-known community)\n"
10526 "Do not advertise to any peer (well-known community)\n"
10527 "Do not export to next AS (well-known community)\n")
10529 ALIAS (show_bgp_community
,
10530 show_bgp_community2_cmd
,
10531 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (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 "Do not send outside local AS (well-known community)\n"
10541 "Do not advertise to any peer (well-known community)\n"
10542 "Do not export to next AS (well-known community)\n")
10544 ALIAS (show_bgp_community
,
10545 show_bgp_ipv6_community2_cmd
,
10546 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10550 "Display routes matching the communities\n"
10552 "Do not send outside local AS (well-known community)\n"
10553 "Do not advertise to any peer (well-known community)\n"
10554 "Do not export to next AS (well-known community)\n"
10556 "Do not send outside local AS (well-known community)\n"
10557 "Do not advertise to any peer (well-known community)\n"
10558 "Do not export to next AS (well-known community)\n")
10560 ALIAS (show_bgp_community
,
10561 show_bgp_community3_cmd
,
10562 "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)",
10565 "Display routes matching the communities\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 "Do not send outside local AS (well-known community)\n"
10572 "Do not advertise to any peer (well-known community)\n"
10573 "Do not export to next AS (well-known community)\n"
10575 "Do not send outside local AS (well-known community)\n"
10576 "Do not advertise to any peer (well-known community)\n"
10577 "Do not export to next AS (well-known community)\n")
10579 ALIAS (show_bgp_community
,
10580 show_bgp_ipv6_community3_cmd
,
10581 "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)",
10585 "Display routes matching the communities\n"
10587 "Do not send outside local AS (well-known community)\n"
10588 "Do not advertise to any peer (well-known community)\n"
10589 "Do not export to next AS (well-known community)\n"
10591 "Do not send outside local AS (well-known community)\n"
10592 "Do not advertise to any peer (well-known community)\n"
10593 "Do not export to next AS (well-known community)\n"
10595 "Do not send outside local AS (well-known community)\n"
10596 "Do not advertise to any peer (well-known community)\n"
10597 "Do not export to next AS (well-known community)\n")
10599 ALIAS (show_bgp_community
,
10600 show_bgp_community4_cmd
,
10601 "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)",
10604 "Display routes matching the communities\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 "Do not send outside local AS (well-known community)\n"
10611 "Do not advertise to any peer (well-known community)\n"
10612 "Do not export to next AS (well-known community)\n"
10614 "Do not send outside local AS (well-known community)\n"
10615 "Do not advertise to any peer (well-known community)\n"
10616 "Do not export to next AS (well-known community)\n"
10618 "Do not send outside local AS (well-known community)\n"
10619 "Do not advertise to any peer (well-known community)\n"
10620 "Do not export to next AS (well-known community)\n")
10622 ALIAS (show_bgp_community
,
10623 show_bgp_ipv6_community4_cmd
,
10624 "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)",
10628 "Display routes matching the communities\n"
10630 "Do not send outside local AS (well-known community)\n"
10631 "Do not advertise to any peer (well-known community)\n"
10632 "Do not export to next AS (well-known community)\n"
10634 "Do not send outside local AS (well-known community)\n"
10635 "Do not advertise to any peer (well-known community)\n"
10636 "Do not export to next AS (well-known community)\n"
10638 "Do not send outside local AS (well-known community)\n"
10639 "Do not advertise to any peer (well-known community)\n"
10640 "Do not export to next AS (well-known community)\n"
10642 "Do not send outside local AS (well-known community)\n"
10643 "Do not advertise to any peer (well-known community)\n"
10644 "Do not export to next AS (well-known community)\n")
10647 DEFUN (show_ipv6_bgp_community
,
10648 show_ipv6_bgp_community_cmd
,
10649 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10653 "Display routes matching the communities\n"
10655 "Do not send outside local AS (well-known community)\n"
10656 "Do not advertise to any peer (well-known community)\n"
10657 "Do not export to next AS (well-known community)\n")
10659 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10660 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10664 ALIAS (show_ipv6_bgp_community
,
10665 show_ipv6_bgp_community2_cmd
,
10666 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10670 "Display routes matching the communities\n"
10672 "Do not send outside local AS (well-known community)\n"
10673 "Do not advertise to any peer (well-known community)\n"
10674 "Do not export to next AS (well-known community)\n"
10676 "Do not send outside local AS (well-known community)\n"
10677 "Do not advertise to any peer (well-known community)\n"
10678 "Do not export to next AS (well-known community)\n")
10681 ALIAS (show_ipv6_bgp_community
,
10682 show_ipv6_bgp_community3_cmd
,
10683 "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)",
10687 "Display routes matching the communities\n"
10689 "Do not send outside local AS (well-known community)\n"
10690 "Do not advertise to any peer (well-known community)\n"
10691 "Do not export to next AS (well-known community)\n"
10693 "Do not send outside local AS (well-known community)\n"
10694 "Do not advertise to any peer (well-known community)\n"
10695 "Do not export to next AS (well-known community)\n"
10697 "Do not send outside local AS (well-known community)\n"
10698 "Do not advertise to any peer (well-known community)\n"
10699 "Do not export to next AS (well-known community)\n")
10702 ALIAS (show_ipv6_bgp_community
,
10703 show_ipv6_bgp_community4_cmd
,
10704 "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)",
10708 "Display routes matching the communities\n"
10710 "Do not send outside local AS (well-known community)\n"
10711 "Do not advertise to any peer (well-known community)\n"
10712 "Do not export to next AS (well-known community)\n"
10714 "Do not send outside local AS (well-known community)\n"
10715 "Do not advertise to any peer (well-known community)\n"
10716 "Do not export to next AS (well-known community)\n"
10718 "Do not send outside local AS (well-known community)\n"
10719 "Do not advertise to any peer (well-known community)\n"
10720 "Do not export to next AS (well-known community)\n"
10722 "Do not send outside local AS (well-known community)\n"
10723 "Do not advertise to any peer (well-known community)\n"
10724 "Do not export to next AS (well-known community)\n")
10726 DEFUN (show_bgp_community_exact
,
10727 show_bgp_community_exact_cmd
,
10728 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10731 "Display routes matching the communities\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"
10736 "Exact match of the communities")
10738 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10741 ALIAS (show_bgp_community_exact
,
10742 show_bgp_ipv6_community_exact_cmd
,
10743 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10747 "Display routes matching the communities\n"
10749 "Do not send outside local AS (well-known community)\n"
10750 "Do not advertise to any peer (well-known community)\n"
10751 "Do not export to next AS (well-known community)\n"
10752 "Exact match of the communities")
10754 ALIAS (show_bgp_community_exact
,
10755 show_bgp_community2_exact_cmd
,
10756 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10759 "Display routes matching the communities\n"
10761 "Do not send outside local AS (well-known community)\n"
10762 "Do not advertise to any peer (well-known community)\n"
10763 "Do not export to next AS (well-known community)\n"
10765 "Do not send outside local AS (well-known community)\n"
10766 "Do not advertise to any peer (well-known community)\n"
10767 "Do not export to next AS (well-known community)\n"
10768 "Exact match of the communities")
10770 ALIAS (show_bgp_community_exact
,
10771 show_bgp_ipv6_community2_exact_cmd
,
10772 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10776 "Display routes matching the communities\n"
10778 "Do not send outside local AS (well-known community)\n"
10779 "Do not advertise to any peer (well-known community)\n"
10780 "Do not export to next AS (well-known community)\n"
10782 "Do not send outside local AS (well-known community)\n"
10783 "Do not advertise to any peer (well-known community)\n"
10784 "Do not export to next AS (well-known community)\n"
10785 "Exact match of the communities")
10787 ALIAS (show_bgp_community_exact
,
10788 show_bgp_community3_exact_cmd
,
10789 "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",
10792 "Display routes matching the communities\n"
10794 "Do not send outside local AS (well-known community)\n"
10795 "Do not advertise to any peer (well-known community)\n"
10796 "Do not export to next AS (well-known community)\n"
10798 "Do not send outside local AS (well-known community)\n"
10799 "Do not advertise to any peer (well-known community)\n"
10800 "Do not export to next AS (well-known community)\n"
10802 "Do not send outside local AS (well-known community)\n"
10803 "Do not advertise to any peer (well-known community)\n"
10804 "Do not export to next AS (well-known community)\n"
10805 "Exact match of the communities")
10807 ALIAS (show_bgp_community_exact
,
10808 show_bgp_ipv6_community3_exact_cmd
,
10809 "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",
10813 "Display routes matching the communities\n"
10815 "Do not send outside local AS (well-known community)\n"
10816 "Do not advertise to any peer (well-known community)\n"
10817 "Do not export to next AS (well-known community)\n"
10819 "Do not send outside local AS (well-known community)\n"
10820 "Do not advertise to any peer (well-known community)\n"
10821 "Do not export to next AS (well-known community)\n"
10823 "Do not send outside local AS (well-known community)\n"
10824 "Do not advertise to any peer (well-known community)\n"
10825 "Do not export to next AS (well-known community)\n"
10826 "Exact match of the communities")
10828 ALIAS (show_bgp_community_exact
,
10829 show_bgp_community4_exact_cmd
,
10830 "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",
10833 "Display routes matching the communities\n"
10835 "Do not send outside local AS (well-known community)\n"
10836 "Do not advertise to any peer (well-known community)\n"
10837 "Do not export to next AS (well-known community)\n"
10839 "Do not send outside local AS (well-known community)\n"
10840 "Do not advertise to any peer (well-known community)\n"
10841 "Do not export to next AS (well-known community)\n"
10843 "Do not send outside local AS (well-known community)\n"
10844 "Do not advertise to any peer (well-known community)\n"
10845 "Do not export to next AS (well-known community)\n"
10847 "Do not send outside local AS (well-known community)\n"
10848 "Do not advertise to any peer (well-known community)\n"
10849 "Do not export to next AS (well-known community)\n"
10850 "Exact match of the communities")
10852 ALIAS (show_bgp_community_exact
,
10853 show_bgp_ipv6_community4_exact_cmd
,
10854 "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",
10858 "Display routes matching the communities\n"
10860 "Do not send outside local AS (well-known community)\n"
10861 "Do not advertise to any peer (well-known community)\n"
10862 "Do not export to next AS (well-known community)\n"
10864 "Do not send outside local AS (well-known community)\n"
10865 "Do not advertise to any peer (well-known community)\n"
10866 "Do not export to next AS (well-known community)\n"
10868 "Do not send outside local AS (well-known community)\n"
10869 "Do not advertise to any peer (well-known community)\n"
10870 "Do not export to next AS (well-known community)\n"
10872 "Do not send outside local AS (well-known community)\n"
10873 "Do not advertise to any peer (well-known community)\n"
10874 "Do not export to next AS (well-known community)\n"
10875 "Exact match of the communities")
10878 DEFUN (show_ipv6_bgp_community_exact
,
10879 show_ipv6_bgp_community_exact_cmd
,
10880 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10884 "Display routes matching the communities\n"
10886 "Do not send outside local AS (well-known community)\n"
10887 "Do not advertise to any peer (well-known community)\n"
10888 "Do not export to next AS (well-known community)\n"
10889 "Exact match of the communities")
10891 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10892 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10896 ALIAS (show_ipv6_bgp_community_exact
,
10897 show_ipv6_bgp_community2_exact_cmd
,
10898 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10902 "Display routes matching the communities\n"
10904 "Do not send outside local AS (well-known community)\n"
10905 "Do not advertise to any peer (well-known community)\n"
10906 "Do not export to next AS (well-known community)\n"
10908 "Do not send outside local AS (well-known community)\n"
10909 "Do not advertise to any peer (well-known community)\n"
10910 "Do not export to next AS (well-known community)\n"
10911 "Exact match of the communities")
10914 ALIAS (show_ipv6_bgp_community_exact
,
10915 show_ipv6_bgp_community3_exact_cmd
,
10916 "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",
10920 "Display routes matching the communities\n"
10922 "Do not send outside local AS (well-known community)\n"
10923 "Do not advertise to any peer (well-known community)\n"
10924 "Do not export to next AS (well-known community)\n"
10926 "Do not send outside local AS (well-known community)\n"
10927 "Do not advertise to any peer (well-known community)\n"
10928 "Do not export to next AS (well-known community)\n"
10930 "Do not send outside local AS (well-known community)\n"
10931 "Do not advertise to any peer (well-known community)\n"
10932 "Do not export to next AS (well-known community)\n"
10933 "Exact match of the communities")
10936 ALIAS (show_ipv6_bgp_community_exact
,
10937 show_ipv6_bgp_community4_exact_cmd
,
10938 "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",
10942 "Display routes matching the communities\n"
10944 "Do not send outside local AS (well-known community)\n"
10945 "Do not advertise to any peer (well-known community)\n"
10946 "Do not export to next AS (well-known community)\n"
10948 "Do not send outside local AS (well-known community)\n"
10949 "Do not advertise to any peer (well-known community)\n"
10950 "Do not export to next AS (well-known community)\n"
10952 "Do not send outside local AS (well-known community)\n"
10953 "Do not advertise to any peer (well-known community)\n"
10954 "Do not export to next AS (well-known community)\n"
10956 "Do not send outside local AS (well-known community)\n"
10957 "Do not advertise to any peer (well-known community)\n"
10958 "Do not export to next AS (well-known community)\n"
10959 "Exact match of the communities")
10962 DEFUN (show_ipv6_mbgp_community
,
10963 show_ipv6_mbgp_community_cmd
,
10964 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10968 "Display routes matching the communities\n"
10970 "Do not send outside local AS (well-known community)\n"
10971 "Do not advertise to any peer (well-known community)\n"
10972 "Do not export to next AS (well-known community)\n")
10974 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10975 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10979 ALIAS (show_ipv6_mbgp_community
,
10980 show_ipv6_mbgp_community2_cmd
,
10981 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10985 "Display routes matching the communities\n"
10987 "Do not send outside local AS (well-known community)\n"
10988 "Do not advertise to any peer (well-known community)\n"
10989 "Do not export to next AS (well-known community)\n"
10991 "Do not send outside local AS (well-known community)\n"
10992 "Do not advertise to any peer (well-known community)\n"
10993 "Do not export to next AS (well-known community)\n")
10996 ALIAS (show_ipv6_mbgp_community
,
10997 show_ipv6_mbgp_community3_cmd
,
10998 "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)",
11002 "Display routes matching the communities\n"
11004 "Do not send outside local AS (well-known community)\n"
11005 "Do not advertise to any peer (well-known community)\n"
11006 "Do not export to next AS (well-known community)\n"
11008 "Do not send outside local AS (well-known community)\n"
11009 "Do not advertise to any peer (well-known community)\n"
11010 "Do not export to next AS (well-known community)\n"
11012 "Do not send outside local AS (well-known community)\n"
11013 "Do not advertise to any peer (well-known community)\n"
11014 "Do not export to next AS (well-known community)\n")
11017 ALIAS (show_ipv6_mbgp_community
,
11018 show_ipv6_mbgp_community4_cmd
,
11019 "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)",
11023 "Display routes matching the communities\n"
11025 "Do not send outside local AS (well-known community)\n"
11026 "Do not advertise to any peer (well-known community)\n"
11027 "Do not export to next AS (well-known community)\n"
11029 "Do not send outside local AS (well-known community)\n"
11030 "Do not advertise to any peer (well-known community)\n"
11031 "Do not export to next AS (well-known community)\n"
11033 "Do not send outside local AS (well-known community)\n"
11034 "Do not advertise to any peer (well-known community)\n"
11035 "Do not export to next AS (well-known community)\n"
11037 "Do not send outside local AS (well-known community)\n"
11038 "Do not advertise to any peer (well-known community)\n"
11039 "Do not export to next AS (well-known community)\n")
11042 DEFUN (show_ipv6_mbgp_community_exact
,
11043 show_ipv6_mbgp_community_exact_cmd
,
11044 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
11048 "Display routes matching the communities\n"
11050 "Do not send outside local AS (well-known community)\n"
11051 "Do not advertise to any peer (well-known community)\n"
11052 "Do not export to next AS (well-known community)\n"
11053 "Exact match of the communities")
11055 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11056 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
11060 ALIAS (show_ipv6_mbgp_community_exact
,
11061 show_ipv6_mbgp_community2_exact_cmd
,
11062 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11066 "Display routes matching the communities\n"
11068 "Do not send outside local AS (well-known community)\n"
11069 "Do not advertise to any peer (well-known community)\n"
11070 "Do not export to next AS (well-known community)\n"
11072 "Do not send outside local AS (well-known community)\n"
11073 "Do not advertise to any peer (well-known community)\n"
11074 "Do not export to next AS (well-known community)\n"
11075 "Exact match of the communities")
11078 ALIAS (show_ipv6_mbgp_community_exact
,
11079 show_ipv6_mbgp_community3_exact_cmd
,
11080 "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",
11084 "Display routes matching the communities\n"
11086 "Do not send outside local AS (well-known community)\n"
11087 "Do not advertise to any peer (well-known community)\n"
11088 "Do not export to next AS (well-known community)\n"
11090 "Do not send outside local AS (well-known community)\n"
11091 "Do not advertise to any peer (well-known community)\n"
11092 "Do not export to next AS (well-known community)\n"
11094 "Do not send outside local AS (well-known community)\n"
11095 "Do not advertise to any peer (well-known community)\n"
11096 "Do not export to next AS (well-known community)\n"
11097 "Exact match of the communities")
11100 ALIAS (show_ipv6_mbgp_community_exact
,
11101 show_ipv6_mbgp_community4_exact_cmd
,
11102 "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",
11106 "Display routes matching the communities\n"
11108 "Do not send outside local AS (well-known community)\n"
11109 "Do not advertise to any peer (well-known community)\n"
11110 "Do not export to next AS (well-known community)\n"
11112 "Do not send outside local AS (well-known community)\n"
11113 "Do not advertise to any peer (well-known community)\n"
11114 "Do not export to next AS (well-known community)\n"
11116 "Do not send outside local AS (well-known community)\n"
11117 "Do not advertise to any peer (well-known community)\n"
11118 "Do not export to next AS (well-known community)\n"
11120 "Do not send outside local AS (well-known community)\n"
11121 "Do not advertise to any peer (well-known community)\n"
11122 "Do not export to next AS (well-known community)\n"
11123 "Exact match of the communities")
11124 #endif /* HAVE_IPV6 */
11127 bgp_show_community_list (struct vty
*vty
, const char *name
,
11128 const char *com
, int exact
,
11129 afi_t afi
, safi_t safi
)
11131 struct community_list
*list
;
11132 struct bgp
*bgp
= NULL
;
11134 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11136 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11137 return CMD_WARNING
;
11140 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
11143 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
11145 return CMD_WARNING
;
11148 return bgp_show (vty
, bgp
, afi
, safi
,
11149 (exact
? bgp_show_type_community_list_exact
:
11150 bgp_show_type_community_list
), list
, 0);
11153 DEFUN (show_ip_bgp_community_list
,
11154 show_ip_bgp_community_list_cmd
,
11155 "show ip bgp community-list (<1-500>|WORD)",
11159 "Display routes matching the community-list\n"
11160 "community-list number\n"
11161 "community-list name\n")
11163 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
11166 DEFUN (show_ip_bgp_instance_community_list
,
11167 show_ip_bgp_instance_community_list_cmd
,
11168 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
11172 BGP_INSTANCE_HELP_STR
11173 "Display routes matching the community-list\n"
11174 "community-list number\n"
11175 "community-list name\n")
11177 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
11180 DEFUN (show_ip_bgp_ipv4_community_list
,
11181 show_ip_bgp_ipv4_community_list_cmd
,
11182 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11187 "Address Family modifier\n"
11188 "Address Family modifier\n"
11189 "Display routes matching the community-list\n"
11190 "community-list number\n"
11191 "community-list name\n")
11194 safi
= bgp_vty_safi_from_arg(argv
[0]);
11195 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, safi
);
11198 DEFUN (show_ip_bgp_community_list_exact
,
11199 show_ip_bgp_community_list_exact_cmd
,
11200 "show ip bgp community-list (<1-500>|WORD) exact-match",
11204 "Display routes matching the community-list\n"
11205 "community-list number\n"
11206 "community-list name\n"
11207 "Exact match of the communities\n")
11209 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
11212 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
11213 show_ip_bgp_ipv4_community_list_exact_cmd
,
11214 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11219 "Address Family modifier\n"
11220 "Address Family modifier\n"
11221 "Display routes matching the community-list\n"
11222 "community-list number\n"
11223 "community-list name\n"
11224 "Exact match of the communities\n")
11227 safi
= bgp_vty_safi_from_arg(argv
[0]);
11228 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, safi
);
11232 DEFUN (show_bgp_community_list
,
11233 show_bgp_community_list_cmd
,
11234 "show bgp community-list (<1-500>|WORD)",
11237 "Display routes matching the community-list\n"
11238 "community-list number\n"
11239 "community-list name\n")
11241 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11244 ALIAS (show_bgp_community_list
,
11245 show_bgp_ipv6_community_list_cmd
,
11246 "show bgp ipv6 community-list (<1-500>|WORD)",
11250 "Display routes matching the community-list\n"
11251 "community-list number\n"
11252 "community-list name\n")
11255 DEFUN (show_ipv6_bgp_community_list
,
11256 show_ipv6_bgp_community_list_cmd
,
11257 "show ipv6 bgp community-list WORD",
11261 "Display routes matching the community-list\n"
11262 "community-list name\n")
11264 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11265 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11269 DEFUN (show_ipv6_mbgp_community_list
,
11270 show_ipv6_mbgp_community_list_cmd
,
11271 "show ipv6 mbgp community-list WORD",
11275 "Display routes matching the community-list\n"
11276 "community-list name\n")
11278 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11279 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
11282 DEFUN (show_bgp_community_list_exact
,
11283 show_bgp_community_list_exact_cmd
,
11284 "show bgp community-list (<1-500>|WORD) exact-match",
11287 "Display routes matching the community-list\n"
11288 "community-list number\n"
11289 "community-list name\n"
11290 "Exact match of the communities\n")
11292 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11295 ALIAS (show_bgp_community_list_exact
,
11296 show_bgp_ipv6_community_list_exact_cmd
,
11297 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11301 "Display routes matching the community-list\n"
11302 "community-list number\n"
11303 "community-list name\n"
11304 "Exact match of the communities\n")
11307 DEFUN (show_ipv6_bgp_community_list_exact
,
11308 show_ipv6_bgp_community_list_exact_cmd
,
11309 "show ipv6 bgp community-list WORD exact-match",
11313 "Display routes matching the community-list\n"
11314 "community-list name\n"
11315 "Exact match of the communities\n")
11317 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11318 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11322 DEFUN (show_ipv6_mbgp_community_list_exact
,
11323 show_ipv6_mbgp_community_list_exact_cmd
,
11324 "show ipv6 mbgp community-list WORD exact-match",
11328 "Display routes matching the community-list\n"
11329 "community-list name\n"
11330 "Exact match of the communities\n")
11332 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11333 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
11335 #endif /* HAVE_IPV6 */
11338 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11339 const char *prefix
, afi_t afi
,
11340 safi_t safi
, enum bgp_show_type type
)
11344 struct bgp
*bgp
= NULL
;
11346 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11348 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11349 return CMD_WARNING
;
11354 ret
= str2prefix (prefix
, p
);
11357 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11358 return CMD_WARNING
;
11361 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11366 DEFUN (show_ip_bgp_prefix_longer
,
11367 show_ip_bgp_prefix_longer_cmd
,
11368 "show ip bgp A.B.C.D/M longer-prefixes",
11372 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11373 "Display route and more specific routes\n")
11375 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11376 bgp_show_type_prefix_longer
);
11379 DEFUN (show_ip_bgp_instance_prefix_longer
,
11380 show_ip_bgp_instance_prefix_longer_cmd
,
11381 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11385 BGP_INSTANCE_HELP_STR
11386 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11387 "Display route and more specific routes\n")
11389 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
11390 bgp_show_type_prefix_longer
);
11393 DEFUN (show_ip_bgp_flap_prefix_longer
,
11394 show_ip_bgp_flap_prefix_longer_cmd
,
11395 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11399 "Display flap statistics of routes\n"
11400 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11401 "Display route and more specific routes\n")
11403 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11404 bgp_show_type_flap_prefix_longer
);
11407 ALIAS (show_ip_bgp_flap_prefix_longer
,
11408 show_ip_bgp_damp_flap_prefix_longer_cmd
,
11409 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11413 "Display detailed information about dampening\n"
11414 "Display flap statistics of routes\n"
11415 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11416 "Display route and more specific routes\n")
11418 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11419 show_ip_bgp_ipv4_prefix_longer_cmd
,
11420 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11425 "Address Family modifier\n"
11426 "Address Family modifier\n"
11427 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11428 "Display route and more specific routes\n")
11431 safi
= bgp_vty_safi_from_arg(argv
[0]);
11432 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, safi
,
11433 bgp_show_type_prefix_longer
);
11436 DEFUN (show_ip_bgp_flap_address
,
11437 show_ip_bgp_flap_address_cmd
,
11438 "show ip bgp flap-statistics A.B.C.D",
11442 "Display flap statistics of routes\n"
11443 "Network in the BGP routing table to display\n")
11445 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11446 bgp_show_type_flap_address
);
11449 ALIAS (show_ip_bgp_flap_address
,
11450 show_ip_bgp_damp_flap_address_cmd
,
11451 "show ip bgp dampening flap-statistics A.B.C.D",
11455 "Display detailed information about dampening\n"
11456 "Display flap statistics of routes\n"
11457 "Network in the BGP routing table to display\n")
11459 DEFUN (show_ip_bgp_flap_prefix
,
11460 show_ip_bgp_flap_prefix_cmd
,
11461 "show ip bgp flap-statistics A.B.C.D/M",
11465 "Display flap statistics of routes\n"
11466 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11468 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11469 bgp_show_type_flap_prefix
);
11472 ALIAS (show_ip_bgp_flap_prefix
,
11473 show_ip_bgp_damp_flap_prefix_cmd
,
11474 "show ip bgp dampening flap-statistics A.B.C.D/M",
11478 "Display detailed information about dampening\n"
11479 "Display flap statistics of routes\n"
11480 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11483 DEFUN (show_bgp_prefix_longer
,
11484 show_bgp_prefix_longer_cmd
,
11485 "show bgp X:X::X:X/M longer-prefixes",
11488 "IPv6 prefix <network>/<length>\n"
11489 "Display route and more specific routes\n")
11491 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11492 bgp_show_type_prefix_longer
);
11495 ALIAS (show_bgp_prefix_longer
,
11496 show_bgp_ipv6_prefix_longer_cmd
,
11497 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11501 "IPv6 prefix <network>/<length>\n"
11502 "Display route and more specific routes\n")
11505 DEFUN (show_ipv6_bgp_prefix_longer
,
11506 show_ipv6_bgp_prefix_longer_cmd
,
11507 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11511 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11512 "Display route and more specific routes\n")
11514 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11515 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11516 bgp_show_type_prefix_longer
);
11520 DEFUN (show_ipv6_mbgp_prefix_longer
,
11521 show_ipv6_mbgp_prefix_longer_cmd
,
11522 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11526 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11527 "Display route and more specific routes\n")
11529 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11530 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11531 bgp_show_type_prefix_longer
);
11533 #endif /* HAVE_IPV6 */
11535 static struct peer
*
11536 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11537 const char *ip_str
, u_char use_json
)
11542 union sockunion su
;
11544 /* BGP structure lookup. */
11547 bgp
= bgp_lookup_by_name (view_name
);
11552 json_object
*json_no
= NULL
;
11553 json_no
= json_object_new_object();
11554 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11555 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11556 json_object_free(json_no
);
11559 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11565 bgp
= bgp_get_default ();
11570 json_object
*json_no
= NULL
;
11571 json_no
= json_object_new_object();
11572 json_object_string_add(json_no
, "warning", "No BGP process configured");
11573 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11574 json_object_free(json_no
);
11577 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11582 /* Get peer sockunion. */
11583 ret
= str2sockunion (ip_str
, &su
);
11586 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11589 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11595 json_object
*json_no
= NULL
;
11596 json_no
= json_object_new_object();
11597 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11598 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11599 json_object_free(json_no
);
11602 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11609 /* Peer structure lookup. */
11610 peer
= peer_lookup (bgp
, &su
);
11615 json_object
*json_no
= NULL
;
11616 json_no
= json_object_new_object();
11617 json_object_string_add(json_no
, "warning","No such neighbor");
11618 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11619 json_object_free(json_no
);
11622 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11631 BGP_STATS_MAXBITLEN
= 0,
11633 BGP_STATS_PREFIXES
,
11635 BGP_STATS_UNAGGREGATEABLE
,
11636 BGP_STATS_MAX_AGGREGATEABLE
,
11637 BGP_STATS_AGGREGATES
,
11639 BGP_STATS_ASPATH_COUNT
,
11640 BGP_STATS_ASPATH_MAXHOPS
,
11641 BGP_STATS_ASPATH_TOTHOPS
,
11642 BGP_STATS_ASPATH_MAXSIZE
,
11643 BGP_STATS_ASPATH_TOTSIZE
,
11644 BGP_STATS_ASN_HIGHEST
,
11648 static const char *table_stats_strs
[] =
11650 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11651 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11652 [BGP_STATS_RIB
] = "Total Advertisements",
11653 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11654 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11655 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11656 [BGP_STATS_SPACE
] = "Address space advertised",
11657 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11658 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11659 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11660 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11661 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11662 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11663 [BGP_STATS_MAX
] = NULL
,
11666 struct bgp_table_stats
11668 struct bgp_table
*table
;
11669 unsigned long long counts
[BGP_STATS_MAX
];
11673 #define TALLY_SIGFIG 100000
11674 static unsigned long
11675 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11677 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11678 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11679 unsigned long ret
= newtot
/ count
;
11681 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11689 bgp_table_stats_walker (struct thread
*t
)
11691 struct bgp_node
*rn
;
11692 struct bgp_node
*top
;
11693 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11694 unsigned int space
= 0;
11696 if (!(top
= bgp_table_top (ts
->table
)))
11699 switch (top
->p
.family
)
11702 space
= IPV4_MAX_BITLEN
;
11705 space
= IPV6_MAX_BITLEN
;
11709 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11711 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11713 struct bgp_info
*ri
;
11714 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11715 unsigned int rinum
= 0;
11723 ts
->counts
[BGP_STATS_PREFIXES
]++;
11724 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11727 ts
->counts
[BGP_STATS_AVGPLEN
]
11728 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11729 ts
->counts
[BGP_STATS_AVGPLEN
],
11733 /* check if the prefix is included by any other announcements */
11734 while (prn
&& !prn
->info
)
11735 prn
= bgp_node_parent_nolock (prn
);
11737 if (prn
== NULL
|| prn
== top
)
11739 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11740 /* announced address space */
11742 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11744 else if (prn
->info
)
11745 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11747 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11750 ts
->counts
[BGP_STATS_RIB
]++;
11753 (CHECK_FLAG (ri
->attr
->flag
,
11754 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11755 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11757 /* as-path stats */
11758 if (ri
->attr
&& ri
->attr
->aspath
)
11760 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11761 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11762 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11764 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11766 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11767 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11769 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11770 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11772 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11773 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11775 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11776 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11777 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11779 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11780 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11781 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11784 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11785 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11793 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11795 struct bgp_table_stats ts
;
11798 if (!bgp
->rib
[afi
][safi
])
11800 vty_out (vty
, "%% No RIB exists for the AFI(%d)/SAFI(%d)%s",
11801 afi
, safi
, VTY_NEWLINE
);
11802 return CMD_WARNING
;
11805 memset (&ts
, 0, sizeof (ts
));
11806 ts
.table
= bgp
->rib
[afi
][safi
];
11807 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11809 vty_out (vty
, "BGP %s RIB statistics%s%s",
11810 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11812 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11814 if (!table_stats_strs
[i
])
11820 case BGP_STATS_ASPATH_AVGHOPS
:
11821 case BGP_STATS_ASPATH_AVGSIZE
:
11822 case BGP_STATS_AVGPLEN
:
11823 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11824 vty_out (vty
, "%12.2f",
11825 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11828 case BGP_STATS_ASPATH_TOTHOPS
:
11829 case BGP_STATS_ASPATH_TOTSIZE
:
11830 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11831 vty_out (vty
, "%12.2f",
11833 (float)ts
.counts
[i
] /
11834 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11837 case BGP_STATS_TOTPLEN
:
11838 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11839 vty_out (vty
, "%12.2f",
11841 (float)ts
.counts
[i
] /
11842 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11845 case BGP_STATS_SPACE
:
11846 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11847 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11848 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11850 vty_out (vty
, "%30s: ", "%% announced ");
11851 vty_out (vty
, "%12.2f%s",
11852 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11853 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11855 vty_out (vty
, "%30s: ", "/8 equivalent ");
11856 vty_out (vty
, "%12.2f%s",
11857 (float)ts
.counts
[BGP_STATS_SPACE
] /
11858 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11860 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11862 vty_out (vty
, "%30s: ", "/24 equivalent ");
11863 vty_out (vty
, "%12.2f",
11864 (float)ts
.counts
[BGP_STATS_SPACE
] /
11865 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11868 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11869 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11872 vty_out (vty
, "%s", VTY_NEWLINE
);
11874 return CMD_SUCCESS
;
11878 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11879 const char *afi_str
, const char *safi_str
)
11886 bgp
= bgp_lookup_by_name (name
);
11888 bgp
= bgp_get_default ();
11892 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11893 return CMD_WARNING
;
11895 afi
= bgp_vty_afi_from_arg(afi_str
);
11896 if (afi
== AFI_MAX
)
11898 vty_out (vty
, "%% Invalid address family \"%s\"%s",
11899 afi_str
, VTY_NEWLINE
);
11900 return CMD_WARNING
;
11902 safi
= bgp_vty_safi_from_arg(safi_str
);
11903 if (safi
== SAFI_MAX
)
11905 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11906 safi_str
, VTY_NEWLINE
);
11907 return CMD_WARNING
;
11910 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11913 DEFUN (show_bgp_statistics
,
11914 show_bgp_statistics_cmd
,
11915 "show bgp "BGP_AFI_SAFI_CMD_STR
" statistics",
11918 BGP_AFI_SAFI_HELP_STR
11919 "BGP RIB advertisement statistics\n")
11921 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11924 DEFUN (show_bgp_statistics_view
,
11925 show_bgp_statistics_view_cmd
,
11926 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" statistics",
11929 BGP_INSTANCE_HELP_STR
11930 BGP_AFI_SAFI_HELP_STR
11931 "BGP RIB advertisement statistics\n")
11933 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11946 PCOUNT_PFCNT
, /* the figure we display to users */
11950 static const char *pcount_strs
[] =
11952 [PCOUNT_ADJ_IN
] = "Adj-in",
11953 [PCOUNT_DAMPED
] = "Damped",
11954 [PCOUNT_REMOVED
] = "Removed",
11955 [PCOUNT_HISTORY
] = "History",
11956 [PCOUNT_STALE
] = "Stale",
11957 [PCOUNT_VALID
] = "Valid",
11958 [PCOUNT_ALL
] = "All RIB",
11959 [PCOUNT_COUNTED
] = "PfxCt counted",
11960 [PCOUNT_PFCNT
] = "Useable",
11961 [PCOUNT_MAX
] = NULL
,
11964 struct peer_pcounts
11966 unsigned int count
[PCOUNT_MAX
];
11967 const struct peer
*peer
;
11968 const struct bgp_table
*table
;
11972 bgp_peer_count_walker (struct thread
*t
)
11974 struct bgp_node
*rn
;
11975 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11976 const struct peer
*peer
= pc
->peer
;
11978 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11980 struct bgp_adj_in
*ain
;
11981 struct bgp_info
*ri
;
11983 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11984 if (ain
->peer
== peer
)
11985 pc
->count
[PCOUNT_ADJ_IN
]++;
11987 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11989 char buf
[SU_ADDRSTRLEN
];
11991 if (ri
->peer
!= peer
)
11994 pc
->count
[PCOUNT_ALL
]++;
11996 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11997 pc
->count
[PCOUNT_DAMPED
]++;
11998 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11999 pc
->count
[PCOUNT_HISTORY
]++;
12000 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
12001 pc
->count
[PCOUNT_REMOVED
]++;
12002 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
12003 pc
->count
[PCOUNT_STALE
]++;
12004 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
12005 pc
->count
[PCOUNT_VALID
]++;
12006 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12007 pc
->count
[PCOUNT_PFCNT
]++;
12009 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
12011 pc
->count
[PCOUNT_COUNTED
]++;
12012 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12013 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
12015 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12016 buf
, SU_ADDRSTRLEN
),
12022 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12023 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
12025 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12026 buf
, SU_ADDRSTRLEN
),
12036 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
12038 struct peer_pcounts pcounts
= { .peer
= peer
};
12040 json_object
*json
= NULL
;
12041 json_object
*json_loop
= NULL
;
12045 json
= json_object_new_object();
12046 json_loop
= json_object_new_object();
12049 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
12050 || !peer
->bgp
->rib
[afi
][safi
])
12054 json_object_string_add(json
, "warning", "No such neighbor or address family");
12055 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12056 json_object_free(json
);
12059 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12061 return CMD_WARNING
;
12064 memset (&pcounts
, 0, sizeof(pcounts
));
12065 pcounts
.peer
= peer
;
12066 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
12068 /* in-place call via thread subsystem so as to record execution time
12069 * * stats for the thread-walk (i.e. ensure this can't be blamed on
12070 * * on just vty_read()).
12072 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
12076 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
12077 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
12078 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
12080 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12081 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
12083 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
12085 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12087 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
12088 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
12090 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12091 json_object_free(json
);
12096 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
12098 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
12099 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
12104 vty_out (vty
, "Prefix counts for %s, %s%s",
12105 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
12108 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
12109 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
12110 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
12112 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12113 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
12115 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12117 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
12118 peer
->host
, VTY_NEWLINE
);
12119 vty_out (vty
, "Please report this bug, with the above command output%s",
12124 return CMD_SUCCESS
;
12127 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
12128 show_ip_bgp_neighbor_prefix_counts_cmd
,
12129 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12133 "Detailed information on TCP and BGP neighbor connections\n"
12134 "Neighbor to display information about\n"
12135 "Neighbor to display information about\n"
12136 "Neighbor on bgp configured interface\n"
12137 "Display detailed prefix count information\n"
12138 "JavaScript Object Notation\n")
12141 u_char uj
= use_json(argc
, argv
);
12143 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12145 return CMD_WARNING
;
12147 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12150 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
12151 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
12152 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12156 BGP_INSTANCE_HELP_STR
12157 "Detailed information on TCP and BGP neighbor connections\n"
12158 "Neighbor to display information about\n"
12159 "Neighbor to display information about\n"
12160 "Neighbor on bgp configured interface\n"
12161 "Display detailed prefix count information\n"
12162 "JavaScript Object Notation\n")
12165 u_char uj
= use_json(argc
, argv
);
12167 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12169 return CMD_WARNING
;
12171 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12174 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
12175 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
12176 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12180 "Detailed information on TCP and BGP neighbor connections\n"
12181 "Neighbor to display information about\n"
12182 "Neighbor to display information about\n"
12183 "Neighbor on bgp configured interface\n"
12184 "Display detailed prefix count information\n"
12185 "JavaScript Object Notation\n")
12188 u_char uj
= use_json(argc
, argv
);
12190 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12192 return CMD_WARNING
;
12194 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12197 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
12198 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
12199 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12202 BGP_INSTANCE_HELP_STR
12204 "Detailed information on TCP and BGP neighbor connections\n"
12205 "Neighbor to display information about\n"
12206 "Neighbor to display information about\n"
12207 "Neighbor on bgp configured interface\n"
12208 "Display detailed prefix count information\n"
12209 "JavaScript Object Notation\n")
12212 u_char uj
= use_json(argc
, argv
);
12214 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12216 return CMD_WARNING
;
12218 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12221 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
12222 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
12223 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12228 "Address Family modifier\n"
12229 "Address Family modifier\n"
12230 "Detailed information on TCP and BGP neighbor connections\n"
12231 "Neighbor to display information about\n"
12232 "Neighbor to display information about\n"
12233 "Neighbor on bgp configured interface\n"
12234 "Display detailed prefix count information\n"
12235 "JavaScript Object Notation\n")
12238 u_char uj
= use_json(argc
, argv
);
12240 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12242 return CMD_WARNING
;
12245 safi
= bgp_vty_safi_from_arg(argv
[0]);
12246 return bgp_peer_counts (vty
, peer
, AFI_IP
, safi
, uj
);
12250 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12251 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
12253 struct bgp_table
*table
;
12254 struct bgp_adj_in
*ain
;
12255 struct bgp_adj_out
*adj
;
12256 unsigned long output_count
;
12257 unsigned long filtered_count
;
12258 struct bgp_node
*rn
;
12263 struct attr_extra extra
;
12265 struct update_subgroup
*subgrp
;
12266 json_object
*json_scode
= NULL
;
12267 json_object
*json_ocode
= NULL
;
12268 json_object
*json_ar
= NULL
;
12269 struct peer_af
*paf
;
12273 json_scode
= json_object_new_object();
12274 json_ocode
= json_object_new_object();
12275 json_ar
= json_object_new_object();
12277 json_object_string_add(json_scode
, "suppressed", "s");
12278 json_object_string_add(json_scode
, "damped", "d");
12279 json_object_string_add(json_scode
, "history", "h");
12280 json_object_string_add(json_scode
, "valid", "*");
12281 json_object_string_add(json_scode
, "best", ">");
12282 json_object_string_add(json_scode
, "multipath", "=");
12283 json_object_string_add(json_scode
, "internal", "i");
12284 json_object_string_add(json_scode
, "ribFailure", "r");
12285 json_object_string_add(json_scode
, "stale", "S");
12286 json_object_string_add(json_scode
, "removed", "R");
12288 json_object_string_add(json_ocode
, "igp", "i");
12289 json_object_string_add(json_ocode
, "egp", "e");
12290 json_object_string_add(json_ocode
, "incomplete", "?");
12299 json_object_string_add(json
, "alert", "no BGP");
12300 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12301 json_object_free(json
);
12304 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12308 table
= bgp
->rib
[afi
][safi
];
12310 output_count
= filtered_count
= 0;
12311 subgrp
= peer_subgroup(peer
, afi
, safi
);
12313 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12317 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12318 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12319 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12320 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12321 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12325 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12326 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12327 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12329 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12330 VTY_NEWLINE
, VTY_NEWLINE
);
12335 attr
.extra
= &extra
;
12336 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12340 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12342 if (ain
->peer
== peer
)
12348 json_object_int_add(json
, "bgpTableVersion", 0);
12349 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12350 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12351 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12355 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12356 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12357 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12364 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12369 bgp_attr_dup(&attr
, ain
->attr
);
12370 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12372 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12383 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12384 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12385 if (paf
->peer
== peer
)
12391 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12392 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12393 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12394 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12398 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12399 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12400 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12401 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12409 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12415 bgp_attr_dup(&attr
, adj
->attr
);
12416 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12417 if (ret
!= RMAP_DENY
)
12419 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12429 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12431 if (output_count
!= 0)
12434 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12436 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12437 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12441 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12442 json_object_free(json
);
12448 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12449 int in
, const char *rmap_name
, u_char use_json
)
12451 json_object
*json
= NULL
;
12454 json
= json_object_new_object();
12456 if (!peer
|| !peer
->afc
[afi
][safi
])
12460 json_object_string_add(json
, "warning", "No such neighbor or address family");
12461 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12462 json_object_free(json
);
12465 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12467 return CMD_WARNING
;
12470 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12474 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12475 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12476 json_object_free(json
);
12479 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12481 return CMD_WARNING
;
12484 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12486 return CMD_SUCCESS
;
12489 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12490 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12491 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12495 BGP_INSTANCE_HELP_STR
12496 "Detailed information on TCP and BGP neighbor connections\n"
12497 "Neighbor to display information about\n"
12498 "Neighbor to display information about\n"
12499 "Display the routes advertised to a BGP neighbor\n"
12500 "JavaScript Object Notation\n")
12503 u_char uj
= use_json(argc
, argv
);
12505 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12506 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12508 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12511 return CMD_WARNING
;
12513 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12516 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12517 show_ip_bgp_neighbor_advertised_route_cmd
,
12518 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12522 "Detailed information on TCP and BGP neighbor connections\n"
12523 "Neighbor to display information about\n"
12524 "Neighbor to display information about\n"
12525 "Neighbor on bgp configured interface\n"
12526 "Display the routes advertised to a BGP neighbor\n"
12527 "JavaScript Object Notation\n")
12531 const char *rmap_name
= NULL
;
12532 u_char uj
= use_json(argc
, argv
);
12534 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12537 return CMD_WARNING
;
12539 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12541 rmap_name
= argv
[1];
12543 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12546 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12547 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12548 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12552 "Detailed information on TCP and BGP neighbor connections\n"
12553 "Neighbor to display information about\n"
12554 "Neighbor to display information about\n"
12555 "Neighbor on bgp configured interface\n"
12556 "Display the routes advertised to a BGP neighbor\n"
12557 "JavaScript Object Notation\n")
12559 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12560 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12561 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12565 BGP_INSTANCE_HELP_STR
12566 "Detailed information on TCP and BGP neighbor connections\n"
12567 "Neighbor to display information about\n"
12568 "Neighbor to display information about\n"
12569 "Neighbor on bgp configured interface\n"
12570 "Display the routes advertised to a BGP neighbor\n"
12571 "JavaScript Object Notation\n")
12572 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12573 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12574 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12579 "Address Family modifier\n"
12580 "Address Family modifier\n"
12581 "Detailed information on TCP and BGP neighbor connections\n"
12582 "Neighbor to display information about\n"
12583 "Neighbor to display information about\n"
12584 "Neighbor on bgp configured interface\n"
12585 "Display the routes advertised to a BGP neighbor\n"
12586 "JavaScript Object Notation\n")
12589 const char *rmap_name
= NULL
;
12592 u_char uj
= use_json(argc
, argv
);
12594 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12596 return CMD_WARNING
;
12598 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12599 rmap_name
= argv
[2];
12601 safi
= bgp_vty_safi_from_arg(argv
[0]);
12602 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 0, rmap_name
, uj
);
12605 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12606 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12607 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12612 "Address Family modifier\n"
12613 "Address Family modifier\n"
12614 "Detailed information on TCP and BGP neighbor connections\n"
12615 "Neighbor to display information about\n"
12616 "Neighbor to display information about\n"
12617 "Neighbor on bgp configured interface\n"
12618 "Display the routes advertised to a BGP neighbor\n"
12619 "Route-map to control what is displayed\n"
12620 "JavaScript Object Notation\n")
12623 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12624 show_bgp_instance_neighbor_advertised_route_cmd
,
12625 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12628 BGP_INSTANCE_HELP_STR
12629 "Detailed information on TCP and BGP neighbor connections\n"
12630 "Neighbor to display information about\n"
12631 "Neighbor to display information about\n"
12632 "Neighbor on bgp configured interface\n"
12633 "Display the routes advertised to a BGP neighbor\n"
12634 "JavaScript Object Notation\n")
12637 u_char uj
= use_json(argc
, argv
);
12639 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12640 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12642 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12645 return CMD_WARNING
;
12647 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12650 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12651 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12652 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12655 BGP_INSTANCE_HELP_STR
12657 "Detailed information on TCP and BGP neighbor connections\n"
12658 "Neighbor to display information about\n"
12659 "Neighbor to display information about\n"
12660 "Neighbor on bgp configured interface\n"
12661 "Display the routes advertised to a BGP neighbor\n"
12662 "JavaScript Object Notation\n")
12664 DEFUN (show_bgp_neighbor_advertised_route
,
12665 show_bgp_neighbor_advertised_route_cmd
,
12666 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12669 "Detailed information on TCP and BGP neighbor connections\n"
12670 "Neighbor to display information about\n"
12671 "Neighbor to display information about\n"
12672 "Neighbor on bgp configured interface\n"
12673 "Display the routes advertised to a BGP neighbor\n"
12674 "JavaScript Object Notation\n")
12678 const char *rmap_name
= NULL
;
12679 u_char uj
= use_json(argc
, argv
);
12681 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12684 return CMD_WARNING
;
12686 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12687 rmap_name
= argv
[1];
12689 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12692 ALIAS (show_bgp_neighbor_advertised_route
,
12693 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12694 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12698 "Detailed information on TCP and BGP neighbor connections\n"
12699 "Neighbor to display information about\n"
12700 "Neighbor to display information about\n"
12701 "Neighbor on bgp configured interface\n"
12702 "Display the routes advertised to a BGP neighbor\n"
12703 "JavaScript Object Notation\n")
12706 ALIAS (show_bgp_neighbor_advertised_route
,
12707 ipv6_bgp_neighbor_advertised_route_cmd
,
12708 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12712 "Detailed information on TCP and BGP neighbor connections\n"
12713 "Neighbor to display information about\n"
12714 "Neighbor to display information about\n"
12715 "Neighbor on bgp configured interface\n"
12716 "Display the routes advertised to a BGP neighbor\n"
12717 "JavaScript Object Notation\n")
12720 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12721 ipv6_mbgp_neighbor_advertised_route_cmd
,
12722 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12726 "Detailed information on TCP and BGP neighbor connections\n"
12727 "Neighbor to display information about\n"
12728 "Neighbor to display information about\n"
12729 "Neighbor on bgp configured interface\n"
12730 "Neighbor on bgp configured interface\n"
12731 "Display the routes advertised to a BGP neighbor\n"
12732 "JavaScript Object Notation\n")
12735 u_char uj
= use_json(argc
, argv
);
12737 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12739 return CMD_WARNING
;
12741 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12742 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12744 #endif /* HAVE_IPV6 */
12746 DEFUN (show_bgp_instance_neighbor_received_routes
,
12747 show_bgp_instance_neighbor_received_routes_cmd
,
12748 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12751 BGP_INSTANCE_HELP_STR
12752 "Detailed information on TCP and BGP neighbor connections\n"
12753 "Neighbor to display information about\n"
12754 "Neighbor to display information about\n"
12755 "Neighbor on bgp configured interface\n"
12756 "Display the received routes from neighbor\n"
12757 "JavaScript Object Notation\n")
12760 u_char uj
= use_json(argc
, argv
);
12762 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12764 return CMD_WARNING
;
12766 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12769 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12770 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12771 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12775 BGP_INSTANCE_HELP_STR
12776 "Detailed information on TCP and BGP neighbor connections\n"
12777 "Neighbor to display information about\n"
12778 "Neighbor to display information about\n"
12779 "Neighbor on bgp configured interface\n"
12780 "Display the received routes from neighbor\n"
12781 "JavaScript Object Notation\n")
12784 u_char uj
= use_json(argc
, argv
);
12786 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12788 return CMD_WARNING
;
12790 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12793 ALIAS (show_bgp_instance_neighbor_received_routes
,
12794 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12795 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12798 BGP_INSTANCE_HELP_STR
12800 "Detailed information on TCP and BGP neighbor connections\n"
12801 "Neighbor to display information about\n"
12802 "Neighbor to display information about\n"
12803 "Neighbor on bgp configured interface\n"
12804 "Display the received routes from neighbor\n"
12805 "JavaScript Object Notation\n")
12807 DEFUN (show_ip_bgp_neighbor_received_routes
,
12808 show_ip_bgp_neighbor_received_routes_cmd
,
12809 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12813 "Detailed information on TCP and BGP neighbor connections\n"
12814 "Neighbor to display information about\n"
12815 "Neighbor to display information about\n"
12816 "Neighbor on bgp configured interface\n"
12817 "Display the received routes from neighbor\n"
12818 "JavaScript Object Notation\n")
12822 const char *rmap_name
= NULL
;
12823 u_char uj
= use_json(argc
, argv
);
12825 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12828 return CMD_WARNING
;
12830 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12831 rmap_name
= argv
[1];
12833 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12836 ALIAS (show_ip_bgp_neighbor_received_routes
,
12837 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12838 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12842 "Detailed information on TCP and BGP neighbor connections\n"
12843 "Neighbor to display information about\n"
12844 "Neighbor to display information about\n"
12845 "Neighbor on bgp configured interface\n"
12846 "Display the received routes from neighbor\n"
12847 "JavaScript Object Notation\n")
12849 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12850 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12851 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12855 BGP_INSTANCE_HELP_STR
12856 "Detailed information on TCP and BGP neighbor connections\n"
12857 "Neighbor to display information about\n"
12858 "Neighbor to display information about\n"
12859 "Neighbor on bgp configured interface\n"
12860 "Display the received routes from neighbor\n"
12861 "JavaScript Object Notation\n")
12863 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12864 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12865 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12870 "Address Family modifier\n"
12871 "Address Family modifier\n"
12872 "Detailed information on TCP and BGP neighbor connections\n"
12873 "Neighbor to display information about\n"
12874 "Neighbor to display information about\n"
12875 "Neighbor on bgp configured interface\n"
12876 "Display the received routes from neighbor\n"
12877 "JavaScript Object Notation\n")
12880 const char *rmap_name
= NULL
;
12882 u_char uj
= use_json(argc
, argv
);
12884 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12886 return CMD_WARNING
;
12888 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12889 rmap_name
= argv
[2];
12891 safi
= bgp_vty_safi_from_arg(argv
[0]);
12892 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 1, rmap_name
, uj
);
12895 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12896 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12897 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12902 "Address Family modifier\n"
12903 "Address Family modifier\n"
12904 "Detailed information on TCP and BGP neighbor connections\n"
12905 "Neighbor to display information about\n"
12906 "Neighbor to display information about\n"
12907 "Neighbor on bgp configured interface\n"
12908 "Display the received routes from neighbor\n"
12909 "JavaScript Object Notation\n")
12911 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12912 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12913 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12916 BGP_INSTANCE_HELP_STR
12919 "Address family modifier\n"
12920 "Address family modifier\n"
12921 "Detailed information on TCP and BGP neighbor connections\n"
12922 "Neighbor to display information about\n"
12923 "Neighbor to display information about\n"
12924 "Neighbor on bgp configured interface\n"
12925 "Display the advertised routes to neighbor\n"
12926 "Display the received routes from neighbor\n"
12927 "JavaScript Object Notation\n")
12933 u_char uj
= use_json(argc
, argv
);
12935 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12938 return CMD_WARNING
;
12940 afi
= bgp_vty_safi_from_arg(argv
[2]);
12941 safi
= bgp_vty_safi_from_arg(argv
[3]);
12942 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12944 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12947 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12948 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12949 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12953 "Detailed information on TCP and BGP neighbor connections\n"
12954 "Neighbor to display information about\n"
12955 "Neighbor to display information about\n"
12956 "Neighbor on bgp configured interface\n"
12957 "Display information received from a BGP neighbor\n"
12958 "Display the prefixlist filter\n"
12959 "JavaScript Object Notation\n")
12962 union sockunion su
;
12965 u_char uj
= use_json(argc
, argv
);
12967 ret
= str2sockunion (argv
[0], &su
);
12970 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12975 json_object
*json_no
= NULL
;
12976 json_object
*json_sub
= NULL
;
12977 json_no
= json_object_new_object();
12978 json_sub
= json_object_new_object();
12979 json_object_string_add(json_no
, "warning", "Malformed address or name");
12980 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12981 json_object_object_add(json_no
, "detail", json_sub
);
12982 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12983 json_object_free(json_no
);
12986 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12987 return CMD_WARNING
;
12992 peer
= peer_lookup (NULL
, &su
);
12997 json_object
*json_no
= NULL
;
12998 json_no
= json_object_new_object();
12999 json_object_string_add(json_no
, "warning", "Peer not found");
13000 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13001 json_object_free(json_no
);
13004 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13005 return CMD_WARNING
;
13009 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
13010 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13014 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
13015 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13021 json_object
*json_no
= NULL
;
13022 json_no
= json_object_new_object();
13023 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13024 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13025 json_object_free(json_no
);
13028 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13031 return CMD_SUCCESS
;
13034 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
13035 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
13036 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13041 "Address Family modifier\n"
13042 "Address Family modifier\n"
13043 "Detailed information on TCP and BGP neighbor connections\n"
13044 "Neighbor to display information about\n"
13045 "Neighbor to display information about\n"
13046 "Neighbor on bgp configured interface\n"
13047 "Display information received from a BGP neighbor\n"
13048 "Display the prefixlist filter\n"
13049 "JavaScript Object Notation\n")
13052 union sockunion su
;
13055 u_char uj
= use_json(argc
, argv
);
13057 ret
= str2sockunion (argv
[1], &su
);
13060 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
13065 json_object
*json_no
= NULL
;
13066 json_object
*json_sub
= NULL
;
13067 json_no
= json_object_new_object();
13068 json_sub
= json_object_new_object();
13069 json_object_string_add(json_no
, "warning", "Malformed address or name");
13070 json_object_string_add(json_sub
, "warningCause", argv
[1]);
13071 json_object_object_add(json_no
, "detail", json_sub
);
13072 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13073 json_object_free(json_no
);
13076 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
13077 return CMD_WARNING
;
13082 peer
= peer_lookup (NULL
, &su
);
13087 json_object
*json_no
= NULL
;
13088 json_no
= json_object_new_object();
13089 json_object_string_add(json_no
, "warning", "Peer not found");
13090 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13091 json_object_free(json_no
);
13094 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13095 return CMD_WARNING
;
13101 safi
= bgp_vty_safi_from_arg(argv
[0]);
13102 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, safi
);
13103 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13107 vty_out (vty
, "Address family: %s%s",
13108 afi_safi_print (AFI_IP
, safi
), VTY_NEWLINE
);
13109 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13115 json_object
*json_no
= NULL
;
13116 json_no
= json_object_new_object();
13117 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13118 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13119 json_object_free(json_no
);
13122 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13126 return CMD_SUCCESS
;
13129 DEFUN (show_bgp_neighbor_received_routes
,
13130 show_bgp_neighbor_received_routes_cmd
,
13131 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13134 "Detailed information on TCP and BGP neighbor connections\n"
13135 "Neighbor to display information about\n"
13136 "Neighbor to display information about\n"
13137 "Neighbor on bgp configured interface\n"
13138 "Display the received routes from neighbor\n"
13139 "JavaScript Object Notation\n")
13142 const char *rmap_name
= NULL
;
13143 u_char uj
= use_json(argc
, argv
);
13145 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13148 return CMD_WARNING
;
13150 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
13151 rmap_name
= argv
[1];
13153 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13156 ALIAS (show_bgp_neighbor_received_routes
,
13157 show_bgp_ipv6_neighbor_received_routes_cmd
,
13158 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13162 "Detailed information on TCP and BGP neighbor connections\n"
13163 "Neighbor to display information about\n"
13164 "Neighbor to display information about\n"
13165 "Neighbor on bgp configured interface\n"
13166 "Display the received routes from neighbor\n"
13167 "JavaScript Object Notation\n")
13169 DEFUN (show_bgp_neighbor_received_prefix_filter
,
13170 show_bgp_neighbor_received_prefix_filter_cmd
,
13171 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13174 "Detailed information on TCP and BGP neighbor connections\n"
13175 "Neighbor to display information about\n"
13176 "Neighbor to display information about\n"
13177 "Neighbor on bgp configured interface\n"
13178 "Display information received from a BGP neighbor\n"
13179 "Display the prefixlist filter\n"
13180 "JavaScript Object Notation\n")
13183 union sockunion su
;
13186 u_char uj
= use_json(argc
, argv
);
13188 ret
= str2sockunion (argv
[0], &su
);
13191 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13196 json_object
*json_no
= NULL
;
13197 json_object
*json_sub
= NULL
;
13198 json_no
= json_object_new_object();
13199 json_sub
= json_object_new_object();
13200 json_object_string_add(json_no
, "warning", "Malformed address or name");
13201 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13202 json_object_object_add(json_no
, "detail", json_sub
);
13203 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13204 json_object_free(json_no
);
13207 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13208 return CMD_WARNING
;
13213 peer
= peer_lookup (NULL
, &su
);
13218 json_object
*json_no
= NULL
;
13219 json_no
= json_object_new_object();
13220 json_object_string_add(json_no
, "warning", "No Peer");
13221 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13222 json_object_free(json_no
);
13225 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13226 return CMD_WARNING
;
13230 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13231 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13235 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13236 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13242 json_object
*json_no
= NULL
;
13243 json_no
= json_object_new_object();
13244 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13245 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13246 json_object_free(json_no
);
13249 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13252 return CMD_SUCCESS
;
13255 ALIAS (show_bgp_neighbor_received_prefix_filter
,
13256 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
13257 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13261 "Detailed information on TCP and BGP neighbor connections\n"
13262 "Neighbor to display information about\n"
13263 "Neighbor to display information about\n"
13264 "Neighbor on bgp configured interface\n"
13265 "Display information received from a BGP neighbor\n"
13266 "Display the prefixlist filter\n"
13267 "JavaScript Object Notation\n")
13270 ALIAS (show_bgp_neighbor_received_routes
,
13271 ipv6_bgp_neighbor_received_routes_cmd
,
13272 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13276 "Detailed information on TCP and BGP neighbor connections\n"
13277 "Neighbor to display information about\n"
13278 "Neighbor to display information about\n"
13279 "Neighbor on bgp configured interface\n"
13280 "Display the received routes from neighbor\n"
13281 "JavaScript Object Notation\n")
13284 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13285 ipv6_mbgp_neighbor_received_routes_cmd
,
13286 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13290 "Detailed information on TCP and BGP neighbor connections\n"
13291 "Neighbor to display information about\n"
13292 "Neighbor to display information about\n"
13293 "Neighbor on bgp configured interface\n"
13294 "Display the received routes from neighbor\n"
13295 "JavaScript Object Notation\n")
13298 u_char uj
= use_json(argc
, argv
);
13300 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13302 return CMD_WARNING
;
13304 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13305 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13308 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13309 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13310 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13313 BGP_INSTANCE_HELP_STR
13314 "Detailed information on TCP and BGP neighbor connections\n"
13315 "Neighbor to display information about\n"
13316 "Neighbor to display information about\n"
13317 "Neighbor on bgp configured interface\n"
13318 "Display information received from a BGP neighbor\n"
13319 "Display the prefixlist filter\n"
13320 "JavaScript Object Notation\n")
13323 union sockunion su
;
13327 u_char uj
= use_json(argc
, argv
);
13329 /* BGP structure lookup. */
13330 bgp
= bgp_lookup_by_name (argv
[1]);
13335 json_object
*json_no
= NULL
;
13336 json_no
= json_object_new_object();
13337 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13338 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13339 json_object_free(json_no
);
13342 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13343 return CMD_WARNING
;
13346 ret
= str2sockunion (argv
[2], &su
);
13349 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13354 json_object
*json_no
= NULL
;
13355 json_object
*json_sub
= NULL
;
13356 json_no
= json_object_new_object();
13357 json_sub
= json_object_new_object();
13358 json_object_string_add(json_no
, "warning", "Malformed address or name");
13359 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13360 json_object_object_add(json_no
, "detail", json_sub
);
13361 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13362 json_object_free(json_no
);
13365 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13366 return CMD_WARNING
;
13371 peer
= peer_lookup (bgp
, &su
);
13376 json_object
*json_no
= NULL
;
13377 json_no
= json_object_new_object();
13378 json_object_boolean_true_add(json_no
, "noPeer");
13379 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13380 json_object_free(json_no
);
13383 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13384 return CMD_WARNING
;
13389 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13390 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13394 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13395 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13398 return CMD_SUCCESS
;
13400 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13401 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13402 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13405 BGP_INSTANCE_HELP_STR
13407 "Detailed information on TCP and BGP neighbor connections\n"
13408 "Neighbor to display information about\n"
13409 "Neighbor to display information about\n"
13410 "Neighbor on bgp configured interface\n"
13411 "Display information received from a BGP neighbor\n"
13412 "Display the prefixlist filter\n"
13413 "JavaScript Object NOtation\n")
13414 #endif /* HAVE_IPV6 */
13417 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13418 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13420 if (! peer
|| ! peer
->afc
[afi
][safi
])
13424 json_object
*json_no
= NULL
;
13425 json_no
= json_object_new_object();
13426 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13427 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13428 json_object_free(json_no
);
13431 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13432 return CMD_WARNING
;
13435 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13438 DEFUN (show_ip_bgp_neighbor_routes
,
13439 show_ip_bgp_neighbor_routes_cmd
,
13440 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13444 "Detailed information on TCP and BGP neighbor connections\n"
13445 "Neighbor to display information about\n"
13446 "Neighbor to display information about\n"
13447 "Neighbor on bgp configured interface\n"
13448 "Display routes learned from neighbor\n"
13449 "JavaScript Object Notation\n")
13452 u_char uj
= use_json(argc
, argv
);
13454 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13456 return CMD_WARNING
;
13458 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13459 bgp_show_type_neighbor
, uj
);
13462 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13463 show_ip_bgp_instance_neighbor_routes_cmd
,
13464 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13468 BGP_INSTANCE_HELP_STR
13469 "Detailed information on TCP and BGP neighbor connections\n"
13470 "Neighbor to display information about\n"
13471 "Neighbor to display information about\n"
13472 "Neighbor on bgp configured interface\n"
13473 "Display routes learned from neighbor\n"
13474 "JavaScript Object Notation\n")
13477 u_char uj
= use_json(argc
, argv
);
13479 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13481 return CMD_WARNING
;
13483 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13484 bgp_show_type_neighbor
, uj
);
13487 DEFUN (show_ip_bgp_neighbor_flap
,
13488 show_ip_bgp_neighbor_flap_cmd
,
13489 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13493 "Detailed information on TCP and BGP neighbor connections\n"
13494 "Neighbor to display information about\n"
13495 "Neighbor to display information about\n"
13496 "Neighbor on bgp configured interface\n"
13497 "Display flap statistics of the routes learned from neighbor\n"
13498 "JavaScript Object Notation\n")
13501 u_char uj
= use_json(argc
, argv
);
13503 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13505 return CMD_WARNING
;
13507 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13508 bgp_show_type_flap_neighbor
, uj
);
13511 DEFUN (show_ip_bgp_neighbor_damp
,
13512 show_ip_bgp_neighbor_damp_cmd
,
13513 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13517 "Detailed information on TCP and BGP neighbor connections\n"
13518 "Neighbor to display information about\n"
13519 "Neighbor to display information about\n"
13520 "Neighbor on bgp configured interface\n"
13521 "Display the dampened routes received from neighbor\n"
13522 "JavaScript Object Notation\n")
13525 u_char uj
= use_json(argc
, argv
);
13527 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13529 return CMD_WARNING
;
13531 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13532 bgp_show_type_damp_neighbor
, uj
);
13535 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13536 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13537 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13542 "Address Family modifier\n"
13543 "Address Family modifier\n"
13544 "Detailed information on TCP and BGP neighbor connections\n"
13545 "Neighbor to display information about\n"
13546 "Neighbor to display information about\n"
13547 "Neighbor on bgp configured interface\n"
13548 "Display routes learned from neighbor\n"
13549 "JavaScript Object Notation\n")
13553 u_char uj
= use_json(argc
, argv
);
13555 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13557 return CMD_WARNING
;
13559 safi
= bgp_vty_safi_from_arg(argv
[0]);
13560 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, safi
,
13561 bgp_show_type_neighbor
, uj
);
13565 DEFUN (show_bgp_instance_neighbor_routes
,
13566 show_bgp_instance_neighbor_routes_cmd
,
13567 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13570 BGP_INSTANCE_HELP_STR
13571 "Detailed information on TCP and BGP neighbor connections\n"
13572 "Neighbor to display information about\n"
13573 "Neighbor to display information about\n"
13574 "Neighbor on bgp configured interface\n"
13575 "Display routes learned from neighbor\n"
13576 "JavaScript Object Notation\n")
13579 u_char uj
= use_json(argc
, argv
);
13581 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13583 return CMD_WARNING
;
13585 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13586 bgp_show_type_neighbor
, uj
);
13589 ALIAS (show_bgp_instance_neighbor_routes
,
13590 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13591 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13594 BGP_INSTANCE_HELP_STR
13596 "Detailed information on TCP and BGP neighbor connections\n"
13597 "Neighbor to display information about\n"
13598 "Neighbor to display information about\n"
13599 "Neighbor on bgp configured interface\n"
13600 "Display routes learned from neighbor\n"
13601 "JavaScript Object Notation\n")
13603 DEFUN (show_bgp_instance_neighbor_damp
,
13604 show_bgp_instance_neighbor_damp_cmd
,
13605 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13608 BGP_INSTANCE_HELP_STR
13609 "Detailed information on TCP and BGP neighbor connections\n"
13610 "Neighbor to display information about\n"
13611 "Neighbor to display information about\n"
13612 "Neighbor on bgp configured interface\n"
13613 "Display the dampened routes received from neighbor\n"
13614 "JavaScript Object Notation\n")
13617 u_char uj
= use_json(argc
, argv
);
13619 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13620 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13621 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13623 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13626 return CMD_WARNING
;
13628 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13629 bgp_show_type_damp_neighbor
, uj
);
13632 ALIAS (show_bgp_instance_neighbor_damp
,
13633 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13634 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13637 BGP_INSTANCE_HELP_STR
13639 "Detailed information on TCP and BGP neighbor connections\n"
13640 "Neighbor to display information about\n"
13641 "Neighbor to display information about\n"
13642 "Neighbor on bgp configured interface\n"
13643 "Display the dampened routes received from neighbor\n"
13644 "JavaScript Object Notation\n")
13646 DEFUN (show_bgp_instance_neighbor_flap
,
13647 show_bgp_instance_neighbor_flap_cmd
,
13648 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13651 BGP_INSTANCE_HELP_STR
13652 "Detailed information on TCP and BGP neighbor connections\n"
13653 "Neighbor to display information about\n"
13654 "Neighbor to display information about\n"
13655 "Neighbor on bgp configured interface\n"
13656 "Display flap statistics of the routes learned from neighbor\n"
13657 "JavaScript Object Notation\n")
13660 u_char uj
= use_json(argc
, argv
);
13662 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13663 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13664 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13666 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13669 return CMD_WARNING
;
13671 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13672 bgp_show_type_flap_neighbor
, uj
);
13675 ALIAS (show_bgp_instance_neighbor_flap
,
13676 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13677 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13680 BGP_INSTANCE_HELP_STR
13682 "Detailed information on TCP and BGP neighbor connections\n"
13683 "Neighbor to display information about\n"
13684 "Neighbor to display information about\n"
13685 "Neighbor on bgp configured interface\n"
13686 "Display flap statistics of the routes learned from neighbor\n"
13687 "JavaScript Object Notation\n")
13689 DEFUN (show_bgp_neighbor_routes
,
13690 show_bgp_neighbor_routes_cmd
,
13691 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13694 "Detailed information on TCP and BGP neighbor connections\n"
13695 "Neighbor to display information about\n"
13696 "Neighbor to display information about\n"
13697 "Neighbor on bgp configured interface\n"
13698 "Display routes learned from neighbor\n"
13699 "JavaScript Object Notation\n")
13702 u_char uj
= use_json(argc
, argv
);
13704 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13706 return CMD_WARNING
;
13708 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13709 bgp_show_type_neighbor
, uj
);
13713 ALIAS (show_bgp_neighbor_routes
,
13714 show_bgp_ipv6_neighbor_routes_cmd
,
13715 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13719 "Detailed information on TCP and BGP neighbor connections\n"
13720 "Neighbor to display information about\n"
13721 "Neighbor to display information about\n"
13722 "Neighbor on bgp configured interface\n"
13723 "Display routes learned from neighbor\n"
13724 "JavaScript Object Notation\n")
13727 ALIAS (show_bgp_neighbor_routes
,
13728 ipv6_bgp_neighbor_routes_cmd
,
13729 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13733 "Detailed information on TCP and BGP neighbor connections\n"
13734 "Neighbor to display information about\n"
13735 "Neighbor to display information about\n"
13736 "Neighbor on bgp configured interface\n"
13737 "Display routes learned from neighbor\n"
13738 "JavaScript Object Notation\n")
13741 DEFUN (ipv6_mbgp_neighbor_routes
,
13742 ipv6_mbgp_neighbor_routes_cmd
,
13743 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13747 "Detailed information on TCP and BGP neighbor connections\n"
13748 "Neighbor to display information about\n"
13749 "Neighbor to display information about\n"
13750 "Neighbor on bgp configured interface\n"
13751 "Display routes learned from neighbor\n"
13752 "JavaScript Object Notation\n")
13755 u_char uj
= use_json(argc
, argv
);
13757 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13759 return CMD_WARNING
;
13761 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13762 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13763 bgp_show_type_neighbor
, uj
);
13766 ALIAS (show_bgp_instance_neighbor_flap
,
13767 show_bgp_neighbor_flap_cmd
,
13768 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13771 "Detailed information on TCP and BGP neighbor connections\n"
13772 "Neighbor to display information about\n"
13773 "Neighbor to display information about\n"
13774 "Neighbor on bgp configured interface\n"
13775 "Display flap statistics of the routes learned from neighbor\n"
13776 "JavaScript Object Notation\n")
13778 ALIAS (show_bgp_instance_neighbor_flap
,
13779 show_bgp_ipv6_neighbor_flap_cmd
,
13780 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13784 "Detailed information on TCP and BGP neighbor connections\n"
13785 "Neighbor to display information about\n"
13786 "Neighbor to display information about\n"
13787 "Neighbor on bgp configured interface\n"
13788 "Display flap statistics of the routes learned from neighbor\n"
13789 "JavaScript Object Notation\n")
13791 ALIAS (show_bgp_instance_neighbor_damp
,
13792 show_bgp_neighbor_damp_cmd
,
13793 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13796 "Detailed information on TCP and BGP neighbor connections\n"
13797 "Neighbor to display information about\n"
13798 "Neighbor to display information about\n"
13799 "Neighbor on bgp configured interface\n"
13800 "Display the dampened routes received from neighbor\n"
13801 "JavaScript Object Notation\n")
13803 ALIAS (show_bgp_instance_neighbor_damp
,
13804 show_bgp_ipv6_neighbor_damp_cmd
,
13805 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13809 "Detailed information on TCP and BGP neighbor connections\n"
13810 "Neighbor to display information about\n"
13811 "Neighbor to display information about\n"
13812 "Neighbor on bgp configured interface\n"
13813 "Display the dampened routes received from neighbor\n"
13814 "JavaScript Object Notation\n")
13816 #endif /* HAVE_IPV6 */
13818 struct bgp_table
*bgp_distance_table
[AFI_MAX
][SAFI_MAX
];
13820 struct bgp_distance
13822 /* Distance value for the IP source prefix. */
13825 /* Name of the access-list to be matched. */
13829 static struct bgp_distance
*
13830 bgp_distance_new (void)
13832 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13836 bgp_distance_free (struct bgp_distance
*bdistance
)
13838 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13842 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13843 const char *ip_str
, const char *access_list_str
)
13850 struct bgp_node
*rn
;
13851 struct bgp_distance
*bdistance
;
13853 afi
= bgp_node_afi (vty
);
13854 safi
= bgp_node_safi (vty
);
13856 ret
= str2prefix (ip_str
, &p
);
13859 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13860 return CMD_WARNING
;
13863 distance
= atoi (distance_str
);
13865 /* Get BGP distance node. */
13866 rn
= bgp_node_get (bgp_distance_table
[afi
][safi
], (struct prefix
*) &p
);
13869 bdistance
= rn
->info
;
13870 bgp_unlock_node (rn
);
13874 bdistance
= bgp_distance_new ();
13875 rn
->info
= bdistance
;
13878 /* Set distance value. */
13879 bdistance
->distance
= distance
;
13881 /* Reset access-list configuration. */
13882 if (bdistance
->access_list
)
13884 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13885 bdistance
->access_list
= NULL
;
13887 if (access_list_str
)
13888 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13890 return CMD_SUCCESS
;
13894 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13895 const char *ip_str
, const char *access_list_str
)
13902 struct bgp_node
*rn
;
13903 struct bgp_distance
*bdistance
;
13905 afi
= bgp_node_afi (vty
);
13906 safi
= bgp_node_safi (vty
);
13908 ret
= str2prefix (ip_str
, &p
);
13911 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13912 return CMD_WARNING
;
13915 rn
= bgp_node_lookup (bgp_distance_table
[afi
][safi
], (struct prefix
*)&p
);
13918 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13919 return CMD_WARNING
;
13922 bdistance
= rn
->info
;
13923 distance
= atoi(distance_str
);
13925 if (bdistance
->distance
!= distance
)
13927 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13928 return CMD_WARNING
;
13931 if (bdistance
->access_list
)
13932 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13933 bgp_distance_free (bdistance
);
13936 bgp_unlock_node (rn
);
13937 bgp_unlock_node (rn
);
13939 return CMD_SUCCESS
;
13942 /* Apply BGP information to distance method. */
13944 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, afi_t afi
,
13945 safi_t safi
, struct bgp
*bgp
)
13947 struct bgp_node
*rn
;
13950 struct bgp_distance
*bdistance
;
13951 struct access_list
*alist
;
13952 struct bgp_static
*bgp_static
;
13957 peer
= rinfo
->peer
;
13959 /* Check source address. */
13960 sockunion2hostprefix (&peer
->su
, &q
);
13961 rn
= bgp_node_match (bgp_distance_table
[afi
][safi
], &q
);
13964 bdistance
= rn
->info
;
13965 bgp_unlock_node (rn
);
13967 if (bdistance
->access_list
)
13969 alist
= access_list_lookup (afi
, bdistance
->access_list
);
13970 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13971 return bdistance
->distance
;
13974 return bdistance
->distance
;
13977 /* Backdoor check. */
13978 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], p
);
13981 bgp_static
= rn
->info
;
13982 bgp_unlock_node (rn
);
13984 if (bgp_static
->backdoor
)
13986 if (bgp
->distance_local
[afi
][safi
])
13987 return bgp
->distance_local
[afi
][safi
];
13989 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13993 if (peer
->sort
== BGP_PEER_EBGP
)
13995 if (bgp
->distance_ebgp
[afi
][safi
])
13996 return bgp
->distance_ebgp
[afi
][safi
];
13997 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
14001 if (bgp
->distance_ibgp
[afi
][safi
])
14002 return bgp
->distance_ibgp
[afi
][safi
];
14003 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
14007 DEFUN (bgp_distance
,
14009 "distance bgp <1-255> <1-255> <1-255>",
14010 "Define an administrative distance\n"
14012 "Distance for routes external to the AS\n"
14013 "Distance for routes internal to the AS\n"
14014 "Distance for local routes\n")
14021 afi
= bgp_node_afi (vty
);
14022 safi
= bgp_node_safi (vty
);
14024 bgp
->distance_ebgp
[afi
][safi
] = atoi (argv
[0]);
14025 bgp
->distance_ibgp
[afi
][safi
] = atoi (argv
[1]);
14026 bgp
->distance_local
[afi
][safi
] = atoi (argv
[2]);
14027 return CMD_SUCCESS
;
14030 DEFUN (no_bgp_distance
,
14031 no_bgp_distance_cmd
,
14032 "no distance bgp <1-255> <1-255> <1-255>",
14034 "Define an administrative distance\n"
14036 "Distance for routes external to the AS\n"
14037 "Distance for routes internal to the AS\n"
14038 "Distance for local routes\n")
14045 afi
= bgp_node_afi (vty
);
14046 safi
= bgp_node_safi (vty
);
14048 bgp
->distance_ebgp
[afi
][safi
] = 0;
14049 bgp
->distance_ibgp
[afi
][safi
] = 0;
14050 bgp
->distance_local
[afi
][safi
] = 0;
14051 return CMD_SUCCESS
;
14054 ALIAS (no_bgp_distance
,
14055 no_bgp_distance2_cmd
,
14058 "Define an administrative distance\n"
14061 DEFUN (bgp_distance_source
,
14062 bgp_distance_source_cmd
,
14063 "distance <1-255> A.B.C.D/M",
14064 "Define an administrative distance\n"
14065 "Administrative distance\n"
14066 "IP source prefix\n")
14068 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14069 return CMD_SUCCESS
;
14072 DEFUN (no_bgp_distance_source
,
14073 no_bgp_distance_source_cmd
,
14074 "no distance <1-255> A.B.C.D/M",
14076 "Define an administrative distance\n"
14077 "Administrative distance\n"
14078 "IP source prefix\n")
14080 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14081 return CMD_SUCCESS
;
14084 DEFUN (bgp_distance_source_access_list
,
14085 bgp_distance_source_access_list_cmd
,
14086 "distance <1-255> A.B.C.D/M WORD",
14087 "Define an administrative distance\n"
14088 "Administrative distance\n"
14089 "IP source prefix\n"
14090 "Access list name\n")
14092 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14093 return CMD_SUCCESS
;
14096 DEFUN (no_bgp_distance_source_access_list
,
14097 no_bgp_distance_source_access_list_cmd
,
14098 "no distance <1-255> A.B.C.D/M WORD",
14100 "Define an administrative distance\n"
14101 "Administrative distance\n"
14102 "IP source prefix\n"
14103 "Access list name\n")
14105 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14106 return CMD_SUCCESS
;
14109 DEFUN (ipv6_bgp_distance_source
,
14110 ipv6_bgp_distance_source_cmd
,
14111 "distance <1-255> X:X::X:X/M",
14112 "Define an administrative distance\n"
14113 "Administrative distance\n"
14114 "IP source prefix\n")
14116 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14117 return CMD_SUCCESS
;
14120 DEFUN (no_ipv6_bgp_distance_source
,
14121 no_ipv6_bgp_distance_source_cmd
,
14122 "no distance <1-255> X:X::X:X/M",
14124 "Define an administrative distance\n"
14125 "Administrative distance\n"
14126 "IP source prefix\n")
14128 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14129 return CMD_SUCCESS
;
14132 DEFUN (ipv6_bgp_distance_source_access_list
,
14133 ipv6_bgp_distance_source_access_list_cmd
,
14134 "distance <1-255> X:X::X:X/M WORD",
14135 "Define an administrative distance\n"
14136 "Administrative distance\n"
14137 "IP source prefix\n"
14138 "Access list name\n")
14140 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14141 return CMD_SUCCESS
;
14144 DEFUN (no_ipv6_bgp_distance_source_access_list
,
14145 no_ipv6_bgp_distance_source_access_list_cmd
,
14146 "no distance <1-255> X:X::X:X/M WORD",
14148 "Define an administrative distance\n"
14149 "Administrative distance\n"
14150 "IP source prefix\n"
14151 "Access list name\n")
14153 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14154 return CMD_SUCCESS
;
14157 DEFUN (bgp_damp_set
,
14159 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14160 "BGP Specific commands\n"
14161 "Enable route-flap dampening\n"
14162 "Half-life time for the penalty\n"
14163 "Value to start reusing a route\n"
14164 "Value to start suppressing a route\n"
14165 "Maximum duration to suppress a stable route\n")
14168 int half
= DEFAULT_HALF_LIFE
* 60;
14169 int reuse
= DEFAULT_REUSE
;
14170 int suppress
= DEFAULT_SUPPRESS
;
14171 int max
= 4 * half
;
14175 half
= atoi (argv
[0]) * 60;
14176 reuse
= atoi (argv
[1]);
14177 suppress
= atoi (argv
[2]);
14178 max
= atoi (argv
[3]) * 60;
14180 else if (argc
== 1)
14182 half
= atoi (argv
[0]) * 60;
14188 if (suppress
< reuse
)
14190 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
14195 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
14196 half
, reuse
, suppress
, max
);
14199 ALIAS (bgp_damp_set
,
14201 "bgp dampening <1-45>",
14202 "BGP Specific commands\n"
14203 "Enable route-flap dampening\n"
14204 "Half-life time for the penalty\n")
14206 ALIAS (bgp_damp_set
,
14209 "BGP Specific commands\n"
14210 "Enable route-flap dampening\n")
14212 DEFUN (bgp_damp_unset
,
14213 bgp_damp_unset_cmd
,
14214 "no bgp dampening",
14216 "BGP Specific commands\n"
14217 "Enable route-flap dampening\n")
14222 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
14225 ALIAS (bgp_damp_unset
,
14226 bgp_damp_unset2_cmd
,
14227 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14229 "BGP Specific commands\n"
14230 "Enable route-flap dampening\n"
14231 "Half-life time for the penalty\n"
14232 "Value to start reusing a route\n"
14233 "Value to start suppressing a route\n"
14234 "Maximum duration to suppress a stable route\n")
14236 ALIAS (bgp_damp_unset
,
14237 bgp_damp_unset3_cmd
,
14238 "no bgp dampening <1-45>",
14240 "BGP Specific commands\n"
14241 "Enable route-flap dampening\n"
14242 "Half-life time for the penalty\n")
14244 DEFUN (show_ip_bgp_dampened_paths
,
14245 show_ip_bgp_dampened_paths_cmd
,
14246 "show ip bgp dampened-paths",
14250 "Display paths suppressed due to dampening\n")
14252 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
14256 ALIAS (show_ip_bgp_dampened_paths
,
14257 show_ip_bgp_damp_dampened_paths_cmd
,
14258 "show ip bgp dampening dampened-paths",
14262 "Display detailed information about dampening\n"
14263 "Display paths suppressed due to dampening\n")
14265 DEFUN (show_ip_bgp_flap_statistics
,
14266 show_ip_bgp_flap_statistics_cmd
,
14267 "show ip bgp flap-statistics",
14271 "Display flap statistics of routes\n")
14273 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
14274 bgp_show_type_flap_statistics
, NULL
, 0);
14277 ALIAS (show_ip_bgp_flap_statistics
,
14278 show_ip_bgp_damp_flap_statistics_cmd
,
14279 "show ip bgp dampening flap-statistics",
14283 "Display detailed information about dampening\n"
14284 "Display flap statistics of routes\n")
14286 /* Display specified route of BGP table. */
14288 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
14289 const char *ip_str
, afi_t afi
, safi_t safi
,
14290 struct prefix_rd
*prd
, int prefix_check
)
14293 struct prefix match
;
14294 struct bgp_node
*rn
;
14295 struct bgp_node
*rm
;
14296 struct bgp_info
*ri
;
14297 struct bgp_info
*ri_temp
;
14299 struct bgp_table
*table
;
14301 /* BGP structure lookup. */
14304 bgp
= bgp_lookup_by_name (view_name
);
14307 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
14308 return CMD_WARNING
;
14313 bgp
= bgp_get_default ();
14316 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14317 return CMD_WARNING
;
14321 /* Check IP address argument. */
14322 ret
= str2prefix (ip_str
, &match
);
14325 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14326 return CMD_WARNING
;
14329 match
.family
= afi2family (afi
);
14331 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14333 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14335 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14338 if ((table
= rn
->info
) != NULL
)
14339 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14341 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14346 if (ri
->extra
&& ri
->extra
->damp_info
)
14348 ri_temp
= ri
->next
;
14349 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14357 bgp_unlock_node (rm
);
14363 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14365 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14370 if (ri
->extra
&& ri
->extra
->damp_info
)
14372 ri_temp
= ri
->next
;
14373 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14381 bgp_unlock_node (rn
);
14385 return CMD_SUCCESS
;
14388 DEFUN (clear_ip_bgp_dampening
,
14389 clear_ip_bgp_dampening_cmd
,
14390 "clear ip bgp dampening",
14394 "Clear route flap dampening information\n")
14396 bgp_damp_info_clean ();
14397 return CMD_SUCCESS
;
14400 DEFUN (clear_ip_bgp_dampening_prefix
,
14401 clear_ip_bgp_dampening_prefix_cmd
,
14402 "clear ip bgp dampening A.B.C.D/M",
14406 "Clear route flap dampening information\n"
14407 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14409 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14410 SAFI_UNICAST
, NULL
, 1);
14413 DEFUN (clear_ip_bgp_dampening_address
,
14414 clear_ip_bgp_dampening_address_cmd
,
14415 "clear ip bgp dampening A.B.C.D",
14419 "Clear route flap dampening information\n"
14420 "Network to clear damping information\n")
14422 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14423 SAFI_UNICAST
, NULL
, 0);
14426 DEFUN (clear_ip_bgp_dampening_address_mask
,
14427 clear_ip_bgp_dampening_address_mask_cmd
,
14428 "clear ip bgp dampening A.B.C.D A.B.C.D",
14432 "Clear route flap dampening information\n"
14433 "Network to clear damping information\n"
14437 char prefix_str
[BUFSIZ
];
14439 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14442 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14443 return CMD_WARNING
;
14446 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14447 SAFI_UNICAST
, NULL
, 0);
14450 /* also used for encap safi */
14452 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14453 afi_t afi
, safi_t safi
, int *write
)
14455 struct bgp_node
*prn
;
14456 struct bgp_node
*rn
;
14457 struct bgp_table
*table
;
14459 struct prefix_rd
*prd
;
14460 struct bgp_static
*bgp_static
;
14462 char buf
[SU_ADDRSTRLEN
];
14463 char rdbuf
[RD_ADDRSTRLEN
];
14465 /* Network configuration. */
14466 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14467 if ((table
= prn
->info
) != NULL
)
14468 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14469 if ((bgp_static
= rn
->info
) != NULL
)
14472 prd
= (struct prefix_rd
*) &prn
->p
;
14474 /* "address-family" display. */
14475 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14477 /* "network" configuration display. */
14478 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14479 label
= decode_label (bgp_static
->tag
);
14481 vty_out (vty
, " network %s/%d rd %s tag %d",
14482 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14485 vty_out (vty
, "%s", VTY_NEWLINE
);
14490 /* Configuration of static route announcement and aggregate
14493 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14494 afi_t afi
, safi_t safi
, int *write
)
14496 struct bgp_node
*rn
;
14498 struct bgp_static
*bgp_static
;
14499 struct bgp_aggregate
*bgp_aggregate
;
14500 char buf
[SU_ADDRSTRLEN
];
14502 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14503 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14505 /* Network configuration. */
14506 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14507 if ((bgp_static
= rn
->info
) != NULL
)
14511 /* "address-family" display. */
14512 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14514 /* "network" configuration display. */
14515 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14517 u_int32_t destination
;
14518 struct in_addr netmask
;
14520 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14521 masklen2ip (p
->prefixlen
, &netmask
);
14522 vty_out (vty
, " network %s",
14523 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14525 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14526 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14527 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14528 || p
->u
.prefix4
.s_addr
== 0)
14530 /* Natural mask is not display. */
14533 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14537 vty_out (vty
, " network %s/%d",
14538 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14542 if (bgp_static
->rmap
.name
)
14543 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14546 if (bgp_static
->backdoor
)
14547 vty_out (vty
, " backdoor");
14550 vty_out (vty
, "%s", VTY_NEWLINE
);
14553 /* Aggregate-address configuration. */
14554 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14555 if ((bgp_aggregate
= rn
->info
) != NULL
)
14559 /* "address-family" display. */
14560 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14562 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14564 struct in_addr netmask
;
14566 masklen2ip (p
->prefixlen
, &netmask
);
14567 vty_out (vty
, " aggregate-address %s %s",
14568 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14569 inet_ntoa (netmask
));
14573 vty_out (vty
, " aggregate-address %s/%d",
14574 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14578 if (bgp_aggregate
->as_set
)
14579 vty_out (vty
, " as-set");
14581 if (bgp_aggregate
->summary_only
)
14582 vty_out (vty
, " summary-only");
14584 vty_out (vty
, "%s", VTY_NEWLINE
);
14591 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
14592 safi_t safi
, int *write
)
14594 struct bgp_node
*rn
;
14595 struct bgp_distance
*bdistance
;
14597 /* Distance configuration. */
14598 if (bgp
->distance_ebgp
[afi
][safi
]
14599 && bgp
->distance_ibgp
[afi
][safi
]
14600 && bgp
->distance_local
[afi
][safi
]
14601 && (bgp
->distance_ebgp
[afi
][safi
] != ZEBRA_EBGP_DISTANCE_DEFAULT
14602 || bgp
->distance_ibgp
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
14603 || bgp
->distance_local
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
))
14605 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14606 vty_out (vty
, " distance bgp %d %d %d%s",
14607 bgp
->distance_ebgp
[afi
][safi
], bgp
->distance_ibgp
[afi
][safi
],
14608 bgp
->distance_local
[afi
][safi
], VTY_NEWLINE
);
14611 for (rn
= bgp_table_top (bgp_distance_table
[afi
][safi
]); rn
;
14612 rn
= bgp_route_next (rn
))
14613 if ((bdistance
= rn
->info
) != NULL
)
14615 char buf
[PREFIX_STRLEN
];
14617 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14618 vty_out (vty
, " distance %d %s %s%s", bdistance
->distance
,
14619 prefix2str (&rn
->p
, buf
, sizeof (buf
)),
14620 bdistance
->access_list
? bdistance
->access_list
: "",
14627 /* Allocate routing table structure and install commands. */
14629 bgp_route_init (void)
14634 /* Init BGP distance table. */
14635 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
14636 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
14637 bgp_distance_table
[afi
][safi
] = bgp_table_init (afi
, safi
);
14639 /* IPv4 BGP commands. */
14640 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14641 install_element (BGP_NODE
, &bgp_network_cmd
);
14642 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14643 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14644 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14645 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14646 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14647 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14648 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14649 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14650 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14651 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14652 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14653 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14654 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14655 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14656 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14657 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14658 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14659 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14661 install_element (BGP_NODE
, &aggregate_address_cmd
);
14662 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14663 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14664 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14665 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14666 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14667 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14668 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14669 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14670 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14671 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14672 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14673 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14674 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14675 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14676 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14677 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14678 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14679 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14680 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14682 /* IPv4 unicast configuration. */
14683 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14684 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14685 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14686 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14687 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14688 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14689 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14690 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14691 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14692 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14693 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14694 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14695 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14696 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14698 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14699 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14700 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14701 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14702 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14703 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14704 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14705 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14706 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14707 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14708 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14709 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14710 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14711 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14712 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14713 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14714 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14715 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14716 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14717 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14719 /* IPv4 multicast configuration. */
14720 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14721 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14722 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14723 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14724 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14725 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14726 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14727 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14728 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14729 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14730 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14731 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14732 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14733 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14734 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14735 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14736 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14737 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14738 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14739 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14740 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14741 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14742 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14743 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14744 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14745 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14746 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14747 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14748 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14749 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14750 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14751 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14752 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14753 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14755 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14756 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14757 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14758 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14759 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14760 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14761 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14762 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14763 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14764 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14765 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14766 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14767 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14768 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14769 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14770 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14771 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14772 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14773 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14774 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14776 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14777 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14778 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14779 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14780 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14781 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14782 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14783 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14784 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14785 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14786 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14787 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14788 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14789 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14790 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14791 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14792 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14793 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14794 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14795 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14796 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14797 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14798 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14799 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14800 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14801 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14802 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14803 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14804 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14805 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14806 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14807 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14808 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14809 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14810 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14811 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14812 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14813 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14814 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14815 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14816 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14817 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14818 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14819 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14820 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14821 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14822 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14823 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14824 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14825 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14826 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14827 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14828 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14829 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14830 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14831 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14832 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14833 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14834 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14835 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14836 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14837 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14838 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14839 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
14840 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14841 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
14842 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
14843 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14844 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14845 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14846 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14847 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14848 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14849 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14850 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14851 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14852 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14853 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14854 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14855 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14856 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14857 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14858 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14859 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14860 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14861 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14863 install_element (VIEW_NODE
, &show_bgp_ipv4_prefix_cmd
);
14864 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_route_cmd
);
14865 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_route_cmd
);
14866 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_prefix_cmd
);
14867 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_prefix_cmd
);
14869 /* BGP dampening clear commands */
14870 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14871 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14872 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14873 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14876 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14877 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14878 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14880 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14881 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14883 /* New config IPv6 BGP commands. */
14884 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14885 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14886 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14887 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14888 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14889 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14891 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14892 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14893 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14894 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14896 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14897 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14899 /* Old config IPv6 BGP commands. */
14900 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14901 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14903 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14904 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14905 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14906 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14908 install_element (VIEW_NODE
, &show_bgp_cmd
);
14909 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14910 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14911 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14912 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14913 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14914 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14915 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14916 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14917 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14918 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14919 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14920 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14921 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14922 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14923 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14924 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14925 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14926 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14927 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14928 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14929 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14930 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14931 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14932 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14933 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14934 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14935 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14936 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14937 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14938 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14939 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14940 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14941 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14942 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14943 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14944 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14945 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14946 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14947 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14948 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14949 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14950 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14951 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14952 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14953 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14954 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14955 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14956 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14957 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14958 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14959 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14960 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14961 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14962 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14963 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14964 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14965 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14966 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14967 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14968 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14969 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14970 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14971 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14972 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14973 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14974 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14975 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14976 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14977 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14978 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14979 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14980 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14981 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14982 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14983 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14984 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14985 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14986 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14987 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14988 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14989 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14990 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14991 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14992 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14993 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14994 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14995 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14996 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14997 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14998 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14999 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
15002 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
15003 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
15004 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
15005 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
15008 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
15009 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
15010 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
15011 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
15012 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
15013 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
15014 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
15015 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
15016 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
15017 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
15018 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
15019 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
15020 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
15021 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
15022 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
15023 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
15024 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15025 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15026 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
15027 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
15028 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15029 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15030 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15031 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15032 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15033 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
15034 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
15035 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
15036 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
15037 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15038 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
15039 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
15040 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
15041 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15042 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15043 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15046 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
15047 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15050 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
15051 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15054 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
15055 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15056 #endif /* HAVE_IPV6 */
15058 install_element (BGP_NODE
, &bgp_distance_cmd
);
15059 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
15060 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
15061 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
15062 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
15063 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
15064 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
15065 install_element (BGP_IPV4_NODE
, &bgp_distance_cmd
);
15066 install_element (BGP_IPV4_NODE
, &no_bgp_distance_cmd
);
15067 install_element (BGP_IPV4_NODE
, &no_bgp_distance2_cmd
);
15068 install_element (BGP_IPV4_NODE
, &bgp_distance_source_cmd
);
15069 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_cmd
);
15070 install_element (BGP_IPV4_NODE
, &bgp_distance_source_access_list_cmd
);
15071 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_access_list_cmd
);
15072 install_element (BGP_IPV4M_NODE
, &bgp_distance_cmd
);
15073 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_cmd
);
15074 install_element (BGP_IPV4M_NODE
, &no_bgp_distance2_cmd
);
15075 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_cmd
);
15076 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_cmd
);
15077 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_access_list_cmd
);
15078 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_access_list_cmd
);
15079 install_element (BGP_IPV6_NODE
, &bgp_distance_cmd
);
15080 install_element (BGP_IPV6_NODE
, &no_bgp_distance_cmd
);
15081 install_element (BGP_IPV6_NODE
, &no_bgp_distance2_cmd
);
15082 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_cmd
);
15083 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15084 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15085 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15086 install_element (BGP_IPV6M_NODE
, &bgp_distance_cmd
);
15087 install_element (BGP_IPV6M_NODE
, &no_bgp_distance_cmd
);
15088 install_element (BGP_IPV6M_NODE
, &no_bgp_distance2_cmd
);
15089 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_cmd
);
15090 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15091 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15092 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15094 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15095 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15096 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15097 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15098 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15099 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15100 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15101 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15102 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15103 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15104 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15105 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15107 /* IPv4 Multicast Mode */
15108 install_element (BGP_IPV4M_NODE
, &bgp_damp_set_cmd
);
15109 install_element (BGP_IPV4M_NODE
, &bgp_damp_set2_cmd
);
15110 install_element (BGP_IPV4M_NODE
, &bgp_damp_set3_cmd
);
15111 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset_cmd
);
15112 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset2_cmd
);
15116 bgp_route_finish (void)
15121 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
15122 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
15124 bgp_table_unlock (bgp_distance_table
[afi
][safi
]);
15125 bgp_distance_table
[afi
][safi
] = NULL
;