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
);
2842 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2843 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2844 struct prefix_rd
*prd
, u_char
*tag
)
2847 char buf
[SU_ADDRSTRLEN
];
2849 struct bgp_node
*rn
;
2850 struct bgp_info
*ri
;
2853 if ((SAFI_MPLS_VPN
== safi
) || (SAFI_ENCAP
== safi
))
2855 rfapiProcessWithdraw(peer
, NULL
, p
, prd
, NULL
, afi
, safi
, type
, 0);
2862 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2864 /* If peer is soft reconfiguration enabled. Record input packet for
2865 * further calculation.
2867 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2868 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2869 * the iteration over all RS clients.
2870 * Since we need to remove the entry from adj_in anyway, do that first and
2871 * if there was no entry, we don't need to do anything more.
2873 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2874 && peer
!= bgp
->peer_self
)
2875 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2877 if (bgp_debug_update (peer
, p
, NULL
, 1))
2878 zlog_debug ("%s withdrawing route %s/%d "
2879 "not in adj-in", peer
->host
,
2880 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2882 bgp_unlock_node (rn
);
2886 /* Lookup withdrawn route. */
2887 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2888 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2889 ri
->addpath_rx_id
== addpath_id
)
2893 if (bgp_debug_update(peer
, p
, NULL
, 1))
2895 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2896 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2898 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2899 p
->prefixlen
, buf2
);
2902 /* Withdraw specified route from routing table. */
2903 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2904 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
, prd
);
2905 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2906 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2907 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2910 /* Unlock bgp_node_get() lock. */
2911 bgp_unlock_node (rn
);
2917 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2919 struct update_subgroup
*subgrp
;
2920 subgrp
= peer_subgroup(peer
, afi
, safi
);
2921 subgroup_default_originate(subgrp
, withdraw
);
2926 * bgp_stop_announce_route_timer
2929 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2931 if (!paf
->t_announce_route
)
2934 THREAD_TIMER_OFF (paf
->t_announce_route
);
2938 * bgp_announce_route_timer_expired
2940 * Callback that is invoked when the route announcement timer for a
2944 bgp_announce_route_timer_expired (struct thread
*t
)
2946 struct peer_af
*paf
;
2949 paf
= THREAD_ARG (t
);
2952 assert (paf
->t_announce_route
);
2953 paf
->t_announce_route
= NULL
;
2955 if (peer
->status
!= Established
)
2958 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2961 peer_af_announce_route (paf
, 1);
2966 * bgp_announce_route
2968 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2971 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2973 struct peer_af
*paf
;
2974 struct update_subgroup
*subgrp
;
2976 paf
= peer_af_find (peer
, afi
, safi
);
2979 subgrp
= PAF_SUBGRP(paf
);
2982 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2983 * or a refresh has already been triggered.
2985 if (!subgrp
|| paf
->t_announce_route
)
2989 * Start a timer to stagger/delay the announce. This serves
2990 * two purposes - announcement can potentially be combined for
2991 * multiple peers and the announcement doesn't happen in the
2994 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2995 bgp_announce_route_timer_expired
, paf
,
2996 (subgrp
->peer_count
== 1) ?
2997 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2998 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
3002 * Announce routes from all AF tables to a peer.
3004 * This should ONLY be called when there is a need to refresh the
3005 * routes to the peer based on a policy change for this peer alone
3006 * or a route refresh request received from the peer.
3007 * The operation will result in splitting the peer from its existing
3008 * subgroups and putting it in new subgroups.
3011 bgp_announce_route_all (struct peer
*peer
)
3016 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3017 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3018 bgp_announce_route (peer
, afi
, safi
);
3022 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3023 struct bgp_table
*table
, struct prefix_rd
*prd
)
3026 struct bgp_node
*rn
;
3027 struct bgp_adj_in
*ain
;
3030 table
= peer
->bgp
->rib
[afi
][safi
];
3032 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3033 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
3035 if (ain
->peer
== peer
)
3037 struct bgp_info
*ri
= rn
->info
;
3038 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
3040 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
3041 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
3046 bgp_unlock_node (rn
);
3054 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3056 struct bgp_node
*rn
;
3057 struct bgp_table
*table
;
3059 if (peer
->status
!= Established
)
3062 if ((safi
!= SAFI_MPLS_VPN
) && (safi
!= SAFI_ENCAP
))
3063 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
3065 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3066 rn
= bgp_route_next (rn
))
3067 if ((table
= rn
->info
) != NULL
)
3069 struct prefix_rd prd
;
3070 prd
.family
= AF_UNSPEC
;
3072 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
3074 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
3079 struct bgp_clear_node_queue
3081 struct bgp_node
*rn
;
3084 static wq_item_status
3085 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
3087 struct bgp_clear_node_queue
*cnq
= data
;
3088 struct bgp_node
*rn
= cnq
->rn
;
3089 struct peer
*peer
= wq
->spec
.data
;
3090 struct bgp_info
*ri
;
3091 afi_t afi
= bgp_node_table (rn
)->afi
;
3092 safi_t safi
= bgp_node_table (rn
)->safi
;
3094 assert (rn
&& peer
);
3096 /* It is possible that we have multiple paths for a prefix from a peer
3097 * if that peer is using AddPath.
3099 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3100 if (ri
->peer
== peer
)
3102 /* graceful restart STALE flag set. */
3103 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
3104 && peer
->nsf
[afi
][safi
]
3105 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
3106 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
3107 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
3109 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3115 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
3117 struct bgp_clear_node_queue
*cnq
= data
;
3118 struct bgp_node
*rn
= cnq
->rn
;
3119 struct bgp_table
*table
= bgp_node_table (rn
);
3121 bgp_unlock_node (rn
);
3122 bgp_table_unlock (table
);
3123 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
3127 bgp_clear_node_complete (struct work_queue
*wq
)
3129 struct peer
*peer
= wq
->spec
.data
;
3131 /* Tickle FSM to start moving again */
3132 BGP_EVENT_ADD (peer
, Clearing_Completed
);
3134 peer_unlock (peer
); /* bgp_clear_route */
3138 bgp_clear_node_queue_init (struct peer
*peer
)
3140 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
3142 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
3143 #undef CLEAR_QUEUE_NAME_LEN
3145 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
3147 zlog_err ("%s: Failed to allocate work queue", __func__
);
3150 peer
->clear_node_queue
->spec
.hold
= 10;
3151 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
3152 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
3153 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
3154 peer
->clear_node_queue
->spec
.max_retries
= 0;
3156 /* we only 'lock' this peer reference when the queue is actually active */
3157 peer
->clear_node_queue
->spec
.data
= peer
;
3161 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3162 struct bgp_table
*table
)
3164 struct bgp_node
*rn
;
3165 int force
= bm
->process_main_queue
? 0 : 1;
3168 table
= peer
->bgp
->rib
[afi
][safi
];
3170 /* If still no table => afi/safi isn't configured at all or smth. */
3174 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3176 struct bgp_info
*ri
, *next
;
3177 struct bgp_adj_in
*ain
;
3178 struct bgp_adj_in
*ain_next
;
3180 /* XXX:TODO: This is suboptimal, every non-empty route_node is
3181 * queued for every clearing peer, regardless of whether it is
3182 * relevant to the peer at hand.
3184 * Overview: There are 3 different indices which need to be
3185 * scrubbed, potentially, when a peer is removed:
3187 * 1 peer's routes visible via the RIB (ie accepted routes)
3188 * 2 peer's routes visible by the (optional) peer's adj-in index
3189 * 3 other routes visible by the peer's adj-out index
3191 * 3 there is no hurry in scrubbing, once the struct peer is
3192 * removed from bgp->peer, we could just GC such deleted peer's
3193 * adj-outs at our leisure.
3195 * 1 and 2 must be 'scrubbed' in some way, at least made
3196 * invisible via RIB index before peer session is allowed to be
3197 * brought back up. So one needs to know when such a 'search' is
3202 * - there'd be a single global queue or a single RIB walker
3203 * - rather than tracking which route_nodes still need to be
3204 * examined on a peer basis, we'd track which peers still
3207 * Given that our per-peer prefix-counts now should be reliable,
3208 * this may actually be achievable. It doesn't seem to be a huge
3209 * problem at this time,
3211 * It is possible that we have multiple paths for a prefix from a peer
3212 * if that peer is using AddPath.
3217 ain_next
= ain
->next
;
3219 if (ain
->peer
== peer
)
3221 bgp_adj_in_remove (rn
, ain
);
3222 bgp_unlock_node (rn
);
3228 for (ri
= rn
->info
; ri
; ri
= next
)
3231 if (ri
->peer
!= peer
)
3235 bgp_info_reap (rn
, ri
);
3238 struct bgp_clear_node_queue
*cnq
;
3240 /* both unlocked in bgp_clear_node_queue_del */
3241 bgp_table_lock (bgp_node_table (rn
));
3243 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
3244 sizeof (struct bgp_clear_node_queue
));
3246 work_queue_add (peer
->clear_node_queue
, cnq
);
3255 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3257 struct bgp_node
*rn
;
3258 struct bgp_table
*table
;
3260 if (peer
->clear_node_queue
== NULL
)
3261 bgp_clear_node_queue_init (peer
);
3263 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3264 * Idle until it receives a Clearing_Completed event. This protects
3265 * against peers which flap faster than we can we clear, which could
3268 * a) race with routes from the new session being installed before
3269 * clear_route_node visits the node (to delete the route of that
3271 * b) resource exhaustion, clear_route_node likely leads to an entry
3272 * on the process_main queue. Fast-flapping could cause that queue
3276 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3277 * the unlock will happen upon work-queue completion; other wise, the
3278 * unlock happens at the end of this function.
3280 if (!peer
->clear_node_queue
->thread
)
3283 if (safi
!= SAFI_MPLS_VPN
&& safi
!= SAFI_ENCAP
)
3284 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
3286 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3287 rn
= bgp_route_next (rn
))
3288 if ((table
= rn
->info
) != NULL
)
3289 bgp_clear_route_table (peer
, afi
, safi
, table
);
3291 /* unlock if no nodes got added to the clear-node-queue. */
3292 if (!peer
->clear_node_queue
->thread
)
3298 bgp_clear_route_all (struct peer
*peer
)
3303 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3304 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3305 bgp_clear_route (peer
, afi
, safi
);
3308 rfapiProcessPeerDown(peer
);
3313 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3315 struct bgp_table
*table
;
3316 struct bgp_node
*rn
;
3317 struct bgp_adj_in
*ain
;
3318 struct bgp_adj_in
*ain_next
;
3320 table
= peer
->bgp
->rib
[afi
][safi
];
3322 /* It is possible that we have multiple paths for a prefix from a peer
3323 * if that peer is using AddPath.
3325 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3331 ain_next
= ain
->next
;
3333 if (ain
->peer
== peer
)
3335 bgp_adj_in_remove (rn
, ain
);
3336 bgp_unlock_node (rn
);
3345 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3347 struct bgp_node
*rn
;
3348 struct bgp_info
*ri
;
3349 struct bgp_table
*table
;
3351 table
= peer
->bgp
->rib
[afi
][safi
];
3353 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3355 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3356 if (ri
->peer
== peer
)
3358 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3359 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3366 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3368 struct bgp_node
*rn
;
3369 struct bgp_info
*ri
;
3370 struct bgp_info
*next
;
3372 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3373 for (ri
= rn
->info
; ri
; ri
= next
)
3376 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3377 && ri
->type
== ZEBRA_ROUTE_BGP
3378 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3379 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3382 if (table
->owner
&& table
->owner
->bgp
)
3383 vnc_import_bgp_del_route(table
->owner
->bgp
, &rn
->p
, ri
);
3385 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3386 bgp_info_reap (rn
, ri
);
3391 /* Delete all kernel routes. */
3393 bgp_cleanup_routes (struct bgp
*bgp
)
3397 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3399 struct bgp_node
*rn
;
3401 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3404 * VPN and ENCAP tables are two-level (RD is top level)
3406 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3407 rn
= bgp_route_next (rn
))
3411 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3412 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3414 bgp_unlock_node(rn
);
3418 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_ENCAP
]); rn
;
3419 rn
= bgp_route_next (rn
))
3423 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_ENCAP
);
3424 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3426 bgp_unlock_node(rn
);
3436 bgp_zclient_reset ();
3437 access_list_reset ();
3438 prefix_list_reset ();
3442 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3444 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3445 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3448 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3451 bgp_nlri_parse_ip (struct peer
*peer
, struct attr
*attr
,
3452 struct bgp_nlri
*packet
)
3461 int addpath_encoded
;
3462 u_int32_t addpath_id
;
3464 /* Check peer status. */
3465 if (peer
->status
!= Established
)
3469 lim
= pnt
+ packet
->length
;
3471 safi
= packet
->safi
;
3473 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3475 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3476 syntactic validity. If the field is syntactically incorrect,
3477 then the Error Subcode is set to Invalid Network Field. */
3478 for (; pnt
< lim
; pnt
+= psize
)
3480 /* Clear prefix structure. */
3481 memset (&p
, 0, sizeof (struct prefix
));
3483 if (addpath_encoded
)
3486 /* When packet overflow occurs return immediately. */
3487 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3490 addpath_id
= ntohl(*((uint32_t*) pnt
));
3491 pnt
+= BGP_ADDPATH_ID_LEN
;
3494 /* Fetch prefix length. */
3495 p
.prefixlen
= *pnt
++;
3496 /* afi/safi validity already verified by caller, bgp_update_receive */
3497 p
.family
= afi2family (afi
);
3499 /* Prefix length check. */
3500 if (p
.prefixlen
> prefix_blen (&p
) * 8)
3502 zlog_err("%s [Error] Update packet error (wrong perfix length %d for afi %u)",
3503 peer
->host
, p
.prefixlen
, packet
->afi
);
3507 /* Packet size overflow check. */
3508 psize
= PSIZE (p
.prefixlen
);
3510 /* When packet overflow occur return immediately. */
3511 if (pnt
+ psize
> lim
)
3513 zlog_err("%s [Error] Update packet error (prefix length %d overflows packet)",
3514 peer
->host
, p
.prefixlen
);
3518 /* Defensive coding, double-check the psize fits in a struct prefix */
3519 if (psize
> (ssize_t
) sizeof(p
.u
))
3521 zlog_err("%s [Error] Update packet error (prefix length %d too large for prefix storage %zu)",
3522 peer
->host
, p
.prefixlen
, sizeof(p
.u
));
3526 /* Fetch prefix from NLRI packet. */
3527 memcpy (&p
.u
.prefix
, pnt
, psize
);
3529 /* Check address. */
3530 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3532 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3534 /* From RFC4271 Section 6.3:
3536 * If a prefix in the NLRI field is semantically incorrect
3537 * (e.g., an unexpected multicast IP address), an error SHOULD
3538 * be logged locally, and the prefix SHOULD be ignored.
3540 zlog_err ("%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3541 peer
->host
, inet_ntoa (p
.u
.prefix4
));
3547 /* Check address. */
3548 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3550 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3554 zlog_err ("%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3555 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3559 if (IN6_IS_ADDR_MULTICAST (&p
.u
.prefix6
))
3563 zlog_err ("%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3564 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3569 #endif /* HAVE_IPV6 */
3571 /* Normal process. */
3573 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3574 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3576 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3577 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3579 /* Address family configuration mismatch or maximum-prefix count
3585 /* Packet length consistency check. */
3588 zlog_err ("%s [Error] Update packet error (prefix length mismatch with total length)",
3596 static struct bgp_static
*
3597 bgp_static_new (void)
3599 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3603 bgp_static_free (struct bgp_static
*bgp_static
)
3605 if (bgp_static
->rmap
.name
)
3606 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3607 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3611 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3612 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3614 struct bgp_node
*rn
;
3615 struct bgp_info
*ri
;
3616 struct bgp_info
*new;
3617 struct bgp_info info
;
3619 struct attr
*attr_new
;
3622 int vnc_implicit_withdraw
= 0;
3625 assert (bgp_static
);
3629 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3631 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3633 attr
.nexthop
= bgp_static
->igpnexthop
;
3634 attr
.med
= bgp_static
->igpmetric
;
3635 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3637 if (bgp_static
->atomic
)
3638 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3640 /* Apply route-map. */
3641 if (bgp_static
->rmap
.name
)
3643 struct attr attr_tmp
= attr
;
3644 info
.peer
= bgp
->peer_self
;
3645 info
.attr
= &attr_tmp
;
3647 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3649 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3651 bgp
->peer_self
->rmap_type
= 0;
3653 if (ret
== RMAP_DENYMATCH
)
3655 /* Free uninterned attribute. */
3656 bgp_attr_flush (&attr_tmp
);
3658 /* Unintern original. */
3659 aspath_unintern (&attr
.aspath
);
3660 bgp_attr_extra_free (&attr
);
3661 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3664 attr_new
= bgp_attr_intern (&attr_tmp
);
3667 attr_new
= bgp_attr_intern (&attr
);
3669 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3670 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3671 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3676 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3677 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3678 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3680 bgp_unlock_node (rn
);
3681 bgp_attr_unintern (&attr_new
);
3682 aspath_unintern (&attr
.aspath
);
3683 bgp_attr_extra_free (&attr
);
3688 /* The attribute is changed. */
3689 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3691 /* Rewrite BGP route information. */
3692 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3693 bgp_info_restore(rn
, ri
);
3695 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3697 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3699 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
3702 * Implicit withdraw case.
3703 * We have to do this before ri is changed
3705 ++vnc_implicit_withdraw
;
3706 vnc_import_bgp_del_route(bgp
, p
, ri
);
3707 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
3711 bgp_attr_unintern (&ri
->attr
);
3712 ri
->attr
= attr_new
;
3713 ri
->uptime
= bgp_clock ();
3715 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3717 if (vnc_implicit_withdraw
)
3719 vnc_import_bgp_add_route(bgp
, p
, ri
);
3720 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
3725 /* Nexthop reachability check. */
3726 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3728 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3729 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3732 if (BGP_DEBUG(nht
, NHT
))
3734 char buf1
[INET6_ADDRSTRLEN
];
3735 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3737 zlog_debug("%s(%s): Route not in table, not advertising",
3738 __FUNCTION__
, buf1
);
3740 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3745 /* Delete the NHT structure if any, if we're toggling between
3746 * enabling/disabling import check. We deregister the route
3747 * from NHT to avoid overloading NHT and the process interaction
3749 bgp_unlink_nexthop(ri
);
3750 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3752 /* Process change. */
3753 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3754 bgp_process (bgp
, rn
, afi
, safi
);
3755 bgp_unlock_node (rn
);
3756 aspath_unintern (&attr
.aspath
);
3757 bgp_attr_extra_free (&attr
);
3762 /* Make new BGP info. */
3763 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3765 /* Nexthop reachability check. */
3766 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3768 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3769 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3772 if (BGP_DEBUG(nht
, NHT
))
3774 char buf1
[INET6_ADDRSTRLEN
];
3775 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3777 zlog_debug("%s(%s): Route not in table, not advertising",
3778 __FUNCTION__
, buf1
);
3780 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3785 /* Delete the NHT structure if any, if we're toggling between
3786 * enabling/disabling import check. We deregister the route
3787 * from NHT to avoid overloading NHT and the process interaction
3789 bgp_unlink_nexthop(new);
3791 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3794 /* Aggregate address increment. */
3795 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3797 /* Register new BGP information. */
3798 bgp_info_add (rn
, new);
3800 /* route_node_get lock */
3801 bgp_unlock_node (rn
);
3803 /* Process change. */
3804 bgp_process (bgp
, rn
, afi
, safi
);
3806 /* Unintern original. */
3807 aspath_unintern (&attr
.aspath
);
3808 bgp_attr_extra_free (&attr
);
3812 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3813 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3815 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3819 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3822 struct bgp_node
*rn
;
3823 struct bgp_info
*ri
;
3825 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3827 /* Check selected route and self inserted route. */
3828 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3829 if (ri
->peer
== bgp
->peer_self
3830 && ri
->type
== ZEBRA_ROUTE_BGP
3831 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3834 /* Withdraw static BGP route from routing table. */
3837 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3838 bgp_unlink_nexthop(ri
);
3839 bgp_info_delete (rn
, ri
);
3840 bgp_process (bgp
, rn
, afi
, safi
);
3843 /* Unlock bgp_node_lookup. */
3844 bgp_unlock_node (rn
);
3848 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3851 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3852 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3854 struct bgp_node
*rn
;
3855 struct bgp_info
*ri
;
3857 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3859 /* Check selected route and self inserted route. */
3860 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3861 if (ri
->peer
== bgp
->peer_self
3862 && ri
->type
== ZEBRA_ROUTE_BGP
3863 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3866 /* Withdraw static BGP route from routing table. */
3870 rfapiProcessWithdraw(
3879 1); /* Kill, since it is an administrative change */
3881 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3882 bgp_info_delete (rn
, ri
);
3883 bgp_process (bgp
, rn
, afi
, safi
);
3886 /* Unlock bgp_node_lookup. */
3887 bgp_unlock_node (rn
);
3891 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3892 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3894 struct bgp_node
*rn
;
3895 struct bgp_info
*new;
3896 struct attr
*attr_new
;
3897 struct attr attr
= { 0 };
3898 struct bgp_info
*ri
;
3900 u_int32_t label
= 0;
3903 assert (bgp_static
);
3905 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3907 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3909 attr
.nexthop
= bgp_static
->igpnexthop
;
3910 attr
.med
= bgp_static
->igpmetric
;
3911 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3913 /* Apply route-map. */
3914 if (bgp_static
->rmap
.name
)
3916 struct attr attr_tmp
= attr
;
3917 struct bgp_info info
;
3920 info
.peer
= bgp
->peer_self
;
3921 info
.attr
= &attr_tmp
;
3923 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3925 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3927 bgp
->peer_self
->rmap_type
= 0;
3929 if (ret
== RMAP_DENYMATCH
)
3931 /* Free uninterned attribute. */
3932 bgp_attr_flush (&attr_tmp
);
3934 /* Unintern original. */
3935 aspath_unintern (&attr
.aspath
);
3936 bgp_attr_extra_free (&attr
);
3937 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3942 attr_new
= bgp_attr_intern (&attr_tmp
);
3946 attr_new
= bgp_attr_intern (&attr
);
3949 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3950 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3951 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3956 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3957 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3959 bgp_unlock_node (rn
);
3960 bgp_attr_unintern (&attr_new
);
3961 aspath_unintern (&attr
.aspath
);
3962 bgp_attr_extra_free (&attr
);
3967 /* The attribute is changed. */
3968 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3970 /* Rewrite BGP route information. */
3971 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3972 bgp_info_restore(rn
, ri
);
3974 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3975 bgp_attr_unintern (&ri
->attr
);
3976 ri
->attr
= attr_new
;
3977 ri
->uptime
= bgp_clock ();
3980 label
= decode_label (ri
->extra
->tag
);
3983 /* Process change. */
3984 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3985 bgp_process (bgp
, rn
, afi
, safi
);
3987 rfapiProcessUpdate(ri
->peer
, NULL
, p
, &bgp_static
->prd
,
3988 ri
->attr
, afi
, safi
,
3989 ri
->type
, ri
->sub_type
, &label
);
3991 bgp_unlock_node (rn
);
3992 aspath_unintern (&attr
.aspath
);
3993 bgp_attr_extra_free (&attr
);
3999 /* Make new BGP info. */
4000 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
4002 SET_FLAG (new->flags
, BGP_INFO_VALID
);
4003 new->extra
= bgp_info_extra_new();
4004 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
4006 label
= decode_label (bgp_static
->tag
);
4009 /* Aggregate address increment. */
4010 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
4012 /* Register new BGP information. */
4013 bgp_info_add (rn
, new);
4015 /* route_node_get lock */
4016 bgp_unlock_node (rn
);
4018 /* Process change. */
4019 bgp_process (bgp
, rn
, afi
, safi
);
4022 rfapiProcessUpdate(new->peer
, NULL
, p
, &bgp_static
->prd
,
4023 new->attr
, afi
, safi
,
4024 new->type
, new->sub_type
, &label
);
4027 /* Unintern original. */
4028 aspath_unintern (&attr
.aspath
);
4029 bgp_attr_extra_free (&attr
);
4032 /* Configure static BGP network. When user don't run zebra, static
4033 route should be installed as valid. */
4035 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4036 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
4040 struct bgp_static
*bgp_static
;
4041 struct bgp_node
*rn
;
4042 u_char need_update
= 0;
4044 /* Convert IP prefix string to struct prefix. */
4045 ret
= str2prefix (ip_str
, &p
);
4048 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4052 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4054 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4058 #endif /* HAVE_IPV6 */
4062 /* Set BGP static route configuration. */
4063 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
4067 /* Configuration change. */
4068 bgp_static
= rn
->info
;
4070 /* Check previous routes are installed into BGP. */
4071 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
4074 bgp_static
->backdoor
= backdoor
;
4078 if (bgp_static
->rmap
.name
)
4079 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4080 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4081 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4085 if (bgp_static
->rmap
.name
)
4086 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4087 bgp_static
->rmap
.name
= NULL
;
4088 bgp_static
->rmap
.map
= NULL
;
4089 bgp_static
->valid
= 0;
4091 bgp_unlock_node (rn
);
4095 /* New configuration. */
4096 bgp_static
= bgp_static_new ();
4097 bgp_static
->backdoor
= backdoor
;
4098 bgp_static
->valid
= 0;
4099 bgp_static
->igpmetric
= 0;
4100 bgp_static
->igpnexthop
.s_addr
= 0;
4104 if (bgp_static
->rmap
.name
)
4105 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4106 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4107 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4109 rn
->info
= bgp_static
;
4112 bgp_static
->valid
= 1;
4114 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4116 if (! bgp_static
->backdoor
)
4117 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
4122 /* Configure static BGP network. */
4124 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4125 afi_t afi
, safi_t safi
)
4129 struct bgp_static
*bgp_static
;
4130 struct bgp_node
*rn
;
4132 /* Convert IP prefix string to struct prefix. */
4133 ret
= str2prefix (ip_str
, &p
);
4136 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4140 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4142 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4146 #endif /* HAVE_IPV6 */
4150 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
4153 vty_out (vty
, "%% Can't find specified static route configuration.%s",
4158 bgp_static
= rn
->info
;
4160 /* Update BGP RIB. */
4161 if (! bgp_static
->backdoor
)
4162 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4164 /* Clear configuration. */
4165 bgp_static_free (bgp_static
);
4167 bgp_unlock_node (rn
);
4168 bgp_unlock_node (rn
);
4174 bgp_static_add (struct bgp
*bgp
)
4178 struct bgp_node
*rn
;
4179 struct bgp_node
*rm
;
4180 struct bgp_table
*table
;
4181 struct bgp_static
*bgp_static
;
4183 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4184 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4185 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4186 if (rn
->info
!= NULL
)
4188 if (safi
== SAFI_MPLS_VPN
)
4192 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4194 bgp_static
= rn
->info
;
4195 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
4200 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
4205 /* Called from bgp_delete(). Delete all static routes from the BGP
4208 bgp_static_delete (struct bgp
*bgp
)
4212 struct bgp_node
*rn
;
4213 struct bgp_node
*rm
;
4214 struct bgp_table
*table
;
4215 struct bgp_static
*bgp_static
;
4217 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4218 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4219 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4220 if (rn
->info
!= NULL
)
4222 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4226 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4228 bgp_static
= rn
->info
;
4229 bgp_static_withdraw_safi (bgp
, &rm
->p
,
4231 (struct prefix_rd
*)&rn
->p
,
4233 bgp_static_free (bgp_static
);
4235 bgp_unlock_node (rn
);
4240 bgp_static
= rn
->info
;
4241 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
4242 bgp_static_free (bgp_static
);
4244 bgp_unlock_node (rn
);
4250 bgp_static_redo_import_check (struct bgp
*bgp
)
4254 struct bgp_node
*rn
;
4255 struct bgp_static
*bgp_static
;
4257 /* Use this flag to force reprocessing of the route */
4258 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4259 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4260 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4261 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4262 if (rn
->info
!= NULL
)
4264 bgp_static
= rn
->info
;
4265 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
4267 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4271 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
4273 struct bgp_table
*table
;
4274 struct bgp_node
*rn
;
4275 struct bgp_info
*ri
;
4277 table
= bgp
->rib
[afi
][safi
];
4278 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
4280 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4282 if (ri
->peer
== bgp
->peer_self
&&
4283 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
4284 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
4285 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
4286 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
4288 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4289 bgp_unlink_nexthop(ri
);
4290 bgp_info_delete (rn
, ri
);
4291 bgp_process (bgp
, rn
, afi
, safi
);
4298 * Purge all networks and redistributed routes from routing table.
4299 * Invoked upon the instance going down.
4302 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4307 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4308 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4309 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4314 * Currently this is used to set static routes for VPN and ENCAP.
4315 * I think it can probably be factored with bgp_static_set.
4318 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4319 const char *rd_str
, const char *tag_str
,
4320 const char *rmap_str
)
4324 struct prefix_rd prd
;
4326 struct bgp_node
*prn
;
4327 struct bgp_node
*rn
;
4328 struct bgp_table
*table
;
4329 struct bgp_static
*bgp_static
;
4334 ret
= str2prefix (ip_str
, &p
);
4337 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4342 ret
= str2prefix_rd (rd_str
, &prd
);
4345 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4349 ret
= str2tag (tag_str
, tag
);
4352 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4356 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4357 (struct prefix
*)&prd
);
4358 if (prn
->info
== NULL
)
4359 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4361 bgp_unlock_node (prn
);
4364 rn
= bgp_node_get (table
, &p
);
4368 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4369 bgp_unlock_node (rn
);
4373 /* New configuration. */
4374 bgp_static
= bgp_static_new ();
4375 bgp_static
->backdoor
= 0;
4376 bgp_static
->valid
= 0;
4377 bgp_static
->igpmetric
= 0;
4378 bgp_static
->igpnexthop
.s_addr
= 0;
4379 memcpy(bgp_static
->tag
, tag
, 3);
4380 bgp_static
->prd
= prd
;
4384 if (bgp_static
->rmap
.name
)
4385 free (bgp_static
->rmap
.name
);
4386 bgp_static
->rmap
.name
= strdup (rmap_str
);
4387 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4389 rn
->info
= bgp_static
;
4391 bgp_static
->valid
= 1;
4392 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4398 /* Configure static BGP network. */
4400 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4401 const char *rd_str
, const char *tag_str
)
4406 struct prefix_rd prd
;
4407 struct bgp_node
*prn
;
4408 struct bgp_node
*rn
;
4409 struct bgp_table
*table
;
4410 struct bgp_static
*bgp_static
;
4415 /* Convert IP prefix string to struct prefix. */
4416 ret
= str2prefix (ip_str
, &p
);
4419 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4424 ret
= str2prefix_rd (rd_str
, &prd
);
4427 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4431 ret
= str2tag (tag_str
, tag
);
4434 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4438 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4439 (struct prefix
*)&prd
);
4440 if (prn
->info
== NULL
)
4441 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4443 bgp_unlock_node (prn
);
4446 rn
= bgp_node_lookup (table
, &p
);
4450 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4452 bgp_static
= rn
->info
;
4453 bgp_static_free (bgp_static
);
4455 bgp_unlock_node (rn
);
4456 bgp_unlock_node (rn
);
4459 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4465 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4466 const char *rmap_name
)
4468 struct bgp_rmap
*rmap
;
4470 rmap
= &bgp
->table_map
[afi
][safi
];
4474 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4475 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4476 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4481 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4486 bgp_zebra_announce_table(bgp
, afi
, safi
);
4492 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4493 const char *rmap_name
)
4495 struct bgp_rmap
*rmap
;
4497 rmap
= &bgp
->table_map
[afi
][safi
];
4499 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4503 bgp_zebra_announce_table(bgp
, afi
, safi
);
4509 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4510 safi_t safi
, int *write
)
4512 if (bgp
->table_map
[afi
][safi
].name
)
4514 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4515 vty_out (vty
, " table-map %s%s",
4516 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4522 DEFUN (bgp_table_map
,
4525 "BGP table to RIB route download filter\n"
4526 "Name of the route map\n")
4528 return bgp_table_map_set (vty
, vty
->index
,
4529 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4531 DEFUN (no_bgp_table_map
,
4532 no_bgp_table_map_cmd
,
4533 "no table-map WORD",
4534 "BGP table to RIB route download filter\n"
4535 "Name of the route map\n")
4537 return bgp_table_map_unset (vty
, vty
->index
,
4538 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4543 "network A.B.C.D/M",
4544 "Specify a network to announce via BGP\n"
4545 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4547 return bgp_static_set (vty
, vty
->index
, argv
[0],
4548 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4551 DEFUN (bgp_network_route_map
,
4552 bgp_network_route_map_cmd
,
4553 "network A.B.C.D/M route-map WORD",
4554 "Specify a network to announce via BGP\n"
4555 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4556 "Route-map to modify the attributes\n"
4557 "Name of the route map\n")
4559 return bgp_static_set (vty
, vty
->index
, argv
[0],
4560 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4563 DEFUN (bgp_network_backdoor
,
4564 bgp_network_backdoor_cmd
,
4565 "network A.B.C.D/M backdoor",
4566 "Specify a network to announce via BGP\n"
4567 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4568 "Specify a BGP backdoor route\n")
4570 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4574 DEFUN (bgp_network_mask
,
4575 bgp_network_mask_cmd
,
4576 "network A.B.C.D mask A.B.C.D",
4577 "Specify a network to announce via BGP\n"
4583 char prefix_str
[BUFSIZ
];
4585 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4588 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4592 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4593 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4596 DEFUN (bgp_network_mask_route_map
,
4597 bgp_network_mask_route_map_cmd
,
4598 "network A.B.C.D mask A.B.C.D route-map WORD",
4599 "Specify a network to announce via BGP\n"
4603 "Route-map to modify the attributes\n"
4604 "Name of the route map\n")
4607 char prefix_str
[BUFSIZ
];
4609 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4612 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4616 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4617 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4620 DEFUN (bgp_network_mask_backdoor
,
4621 bgp_network_mask_backdoor_cmd
,
4622 "network A.B.C.D mask A.B.C.D backdoor",
4623 "Specify a network to announce via BGP\n"
4627 "Specify a BGP backdoor route\n")
4630 char prefix_str
[BUFSIZ
];
4632 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4635 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4639 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4643 DEFUN (bgp_network_mask_natural
,
4644 bgp_network_mask_natural_cmd
,
4646 "Specify a network to announce via BGP\n"
4650 char prefix_str
[BUFSIZ
];
4652 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4655 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4659 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4660 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4663 DEFUN (bgp_network_mask_natural_route_map
,
4664 bgp_network_mask_natural_route_map_cmd
,
4665 "network A.B.C.D route-map WORD",
4666 "Specify a network to announce via BGP\n"
4668 "Route-map to modify the attributes\n"
4669 "Name of the route map\n")
4672 char prefix_str
[BUFSIZ
];
4674 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4677 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4681 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4682 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4685 DEFUN (bgp_network_mask_natural_backdoor
,
4686 bgp_network_mask_natural_backdoor_cmd
,
4687 "network A.B.C.D backdoor",
4688 "Specify a network to announce via BGP\n"
4690 "Specify a BGP backdoor route\n")
4693 char prefix_str
[BUFSIZ
];
4695 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4698 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4702 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4706 DEFUN (no_bgp_network
,
4708 "no network A.B.C.D/M",
4710 "Specify a network to announce via BGP\n"
4711 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4713 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4714 bgp_node_safi (vty
));
4717 ALIAS (no_bgp_network
,
4718 no_bgp_network_route_map_cmd
,
4719 "no network A.B.C.D/M route-map WORD",
4721 "Specify a network to announce via BGP\n"
4722 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4723 "Route-map to modify the attributes\n"
4724 "Name of the route map\n")
4726 ALIAS (no_bgp_network
,
4727 no_bgp_network_backdoor_cmd
,
4728 "no network A.B.C.D/M backdoor",
4730 "Specify a network to announce via BGP\n"
4731 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4732 "Specify a BGP backdoor route\n")
4734 DEFUN (no_bgp_network_mask
,
4735 no_bgp_network_mask_cmd
,
4736 "no network A.B.C.D mask A.B.C.D",
4738 "Specify a network to announce via BGP\n"
4744 char prefix_str
[BUFSIZ
];
4746 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4749 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4753 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4754 bgp_node_safi (vty
));
4757 ALIAS (no_bgp_network_mask
,
4758 no_bgp_network_mask_route_map_cmd
,
4759 "no network A.B.C.D mask A.B.C.D route-map WORD",
4761 "Specify a network to announce via BGP\n"
4765 "Route-map to modify the attributes\n"
4766 "Name of the route map\n")
4768 ALIAS (no_bgp_network_mask
,
4769 no_bgp_network_mask_backdoor_cmd
,
4770 "no network A.B.C.D mask A.B.C.D backdoor",
4772 "Specify a network to announce via BGP\n"
4776 "Specify a BGP backdoor route\n")
4778 DEFUN (no_bgp_network_mask_natural
,
4779 no_bgp_network_mask_natural_cmd
,
4780 "no network A.B.C.D",
4782 "Specify a network to announce via BGP\n"
4786 char prefix_str
[BUFSIZ
];
4788 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4791 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4795 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4796 bgp_node_safi (vty
));
4799 ALIAS (no_bgp_network_mask_natural
,
4800 no_bgp_network_mask_natural_route_map_cmd
,
4801 "no network A.B.C.D route-map WORD",
4803 "Specify a network to announce via BGP\n"
4805 "Route-map to modify the attributes\n"
4806 "Name of the route map\n")
4808 ALIAS (no_bgp_network_mask_natural
,
4809 no_bgp_network_mask_natural_backdoor_cmd
,
4810 "no network A.B.C.D backdoor",
4812 "Specify a network to announce via BGP\n"
4814 "Specify a BGP backdoor route\n")
4817 DEFUN (ipv6_bgp_network
,
4818 ipv6_bgp_network_cmd
,
4819 "network X:X::X:X/M",
4820 "Specify a network to announce via BGP\n"
4821 "IPv6 prefix <network>/<length>\n")
4823 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4827 DEFUN (ipv6_bgp_network_route_map
,
4828 ipv6_bgp_network_route_map_cmd
,
4829 "network X:X::X:X/M route-map WORD",
4830 "Specify a network to announce via BGP\n"
4831 "IPv6 prefix <network>/<length>\n"
4832 "Route-map to modify the attributes\n"
4833 "Name of the route map\n")
4835 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4836 bgp_node_safi (vty
), argv
[1], 0);
4839 DEFUN (no_ipv6_bgp_network
,
4840 no_ipv6_bgp_network_cmd
,
4841 "no network X:X::X:X/M",
4843 "Specify a network to announce via BGP\n"
4844 "IPv6 prefix <network>/<length>\n")
4846 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4849 ALIAS (no_ipv6_bgp_network
,
4850 no_ipv6_bgp_network_route_map_cmd
,
4851 "no network X:X::X:X/M route-map WORD",
4853 "Specify a network to announce via BGP\n"
4854 "IPv6 prefix <network>/<length>\n"
4855 "Route-map to modify the attributes\n"
4856 "Name of the route map\n")
4858 ALIAS (ipv6_bgp_network
,
4859 old_ipv6_bgp_network_cmd
,
4860 "ipv6 bgp network X:X::X:X/M",
4863 "Specify a network to announce via BGP\n"
4864 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4866 ALIAS (no_ipv6_bgp_network
,
4867 old_no_ipv6_bgp_network_cmd
,
4868 "no ipv6 bgp network X:X::X:X/M",
4872 "Specify a network to announce via BGP\n"
4873 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4874 #endif /* HAVE_IPV6 */
4876 /* Aggreagete address:
4878 advertise-map Set condition to advertise attribute
4879 as-set Generate AS set path information
4880 attribute-map Set attributes of aggregate
4881 route-map Set parameters of aggregate
4882 summary-only Filter more specific routes from updates
4883 suppress-map Conditionally filter more specific routes from updates
4886 struct bgp_aggregate
4888 /* Summary-only flag. */
4889 u_char summary_only
;
4891 /* AS set generation. */
4894 /* Route-map for aggregated route. */
4895 struct route_map
*map
;
4897 /* Suppress-count. */
4898 unsigned long count
;
4900 /* SAFI configuration. */
4904 static struct bgp_aggregate
*
4905 bgp_aggregate_new (void)
4907 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4911 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4913 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4916 /* Update an aggregate as routes are added/removed from the BGP table */
4918 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4919 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4920 struct bgp_aggregate
*aggregate
)
4922 struct bgp_table
*table
;
4923 struct bgp_node
*top
;
4924 struct bgp_node
*rn
;
4926 struct aspath
*aspath
= NULL
;
4927 struct aspath
*asmerge
= NULL
;
4928 struct community
*community
= NULL
;
4929 struct community
*commerge
= NULL
;
4930 #if defined(AGGREGATE_NEXTHOP_CHECK)
4931 struct in_addr nexthop
;
4934 struct bgp_info
*ri
;
4935 struct bgp_info
*new;
4937 unsigned long match
= 0;
4938 u_char atomic_aggregate
= 0;
4940 /* Record adding route's nexthop and med. */
4943 #if defined(AGGREGATE_NEXTHOP_CHECK)
4944 nexthop
= rinew
->attr
->nexthop
;
4945 med
= rinew
->attr
->med
;
4949 /* ORIGIN attribute: If at least one route among routes that are
4950 aggregated has ORIGIN with the value INCOMPLETE, then the
4951 aggregated route must have the ORIGIN attribute with the value
4952 INCOMPLETE. Otherwise, if at least one route among routes that
4953 are aggregated has ORIGIN with the value EGP, then the aggregated
4954 route must have the origin attribute with the value EGP. In all
4955 other case the value of the ORIGIN attribute of the aggregated
4956 route is INTERNAL. */
4957 origin
= BGP_ORIGIN_IGP
;
4959 table
= bgp
->rib
[afi
][safi
];
4961 top
= bgp_node_get (table
, p
);
4962 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4963 if (rn
->p
.prefixlen
> p
->prefixlen
)
4967 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4969 if (BGP_INFO_HOLDDOWN (ri
))
4972 if (del
&& ri
== del
)
4975 if (! rinew
&& first
)
4977 #if defined(AGGREGATE_NEXTHOP_CHECK)
4978 nexthop
= ri
->attr
->nexthop
;
4979 med
= ri
->attr
->med
;
4984 #ifdef AGGREGATE_NEXTHOP_CHECK
4985 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4986 || ri
->attr
->med
!= med
)
4989 aspath_free (aspath
);
4991 community_free (community
);
4992 bgp_unlock_node (rn
);
4993 bgp_unlock_node (top
);
4996 #endif /* AGGREGATE_NEXTHOP_CHECK */
4998 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4999 atomic_aggregate
= 1;
5001 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5003 if (aggregate
->summary_only
)
5005 (bgp_info_extra_get (ri
))->suppress
++;
5006 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5012 if (origin
< ri
->attr
->origin
)
5013 origin
= ri
->attr
->origin
;
5015 if (aggregate
->as_set
)
5019 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5020 aspath_free (aspath
);
5024 aspath
= aspath_dup (ri
->attr
->aspath
);
5026 if (ri
->attr
->community
)
5030 commerge
= community_merge (community
,
5031 ri
->attr
->community
);
5032 community
= community_uniq_sort (commerge
);
5033 community_free (commerge
);
5036 community
= community_dup (ri
->attr
->community
);
5042 bgp_process (bgp
, rn
, afi
, safi
);
5044 bgp_unlock_node (top
);
5050 if (aggregate
->summary_only
)
5051 (bgp_info_extra_get (rinew
))->suppress
++;
5053 if (origin
< rinew
->attr
->origin
)
5054 origin
= rinew
->attr
->origin
;
5056 if (aggregate
->as_set
)
5060 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
5061 aspath_free (aspath
);
5065 aspath
= aspath_dup (rinew
->attr
->aspath
);
5067 if (rinew
->attr
->community
)
5071 commerge
= community_merge (community
,
5072 rinew
->attr
->community
);
5073 community
= community_uniq_sort (commerge
);
5074 community_free (commerge
);
5077 community
= community_dup (rinew
->attr
->community
);
5082 if (aggregate
->count
> 0)
5084 rn
= bgp_node_get (table
, p
);
5085 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5086 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5088 atomic_aggregate
), rn
);
5089 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5091 bgp_info_add (rn
, new);
5092 bgp_unlock_node (rn
);
5093 bgp_process (bgp
, rn
, afi
, safi
);
5098 aspath_free (aspath
);
5100 community_free (community
);
5104 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
5105 struct bgp_aggregate
*);
5108 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
5109 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
5111 struct bgp_node
*child
;
5112 struct bgp_node
*rn
;
5113 struct bgp_aggregate
*aggregate
;
5114 struct bgp_table
*table
;
5116 /* MPLS-VPN aggregation is not yet supported. */
5117 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5120 table
= bgp
->aggregate
[afi
][safi
];
5122 /* No aggregates configured. */
5123 if (bgp_table_top_nolock (table
) == NULL
)
5126 if (p
->prefixlen
== 0)
5129 if (BGP_INFO_HOLDDOWN (ri
))
5132 child
= bgp_node_get (table
, p
);
5134 /* Aggregate address configuration check. */
5135 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5136 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5138 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5139 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
5141 bgp_unlock_node (child
);
5145 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
5146 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
5148 struct bgp_node
*child
;
5149 struct bgp_node
*rn
;
5150 struct bgp_aggregate
*aggregate
;
5151 struct bgp_table
*table
;
5153 /* MPLS-VPN aggregation is not yet supported. */
5154 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5157 table
= bgp
->aggregate
[afi
][safi
];
5159 /* No aggregates configured. */
5160 if (bgp_table_top_nolock (table
) == NULL
)
5163 if (p
->prefixlen
== 0)
5166 child
= bgp_node_get (table
, p
);
5168 /* Aggregate address configuration check. */
5169 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5170 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5172 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5173 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
5175 bgp_unlock_node (child
);
5178 /* Called via bgp_aggregate_set when the user configures aggregate-address */
5180 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
5181 struct bgp_aggregate
*aggregate
)
5183 struct bgp_table
*table
;
5184 struct bgp_node
*top
;
5185 struct bgp_node
*rn
;
5186 struct bgp_info
*new;
5187 struct bgp_info
*ri
;
5188 unsigned long match
;
5189 u_char origin
= BGP_ORIGIN_IGP
;
5190 struct aspath
*aspath
= NULL
;
5191 struct aspath
*asmerge
= NULL
;
5192 struct community
*community
= NULL
;
5193 struct community
*commerge
= NULL
;
5194 u_char atomic_aggregate
= 0;
5196 table
= bgp
->rib
[afi
][safi
];
5199 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5201 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5204 /* If routes exists below this node, generate aggregate routes. */
5205 top
= bgp_node_get (table
, p
);
5206 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5207 if (rn
->p
.prefixlen
> p
->prefixlen
)
5211 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5213 if (BGP_INFO_HOLDDOWN (ri
))
5216 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5217 atomic_aggregate
= 1;
5219 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5221 /* summary-only aggregate route suppress aggregated
5222 route announcement. */
5223 if (aggregate
->summary_only
)
5225 (bgp_info_extra_get (ri
))->suppress
++;
5226 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5230 /* If at least one route among routes that are aggregated has
5231 * ORIGIN with the value INCOMPLETE, then the aggregated route
5232 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5233 * Otherwise, if at least one route among routes that are
5234 * aggregated has ORIGIN with the value EGP, then the aggregated
5235 * route MUST have the ORIGIN attribute with the value EGP.
5237 if (origin
< ri
->attr
->origin
)
5238 origin
= ri
->attr
->origin
;
5240 /* as-set aggregate route generate origin, as path,
5241 community aggregation. */
5242 if (aggregate
->as_set
)
5246 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5247 aspath_free (aspath
);
5251 aspath
= aspath_dup (ri
->attr
->aspath
);
5253 if (ri
->attr
->community
)
5257 commerge
= community_merge (community
,
5258 ri
->attr
->community
);
5259 community
= community_uniq_sort (commerge
);
5260 community_free (commerge
);
5263 community
= community_dup (ri
->attr
->community
);
5270 /* If this node is suppressed, process the change. */
5272 bgp_process (bgp
, rn
, afi
, safi
);
5274 bgp_unlock_node (top
);
5276 /* Add aggregate route to BGP table. */
5277 if (aggregate
->count
)
5279 rn
= bgp_node_get (table
, p
);
5280 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5281 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5283 atomic_aggregate
), rn
);
5284 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5286 bgp_info_add (rn
, new);
5287 bgp_unlock_node (rn
);
5289 /* Process change. */
5290 bgp_process (bgp
, rn
, afi
, safi
);
5295 aspath_free (aspath
);
5297 community_free (community
);
5302 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5303 safi_t safi
, struct bgp_aggregate
*aggregate
)
5305 struct bgp_table
*table
;
5306 struct bgp_node
*top
;
5307 struct bgp_node
*rn
;
5308 struct bgp_info
*ri
;
5309 unsigned long match
;
5311 table
= bgp
->rib
[afi
][safi
];
5313 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5315 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5318 /* If routes exists below this node, generate aggregate routes. */
5319 top
= bgp_node_get (table
, p
);
5320 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5321 if (rn
->p
.prefixlen
> p
->prefixlen
)
5325 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5327 if (BGP_INFO_HOLDDOWN (ri
))
5330 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5332 if (aggregate
->summary_only
&& ri
->extra
)
5334 ri
->extra
->suppress
--;
5336 if (ri
->extra
->suppress
== 0)
5338 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5346 /* If this node was suppressed, process the change. */
5348 bgp_process (bgp
, rn
, afi
, safi
);
5350 bgp_unlock_node (top
);
5352 /* Delete aggregate route from BGP table. */
5353 rn
= bgp_node_get (table
, p
);
5355 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5356 if (ri
->peer
== bgp
->peer_self
5357 && ri
->type
== ZEBRA_ROUTE_BGP
5358 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5361 /* Withdraw static BGP route from routing table. */
5364 bgp_info_delete (rn
, ri
);
5365 bgp_process (bgp
, rn
, afi
, safi
);
5368 /* Unlock bgp_node_lookup. */
5369 bgp_unlock_node (rn
);
5372 /* Aggregate route attribute. */
5373 #define AGGREGATE_SUMMARY_ONLY 1
5374 #define AGGREGATE_AS_SET 1
5377 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5378 afi_t afi
, safi_t safi
)
5382 struct bgp_node
*rn
;
5384 struct bgp_aggregate
*aggregate
;
5386 /* Convert string to prefix structure. */
5387 ret
= str2prefix (prefix_str
, &p
);
5390 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5395 /* Get BGP structure. */
5398 /* Old configuration check. */
5399 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5402 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5407 aggregate
= rn
->info
;
5408 if (aggregate
->safi
& SAFI_UNICAST
)
5409 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5410 if (aggregate
->safi
& SAFI_MULTICAST
)
5411 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5413 /* Unlock aggregate address configuration. */
5415 bgp_aggregate_free (aggregate
);
5416 bgp_unlock_node (rn
);
5417 bgp_unlock_node (rn
);
5423 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5424 afi_t afi
, safi_t safi
,
5425 u_char summary_only
, u_char as_set
)
5429 struct bgp_node
*rn
;
5431 struct bgp_aggregate
*aggregate
;
5433 /* Convert string to prefix structure. */
5434 ret
= str2prefix (prefix_str
, &p
);
5437 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5442 /* Get BGP structure. */
5445 /* Old configuration check. */
5446 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5450 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5451 /* try to remove the old entry */
5452 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5455 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5456 bgp_unlock_node (rn
);
5461 /* Make aggregate address structure. */
5462 aggregate
= bgp_aggregate_new ();
5463 aggregate
->summary_only
= summary_only
;
5464 aggregate
->as_set
= as_set
;
5465 aggregate
->safi
= safi
;
5466 rn
->info
= aggregate
;
5468 /* Aggregate address insert into BGP routing table. */
5469 if (safi
& SAFI_UNICAST
)
5470 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5471 if (safi
& SAFI_MULTICAST
)
5472 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5477 DEFUN (aggregate_address
,
5478 aggregate_address_cmd
,
5479 "aggregate-address A.B.C.D/M",
5480 "Configure BGP aggregate entries\n"
5481 "Aggregate prefix\n")
5483 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5486 DEFUN (aggregate_address_mask
,
5487 aggregate_address_mask_cmd
,
5488 "aggregate-address A.B.C.D A.B.C.D",
5489 "Configure BGP aggregate entries\n"
5490 "Aggregate address\n"
5494 char prefix_str
[BUFSIZ
];
5496 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5500 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5504 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5508 DEFUN (aggregate_address_summary_only
,
5509 aggregate_address_summary_only_cmd
,
5510 "aggregate-address A.B.C.D/M summary-only",
5511 "Configure BGP aggregate entries\n"
5512 "Aggregate prefix\n"
5513 "Filter more specific routes from updates\n")
5515 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5516 AGGREGATE_SUMMARY_ONLY
, 0);
5519 DEFUN (aggregate_address_mask_summary_only
,
5520 aggregate_address_mask_summary_only_cmd
,
5521 "aggregate-address A.B.C.D A.B.C.D summary-only",
5522 "Configure BGP aggregate entries\n"
5523 "Aggregate address\n"
5525 "Filter more specific routes from updates\n")
5528 char prefix_str
[BUFSIZ
];
5530 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5534 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5538 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5539 AGGREGATE_SUMMARY_ONLY
, 0);
5542 DEFUN (aggregate_address_as_set
,
5543 aggregate_address_as_set_cmd
,
5544 "aggregate-address A.B.C.D/M as-set",
5545 "Configure BGP aggregate entries\n"
5546 "Aggregate prefix\n"
5547 "Generate AS set path information\n")
5549 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5550 0, AGGREGATE_AS_SET
);
5553 DEFUN (aggregate_address_mask_as_set
,
5554 aggregate_address_mask_as_set_cmd
,
5555 "aggregate-address A.B.C.D A.B.C.D as-set",
5556 "Configure BGP aggregate entries\n"
5557 "Aggregate address\n"
5559 "Generate AS set path information\n")
5562 char prefix_str
[BUFSIZ
];
5564 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5568 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5572 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5573 0, AGGREGATE_AS_SET
);
5577 DEFUN (aggregate_address_as_set_summary
,
5578 aggregate_address_as_set_summary_cmd
,
5579 "aggregate-address A.B.C.D/M as-set summary-only",
5580 "Configure BGP aggregate entries\n"
5581 "Aggregate prefix\n"
5582 "Generate AS set path information\n"
5583 "Filter more specific routes from updates\n")
5585 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5586 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5589 ALIAS (aggregate_address_as_set_summary
,
5590 aggregate_address_summary_as_set_cmd
,
5591 "aggregate-address A.B.C.D/M summary-only as-set",
5592 "Configure BGP aggregate entries\n"
5593 "Aggregate prefix\n"
5594 "Filter more specific routes from updates\n"
5595 "Generate AS set path information\n")
5597 DEFUN (aggregate_address_mask_as_set_summary
,
5598 aggregate_address_mask_as_set_summary_cmd
,
5599 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5600 "Configure BGP aggregate entries\n"
5601 "Aggregate address\n"
5603 "Generate AS set path information\n"
5604 "Filter more specific routes from updates\n")
5607 char prefix_str
[BUFSIZ
];
5609 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5613 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5617 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5618 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5621 ALIAS (aggregate_address_mask_as_set_summary
,
5622 aggregate_address_mask_summary_as_set_cmd
,
5623 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5624 "Configure BGP aggregate entries\n"
5625 "Aggregate address\n"
5627 "Filter more specific routes from updates\n"
5628 "Generate AS set path information\n")
5630 DEFUN (no_aggregate_address
,
5631 no_aggregate_address_cmd
,
5632 "no aggregate-address A.B.C.D/M",
5634 "Configure BGP aggregate entries\n"
5635 "Aggregate prefix\n")
5637 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5640 ALIAS (no_aggregate_address
,
5641 no_aggregate_address_summary_only_cmd
,
5642 "no aggregate-address A.B.C.D/M summary-only",
5644 "Configure BGP aggregate entries\n"
5645 "Aggregate prefix\n"
5646 "Filter more specific routes from updates\n")
5648 ALIAS (no_aggregate_address
,
5649 no_aggregate_address_as_set_cmd
,
5650 "no aggregate-address A.B.C.D/M as-set",
5652 "Configure BGP aggregate entries\n"
5653 "Aggregate prefix\n"
5654 "Generate AS set path information\n")
5656 ALIAS (no_aggregate_address
,
5657 no_aggregate_address_as_set_summary_cmd
,
5658 "no aggregate-address A.B.C.D/M as-set summary-only",
5660 "Configure BGP aggregate entries\n"
5661 "Aggregate prefix\n"
5662 "Generate AS set path information\n"
5663 "Filter more specific routes from updates\n")
5665 ALIAS (no_aggregate_address
,
5666 no_aggregate_address_summary_as_set_cmd
,
5667 "no aggregate-address A.B.C.D/M summary-only as-set",
5669 "Configure BGP aggregate entries\n"
5670 "Aggregate prefix\n"
5671 "Filter more specific routes from updates\n"
5672 "Generate AS set path information\n")
5674 DEFUN (no_aggregate_address_mask
,
5675 no_aggregate_address_mask_cmd
,
5676 "no aggregate-address A.B.C.D A.B.C.D",
5678 "Configure BGP aggregate entries\n"
5679 "Aggregate address\n"
5683 char prefix_str
[BUFSIZ
];
5685 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5689 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5693 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5696 ALIAS (no_aggregate_address_mask
,
5697 no_aggregate_address_mask_summary_only_cmd
,
5698 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5700 "Configure BGP aggregate entries\n"
5701 "Aggregate address\n"
5703 "Filter more specific routes from updates\n")
5705 ALIAS (no_aggregate_address_mask
,
5706 no_aggregate_address_mask_as_set_cmd
,
5707 "no aggregate-address A.B.C.D A.B.C.D as-set",
5709 "Configure BGP aggregate entries\n"
5710 "Aggregate address\n"
5712 "Generate AS set path information\n")
5714 ALIAS (no_aggregate_address_mask
,
5715 no_aggregate_address_mask_as_set_summary_cmd
,
5716 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5718 "Configure BGP aggregate entries\n"
5719 "Aggregate address\n"
5721 "Generate AS set path information\n"
5722 "Filter more specific routes from updates\n")
5724 ALIAS (no_aggregate_address_mask
,
5725 no_aggregate_address_mask_summary_as_set_cmd
,
5726 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5728 "Configure BGP aggregate entries\n"
5729 "Aggregate address\n"
5731 "Filter more specific routes from updates\n"
5732 "Generate AS set path information\n")
5735 DEFUN (ipv6_aggregate_address
,
5736 ipv6_aggregate_address_cmd
,
5737 "aggregate-address X:X::X:X/M",
5738 "Configure BGP aggregate entries\n"
5739 "Aggregate prefix\n")
5741 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5744 DEFUN (ipv6_aggregate_address_summary_only
,
5745 ipv6_aggregate_address_summary_only_cmd
,
5746 "aggregate-address X:X::X:X/M summary-only",
5747 "Configure BGP aggregate entries\n"
5748 "Aggregate prefix\n"
5749 "Filter more specific routes from updates\n")
5751 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5752 AGGREGATE_SUMMARY_ONLY
, 0);
5755 DEFUN (no_ipv6_aggregate_address
,
5756 no_ipv6_aggregate_address_cmd
,
5757 "no aggregate-address X:X::X:X/M",
5759 "Configure BGP aggregate entries\n"
5760 "Aggregate prefix\n")
5762 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5765 DEFUN (no_ipv6_aggregate_address_summary_only
,
5766 no_ipv6_aggregate_address_summary_only_cmd
,
5767 "no aggregate-address X:X::X:X/M summary-only",
5769 "Configure BGP aggregate entries\n"
5770 "Aggregate prefix\n"
5771 "Filter more specific routes from updates\n")
5773 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5776 ALIAS (ipv6_aggregate_address
,
5777 old_ipv6_aggregate_address_cmd
,
5778 "ipv6 bgp aggregate-address X:X::X:X/M",
5781 "Configure BGP aggregate entries\n"
5782 "Aggregate prefix\n")
5784 ALIAS (ipv6_aggregate_address_summary_only
,
5785 old_ipv6_aggregate_address_summary_only_cmd
,
5786 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5789 "Configure BGP aggregate entries\n"
5790 "Aggregate prefix\n"
5791 "Filter more specific routes from updates\n")
5793 ALIAS (no_ipv6_aggregate_address
,
5794 old_no_ipv6_aggregate_address_cmd
,
5795 "no ipv6 bgp aggregate-address X:X::X:X/M",
5799 "Configure BGP aggregate entries\n"
5800 "Aggregate prefix\n")
5802 ALIAS (no_ipv6_aggregate_address_summary_only
,
5803 old_no_ipv6_aggregate_address_summary_only_cmd
,
5804 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5808 "Configure BGP aggregate entries\n"
5809 "Aggregate prefix\n"
5810 "Filter more specific routes from updates\n")
5811 #endif /* HAVE_IPV6 */
5813 /* Redistribute route treatment. */
5815 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5816 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5817 u_int32_t metric
, u_char type
, u_short instance
, route_tag_t tag
)
5819 struct bgp_info
*new;
5820 struct bgp_info
*bi
;
5821 struct bgp_info info
;
5822 struct bgp_node
*bn
;
5824 struct attr
*new_attr
;
5827 struct bgp_redist
*red
;
5829 /* Make default attribute. */
5830 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5832 attr
.nexthop
= *nexthop
;
5833 attr
.nh_ifindex
= ifindex
;
5838 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5839 extra
->mp_nexthop_global
= *nexthop6
;
5840 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5845 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5846 attr
.extra
->tag
= tag
;
5848 afi
= family2afi (p
->family
);
5850 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5853 struct attr attr_new
;
5854 struct attr_extra extra_new
;
5856 /* Copy attribute for modification. */
5857 attr_new
.extra
= &extra_new
;
5858 bgp_attr_dup (&attr_new
, &attr
);
5860 if (red
->redist_metric_flag
)
5861 attr_new
.med
= red
->redist_metric
;
5863 /* Apply route-map. */
5866 info
.peer
= bgp
->peer_self
;
5867 info
.attr
= &attr_new
;
5869 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5871 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5873 bgp
->peer_self
->rmap_type
= 0;
5875 if (ret
== RMAP_DENYMATCH
)
5877 /* Free uninterned attribute. */
5878 bgp_attr_flush (&attr_new
);
5880 /* Unintern original. */
5881 aspath_unintern (&attr
.aspath
);
5882 bgp_attr_extra_free (&attr
);
5883 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5888 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5889 afi
, SAFI_UNICAST
, p
, NULL
);
5891 new_attr
= bgp_attr_intern (&attr_new
);
5893 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5894 if (bi
->peer
== bgp
->peer_self
5895 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5900 /* Ensure the (source route) type is updated. */
5902 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5903 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5905 bgp_attr_unintern (&new_attr
);
5906 aspath_unintern (&attr
.aspath
);
5907 bgp_attr_extra_free (&attr
);
5908 bgp_unlock_node (bn
);
5913 /* The attribute is changed. */
5914 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5916 /* Rewrite BGP route information. */
5917 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5918 bgp_info_restore(bn
, bi
);
5920 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5921 bgp_attr_unintern (&bi
->attr
);
5922 bi
->attr
= new_attr
;
5923 bi
->uptime
= bgp_clock ();
5925 /* Process change. */
5926 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5927 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5928 bgp_unlock_node (bn
);
5929 aspath_unintern (&attr
.aspath
);
5930 bgp_attr_extra_free (&attr
);
5935 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5937 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5939 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5940 bgp_info_add (bn
, new);
5941 bgp_unlock_node (bn
);
5942 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5945 /* Unintern original. */
5946 aspath_unintern (&attr
.aspath
);
5947 bgp_attr_extra_free (&attr
);
5951 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5954 struct bgp_node
*rn
;
5955 struct bgp_info
*ri
;
5956 struct bgp_redist
*red
;
5958 afi
= family2afi (p
->family
);
5960 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5963 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5965 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5966 if (ri
->peer
== bgp
->peer_self
5967 && ri
->type
== type
)
5972 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5973 bgp_info_delete (rn
, ri
);
5974 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5976 bgp_unlock_node (rn
);
5980 /* Withdraw specified route type's route. */
5982 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5984 struct bgp_node
*rn
;
5985 struct bgp_info
*ri
;
5986 struct bgp_table
*table
;
5988 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5990 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5992 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5993 if (ri
->peer
== bgp
->peer_self
5995 && ri
->instance
== instance
)
6000 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
6001 bgp_info_delete (rn
, ri
);
6002 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
6007 /* Static function to display route. */
6009 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
6012 u_int32_t destination
;
6015 if (p
->family
== AF_INET
)
6017 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
6018 destination
= ntohl (p
->u
.prefix4
.s_addr
);
6020 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
6021 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
6022 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
6023 || p
->u
.prefix4
.s_addr
== 0)
6025 /* When mask is natural, mask is not displayed. */
6028 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
6031 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
6036 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
6038 vty_out (vty
, "%*s", len
, " ");
6041 enum bgp_display_type
6046 /* Print the short form route status for a bgp_info */
6048 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
6049 json_object
*json_path
)
6054 /* Route status display. */
6055 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6056 json_object_boolean_true_add(json_path
, "removed");
6058 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6059 json_object_boolean_true_add(json_path
, "stale");
6061 if (binfo
->extra
&& binfo
->extra
->suppress
)
6062 json_object_boolean_true_add(json_path
, "suppressed");
6064 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6065 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6066 json_object_boolean_true_add(json_path
, "valid");
6069 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6070 json_object_boolean_true_add(json_path
, "history");
6072 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6073 json_object_boolean_true_add(json_path
, "damped");
6075 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6076 json_object_boolean_true_add(json_path
, "bestpath");
6078 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6079 json_object_boolean_true_add(json_path
, "multipath");
6081 /* Internal route. */
6082 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6083 json_object_string_add(json_path
, "pathFrom", "internal");
6085 json_object_string_add(json_path
, "pathFrom", "external");
6090 /* Route status display. */
6091 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6093 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6095 else if (binfo
->extra
&& binfo
->extra
->suppress
)
6097 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6098 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6104 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6106 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6108 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6110 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6115 /* Internal route. */
6116 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6122 /* called from terminal list command */
6124 route_vty_out (struct vty
*vty
, struct prefix
*p
,
6125 struct bgp_info
*binfo
, int display
, safi_t safi
,
6126 json_object
*json_paths
)
6129 json_object
*json_path
= NULL
;
6130 json_object
*json_nexthops
= NULL
;
6131 json_object
*json_nexthop_global
= NULL
;
6132 json_object
*json_nexthop_ll
= NULL
;
6135 json_path
= json_object_new_object();
6137 /* short status lead text */
6138 route_vty_short_status_out (vty
, binfo
, json_path
);
6142 /* print prefix and mask */
6144 route_vty_out_route (p
, vty
);
6146 vty_out (vty
, "%*s", 17, " ");
6149 /* Print attribute */
6154 * For ENCAP routes, nexthop address family is not
6155 * neccessarily the same as the prefix address family.
6156 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
6158 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
6163 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
6168 vty_out (vty
, "%s", inet_ntop(af
,
6169 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
6173 vty_out (vty
, "%s", inet_ntop(af
,
6174 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
6186 else if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6190 json_nexthop_global
= json_object_new_object();
6192 if (safi
== SAFI_MPLS_VPN
)
6193 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6195 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6197 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6198 json_object_boolean_true_add(json_nexthop_global
, "used");
6202 if (safi
== SAFI_MPLS_VPN
)
6203 vty_out (vty
, "%-16s",
6204 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6206 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6211 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6218 json_nexthop_global
= json_object_new_object();
6219 json_object_string_add(json_nexthop_global
, "ip",
6220 inet_ntop (AF_INET6
,
6221 &attr
->extra
->mp_nexthop_global
,
6223 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6224 json_object_string_add(json_nexthop_global
, "scope", "global");
6226 /* We display both LL & GL if both have been received */
6227 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
6229 json_nexthop_ll
= json_object_new_object();
6230 json_object_string_add(json_nexthop_ll
, "ip",
6231 inet_ntop (AF_INET6
,
6232 &attr
->extra
->mp_nexthop_local
,
6234 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6235 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6237 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
6238 &attr
->extra
->mp_nexthop_local
) != 0) &&
6239 !attr
->extra
->mp_nexthop_prefer_global
)
6240 json_object_boolean_true_add(json_nexthop_ll
, "used");
6242 json_object_boolean_true_add(json_nexthop_global
, "used");
6245 json_object_boolean_true_add(json_nexthop_global
, "used");
6249 /* Display LL if LL/Global both in table unless prefer-global is set */
6250 if (((attr
->extra
->mp_nexthop_len
== 32) &&
6251 !attr
->extra
->mp_nexthop_prefer_global
) ||
6252 (binfo
->peer
->conf_if
))
6254 if (binfo
->peer
->conf_if
)
6256 len
= vty_out (vty
, "%s",
6257 binfo
->peer
->conf_if
);
6258 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6261 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6263 vty_out (vty
, "%*s", len
, " ");
6267 len
= vty_out (vty
, "%s",
6268 inet_ntop (AF_INET6
,
6269 &attr
->extra
->mp_nexthop_local
,
6274 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6276 vty_out (vty
, "%*s", len
, " ");
6281 len
= vty_out (vty
, "%s",
6282 inet_ntop (AF_INET6
,
6283 &attr
->extra
->mp_nexthop_global
,
6288 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6290 vty_out (vty
, "%*s", len
, " ");
6296 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6298 json_object_int_add(json_path
, "med", attr
->med
);
6300 vty_out (vty
, "%10u", attr
->med
);
6306 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6308 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6310 vty_out (vty
, "%7u", attr
->local_pref
);
6318 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6320 json_object_int_add(json_path
, "weight", 0);
6323 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6327 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6334 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6336 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6341 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6343 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6348 json_object_string_add(json_path
, "alert", "No attributes");
6350 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6355 if (json_nexthop_global
|| json_nexthop_ll
)
6357 json_nexthops
= json_object_new_array();
6359 if (json_nexthop_global
)
6360 json_object_array_add(json_nexthops
, json_nexthop_global
);
6362 if (json_nexthop_ll
)
6363 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6365 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6368 json_object_array_add(json_paths
, json_path
);
6372 vty_out (vty
, "%s", VTY_NEWLINE
);
6374 /* prints an additional line, indented, with VNC info, if present */
6375 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
6376 rfapi_vty_out_vncinfo(vty
, p
, binfo
, safi
);
6381 /* called from terminal list command */
6383 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6384 u_char use_json
, json_object
*json_ar
)
6386 json_object
*json_status
= NULL
;
6387 json_object
*json_net
= NULL
;
6389 /* Route status display. */
6392 json_status
= json_object_new_object();
6393 json_net
= json_object_new_object();
6402 /* print prefix and mask */
6404 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6406 route_vty_out_route (p
, vty
);
6408 /* Print attribute */
6413 if (p
->family
== AF_INET
&&
6414 (safi
== SAFI_MPLS_VPN
||
6415 safi
== SAFI_ENCAP
||
6416 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6418 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6419 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6421 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6424 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6428 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6431 #endif /* HAVE_IPV6 */
6433 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6434 json_object_int_add(json_net
, "metric", attr
->med
);
6436 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6437 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6440 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6442 json_object_int_add(json_net
, "weight", 0);
6446 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6449 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6453 if (p
->family
== AF_INET
&&
6454 (safi
== SAFI_MPLS_VPN
||
6455 safi
== SAFI_ENCAP
||
6456 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6459 (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
))
6460 vty_out (vty
, "%-16s",
6461 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6463 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6466 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6472 len
= vty_out (vty
, "%s",
6473 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6480 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6482 vty_out (vty
, "%*s", len
, " ");
6484 #endif /* HAVE_IPV6 */
6485 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6486 vty_out (vty
, "%10u", attr
->med
);
6490 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6491 vty_out (vty
, "%7u", attr
->local_pref
);
6495 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6499 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6502 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6507 json_object_boolean_true_add(json_status
, "*");
6508 json_object_boolean_true_add(json_status
, ">");
6509 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6510 char buf_cut
[BUFSIZ
];
6511 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6514 vty_out (vty
, "%s", VTY_NEWLINE
);
6518 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6519 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6521 json_object
*json_out
= NULL
;
6523 u_int32_t label
= 0;
6529 json_out
= json_object_new_object();
6531 /* short status lead text */
6532 route_vty_short_status_out (vty
, binfo
, json_out
);
6534 /* print prefix and mask */
6538 route_vty_out_route (p
, vty
);
6540 vty_out (vty
, "%*s", 17, " ");
6543 /* Print attribute */
6547 if (p
->family
== AF_INET
6548 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6550 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6553 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6555 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6560 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6562 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6566 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6568 assert (attr
->extra
);
6572 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6575 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6576 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6579 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6582 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6586 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6588 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6590 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6591 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6594 vty_out (vty
, "%s(%s)",
6595 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6597 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6602 #endif /* HAVE_IPV6 */
6605 label
= decode_label (binfo
->extra
->tag
);
6610 json_object_int_add(json_out
, "notag", label
);
6611 json_object_array_add(json
, json_out
);
6615 vty_out (vty
, "notag/%d", label
);
6616 vty_out (vty
, "%s", VTY_NEWLINE
);
6620 /* dampening route */
6622 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6623 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6627 char timebuf
[BGP_UPTIME_LEN
];
6629 /* short status lead text */
6630 route_vty_short_status_out (vty
, binfo
, json
);
6632 /* print prefix and mask */
6636 route_vty_out_route (p
, vty
);
6638 vty_out (vty
, "%*s", 17, " ");
6641 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6646 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6651 json_object_int_add(json
, "peerHost", len
);
6653 vty_out (vty
, "%*s", len
, " ");
6657 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6659 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6661 /* Print attribute */
6669 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6671 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6676 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6678 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6681 vty_out (vty
, "%s", VTY_NEWLINE
);
6686 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6687 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6690 struct bgp_damp_info
*bdi
;
6691 char timebuf
[BGP_UPTIME_LEN
];
6697 bdi
= binfo
->extra
->damp_info
;
6699 /* short status lead text */
6700 route_vty_short_status_out (vty
, binfo
, json
);
6702 /* print prefix and mask */
6706 route_vty_out_route (p
, vty
);
6708 vty_out (vty
, "%*s", 17, " ");
6711 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6716 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6721 json_object_int_add(json
, "peerHost", len
);
6723 vty_out (vty
, "%*s", len
, " ");
6726 len
= vty_out (vty
, "%d", bdi
->flap
);
6736 json_object_int_add(json
, "bdiFlap", len
);
6738 vty_out (vty
, "%*s", len
, " ");
6742 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6744 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6745 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6747 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6748 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6751 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6753 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6758 vty_out (vty
, "%*s ", 8, " ");
6761 /* Print attribute */
6769 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6771 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6776 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6778 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6781 vty_out (vty
, "%s", VTY_NEWLINE
);
6785 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6786 const char *header
, json_object
*json_adv_to
)
6788 char buf1
[INET6_ADDRSTRLEN
];
6789 json_object
*json_peer
= NULL
;
6793 /* 'advertised-to' is a dictionary of peers we have advertised this
6794 * prefix too. The key is the peer's IP or swpX, the value is the
6795 * hostname if we know it and "" if not.
6797 json_peer
= json_object_new_object();
6800 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6803 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6805 json_object_object_add(json_adv_to
,
6806 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6813 vty_out (vty
, "%s", header
);
6817 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6820 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6822 vty_out (vty
, " %s(%s)", peer
->hostname
,
6823 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6828 vty_out (vty
, " %s", peer
->conf_if
);
6830 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6836 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6837 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6838 json_object
*json_paths
)
6840 char buf
[INET6_ADDRSTRLEN
];
6843 int sockunion_vty_out (struct vty
*, union sockunion
*);
6844 #ifdef HAVE_CLOCK_MONOTONIC
6847 json_object
*json_bestpath
= NULL
;
6848 json_object
*json_cluster_list
= NULL
;
6849 json_object
*json_cluster_list_list
= NULL
;
6850 json_object
*json_ext_community
= NULL
;
6851 json_object
*json_last_update
= NULL
;
6852 json_object
*json_nexthop_global
= NULL
;
6853 json_object
*json_nexthop_ll
= NULL
;
6854 json_object
*json_nexthops
= NULL
;
6855 json_object
*json_path
= NULL
;
6856 json_object
*json_peer
= NULL
;
6857 json_object
*json_string
= NULL
;
6858 json_object
*json_adv_to
= NULL
;
6860 struct listnode
*node
, *nnode
;
6862 int addpath_capable
;
6864 unsigned int first_as
;
6868 json_path
= json_object_new_object();
6869 json_peer
= json_object_new_object();
6870 json_nexthop_global
= json_object_new_object();
6877 /* Line1 display AS-path, Aggregator */
6882 json_object_lock(attr
->aspath
->json
);
6883 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6887 if (attr
->aspath
->segments
)
6888 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6890 vty_out (vty
, " Local");
6894 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6897 json_object_boolean_true_add(json_path
, "removed");
6899 vty_out (vty
, ", (removed)");
6902 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6905 json_object_boolean_true_add(json_path
, "stale");
6907 vty_out (vty
, ", (stale)");
6910 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6914 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6915 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6919 vty_out (vty
, ", (aggregated by %u %s)",
6920 attr
->extra
->aggregator_as
,
6921 inet_ntoa (attr
->extra
->aggregator_addr
));
6925 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6928 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6930 vty_out (vty
, ", (Received from a RR-client)");
6933 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6936 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6938 vty_out (vty
, ", (Received from a RS-client)");
6941 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6944 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6946 vty_out (vty
, ", (history entry)");
6948 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6951 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6953 vty_out (vty
, ", (suppressed due to dampening)");
6957 vty_out (vty
, "%s", VTY_NEWLINE
);
6959 /* Line2 display Next-hop, Neighbor, Router-id */
6960 /* Display the nexthop */
6961 if (p
->family
== AF_INET
&&
6962 (safi
== SAFI_MPLS_VPN
||
6963 safi
== SAFI_ENCAP
||
6964 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6966 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6969 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6971 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6976 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6978 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6982 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6986 assert (attr
->extra
);
6989 json_object_string_add(json_nexthop_global
, "ip",
6990 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6991 buf
, INET6_ADDRSTRLEN
));
6992 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6993 json_object_string_add(json_nexthop_global
, "scope", "global");
6997 vty_out (vty
, " %s",
6998 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6999 buf
, INET6_ADDRSTRLEN
));
7003 /* Display the IGP cost or 'inaccessible' */
7004 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7007 json_object_boolean_false_add(json_nexthop_global
, "accessible");
7009 vty_out (vty
, " (inaccessible)");
7013 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
7016 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
7018 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
7021 /* IGP cost is 0, display this only for json */
7025 json_object_int_add(json_nexthop_global
, "metric", 0);
7029 json_object_boolean_true_add(json_nexthop_global
, "accessible");
7032 /* Display peer "from" output */
7033 /* This path was originated locally */
7034 if (binfo
->peer
== bgp
->peer_self
)
7037 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
7040 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
7042 vty_out (vty
, " from 0.0.0.0 ");
7047 json_object_string_add(json_peer
, "peerId", "::");
7049 vty_out (vty
, " from :: ");
7053 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
7055 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
7058 /* We RXed this path from one of our peers */
7064 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7065 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7067 if (binfo
->peer
->hostname
)
7068 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
7070 if (binfo
->peer
->domainname
)
7071 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
7073 if (binfo
->peer
->conf_if
)
7074 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
7078 if (binfo
->peer
->conf_if
)
7080 if (binfo
->peer
->hostname
&&
7081 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7082 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7083 binfo
->peer
->conf_if
);
7085 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
7089 if (binfo
->peer
->hostname
&&
7090 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7091 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7094 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7097 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7098 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
7100 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7105 vty_out (vty
, "%s", VTY_NEWLINE
);
7107 /* display the link-local nexthop */
7108 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
7112 json_nexthop_ll
= json_object_new_object();
7113 json_object_string_add(json_nexthop_ll
, "ip",
7114 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7115 buf
, INET6_ADDRSTRLEN
));
7116 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
7117 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
7119 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
7121 if (!attr
->extra
->mp_nexthop_prefer_global
)
7122 json_object_boolean_true_add(json_nexthop_ll
, "used");
7124 json_object_boolean_true_add(json_nexthop_global
, "used");
7128 vty_out (vty
, " (%s) %s%s",
7129 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7130 buf
, INET6_ADDRSTRLEN
),
7131 attr
->extra
->mp_nexthop_prefer_global
?
7132 "(prefer-global)" : "(used)",
7136 /* If we do not have a link-local nexthop then we must flag the global as "used" */
7140 json_object_boolean_true_add(json_nexthop_global
, "used");
7143 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
7145 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
7147 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
7149 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
7152 json_object_int_add(json_path
, "med", attr
->med
);
7154 vty_out (vty
, ", metric %u", attr
->med
);
7157 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
7160 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
7162 vty_out (vty
, ", localpref %u", attr
->local_pref
);
7167 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
7169 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
7172 if (attr
->extra
&& attr
->extra
->weight
!= 0)
7175 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
7177 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
7180 if (attr
->extra
&& attr
->extra
->tag
!= 0)
7183 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
7185 vty_out (vty
, ", tag %"ROUTE_TAG_PRI
, attr
->extra
->tag
);
7188 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7191 json_object_boolean_false_add(json_path
, "valid");
7193 vty_out (vty
, ", invalid");
7195 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
7198 json_object_boolean_true_add(json_path
, "valid");
7200 vty_out (vty
, ", valid");
7203 if (binfo
->peer
!= bgp
->peer_self
)
7205 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
7207 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7210 json_object_string_add(json_peer
, "type", "confed-internal");
7212 vty_out (vty
, ", confed-internal");
7217 json_object_string_add(json_peer
, "type", "internal");
7219 vty_out (vty
, ", internal");
7224 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
7227 json_object_string_add(json_peer
, "type", "confed-external");
7229 vty_out (vty
, ", confed-external");
7234 json_object_string_add(json_peer
, "type", "external");
7236 vty_out (vty
, ", external");
7240 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
7244 json_object_boolean_true_add(json_path
, "aggregated");
7245 json_object_boolean_true_add(json_path
, "local");
7249 vty_out (vty
, ", aggregated, local");
7252 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
7255 json_object_boolean_true_add(json_path
, "sourced");
7257 vty_out (vty
, ", sourced");
7263 json_object_boolean_true_add(json_path
, "sourced");
7264 json_object_boolean_true_add(json_path
, "local");
7268 vty_out (vty
, ", sourced, local");
7272 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7275 json_object_boolean_true_add(json_path
, "atomicAggregate");
7277 vty_out (vty
, ", atomic-aggregate");
7280 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7281 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7282 bgp_info_mpath_count (binfo
)))
7285 json_object_boolean_true_add(json_path
, "multipath");
7287 vty_out (vty
, ", multipath");
7290 // Mark the bestpath(s)
7291 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7293 first_as
= aspath_get_first_as(attr
->aspath
);
7298 json_bestpath
= json_object_new_object();
7299 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7304 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7306 vty_out (vty
, ", bestpath-from-AS Local");
7310 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7315 json_bestpath
= json_object_new_object();
7316 json_object_boolean_true_add(json_bestpath
, "overall");
7319 vty_out (vty
, ", best");
7323 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7326 vty_out (vty
, "%s", VTY_NEWLINE
);
7328 /* Line 4 display Community */
7329 if (attr
->community
)
7333 json_object_lock(attr
->community
->json
);
7334 json_object_object_add(json_path
, "community", attr
->community
->json
);
7338 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7343 /* Line 5 display Extended-community */
7344 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7348 json_ext_community
= json_object_new_object();
7349 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7350 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7354 vty_out (vty
, " Extended Community: %s%s",
7355 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7359 /* Line 6 display Originator, Cluster-id */
7360 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7361 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7363 assert (attr
->extra
);
7364 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7367 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7369 vty_out (vty
, " Originator: %s",
7370 inet_ntoa (attr
->extra
->originator_id
));
7373 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7379 json_cluster_list
= json_object_new_object();
7380 json_cluster_list_list
= json_object_new_array();
7382 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7384 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7385 json_object_array_add(json_cluster_list_list
, json_string
);
7388 /* struct cluster_list does not have "str" variable like
7389 * aspath and community do. Add this someday if someone
7391 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7393 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7394 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7398 vty_out (vty
, ", Cluster list: ");
7400 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7402 vty_out (vty
, "%s ",
7403 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7409 vty_out (vty
, "%s", VTY_NEWLINE
);
7412 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7413 bgp_damp_info_vty (vty
, binfo
, json_path
);
7415 /* Line 7 display Addpath IDs */
7416 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7420 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7421 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7425 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7426 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7431 /* If we used addpath to TX a non-bestpath we need to display
7432 * "Advertised to" on a path-by-path basis */
7433 if (bgp
->addpath_tx_used
[afi
][safi
])
7437 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7439 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7440 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7442 if ((addpath_capable
&& has_adj
) ||
7443 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7445 if (json_path
&& !json_adv_to
)
7446 json_adv_to
= json_object_new_object();
7448 route_vty_out_advertised_to(vty
, peer
, &first
,
7458 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7465 vty_out (vty
, "%s", VTY_NEWLINE
);
7470 /* Line 8 display Uptime */
7471 #ifdef HAVE_CLOCK_MONOTONIC
7472 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7475 json_last_update
= json_object_new_object();
7476 json_object_int_add(json_last_update
, "epoch", tbuf
);
7477 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7478 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7481 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7485 json_last_update
= json_object_new_object();
7486 json_object_int_add(json_last_update
, "epoch", tbuf
);
7487 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7488 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7491 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7492 #endif /* HAVE_CLOCK_MONOTONIC */
7495 /* We've constructed the json object for this path, add it to the json
7500 if (json_nexthop_global
|| json_nexthop_ll
)
7502 json_nexthops
= json_object_new_array();
7504 if (json_nexthop_global
)
7505 json_object_array_add(json_nexthops
, json_nexthop_global
);
7507 if (json_nexthop_ll
)
7508 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7510 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7513 json_object_object_add(json_path
, "peer", json_peer
);
7514 json_object_array_add(json_paths
, json_path
);
7517 vty_out (vty
, "%s", VTY_NEWLINE
);
7520 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7521 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7522 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7526 bgp_show_type_normal
,
7527 bgp_show_type_regexp
,
7528 bgp_show_type_prefix_list
,
7529 bgp_show_type_filter_list
,
7530 bgp_show_type_route_map
,
7531 bgp_show_type_neighbor
,
7532 bgp_show_type_cidr_only
,
7533 bgp_show_type_prefix_longer
,
7534 bgp_show_type_community_all
,
7535 bgp_show_type_community
,
7536 bgp_show_type_community_exact
,
7537 bgp_show_type_community_list
,
7538 bgp_show_type_community_list_exact
,
7539 bgp_show_type_flap_statistics
,
7540 bgp_show_type_flap_address
,
7541 bgp_show_type_flap_prefix
,
7542 bgp_show_type_flap_cidr_only
,
7543 bgp_show_type_flap_regexp
,
7544 bgp_show_type_flap_filter_list
,
7545 bgp_show_type_flap_prefix_list
,
7546 bgp_show_type_flap_prefix_longer
,
7547 bgp_show_type_flap_route_map
,
7548 bgp_show_type_flap_neighbor
,
7549 bgp_show_type_dampend_paths
,
7550 bgp_show_type_damp_neighbor
7554 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7555 const char *prefix_list_str
, afi_t afi
,
7556 safi_t safi
, enum bgp_show_type type
);
7558 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7559 const char *filter
, afi_t afi
,
7560 safi_t safi
, enum bgp_show_type type
);
7562 bgp_show_route_map (struct vty
*vty
, const char *name
,
7563 const char *rmap_str
, afi_t afi
,
7564 safi_t safi
, enum bgp_show_type type
);
7566 bgp_show_community_list (struct vty
*vty
, const char *name
,
7567 const char *com
, int exact
,
7568 afi_t afi
, safi_t safi
);
7570 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7571 const char *prefix
, afi_t afi
,
7572 safi_t safi
, enum bgp_show_type type
);
7575 bgp_show_table (struct vty
*vty
, struct bgp
*bgp
, struct bgp_table
*table
,
7576 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7578 struct bgp_info
*ri
;
7579 struct bgp_node
*rn
;
7582 unsigned long output_count
;
7583 unsigned long total_count
;
7587 json_object
*json_paths
= NULL
;
7592 vty_out (vty
, "{ \"vrfId\": %d, \"vrfName\": \"%s\", \"tableVersion\": %" PRId64
", \"routerId\": \"%s\", \"routes\": { ",
7593 bgp
->vrf_id
== VRF_UNKNOWN
? -1 : bgp
->vrf_id
,
7594 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
? "Default" : bgp
->name
,
7595 table
->version
, inet_ntoa (bgp
->router_id
));
7596 json_paths
= json_object_new_object();
7599 /* This is first entry point, so reset total line. */
7603 /* Start processing of routes. */
7604 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7605 if (rn
->info
!= NULL
)
7608 if (!first
&& use_json
)
7613 json_paths
= json_object_new_array();
7617 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7620 if (type
== bgp_show_type_flap_statistics
7621 || type
== bgp_show_type_flap_address
7622 || type
== bgp_show_type_flap_prefix
7623 || type
== bgp_show_type_flap_cidr_only
7624 || type
== bgp_show_type_flap_regexp
7625 || type
== bgp_show_type_flap_filter_list
7626 || type
== bgp_show_type_flap_prefix_list
7627 || type
== bgp_show_type_flap_prefix_longer
7628 || type
== bgp_show_type_flap_route_map
7629 || type
== bgp_show_type_flap_neighbor
7630 || type
== bgp_show_type_dampend_paths
7631 || type
== bgp_show_type_damp_neighbor
)
7633 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7636 if (type
== bgp_show_type_regexp
7637 || type
== bgp_show_type_flap_regexp
)
7639 regex_t
*regex
= output_arg
;
7641 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7644 if (type
== bgp_show_type_prefix_list
7645 || type
== bgp_show_type_flap_prefix_list
)
7647 struct prefix_list
*plist
= output_arg
;
7649 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7652 if (type
== bgp_show_type_filter_list
7653 || type
== bgp_show_type_flap_filter_list
)
7655 struct as_list
*as_list
= output_arg
;
7657 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7660 if (type
== bgp_show_type_route_map
7661 || type
== bgp_show_type_flap_route_map
)
7663 struct route_map
*rmap
= output_arg
;
7664 struct bgp_info binfo
;
7665 struct attr dummy_attr
;
7666 struct attr_extra dummy_extra
;
7669 dummy_attr
.extra
= &dummy_extra
;
7670 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7672 binfo
.peer
= ri
->peer
;
7673 binfo
.attr
= &dummy_attr
;
7675 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7676 if (ret
== RMAP_DENYMATCH
)
7679 if (type
== bgp_show_type_neighbor
7680 || type
== bgp_show_type_flap_neighbor
7681 || type
== bgp_show_type_damp_neighbor
)
7683 union sockunion
*su
= output_arg
;
7685 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7688 if (type
== bgp_show_type_cidr_only
7689 || type
== bgp_show_type_flap_cidr_only
)
7691 u_int32_t destination
;
7693 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7694 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7696 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7698 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7701 if (type
== bgp_show_type_prefix_longer
7702 || type
== bgp_show_type_flap_prefix_longer
)
7704 struct prefix
*p
= output_arg
;
7706 if (! prefix_match (p
, &rn
->p
))
7709 if (type
== bgp_show_type_community_all
)
7711 if (! ri
->attr
->community
)
7714 if (type
== bgp_show_type_community
)
7716 struct community
*com
= output_arg
;
7718 if (! ri
->attr
->community
||
7719 ! community_match (ri
->attr
->community
, com
))
7722 if (type
== bgp_show_type_community_exact
)
7724 struct community
*com
= output_arg
;
7726 if (! ri
->attr
->community
||
7727 ! community_cmp (ri
->attr
->community
, com
))
7730 if (type
== bgp_show_type_community_list
)
7732 struct community_list
*list
= output_arg
;
7734 if (! community_list_match (ri
->attr
->community
, list
))
7737 if (type
== bgp_show_type_community_list_exact
)
7739 struct community_list
*list
= output_arg
;
7741 if (! community_list_exact_match (ri
->attr
->community
, list
))
7744 if (type
== bgp_show_type_flap_address
7745 || type
== bgp_show_type_flap_prefix
)
7747 struct prefix
*p
= output_arg
;
7749 if (! prefix_match (&rn
->p
, p
))
7752 if (type
== bgp_show_type_flap_prefix
)
7753 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7756 if (type
== bgp_show_type_dampend_paths
7757 || type
== bgp_show_type_damp_neighbor
)
7759 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7760 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7764 if (!use_json
&& header
)
7766 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
7767 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7768 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7769 if (type
== bgp_show_type_dampend_paths
7770 || type
== bgp_show_type_damp_neighbor
)
7771 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7772 else if (type
== bgp_show_type_flap_statistics
7773 || type
== bgp_show_type_flap_address
7774 || type
== bgp_show_type_flap_prefix
7775 || type
== bgp_show_type_flap_cidr_only
7776 || type
== bgp_show_type_flap_regexp
7777 || type
== bgp_show_type_flap_filter_list
7778 || type
== bgp_show_type_flap_prefix_list
7779 || type
== bgp_show_type_flap_prefix_longer
7780 || type
== bgp_show_type_flap_route_map
7781 || type
== bgp_show_type_flap_neighbor
)
7782 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7784 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7788 if (type
== bgp_show_type_dampend_paths
7789 || type
== bgp_show_type_damp_neighbor
)
7790 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7791 else if (type
== bgp_show_type_flap_statistics
7792 || type
== bgp_show_type_flap_address
7793 || type
== bgp_show_type_flap_prefix
7794 || type
== bgp_show_type_flap_cidr_only
7795 || type
== bgp_show_type_flap_regexp
7796 || type
== bgp_show_type_flap_filter_list
7797 || type
== bgp_show_type_flap_prefix_list
7798 || type
== bgp_show_type_flap_prefix_longer
7799 || type
== bgp_show_type_flap_route_map
7800 || type
== bgp_show_type_flap_neighbor
)
7801 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7803 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7813 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7814 vty_out (vty
, "\"%s\": ", buf2
);
7815 vty_out (vty
, "%s", json_object_to_json_string (json_paths
));
7816 json_object_free (json_paths
);
7825 json_object_free (json_paths
);
7826 vty_out (vty
, " } }%s", VTY_NEWLINE
);
7830 /* No route is displayed */
7831 if (output_count
== 0)
7833 if (type
== bgp_show_type_normal
)
7834 vty_out (vty
, "No BGP prefixes displayed, %ld exist%s", total_count
, VTY_NEWLINE
);
7837 vty_out (vty
, "%sDisplayed %ld routes and %ld total paths%s",
7838 VTY_NEWLINE
, output_count
, total_count
, VTY_NEWLINE
);
7845 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7846 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7848 struct bgp_table
*table
;
7852 bgp
= bgp_get_default ();
7858 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7862 table
= bgp
->rib
[afi
][safi
];
7864 return bgp_show_table (vty
, bgp
, table
, type
, output_arg
,
7869 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7872 struct listnode
*node
, *nnode
;
7874 struct bgp_table
*table
;
7878 vty_out (vty
, "{%s", VTY_NEWLINE
);
7880 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7885 vty_out (vty
, ",%s", VTY_NEWLINE
);
7889 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7890 ? "Default" : bgp
->name
);
7894 vty_out (vty
, "%sInstance %s:%s",
7896 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7897 ? "Default" : bgp
->name
,
7900 table
= bgp
->rib
[afi
][safi
];
7901 bgp_show_table (vty
, bgp
, table
,
7902 bgp_show_type_normal
, NULL
, use_json
);
7907 vty_out (vty
, "}%s", VTY_NEWLINE
);
7910 /* Header of detailed BGP route information */
7912 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7913 struct bgp_node
*rn
,
7914 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7917 struct bgp_info
*ri
;
7920 struct listnode
*node
, *nnode
;
7921 char buf1
[INET6_ADDRSTRLEN
];
7922 char buf2
[INET6_ADDRSTRLEN
];
7927 int no_advertise
= 0;
7930 json_object
*json_adv_to
= NULL
;
7936 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7937 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7941 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7942 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7943 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7944 safi
== SAFI_MPLS_VPN
? ":" : "",
7945 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7946 p
->prefixlen
, VTY_NEWLINE
);
7949 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7952 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7955 if (ri
->extra
&& ri
->extra
->suppress
)
7957 if (ri
->attr
->community
!= NULL
)
7959 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7961 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7963 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7971 vty_out (vty
, "Paths: (%d available", count
);
7974 vty_out (vty
, ", best #%d", best
);
7975 if (safi
== SAFI_UNICAST
)
7976 vty_out (vty
, ", table %s",
7977 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7978 ? "Default-IP-Routing-Table" : bgp
->name
);
7981 vty_out (vty
, ", no best path");
7984 vty_out (vty
, ", not advertised to any peer");
7986 vty_out (vty
, ", not advertised to EBGP peer");
7988 vty_out (vty
, ", not advertised outside local AS");
7991 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7992 vty_out (vty
, ")%s", VTY_NEWLINE
);
7995 /* If we are not using addpath then we can display Advertised to and that will
7996 * show what peers we advertised the bestpath to. If we are using addpath
7997 * though then we must display Advertised to on a path-by-path basis. */
7998 if (!bgp
->addpath_tx_used
[afi
][safi
])
8000 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
8002 if (bgp_adj_out_lookup (peer
, rn
, 0))
8004 if (json
&& !json_adv_to
)
8005 json_adv_to
= json_object_new_object();
8007 route_vty_out_advertised_to(vty
, peer
, &first
,
8008 " Advertised to non peer-group peers:\n ",
8017 json_object_object_add(json
, "advertisedTo", json_adv_to
);
8023 vty_out (vty
, " Not advertised to any peer");
8024 vty_out (vty
, "%s", VTY_NEWLINE
);
8029 /* Display specified route of BGP table. */
8031 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
8032 struct bgp_table
*rib
, const char *ip_str
,
8033 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8034 int prefix_check
, enum bgp_path_type pathtype
,
8040 struct prefix match
;
8041 struct bgp_node
*rn
;
8042 struct bgp_node
*rm
;
8043 struct bgp_info
*ri
;
8044 struct bgp_table
*table
;
8045 json_object
*json
= NULL
;
8046 json_object
*json_paths
= NULL
;
8048 /* Check IP address argument. */
8049 ret
= str2prefix (ip_str
, &match
);
8052 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
8056 match
.family
= afi2family (afi
);
8060 json
= json_object_new_object();
8061 json_paths
= json_object_new_array();
8064 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
8066 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
8068 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
8071 if ((table
= rn
->info
) != NULL
)
8075 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
8077 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
8079 bgp_unlock_node (rm
);
8083 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
8087 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
8088 AFI_IP
, safi
, json
);
8093 if (pathtype
== BGP_PATH_ALL
||
8094 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8095 (pathtype
== BGP_PATH_MULTIPATH
&&
8096 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8097 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
8100 bgp_unlock_node (rm
);
8109 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
8111 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
8113 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8117 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
8122 if (pathtype
== BGP_PATH_ALL
||
8123 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8124 (pathtype
== BGP_PATH_MULTIPATH
&&
8125 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8126 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
8130 bgp_unlock_node (rn
);
8137 json_object_object_add(json
, "paths", json_paths
);
8139 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
8140 json_object_free(json
);
8146 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
8154 /* Display specified route of Main RIB */
8156 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
8157 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8158 int prefix_check
, enum bgp_path_type pathtype
,
8163 /* BGP structure lookup. */
8166 bgp
= bgp_lookup_by_name (view_name
);
8169 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
8175 bgp
= bgp_get_default ();
8178 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8183 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
8184 afi
, safi
, prd
, prefix_check
, pathtype
,
8188 /* BGP route print out function. */
8191 "show ip bgp {json}",
8195 "JavaScript Object Notation\n")
8197 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8200 DEFUN (show_ip_bgp_ipv4
,
8201 show_ip_bgp_ipv4_cmd
,
8202 "show ip bgp ipv4 (unicast|multicast) {json}",
8207 "Address Family modifier\n"
8208 "Address Family modifier\n"
8209 "JavaScript Object Notation\n")
8211 u_char uj
= use_json(argc
, argv
);
8213 return bgp_show (vty
, NULL
, AFI_IP
,
8214 bgp_vty_safi_from_arg(argv
[0]),
8215 bgp_show_type_normal
, NULL
, uj
);
8218 ALIAS (show_ip_bgp_ipv4
,
8219 show_bgp_ipv4_safi_cmd
,
8220 "show bgp ipv4 (unicast|multicast) {json}",
8224 "Address Family modifier\n"
8225 "Address Family modifier\n"
8226 "JavaScript Object Notation\n")
8228 DEFUN (show_ip_bgp_route
,
8229 show_ip_bgp_route_cmd
,
8230 "show ip bgp A.B.C.D {json}",
8234 "Network in the BGP routing table to display\n"
8235 "JavaScript Object Notation\n")
8237 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8240 DEFUN (show_ip_bgp_route_pathtype
,
8241 show_ip_bgp_route_pathtype_cmd
,
8242 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
8246 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8247 "Display only the bestpath\n"
8248 "Display only multipaths\n"
8249 "JavaScript Object Notation\n")
8251 u_char uj
= use_json(argc
, argv
);
8253 if (strncmp (argv
[1], "b", 1) == 0)
8254 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8256 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8259 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
8260 show_bgp_ipv4_safi_route_pathtype_cmd
,
8261 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D (bestpath|multipath) {json}",
8264 BGP_AFI_SAFI_HELP_STR
8265 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8266 "Display only the bestpath\n"
8267 "Display only multipaths\n"
8268 "JavaScript Object Notation\n")
8270 u_char uj
= use_json(argc
, argv
);
8272 if (strncmp (argv
[2], "b", 1) == 0)
8273 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8274 bgp_vty_safi_from_arg(argv
[0]),
8275 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8277 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8278 bgp_vty_safi_from_arg(argv
[0]),
8279 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8282 DEFUN (show_bgp_ipv4_prefix
,
8283 show_bgp_ipv4_prefix_cmd
,
8284 "show bgp ipv4 A.B.C.D/M {json}",
8288 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8291 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8294 DEFUN (show_bgp_ipv6_route
,
8295 show_bgp_ipv6_route_cmd
,
8296 "show bgp ipv6 X:X::X:X {json}",
8300 "Network in the BGP routing table to display\n"
8303 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8306 DEFUN (show_bgp_ipv6_prefix
,
8307 show_bgp_ipv6_prefix_cmd
,
8308 "show bgp ipv6 X:X::X:X/M {json}",
8312 "IPv6 prefix <network>/<length>\n"
8315 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
,argv
));
8318 DEFUN (show_ip_bgp_ipv4_route
,
8319 show_ip_bgp_ipv4_route_cmd
,
8320 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8324 BGP_AFI_SAFI_HELP_STR
8325 "Network in the BGP routing table to display\n"
8326 "JavaScript Object Notation\n")
8328 u_char uj
= use_json(argc
, argv
);
8330 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8331 bgp_vty_safi_from_arg(argv
[0]),
8332 NULL
, 0, BGP_PATH_ALL
, uj
);
8335 ALIAS (show_ip_bgp_ipv4_route
,
8336 show_bgp_ipv4_safi_route_cmd
,
8337 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8340 BGP_AFI_SAFI_HELP_STR
8341 "Network in the BGP routing table to display\n"
8342 "JavaScript Object Notation\n")
8344 DEFUN (show_bgp_ipv4_safi_rd_route
,
8345 show_bgp_ipv4_safi_rd_route_cmd
,
8346 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8350 "Address Family Modifier\n"
8351 "Address Family Modifier\n"
8352 "Display information for a route distinguisher\n"
8353 "ENCAP Route Distinguisher\n"
8354 "Network in the BGP routing table to display\n")
8357 struct prefix_rd prd
;
8360 if (bgp_parse_safi(argv
[0], &safi
)) {
8361 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8364 ret
= str2prefix_rd (argv
[1], &prd
);
8367 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8370 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8373 DEFUN (show_bgp_ipv6_safi_rd_route
,
8374 show_bgp_ipv6_safi_rd_route_cmd
,
8375 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
8379 "Address Family Modifier\n"
8380 "Address Family Modifier\n"
8381 "Display information for a route distinguisher\n"
8382 "ENCAP Route Distinguisher\n"
8383 "Network in the BGP routing table to display\n")
8386 struct prefix_rd prd
;
8389 if (bgp_parse_safi(argv
[0], &safi
)) {
8390 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8393 ret
= str2prefix_rd (argv
[1], &prd
);
8396 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8399 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, SAFI_ENCAP
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8403 DEFUN (show_bgp_ipv4_safi_rd_prefix
,
8404 show_bgp_ipv4_safi_rd_prefix_cmd
,
8405 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8409 "Address Family Modifier\n"
8410 "Address Family Modifier\n"
8411 "Display information for a route distinguisher\n"
8412 "ENCAP Route Distinguisher\n"
8413 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8416 struct prefix_rd prd
;
8419 if (bgp_parse_safi(argv
[0], &safi
)) {
8420 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8424 ret
= str2prefix_rd (argv
[1], &prd
);
8427 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8430 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8433 DEFUN (show_bgp_ipv6_safi_rd_prefix
,
8434 show_bgp_ipv6_safi_rd_prefix_cmd
,
8435 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M {json}",
8439 "Address Family Modifier\n"
8440 "Address Family Modifier\n"
8441 "Display information for a route distinguisher\n"
8442 "ENCAP Route Distinguisher\n"
8443 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8446 struct prefix_rd prd
;
8449 if (bgp_parse_safi(argv
[0], &safi
)) {
8450 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8454 ret
= str2prefix_rd (argv
[1], &prd
);
8457 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8460 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8463 DEFUN (show_ip_bgp_prefix
,
8464 show_ip_bgp_prefix_cmd
,
8465 "show ip bgp A.B.C.D/M {json}",
8469 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8470 "JavaScript Object Notation\n")
8472 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8475 DEFUN (show_ip_bgp_prefix_pathtype
,
8476 show_ip_bgp_prefix_pathtype_cmd
,
8477 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8481 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8482 "Display only the bestpath\n"
8483 "Display only multipaths\n"
8484 "JavaScript Object Notation\n")
8486 u_char uj
= use_json(argc
, argv
);
8487 if (strncmp (argv
[1], "b", 1) == 0)
8488 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8490 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8493 DEFUN (show_ip_bgp_ipv4_prefix
,
8494 show_ip_bgp_ipv4_prefix_cmd
,
8495 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8499 BGP_AFI_SAFI_HELP_STR
8500 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8501 "JavaScript Object Notation\n")
8503 u_char uj
= use_json(argc
, argv
);
8505 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8506 bgp_vty_safi_from_arg(argv
[0]),
8507 NULL
, 1, BGP_PATH_ALL
, uj
);
8510 ALIAS (show_ip_bgp_ipv4_prefix
,
8511 show_bgp_ipv4_safi_prefix_cmd
,
8512 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8515 BGP_AFI_SAFI_HELP_STR
8516 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8517 "JavaScript Object Notation\n")
8519 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8520 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8521 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8525 BGP_AFI_SAFI_HELP_STR
8526 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8527 "Display only the bestpath\n"
8528 "Display only multipaths\n"
8529 "JavaScript Object Notation\n")
8531 u_char uj
= use_json(argc
, argv
);
8533 if (strncmp (argv
[2], "b", 1) == 0)
8534 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8535 bgp_vty_safi_from_arg(argv
[0]),
8536 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8538 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8539 bgp_vty_safi_from_arg(argv
[0]),
8540 NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8543 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8544 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8545 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8548 BGP_AFI_SAFI_HELP_STR
8549 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8550 "Display only the bestpath\n"
8551 "Display only multipaths\n"
8552 "JavaScript Object Notation\n")
8555 DEFUN (show_ip_bgp_view
,
8556 show_ip_bgp_instance_cmd
,
8557 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8561 BGP_INSTANCE_HELP_STR
8562 "JavaScript Object Notation\n")
8566 /* BGP structure lookup. */
8567 bgp
= bgp_lookup_by_name (argv
[1]);
8570 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8574 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8577 DEFUN (show_ip_bgp_instance_all
,
8578 show_ip_bgp_instance_all_cmd
,
8579 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8583 BGP_INSTANCE_ALL_HELP_STR
8584 "JavaScript Object Notation\n")
8586 u_char uj
= use_json(argc
, argv
);
8588 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8592 DEFUN (show_ip_bgp_instance_route
,
8593 show_ip_bgp_instance_route_cmd
,
8594 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8598 BGP_INSTANCE_HELP_STR
8599 "Network in the BGP routing table to display\n"
8600 "JavaScript Object Notation\n")
8602 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8605 DEFUN (show_ip_bgp_instance_route_pathtype
,
8606 show_ip_bgp_instance_route_pathtype_cmd
,
8607 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8611 BGP_INSTANCE_HELP_STR
8612 "Network in the BGP routing table to display\n"
8613 "Display only the bestpath\n"
8614 "Display only multipaths\n"
8615 "JavaScript Object Notation\n")
8617 u_char uj
= use_json(argc
, argv
);
8619 if (strncmp (argv
[3], "b", 1) == 0)
8620 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8622 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8625 DEFUN (show_ip_bgp_instance_prefix
,
8626 show_ip_bgp_instance_prefix_cmd
,
8627 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8631 BGP_INSTANCE_HELP_STR
8632 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8633 "JavaScript Object Notation\n")
8635 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8638 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8639 show_ip_bgp_instance_prefix_pathtype_cmd
,
8640 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8644 BGP_INSTANCE_HELP_STR
8645 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8646 "Display only the bestpath\n"
8647 "Display only multipaths\n"
8648 "JavaScript Object Notation\n")
8650 u_char uj
= use_json(argc
, argv
);
8651 if (strncmp (argv
[3], "b", 1) == 0)
8652 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8654 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8663 "JavaScript Object Notation\n")
8665 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8666 NULL
, use_json(argc
, argv
));
8671 "show bgp ipv6 {json}",
8675 "JavaScript Object Notation\n")
8677 DEFUN (show_bgp_ipv6_safi
,
8678 show_bgp_ipv6_safi_cmd
,
8679 "show bgp ipv6 (unicast|multicast) {json}",
8683 "Address Family modifier\n"
8684 "Address Family modifier\n"
8685 "JavaScript Object Notation\n")
8687 u_char uj
= use_json(argc
, argv
);
8689 return bgp_show (vty
, NULL
, AFI_IP6
,
8690 bgp_vty_safi_from_arg(argv
[0]),
8691 bgp_show_type_normal
, NULL
, uj
);
8695 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8697 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8698 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8699 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8703 DEFUN (show_ipv6_bgp
,
8705 "show ipv6 bgp {json}",
8709 "JavaScript Object Notation\n")
8711 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8712 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8713 NULL
, use_json(argc
, argv
));
8716 DEFUN (show_bgp_route
,
8718 "show bgp X:X::X:X {json}",
8721 "Network in the BGP routing table to display\n"
8722 "JavaScript Object Notation\n")
8724 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8727 DEFUN (show_bgp_ipv6_safi_route
,
8728 show_bgp_ipv6_safi_route_cmd
,
8729 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X {json}",
8732 BGP_AFI_SAFI_HELP_STR
8733 "Network in the BGP routing table to display\n"
8734 "JavaScript Object Notation\n")
8736 u_char uj
= use_json(argc
, argv
);
8738 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8739 bgp_vty_safi_from_arg(argv
[0]),
8740 NULL
, 0, BGP_PATH_ALL
, uj
);
8743 DEFUN (show_bgp_route_pathtype
,
8744 show_bgp_route_pathtype_cmd
,
8745 "show bgp X:X::X:X (bestpath|multipath) {json}",
8748 "Network in the BGP routing table to display\n"
8749 "Display only the bestpath\n"
8750 "Display only multipaths\n"
8751 "JavaScript Object Notation\n")
8753 u_char uj
= use_json(argc
, argv
);
8754 if (strncmp (argv
[1], "b", 1) == 0)
8755 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8757 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8760 ALIAS (show_bgp_route_pathtype
,
8761 show_bgp_ipv6_route_pathtype_cmd
,
8762 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8766 "Network in the BGP routing table to display\n"
8767 "Display only the bestpath\n"
8768 "Display only multipaths\n"
8769 "JavaScript Object Notation\n")
8771 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8772 show_bgp_ipv6_safi_route_pathtype_cmd
,
8773 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X (bestpath|multipath) {json}",
8776 BGP_AFI_SAFI_HELP_STR
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 u_char uj
= use_json(argc
, argv
);
8783 if (strncmp (argv
[2], "b", 1) == 0)
8784 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8785 bgp_vty_safi_from_arg(argv
[0]),
8786 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8788 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8789 bgp_vty_safi_from_arg(argv
[0]),
8790 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8794 DEFUN (show_ipv6_bgp_route
,
8795 show_ipv6_bgp_route_cmd
,
8796 "show ipv6 bgp X:X::X:X {json}",
8800 "Network in the BGP routing table to display\n"
8801 "JavaScript Object Notation\n")
8803 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8804 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8807 DEFUN (show_bgp_prefix
,
8808 show_bgp_prefix_cmd
,
8809 "show bgp X:X::X:X/M {json}",
8812 "IPv6 prefix <network>/<length>\n"
8813 "JavaScript Object Notation\n")
8815 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8818 DEFUN (show_bgp_ipv6_safi_prefix
,
8819 show_bgp_ipv6_safi_prefix_cmd
,
8820 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M {json}",
8823 BGP_AFI_SAFI_HELP_STR
8824 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8825 "JavaScript Object Notation\n")
8827 u_char uj
= use_json(argc
, argv
);
8829 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8830 bgp_vty_safi_from_arg(argv
[0]),
8831 NULL
, 1, BGP_PATH_ALL
, uj
);
8834 DEFUN (show_bgp_prefix_pathtype
,
8835 show_bgp_prefix_pathtype_cmd
,
8836 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8839 "IPv6 prefix <network>/<length>\n"
8840 "Display only the bestpath\n"
8841 "Display only multipaths\n"
8842 "JavaScript Object Notation\n")
8844 u_char uj
= use_json(argc
, argv
);
8845 if (strncmp (argv
[1], "b", 1) == 0)
8846 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8848 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8851 ALIAS (show_bgp_prefix_pathtype
,
8852 show_bgp_ipv6_prefix_pathtype_cmd
,
8853 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8857 "IPv6 prefix <network>/<length>\n"
8858 "Display only the bestpath\n"
8859 "Display only multipaths\n"
8860 "JavaScript Object Notation\n")
8862 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8863 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8864 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M (bestpath|multipath) {json}",
8867 BGP_AFI_SAFI_HELP_STR
8868 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8869 "Display only the bestpath\n"
8870 "Display only multipaths\n"
8871 "JavaScript Object Notation\n")
8873 u_char uj
= use_json(argc
, argv
);
8874 if (strncmp (argv
[2], "b", 1) == 0)
8875 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8876 bgp_vty_safi_from_arg(argv
[0]),
8877 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8879 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8880 bgp_vty_safi_from_arg(argv
[0]), NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8884 DEFUN (show_ipv6_bgp_prefix
,
8885 show_ipv6_bgp_prefix_cmd
,
8886 "show ipv6 bgp X:X::X:X/M {json}",
8890 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8891 "JavaScript Object Notation\n")
8893 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8894 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8897 DEFUN (show_bgp_view
,
8898 show_bgp_instance_cmd
,
8899 "show bgp " BGP_INSTANCE_CMD
" {json}",
8902 BGP_INSTANCE_HELP_STR
8903 "JavaScript Object Notation\n")
8907 /* BGP structure lookup. */
8908 bgp
= bgp_lookup_by_name (argv
[1]);
8911 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8915 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8918 DEFUN (show_bgp_instance_all
,
8919 show_bgp_instance_all_cmd
,
8920 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8923 BGP_INSTANCE_ALL_HELP_STR
8924 "JavaScript Object Notation\n")
8926 u_char uj
= use_json(argc
, argv
);
8928 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8932 ALIAS (show_bgp_view
,
8933 show_bgp_instance_ipv6_cmd
,
8934 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8937 BGP_INSTANCE_HELP_STR
8939 "JavaScript Object Notation\n")
8941 DEFUN (show_bgp_instance_route
,
8942 show_bgp_instance_route_cmd
,
8943 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8946 BGP_INSTANCE_HELP_STR
8947 "Network in the BGP routing table to display\n"
8948 "JavaScript Object Notation\n")
8950 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8953 ALIAS (show_bgp_instance_route
,
8954 show_bgp_instance_ipv6_route_cmd
,
8955 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8958 BGP_INSTANCE_HELP_STR
8960 "Network in the BGP routing table to display\n"
8961 "JavaScript Object Notation\n")
8963 DEFUN (show_bgp_instance_route_pathtype
,
8964 show_bgp_instance_route_pathtype_cmd
,
8965 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8968 BGP_INSTANCE_HELP_STR
8969 "Network in the BGP routing table to display\n"
8970 "Display only the bestpath\n"
8971 "Display only multipaths\n"
8972 "JavaScript Object Notation\n")
8974 u_char uj
= use_json(argc
, argv
);
8975 if (strncmp (argv
[3], "b", 1) == 0)
8976 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8978 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8981 ALIAS (show_bgp_instance_route_pathtype
,
8982 show_bgp_instance_ipv6_route_pathtype_cmd
,
8983 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
8986 BGP_INSTANCE_HELP_STR
8988 "Network in the BGP routing table to display\n"
8989 "Display only the bestpath\n"
8990 "Display only multipaths\n"
8991 "JavaScript Object Notation\n")
8993 DEFUN (show_bgp_instance_prefix
,
8994 show_bgp_instance_prefix_cmd
,
8995 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
8998 BGP_INSTANCE_HELP_STR
8999 "IPv6 prefix <network>/<length>\n"
9000 "JavaScript Object Notation\n")
9002 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9005 ALIAS (show_bgp_instance_prefix
,
9006 show_bgp_instance_ipv6_prefix_cmd
,
9007 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
9010 BGP_INSTANCE_HELP_STR
9012 "IPv6 prefix <network>/<length>\n"
9013 "JavaScript Object Notation\n")
9015 DEFUN (show_bgp_instance_prefix_pathtype
,
9016 show_bgp_instance_prefix_pathtype_cmd
,
9017 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
9020 BGP_INSTANCE_HELP_STR
9021 "IPv6 prefix <network>/<length>\n"
9022 "Display only the bestpath\n"
9023 "Display only multipaths\n"
9024 "JavaScript Object Notation\n")
9026 u_char uj
= use_json(argc
, argv
);
9027 if (strncmp (argv
[3], "b", 1) == 0)
9028 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
9030 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
9033 ALIAS (show_bgp_instance_prefix_pathtype
,
9034 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
9035 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
9038 BGP_INSTANCE_HELP_STR
9040 "IPv6 prefix <network>/<length>\n"
9041 "Display only the bestpath\n"
9042 "Display only multipaths\n"
9043 "JavaScript Object Notation\n")
9045 DEFUN (show_bgp_instance_prefix_list
,
9046 show_bgp_instance_prefix_list_cmd
,
9047 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9050 BGP_INSTANCE_HELP_STR
9051 "Display routes conforming to the prefix-list\n"
9052 "IPv6 prefix-list name\n")
9054 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9055 bgp_show_type_prefix_list
);
9058 ALIAS (show_bgp_instance_prefix_list
,
9059 show_bgp_instance_ipv6_prefix_list_cmd
,
9060 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
9063 BGP_INSTANCE_HELP_STR
9065 "Display routes conforming to the prefix-list\n"
9066 "IPv6 prefix-list name\n")
9068 DEFUN (show_bgp_instance_filter_list
,
9069 show_bgp_instance_filter_list_cmd
,
9070 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9073 BGP_INSTANCE_HELP_STR
9074 "Display routes conforming to the filter-list\n"
9075 "Regular expression access list name\n")
9077 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9078 bgp_show_type_filter_list
);
9081 ALIAS (show_bgp_instance_filter_list
,
9082 show_bgp_instance_ipv6_filter_list_cmd
,
9083 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
9086 BGP_INSTANCE_HELP_STR
9088 "Display routes conforming to the filter-list\n"
9089 "Regular expression access list name\n")
9091 DEFUN (show_bgp_instance_route_map
,
9092 show_bgp_instance_route_map_cmd
,
9093 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
9096 BGP_INSTANCE_HELP_STR
9097 "Display routes matching the route-map\n"
9098 "A route-map to match on\n")
9100 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9101 bgp_show_type_route_map
);
9104 ALIAS (show_bgp_instance_route_map
,
9105 show_bgp_instance_ipv6_route_map_cmd
,
9106 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
9109 BGP_INSTANCE_HELP_STR
9111 "Display routes matching the route-map\n"
9112 "A route-map to match on\n")
9114 DEFUN (show_bgp_instance_community_list
,
9115 show_bgp_instance_community_list_cmd
,
9116 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
9119 BGP_INSTANCE_HELP_STR
9120 "Display routes matching the community-list\n"
9121 "community-list number\n"
9122 "community-list name\n")
9124 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
9127 ALIAS (show_bgp_instance_community_list
,
9128 show_bgp_instance_ipv6_community_list_cmd
,
9129 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
9132 BGP_INSTANCE_HELP_STR
9134 "Display routes matching the community-list\n"
9135 "community-list number\n"
9136 "community-list name\n")
9138 DEFUN (show_bgp_instance_prefix_longer
,
9139 show_bgp_instance_prefix_longer_cmd
,
9140 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
9143 BGP_INSTANCE_HELP_STR
9144 "IPv6 prefix <network>/<length>\n"
9145 "Display route and more specific routes\n")
9147 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9148 bgp_show_type_prefix_longer
);
9151 ALIAS (show_bgp_instance_prefix_longer
,
9152 show_bgp_instance_ipv6_prefix_longer_cmd
,
9153 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
9156 BGP_INSTANCE_HELP_STR
9158 "IPv6 prefix <network>/<length>\n"
9159 "Display route and more specific routes\n")
9162 DEFUN (show_ipv6_mbgp
,
9164 "show ipv6 mbgp {json}",
9168 "JavaScript Object Notation\n")
9170 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9171 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
9172 NULL
, use_json(argc
, argv
));
9176 DEFUN (show_ipv6_mbgp_route
,
9177 show_ipv6_mbgp_route_cmd
,
9178 "show ipv6 mbgp X:X::X:X {json}",
9182 "Network in the MBGP routing table to display\n"
9183 "JavaScript Object Notation\n")
9185 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9186 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9190 DEFUN (show_ipv6_mbgp_prefix
,
9191 show_ipv6_mbgp_prefix_cmd
,
9192 "show ipv6 mbgp X:X::X:X/M {json}",
9196 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9197 "JavaScript Object Notation\n")
9199 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9200 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9206 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
9207 safi_t safi
, enum bgp_show_type type
)
9217 b
= buffer_new (1024);
9218 for (i
= 0; i
< argc
; i
++)
9221 buffer_putc (b
, ' ');
9224 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9229 buffer_putstr (b
, argv
[i
]);
9231 buffer_putc (b
, '\0');
9233 regstr
= buffer_getstr (b
);
9236 regex
= bgp_regcomp (regstr
);
9237 XFREE(MTYPE_TMP
, regstr
);
9240 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
9245 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
9246 bgp_regex_free (regex
);
9250 DEFUN (show_ip_bgp_regexp
,
9251 show_ip_bgp_regexp_cmd
,
9252 "show ip bgp regexp .LINE",
9256 "Display routes matching the AS path regular expression\n"
9257 "A regular-expression to match the BGP AS paths\n")
9259 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9260 bgp_show_type_regexp
);
9263 DEFUN (show_ip_bgp_flap_regexp
,
9264 show_ip_bgp_flap_regexp_cmd
,
9265 "show ip bgp flap-statistics regexp .LINE",
9269 "Display flap statistics of routes\n"
9270 "Display routes matching the AS path regular expression\n"
9271 "A regular-expression to match the BGP AS paths\n")
9273 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9274 bgp_show_type_flap_regexp
);
9277 ALIAS (show_ip_bgp_flap_regexp
,
9278 show_ip_bgp_damp_flap_regexp_cmd
,
9279 "show ip bgp dampening flap-statistics regexp .LINE",
9283 "Display detailed information about dampening\n"
9284 "Display flap statistics of routes\n"
9285 "Display routes matching the AS path regular expression\n"
9286 "A regular-expression to match the BGP AS paths\n")
9288 DEFUN (show_ip_bgp_ipv4_regexp
,
9289 show_ip_bgp_ipv4_regexp_cmd
,
9290 "show ip bgp ipv4 (unicast|multicast) regexp .LINE",
9295 "Address Family modifier\n"
9296 "Address Family modifier\n"
9297 "Display routes matching the AS path regular expression\n"
9298 "A regular-expression to match the BGP AS paths\n")
9301 safi
= bgp_vty_safi_from_arg(argv
[0]);
9302 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, safi
,
9303 bgp_show_type_regexp
);
9307 DEFUN (show_bgp_regexp
,
9308 show_bgp_regexp_cmd
,
9309 "show bgp regexp .LINE",
9312 "Display routes matching the AS path regular expression\n"
9313 "A regular-expression to match the BGP AS paths\n")
9315 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9316 bgp_show_type_regexp
);
9319 ALIAS (show_bgp_regexp
,
9320 show_bgp_ipv6_regexp_cmd
,
9321 "show bgp ipv6 regexp .LINE",
9325 "Display routes matching the AS path regular expression\n"
9326 "A regular-expression to match the BGP AS paths\n")
9329 DEFUN (show_ipv6_bgp_regexp
,
9330 show_ipv6_bgp_regexp_cmd
,
9331 "show ipv6 bgp regexp .LINE",
9335 "Display routes matching the AS path regular expression\n"
9336 "A regular-expression to match the BGP AS paths\n")
9338 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9339 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9340 bgp_show_type_regexp
);
9344 DEFUN (show_ipv6_mbgp_regexp
,
9345 show_ipv6_mbgp_regexp_cmd
,
9346 "show ipv6 mbgp regexp .LINE",
9350 "Display routes matching the AS path regular expression\n"
9351 "A regular-expression to match the MBGP AS paths\n")
9353 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9354 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9355 bgp_show_type_regexp
);
9357 #endif /* HAVE_IPV6 */
9360 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9361 const char *prefix_list_str
, afi_t afi
,
9362 safi_t safi
, enum bgp_show_type type
)
9364 struct prefix_list
*plist
;
9365 struct bgp
*bgp
= NULL
;
9367 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9369 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9373 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9376 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9377 prefix_list_str
, VTY_NEWLINE
);
9381 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9384 DEFUN (show_ip_bgp_prefix_list
,
9385 show_ip_bgp_prefix_list_cmd
,
9386 "show ip bgp prefix-list WORD",
9390 "Display routes conforming to the prefix-list\n"
9391 "IP prefix-list name\n")
9393 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9394 bgp_show_type_prefix_list
);
9397 DEFUN (show_ip_bgp_instance_prefix_list
,
9398 show_ip_bgp_instance_prefix_list_cmd
,
9399 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9403 BGP_INSTANCE_HELP_STR
9404 "Display routes conforming to the prefix-list\n"
9405 "IP prefix-list name\n")
9407 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9408 bgp_show_type_prefix_list
);
9411 DEFUN (show_ip_bgp_flap_prefix_list
,
9412 show_ip_bgp_flap_prefix_list_cmd
,
9413 "show ip bgp flap-statistics prefix-list WORD",
9417 "Display flap statistics of routes\n"
9418 "Display routes conforming to the prefix-list\n"
9419 "IP prefix-list name\n")
9421 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9422 bgp_show_type_flap_prefix_list
);
9425 ALIAS (show_ip_bgp_flap_prefix_list
,
9426 show_ip_bgp_damp_flap_prefix_list_cmd
,
9427 "show ip bgp dampening flap-statistics prefix-list WORD",
9431 "Display detailed information about dampening\n"
9432 "Display flap statistics of routes\n"
9433 "Display routes conforming to the prefix-list\n"
9434 "IP prefix-list name\n")
9436 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9437 show_ip_bgp_ipv4_prefix_list_cmd
,
9438 "show ip bgp ipv4 (unicast|multicast) prefix-list WORD",
9443 "Address Family modifier\n"
9444 "Address Family modifier\n"
9445 "Display routes conforming to the prefix-list\n"
9446 "IP prefix-list name\n")
9449 safi
= bgp_vty_safi_from_arg(argv
[0]);
9450 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9451 bgp_show_type_prefix_list
);
9455 DEFUN (show_bgp_prefix_list
,
9456 show_bgp_prefix_list_cmd
,
9457 "show bgp prefix-list WORD",
9460 "Display routes conforming to the prefix-list\n"
9461 "IPv6 prefix-list name\n")
9463 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9464 bgp_show_type_prefix_list
);
9467 ALIAS (show_bgp_prefix_list
,
9468 show_bgp_ipv6_prefix_list_cmd
,
9469 "show bgp ipv6 prefix-list WORD",
9473 "Display routes conforming to the prefix-list\n"
9474 "IPv6 prefix-list name\n")
9477 DEFUN (show_ipv6_bgp_prefix_list
,
9478 show_ipv6_bgp_prefix_list_cmd
,
9479 "show ipv6 bgp prefix-list WORD",
9483 "Display routes matching the prefix-list\n"
9484 "IPv6 prefix-list name\n")
9486 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9487 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9488 bgp_show_type_prefix_list
);
9492 DEFUN (show_ipv6_mbgp_prefix_list
,
9493 show_ipv6_mbgp_prefix_list_cmd
,
9494 "show ipv6 mbgp prefix-list WORD",
9498 "Display routes matching the prefix-list\n"
9499 "IPv6 prefix-list name\n")
9501 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9502 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9503 bgp_show_type_prefix_list
);
9505 #endif /* HAVE_IPV6 */
9508 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9509 const char *filter
, afi_t afi
,
9510 safi_t safi
, enum bgp_show_type type
)
9512 struct as_list
*as_list
;
9513 struct bgp
*bgp
= NULL
;
9515 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9517 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9521 as_list
= as_list_lookup (filter
);
9522 if (as_list
== NULL
)
9524 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9528 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9531 DEFUN (show_ip_bgp_filter_list
,
9532 show_ip_bgp_filter_list_cmd
,
9533 "show ip bgp filter-list WORD",
9537 "Display routes conforming to the filter-list\n"
9538 "Regular expression access list name\n")
9540 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9541 bgp_show_type_filter_list
);
9544 DEFUN (show_ip_bgp_instance_filter_list
,
9545 show_ip_bgp_instance_filter_list_cmd
,
9546 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9550 BGP_INSTANCE_HELP_STR
9551 "Display routes conforming to the filter-list\n"
9552 "Regular expression access list name\n")
9554 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9555 bgp_show_type_filter_list
);
9558 DEFUN (show_ip_bgp_flap_filter_list
,
9559 show_ip_bgp_flap_filter_list_cmd
,
9560 "show ip bgp flap-statistics filter-list WORD",
9564 "Display flap statistics of routes\n"
9565 "Display routes conforming to the filter-list\n"
9566 "Regular expression access list name\n")
9568 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9569 bgp_show_type_flap_filter_list
);
9572 ALIAS (show_ip_bgp_flap_filter_list
,
9573 show_ip_bgp_damp_flap_filter_list_cmd
,
9574 "show ip bgp dampening flap-statistics filter-list WORD",
9578 "Display detailed information about dampening\n"
9579 "Display flap statistics of routes\n"
9580 "Display routes conforming to the filter-list\n"
9581 "Regular expression access list name\n")
9583 DEFUN (show_ip_bgp_ipv4_filter_list
,
9584 show_ip_bgp_ipv4_filter_list_cmd
,
9585 "show ip bgp ipv4 (unicast|multicast) filter-list WORD",
9590 "Address Family modifier\n"
9591 "Address Family modifier\n"
9592 "Display routes conforming to the filter-list\n"
9593 "Regular expression access list name\n")
9596 safi
= bgp_vty_safi_from_arg(argv
[0]);
9597 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9598 bgp_show_type_filter_list
);
9602 DEFUN (show_bgp_filter_list
,
9603 show_bgp_filter_list_cmd
,
9604 "show bgp filter-list WORD",
9607 "Display routes conforming to the filter-list\n"
9608 "Regular expression access list name\n")
9610 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9611 bgp_show_type_filter_list
);
9614 ALIAS (show_bgp_filter_list
,
9615 show_bgp_ipv6_filter_list_cmd
,
9616 "show bgp ipv6 filter-list WORD",
9620 "Display routes conforming to the filter-list\n"
9621 "Regular expression access list name\n")
9624 DEFUN (show_ipv6_bgp_filter_list
,
9625 show_ipv6_bgp_filter_list_cmd
,
9626 "show ipv6 bgp filter-list WORD",
9630 "Display routes conforming to the filter-list\n"
9631 "Regular expression access list name\n")
9633 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9634 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9635 bgp_show_type_filter_list
);
9639 DEFUN (show_ipv6_mbgp_filter_list
,
9640 show_ipv6_mbgp_filter_list_cmd
,
9641 "show ipv6 mbgp filter-list WORD",
9645 "Display routes conforming to the filter-list\n"
9646 "Regular expression access list name\n")
9648 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9649 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9650 bgp_show_type_filter_list
);
9652 #endif /* HAVE_IPV6 */
9654 DEFUN (show_ip_bgp_dampening_info
,
9655 show_ip_bgp_dampening_params_cmd
,
9656 "show ip bgp dampening parameters",
9660 "Display detailed information about dampening\n"
9661 "Display detail of configured dampening parameters\n")
9663 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9667 DEFUN (show_ip_bgp_ipv4_dampening_parameters
,
9668 show_ip_bgp_ipv4_dampening_parameters_cmd
,
9669 "show ip bgp ipv4 (unicast|multicast) dampening parameters",
9674 "Address Family modifier\n"
9675 "Address Family modifier\n"
9676 "Display detailed information about dampening\n"
9677 "Display detail of configured dampening parameters\n")
9680 safi
= bgp_vty_safi_from_arg(argv
[0]);
9681 return bgp_show_dampening_parameters (vty
, AFI_IP
, safi
);
9685 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats
,
9686 show_ip_bgp_ipv4_dampening_flap_stats_cmd
,
9687 "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics",
9692 "Address Family modifier\n"
9693 "Address Family modifier\n"
9694 "Display detailed information about dampening\n"
9695 "Display flap statistics of routes\n")
9698 safi
= bgp_vty_safi_from_arg(argv
[0]);
9699 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9700 bgp_show_type_flap_statistics
, NULL
, 0);
9703 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths
,
9704 show_ip_bgp_ipv4_dampening_dampd_paths_cmd
,
9705 "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths",
9710 "Address Family modifier\n"
9711 "Address Family modifier\n"
9712 "Display detailed information about dampening\n"
9713 "Display paths suppressed due to dampening\n")
9716 safi
= bgp_vty_safi_from_arg(argv
[0]);
9717 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9718 bgp_show_type_dampend_paths
, NULL
, 0);
9722 bgp_show_route_map (struct vty
*vty
, const char *name
,
9723 const char *rmap_str
, afi_t afi
,
9724 safi_t safi
, enum bgp_show_type type
)
9726 struct route_map
*rmap
;
9727 struct bgp
*bgp
= NULL
;
9729 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9731 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9735 rmap
= route_map_lookup_by_name (rmap_str
);
9738 vty_out (vty
, "%% %s is not a valid route-map name%s",
9739 rmap_str
, VTY_NEWLINE
);
9743 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9746 DEFUN (show_ip_bgp_route_map
,
9747 show_ip_bgp_route_map_cmd
,
9748 "show ip bgp route-map WORD",
9752 "Display routes matching the route-map\n"
9753 "A route-map to match on\n")
9755 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9756 bgp_show_type_route_map
);
9759 DEFUN (show_ip_bgp_instance_route_map
,
9760 show_ip_bgp_instance_route_map_cmd
,
9761 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9765 BGP_INSTANCE_HELP_STR
9766 "Display routes matching the route-map\n"
9767 "A route-map to match on\n")
9769 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9770 bgp_show_type_route_map
);
9773 DEFUN (show_ip_bgp_flap_route_map
,
9774 show_ip_bgp_flap_route_map_cmd
,
9775 "show ip bgp flap-statistics route-map WORD",
9779 "Display flap statistics of routes\n"
9780 "Display routes matching the route-map\n"
9781 "A route-map to match on\n")
9783 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9784 bgp_show_type_flap_route_map
);
9787 ALIAS (show_ip_bgp_flap_route_map
,
9788 show_ip_bgp_damp_flap_route_map_cmd
,
9789 "show ip bgp dampening flap-statistics route-map WORD",
9793 "Display detailed information about dampening\n"
9794 "Display flap statistics of routes\n"
9795 "Display routes matching the route-map\n"
9796 "A route-map to match on\n")
9798 DEFUN (show_ip_bgp_ipv4_route_map
,
9799 show_ip_bgp_ipv4_route_map_cmd
,
9800 "show ip bgp ipv4 (unicast|multicast) route-map WORD",
9805 "Address Family modifier\n"
9806 "Address Family modifier\n"
9807 "Display routes matching the route-map\n"
9808 "A route-map to match on\n")
9811 safi
= bgp_vty_safi_from_arg(argv
[0]);
9812 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9813 bgp_show_type_route_map
);
9816 DEFUN (show_bgp_route_map
,
9817 show_bgp_route_map_cmd
,
9818 "show bgp route-map WORD",
9821 "Display routes matching the route-map\n"
9822 "A route-map to match on\n")
9824 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9825 bgp_show_type_route_map
);
9828 ALIAS (show_bgp_route_map
,
9829 show_bgp_ipv6_route_map_cmd
,
9830 "show bgp ipv6 route-map WORD",
9834 "Display routes matching the route-map\n"
9835 "A route-map to match on\n")
9837 DEFUN (show_ip_bgp_cidr_only
,
9838 show_ip_bgp_cidr_only_cmd
,
9839 "show ip bgp cidr-only",
9843 "Display only routes with non-natural netmasks\n")
9845 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9846 bgp_show_type_cidr_only
, NULL
, 0);
9849 DEFUN (show_ip_bgp_flap_cidr_only
,
9850 show_ip_bgp_flap_cidr_only_cmd
,
9851 "show ip bgp flap-statistics cidr-only",
9855 "Display flap statistics of routes\n"
9856 "Display only routes with non-natural netmasks\n")
9858 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9859 bgp_show_type_flap_cidr_only
, NULL
, 0);
9862 ALIAS (show_ip_bgp_flap_cidr_only
,
9863 show_ip_bgp_damp_flap_cidr_only_cmd
,
9864 "show ip bgp dampening flap-statistics cidr-only",
9868 "Display detailed information about dampening\n"
9869 "Display flap statistics of routes\n"
9870 "Display only routes with non-natural netmasks\n")
9872 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9873 show_ip_bgp_ipv4_cidr_only_cmd
,
9874 "show ip bgp ipv4 (unicast|multicast) cidr-only",
9879 "Address Family modifier\n"
9880 "Address Family modifier\n"
9881 "Display only routes with non-natural netmasks\n")
9884 safi
= bgp_vty_safi_from_arg(argv
[0]);
9885 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9886 bgp_show_type_cidr_only
, NULL
, 0);
9889 DEFUN (show_ip_bgp_community_all
,
9890 show_ip_bgp_community_all_cmd
,
9891 "show ip bgp community",
9895 "Display routes matching the communities\n")
9897 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9898 bgp_show_type_community_all
, NULL
, 0);
9901 DEFUN (show_ip_bgp_ipv4_community_all
,
9902 show_ip_bgp_ipv4_community_all_cmd
,
9903 "show ip bgp ipv4 (unicast|multicast) community",
9908 "Address Family modifier\n"
9909 "Address Family modifier\n"
9910 "Display routes matching the communities\n")
9913 safi
= bgp_vty_safi_from_arg(argv
[0]);
9914 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9915 bgp_show_type_community_all
, NULL
, 0);
9919 DEFUN (show_bgp_community_all
,
9920 show_bgp_community_all_cmd
,
9921 "show bgp community",
9924 "Display routes matching the communities\n")
9926 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9927 bgp_show_type_community_all
, NULL
, 0);
9930 ALIAS (show_bgp_community_all
,
9931 show_bgp_ipv6_community_all_cmd
,
9932 "show bgp ipv6 community",
9936 "Display routes matching the communities\n")
9939 DEFUN (show_ipv6_bgp_community_all
,
9940 show_ipv6_bgp_community_all_cmd
,
9941 "show ipv6 bgp community",
9945 "Display routes matching the communities\n")
9947 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9948 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9949 bgp_show_type_community_all
, NULL
, 0);
9953 DEFUN (show_ipv6_mbgp_community_all
,
9954 show_ipv6_mbgp_community_all_cmd
,
9955 "show ipv6 mbgp community",
9959 "Display routes matching the communities\n")
9961 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9962 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9963 bgp_show_type_community_all
, NULL
, 0);
9965 #endif /* HAVE_IPV6 */
9968 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9969 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9971 struct community
*com
;
9978 /* BGP structure lookup */
9981 bgp
= bgp_lookup_by_name (view_name
);
9984 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
9990 bgp
= bgp_get_default ();
9993 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9998 b
= buffer_new (1024);
9999 for (i
= 0; i
< argc
; i
++)
10002 buffer_putc (b
, ' ');
10005 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
10010 buffer_putstr (b
, argv
[i
]);
10012 buffer_putc (b
, '\0');
10014 str
= buffer_getstr (b
);
10017 com
= community_str2com (str
);
10018 XFREE (MTYPE_TMP
, str
);
10021 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
10022 return CMD_WARNING
;
10025 return bgp_show (vty
, bgp
, afi
, safi
,
10026 (exact
? bgp_show_type_community_exact
:
10027 bgp_show_type_community
), com
, 0);
10030 DEFUN (show_ip_bgp_community
,
10031 show_ip_bgp_community_cmd
,
10032 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
10036 "Display routes matching the communities\n"
10038 "Do not send outside local AS (well-known community)\n"
10039 "Do not advertise to any peer (well-known community)\n"
10040 "Do not export to next AS (well-known community)\n")
10042 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
10045 ALIAS (show_ip_bgp_community
,
10046 show_ip_bgp_community2_cmd
,
10047 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10051 "Display routes matching the communities\n"
10053 "Do not send outside local AS (well-known community)\n"
10054 "Do not advertise to any peer (well-known community)\n"
10055 "Do not export to next AS (well-known community)\n"
10057 "Do not send outside local AS (well-known community)\n"
10058 "Do not advertise to any peer (well-known community)\n"
10059 "Do not export to next AS (well-known community)\n")
10061 ALIAS (show_ip_bgp_community
,
10062 show_ip_bgp_community3_cmd
,
10063 "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)",
10067 "Display routes matching the communities\n"
10069 "Do not send outside local AS (well-known community)\n"
10070 "Do not advertise to any peer (well-known community)\n"
10071 "Do not export to next AS (well-known community)\n"
10073 "Do not send outside local AS (well-known community)\n"
10074 "Do not advertise to any peer (well-known community)\n"
10075 "Do not export to next AS (well-known community)\n"
10077 "Do not send outside local AS (well-known community)\n"
10078 "Do not advertise to any peer (well-known community)\n"
10079 "Do not export to next AS (well-known community)\n")
10081 ALIAS (show_ip_bgp_community
,
10082 show_ip_bgp_community4_cmd
,
10083 "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)",
10087 "Display routes matching the communities\n"
10089 "Do not send outside local AS (well-known community)\n"
10090 "Do not advertise to any peer (well-known community)\n"
10091 "Do not export to next AS (well-known community)\n"
10093 "Do not send outside local AS (well-known community)\n"
10094 "Do not advertise to any peer (well-known community)\n"
10095 "Do not export to next AS (well-known community)\n"
10097 "Do not send outside local AS (well-known community)\n"
10098 "Do not advertise to any peer (well-known community)\n"
10099 "Do not export to next AS (well-known community)\n"
10101 "Do not send outside local AS (well-known community)\n"
10102 "Do not advertise to any peer (well-known community)\n"
10103 "Do not export to next AS (well-known community)\n")
10105 DEFUN (show_ip_bgp_ipv4_community
,
10106 show_ip_bgp_ipv4_community_cmd
,
10107 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10112 "Address Family modifier\n"
10113 "Address Family modifier\n"
10114 "Display routes matching the communities\n"
10116 "Do not send outside local AS (well-known community)\n"
10117 "Do not advertise to any peer (well-known community)\n"
10118 "Do not export to next AS (well-known community)\n")
10121 safi
= bgp_vty_safi_from_arg(argv
[0]);
10122 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, safi
);
10125 ALIAS (show_ip_bgp_ipv4_community
,
10126 show_ip_bgp_ipv4_community2_cmd
,
10127 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10132 "Address Family modifier\n"
10133 "Address Family modifier\n"
10134 "Display routes matching the communities\n"
10136 "Do not send outside local AS (well-known community)\n"
10137 "Do not advertise to any peer (well-known community)\n"
10138 "Do not export to next AS (well-known community)\n"
10140 "Do not send outside local AS (well-known community)\n"
10141 "Do not advertise to any peer (well-known community)\n"
10142 "Do not export to next AS (well-known community)\n")
10144 ALIAS (show_ip_bgp_ipv4_community
,
10145 show_ip_bgp_ipv4_community3_cmd
,
10146 "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)",
10151 "Address Family modifier\n"
10152 "Address Family modifier\n"
10153 "Display routes matching the communities\n"
10155 "Do not send outside local AS (well-known community)\n"
10156 "Do not advertise to any peer (well-known community)\n"
10157 "Do not export to next AS (well-known community)\n"
10159 "Do not send outside local AS (well-known community)\n"
10160 "Do not advertise to any peer (well-known community)\n"
10161 "Do not export to next AS (well-known community)\n"
10163 "Do not send outside local AS (well-known community)\n"
10164 "Do not advertise to any peer (well-known community)\n"
10165 "Do not export to next AS (well-known community)\n")
10167 ALIAS (show_ip_bgp_ipv4_community
,
10168 show_ip_bgp_ipv4_community4_cmd
,
10169 "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)",
10174 "Address Family modifier\n"
10175 "Address Family modifier\n"
10176 "Display routes matching the communities\n"
10178 "Do not send outside local AS (well-known community)\n"
10179 "Do not advertise to any peer (well-known community)\n"
10180 "Do not export to next AS (well-known community)\n"
10182 "Do not send outside local AS (well-known community)\n"
10183 "Do not advertise to any peer (well-known community)\n"
10184 "Do not export to next AS (well-known community)\n"
10186 "Do not send outside local AS (well-known community)\n"
10187 "Do not advertise to any peer (well-known community)\n"
10188 "Do not export to next AS (well-known community)\n"
10190 "Do not send outside local AS (well-known community)\n"
10191 "Do not advertise to any peer (well-known community)\n"
10192 "Do not export to next AS (well-known community)\n")
10194 DEFUN (show_bgp_instance_afi_safi_community_all
,
10195 show_bgp_instance_afi_safi_community_all_cmd
,
10196 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community",
10199 BGP_INSTANCE_HELP_STR
10202 "Address Family modifier\n"
10203 "Address Family modifier\n"
10204 "Display routes matching the communities\n")
10210 /* BGP structure lookup. */
10211 bgp
= bgp_lookup_by_name (argv
[1]);
10214 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
10215 return CMD_WARNING
;
10218 afi
= bgp_vty_safi_from_arg(argv
[2]);
10219 safi
= bgp_vty_safi_from_arg(argv
[3]);
10220 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
10223 DEFUN (show_bgp_instance_afi_safi_community
,
10224 show_bgp_instance_afi_safi_community_cmd
,
10225 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)",
10228 BGP_INSTANCE_HELP_STR
10231 "Address family modifier\n"
10232 "Address family modifier\n"
10233 "Display routes matching the communities\n"
10235 "Do not send outside local AS (well-known community)\n"
10236 "Do not advertise to any peer (well-known community)\n"
10237 "Do not export to next AS (well-known community)\n")
10242 afi
= bgp_vty_safi_from_arg(argv
[2]);
10243 safi
= bgp_vty_safi_from_arg(argv
[3]);
10244 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
10247 ALIAS (show_bgp_instance_afi_safi_community
,
10248 show_bgp_instance_afi_safi_community2_cmd
,
10249 "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)",
10252 BGP_INSTANCE_HELP_STR
10255 "Address family modifier\n"
10256 "Address family modifier\n"
10257 "Display routes matching the communities\n"
10259 "Do not send outside local AS (well-known community)\n"
10260 "Do not advertise to any peer (well-known community)\n"
10261 "Do not export to next AS (well-known community)\n"
10263 "Do not send outside local AS (well-known community)\n"
10264 "Do not advertise to any peer (well-known community)\n"
10265 "Do not export to next AS (well-known community)\n")
10267 ALIAS (show_bgp_instance_afi_safi_community
,
10268 show_bgp_instance_afi_safi_community3_cmd
,
10269 "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)",
10272 BGP_INSTANCE_HELP_STR
10275 "Address family modifier\n"
10276 "Address family modifier\n"
10277 "Display routes matching the communities\n"
10279 "Do not send outside local AS (well-known community)\n"
10280 "Do not advertise to any peer (well-known community)\n"
10281 "Do not export to next AS (well-known community)\n"
10283 "Do not send outside local AS (well-known community)\n"
10284 "Do not advertise to any peer (well-known community)\n"
10285 "Do not export to next AS (well-known community)\n"
10287 "Do not send outside local AS (well-known community)\n"
10288 "Do not advertise to any peer (well-known community)\n"
10289 "Do not export to next AS (well-known community)\n")
10291 ALIAS (show_bgp_instance_afi_safi_community
,
10292 show_bgp_instance_afi_safi_community4_cmd
,
10293 "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)",
10296 BGP_INSTANCE_HELP_STR
10299 "Address family modifier\n"
10300 "Address family modifier\n"
10301 "Display routes matching the communities\n"
10303 "Do not send outside local AS (well-known community)\n"
10304 "Do not advertise to any peer (well-known community)\n"
10305 "Do not export to next AS (well-known community)\n"
10307 "Do not send outside local AS (well-known community)\n"
10308 "Do not advertise to any peer (well-known community)\n"
10309 "Do not export to next AS (well-known community)\n"
10311 "Do not send outside local AS (well-known community)\n"
10312 "Do not advertise to any peer (well-known community)\n"
10313 "Do not export to next AS (well-known community)\n"
10315 "Do not send outside local AS (well-known community)\n"
10316 "Do not advertise to any peer (well-known community)\n"
10317 "Do not export to next AS (well-known community)\n")
10319 DEFUN (show_ip_bgp_community_exact
,
10320 show_ip_bgp_community_exact_cmd
,
10321 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10325 "Display routes matching the communities\n"
10327 "Do not send outside local AS (well-known community)\n"
10328 "Do not advertise to any peer (well-known community)\n"
10329 "Do not export to next AS (well-known community)\n"
10330 "Exact match of the communities")
10332 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10335 ALIAS (show_ip_bgp_community_exact
,
10336 show_ip_bgp_community2_exact_cmd
,
10337 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10341 "Display routes matching the communities\n"
10343 "Do not send outside local AS (well-known community)\n"
10344 "Do not advertise to any peer (well-known community)\n"
10345 "Do not export to next AS (well-known community)\n"
10347 "Do not send outside local AS (well-known community)\n"
10348 "Do not advertise to any peer (well-known community)\n"
10349 "Do not export to next AS (well-known community)\n"
10350 "Exact match of the communities")
10352 ALIAS (show_ip_bgp_community_exact
,
10353 show_ip_bgp_community3_exact_cmd
,
10354 "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",
10358 "Display routes matching the communities\n"
10360 "Do not send outside local AS (well-known community)\n"
10361 "Do not advertise to any peer (well-known community)\n"
10362 "Do not export to next AS (well-known community)\n"
10364 "Do not send outside local AS (well-known community)\n"
10365 "Do not advertise to any peer (well-known community)\n"
10366 "Do not export to next AS (well-known community)\n"
10368 "Do not send outside local AS (well-known community)\n"
10369 "Do not advertise to any peer (well-known community)\n"
10370 "Do not export to next AS (well-known community)\n"
10371 "Exact match of the communities")
10373 ALIAS (show_ip_bgp_community_exact
,
10374 show_ip_bgp_community4_exact_cmd
,
10375 "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",
10379 "Display routes matching the communities\n"
10381 "Do not send outside local AS (well-known community)\n"
10382 "Do not advertise to any peer (well-known community)\n"
10383 "Do not export to next AS (well-known community)\n"
10385 "Do not send outside local AS (well-known community)\n"
10386 "Do not advertise to any peer (well-known community)\n"
10387 "Do not export to next AS (well-known community)\n"
10389 "Do not send outside local AS (well-known community)\n"
10390 "Do not advertise to any peer (well-known community)\n"
10391 "Do not export to next AS (well-known community)\n"
10393 "Do not send outside local AS (well-known community)\n"
10394 "Do not advertise to any peer (well-known community)\n"
10395 "Do not export to next AS (well-known community)\n"
10396 "Exact match of the communities")
10398 DEFUN (show_ip_bgp_ipv4_community_exact
,
10399 show_ip_bgp_ipv4_community_exact_cmd
,
10400 "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10405 "Address Family modifier\n"
10406 "Address Family modifier\n"
10407 "Display routes matching the communities\n"
10409 "Do not send outside local AS (well-known community)\n"
10410 "Do not advertise to any peer (well-known community)\n"
10411 "Do not export to next AS (well-known community)\n"
10412 "Exact match of the communities")
10415 safi
= bgp_vty_safi_from_arg(argv
[0]);
10416 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, safi
);
10419 ALIAS (show_ip_bgp_ipv4_community_exact
,
10420 show_ip_bgp_ipv4_community2_exact_cmd
,
10421 "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",
10426 "Address Family modifier\n"
10427 "Address Family modifier\n"
10428 "Display routes matching the communities\n"
10430 "Do not send outside local AS (well-known community)\n"
10431 "Do not advertise to any peer (well-known community)\n"
10432 "Do not export to next AS (well-known community)\n"
10434 "Do not send outside local AS (well-known community)\n"
10435 "Do not advertise to any peer (well-known community)\n"
10436 "Do not export to next AS (well-known community)\n"
10437 "Exact match of the communities")
10439 ALIAS (show_ip_bgp_ipv4_community_exact
,
10440 show_ip_bgp_ipv4_community3_exact_cmd
,
10441 "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",
10446 "Address Family modifier\n"
10447 "Address Family modifier\n"
10448 "Display routes matching the communities\n"
10450 "Do not send outside local AS (well-known community)\n"
10451 "Do not advertise to any peer (well-known community)\n"
10452 "Do not export to next AS (well-known community)\n"
10454 "Do not send outside local AS (well-known community)\n"
10455 "Do not advertise to any peer (well-known community)\n"
10456 "Do not export to next AS (well-known community)\n"
10458 "Do not send outside local AS (well-known community)\n"
10459 "Do not advertise to any peer (well-known community)\n"
10460 "Do not export to next AS (well-known community)\n"
10461 "Exact match of the communities")
10463 ALIAS (show_ip_bgp_ipv4_community_exact
,
10464 show_ip_bgp_ipv4_community4_exact_cmd
,
10465 "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",
10470 "Address Family modifier\n"
10471 "Address Family modifier\n"
10472 "Display routes matching the communities\n"
10474 "Do not send outside local AS (well-known community)\n"
10475 "Do not advertise to any peer (well-known community)\n"
10476 "Do not export to next AS (well-known community)\n"
10478 "Do not send outside local AS (well-known community)\n"
10479 "Do not advertise to any peer (well-known community)\n"
10480 "Do not export to next AS (well-known community)\n"
10482 "Do not send outside local AS (well-known community)\n"
10483 "Do not advertise to any peer (well-known community)\n"
10484 "Do not export to next AS (well-known community)\n"
10486 "Do not send outside local AS (well-known community)\n"
10487 "Do not advertise to any peer (well-known community)\n"
10488 "Do not export to next AS (well-known community)\n"
10489 "Exact match of the communities")
10492 DEFUN (show_bgp_community
,
10493 show_bgp_community_cmd
,
10494 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10497 "Display routes matching the communities\n"
10499 "Do not send outside local AS (well-known community)\n"
10500 "Do not advertise to any peer (well-known community)\n"
10501 "Do not export to next AS (well-known community)\n")
10503 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10506 ALIAS (show_bgp_community
,
10507 show_bgp_ipv6_community_cmd
,
10508 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10512 "Display routes matching the communities\n"
10514 "Do not send outside local AS (well-known community)\n"
10515 "Do not advertise to any peer (well-known community)\n"
10516 "Do not export to next AS (well-known community)\n")
10518 ALIAS (show_bgp_community
,
10519 show_bgp_community2_cmd
,
10520 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (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 "Do not send outside local AS (well-known community)\n"
10530 "Do not advertise to any peer (well-known community)\n"
10531 "Do not export to next AS (well-known community)\n")
10533 ALIAS (show_bgp_community
,
10534 show_bgp_ipv6_community2_cmd
,
10535 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10539 "Display routes matching the communities\n"
10541 "Do not send outside local AS (well-known community)\n"
10542 "Do not advertise to any peer (well-known community)\n"
10543 "Do not export to next AS (well-known community)\n"
10545 "Do not send outside local AS (well-known community)\n"
10546 "Do not advertise to any peer (well-known community)\n"
10547 "Do not export to next AS (well-known community)\n")
10549 ALIAS (show_bgp_community
,
10550 show_bgp_community3_cmd
,
10551 "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)",
10554 "Display routes matching the communities\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 "Do not send outside local AS (well-known community)\n"
10561 "Do not advertise to any peer (well-known community)\n"
10562 "Do not export to next AS (well-known community)\n"
10564 "Do not send outside local AS (well-known community)\n"
10565 "Do not advertise to any peer (well-known community)\n"
10566 "Do not export to next AS (well-known community)\n")
10568 ALIAS (show_bgp_community
,
10569 show_bgp_ipv6_community3_cmd
,
10570 "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)",
10574 "Display routes matching the communities\n"
10576 "Do not send outside local AS (well-known community)\n"
10577 "Do not advertise to any peer (well-known community)\n"
10578 "Do not export to next AS (well-known community)\n"
10580 "Do not send outside local AS (well-known community)\n"
10581 "Do not advertise to any peer (well-known community)\n"
10582 "Do not export to next AS (well-known community)\n"
10584 "Do not send outside local AS (well-known community)\n"
10585 "Do not advertise to any peer (well-known community)\n"
10586 "Do not export to next AS (well-known community)\n")
10588 ALIAS (show_bgp_community
,
10589 show_bgp_community4_cmd
,
10590 "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)",
10593 "Display routes matching the communities\n"
10595 "Do not send outside local AS (well-known community)\n"
10596 "Do not advertise to any peer (well-known community)\n"
10597 "Do not export to next AS (well-known community)\n"
10599 "Do not send outside local AS (well-known community)\n"
10600 "Do not advertise to any peer (well-known community)\n"
10601 "Do not export to next AS (well-known community)\n"
10603 "Do not send outside local AS (well-known community)\n"
10604 "Do not advertise to any peer (well-known community)\n"
10605 "Do not export to next AS (well-known community)\n"
10607 "Do not send outside local AS (well-known community)\n"
10608 "Do not advertise to any peer (well-known community)\n"
10609 "Do not export to next AS (well-known community)\n")
10611 ALIAS (show_bgp_community
,
10612 show_bgp_ipv6_community4_cmd
,
10613 "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)",
10617 "Display routes matching the communities\n"
10619 "Do not send outside local AS (well-known community)\n"
10620 "Do not advertise to any peer (well-known community)\n"
10621 "Do not export to next AS (well-known community)\n"
10623 "Do not send outside local AS (well-known community)\n"
10624 "Do not advertise to any peer (well-known community)\n"
10625 "Do not export to next AS (well-known community)\n"
10627 "Do not send outside local AS (well-known community)\n"
10628 "Do not advertise to any peer (well-known community)\n"
10629 "Do not export to next AS (well-known community)\n"
10631 "Do not send outside local AS (well-known community)\n"
10632 "Do not advertise to any peer (well-known community)\n"
10633 "Do not export to next AS (well-known community)\n")
10636 DEFUN (show_ipv6_bgp_community
,
10637 show_ipv6_bgp_community_cmd
,
10638 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10642 "Display routes matching the communities\n"
10644 "Do not send outside local AS (well-known community)\n"
10645 "Do not advertise to any peer (well-known community)\n"
10646 "Do not export to next AS (well-known community)\n")
10648 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10649 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10653 ALIAS (show_ipv6_bgp_community
,
10654 show_ipv6_bgp_community2_cmd
,
10655 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10659 "Display routes matching the communities\n"
10661 "Do not send outside local AS (well-known community)\n"
10662 "Do not advertise to any peer (well-known community)\n"
10663 "Do not export to next AS (well-known community)\n"
10665 "Do not send outside local AS (well-known community)\n"
10666 "Do not advertise to any peer (well-known community)\n"
10667 "Do not export to next AS (well-known community)\n")
10670 ALIAS (show_ipv6_bgp_community
,
10671 show_ipv6_bgp_community3_cmd
,
10672 "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)",
10676 "Display routes matching the communities\n"
10678 "Do not send outside local AS (well-known community)\n"
10679 "Do not advertise to any peer (well-known community)\n"
10680 "Do not export to next AS (well-known community)\n"
10682 "Do not send outside local AS (well-known community)\n"
10683 "Do not advertise to any peer (well-known community)\n"
10684 "Do not export to next AS (well-known community)\n"
10686 "Do not send outside local AS (well-known community)\n"
10687 "Do not advertise to any peer (well-known community)\n"
10688 "Do not export to next AS (well-known community)\n")
10691 ALIAS (show_ipv6_bgp_community
,
10692 show_ipv6_bgp_community4_cmd
,
10693 "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)",
10697 "Display routes matching the communities\n"
10699 "Do not send outside local AS (well-known community)\n"
10700 "Do not advertise to any peer (well-known community)\n"
10701 "Do not export to next AS (well-known community)\n"
10703 "Do not send outside local AS (well-known community)\n"
10704 "Do not advertise to any peer (well-known community)\n"
10705 "Do not export to next AS (well-known community)\n"
10707 "Do not send outside local AS (well-known community)\n"
10708 "Do not advertise to any peer (well-known community)\n"
10709 "Do not export to next AS (well-known community)\n"
10711 "Do not send outside local AS (well-known community)\n"
10712 "Do not advertise to any peer (well-known community)\n"
10713 "Do not export to next AS (well-known community)\n")
10715 DEFUN (show_bgp_community_exact
,
10716 show_bgp_community_exact_cmd
,
10717 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10720 "Display routes matching the communities\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"
10725 "Exact match of the communities")
10727 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10730 ALIAS (show_bgp_community_exact
,
10731 show_bgp_ipv6_community_exact_cmd
,
10732 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10736 "Display routes matching the communities\n"
10738 "Do not send outside local AS (well-known community)\n"
10739 "Do not advertise to any peer (well-known community)\n"
10740 "Do not export to next AS (well-known community)\n"
10741 "Exact match of the communities")
10743 ALIAS (show_bgp_community_exact
,
10744 show_bgp_community2_exact_cmd
,
10745 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10748 "Display routes matching the communities\n"
10750 "Do not send outside local AS (well-known community)\n"
10751 "Do not advertise to any peer (well-known community)\n"
10752 "Do not export to next AS (well-known community)\n"
10754 "Do not send outside local AS (well-known community)\n"
10755 "Do not advertise to any peer (well-known community)\n"
10756 "Do not export to next AS (well-known community)\n"
10757 "Exact match of the communities")
10759 ALIAS (show_bgp_community_exact
,
10760 show_bgp_ipv6_community2_exact_cmd
,
10761 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10765 "Display routes matching the communities\n"
10767 "Do not send outside local AS (well-known community)\n"
10768 "Do not advertise to any peer (well-known community)\n"
10769 "Do not export to next AS (well-known community)\n"
10771 "Do not send outside local AS (well-known community)\n"
10772 "Do not advertise to any peer (well-known community)\n"
10773 "Do not export to next AS (well-known community)\n"
10774 "Exact match of the communities")
10776 ALIAS (show_bgp_community_exact
,
10777 show_bgp_community3_exact_cmd
,
10778 "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",
10781 "Display routes matching the communities\n"
10783 "Do not send outside local AS (well-known community)\n"
10784 "Do not advertise to any peer (well-known community)\n"
10785 "Do not export to next AS (well-known community)\n"
10787 "Do not send outside local AS (well-known community)\n"
10788 "Do not advertise to any peer (well-known community)\n"
10789 "Do not export to next AS (well-known community)\n"
10791 "Do not send outside local AS (well-known community)\n"
10792 "Do not advertise to any peer (well-known community)\n"
10793 "Do not export to next AS (well-known community)\n"
10794 "Exact match of the communities")
10796 ALIAS (show_bgp_community_exact
,
10797 show_bgp_ipv6_community3_exact_cmd
,
10798 "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",
10802 "Display routes matching the communities\n"
10804 "Do not send outside local AS (well-known community)\n"
10805 "Do not advertise to any peer (well-known community)\n"
10806 "Do not export to next AS (well-known community)\n"
10808 "Do not send outside local AS (well-known community)\n"
10809 "Do not advertise to any peer (well-known community)\n"
10810 "Do not export to next AS (well-known community)\n"
10812 "Do not send outside local AS (well-known community)\n"
10813 "Do not advertise to any peer (well-known community)\n"
10814 "Do not export to next AS (well-known community)\n"
10815 "Exact match of the communities")
10817 ALIAS (show_bgp_community_exact
,
10818 show_bgp_community4_exact_cmd
,
10819 "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",
10822 "Display routes matching the communities\n"
10824 "Do not send outside local AS (well-known community)\n"
10825 "Do not advertise to any peer (well-known community)\n"
10826 "Do not export to next AS (well-known community)\n"
10828 "Do not send outside local AS (well-known community)\n"
10829 "Do not advertise to any peer (well-known community)\n"
10830 "Do not export to next AS (well-known community)\n"
10832 "Do not send outside local AS (well-known community)\n"
10833 "Do not advertise to any peer (well-known community)\n"
10834 "Do not export to next AS (well-known community)\n"
10836 "Do not send outside local AS (well-known community)\n"
10837 "Do not advertise to any peer (well-known community)\n"
10838 "Do not export to next AS (well-known community)\n"
10839 "Exact match of the communities")
10841 ALIAS (show_bgp_community_exact
,
10842 show_bgp_ipv6_community4_exact_cmd
,
10843 "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",
10847 "Display routes matching the communities\n"
10849 "Do not send outside local AS (well-known community)\n"
10850 "Do not advertise to any peer (well-known community)\n"
10851 "Do not export to next AS (well-known community)\n"
10853 "Do not send outside local AS (well-known community)\n"
10854 "Do not advertise to any peer (well-known community)\n"
10855 "Do not export to next AS (well-known community)\n"
10857 "Do not send outside local AS (well-known community)\n"
10858 "Do not advertise to any peer (well-known community)\n"
10859 "Do not export to next AS (well-known community)\n"
10861 "Do not send outside local AS (well-known community)\n"
10862 "Do not advertise to any peer (well-known community)\n"
10863 "Do not export to next AS (well-known community)\n"
10864 "Exact match of the communities")
10867 DEFUN (show_ipv6_bgp_community_exact
,
10868 show_ipv6_bgp_community_exact_cmd
,
10869 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10873 "Display routes matching the communities\n"
10875 "Do not send outside local AS (well-known community)\n"
10876 "Do not advertise to any peer (well-known community)\n"
10877 "Do not export to next AS (well-known community)\n"
10878 "Exact match of the communities")
10880 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10881 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10885 ALIAS (show_ipv6_bgp_community_exact
,
10886 show_ipv6_bgp_community2_exact_cmd
,
10887 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10891 "Display routes matching the communities\n"
10893 "Do not send outside local AS (well-known community)\n"
10894 "Do not advertise to any peer (well-known community)\n"
10895 "Do not export to next AS (well-known community)\n"
10897 "Do not send outside local AS (well-known community)\n"
10898 "Do not advertise to any peer (well-known community)\n"
10899 "Do not export to next AS (well-known community)\n"
10900 "Exact match of the communities")
10903 ALIAS (show_ipv6_bgp_community_exact
,
10904 show_ipv6_bgp_community3_exact_cmd
,
10905 "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",
10909 "Display routes matching the communities\n"
10911 "Do not send outside local AS (well-known community)\n"
10912 "Do not advertise to any peer (well-known community)\n"
10913 "Do not export to next AS (well-known community)\n"
10915 "Do not send outside local AS (well-known community)\n"
10916 "Do not advertise to any peer (well-known community)\n"
10917 "Do not export to next AS (well-known community)\n"
10919 "Do not send outside local AS (well-known community)\n"
10920 "Do not advertise to any peer (well-known community)\n"
10921 "Do not export to next AS (well-known community)\n"
10922 "Exact match of the communities")
10925 ALIAS (show_ipv6_bgp_community_exact
,
10926 show_ipv6_bgp_community4_exact_cmd
,
10927 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10931 "Display routes matching the communities\n"
10933 "Do not send outside local AS (well-known community)\n"
10934 "Do not advertise to any peer (well-known community)\n"
10935 "Do not export to next AS (well-known community)\n"
10937 "Do not send outside local AS (well-known community)\n"
10938 "Do not advertise to any peer (well-known community)\n"
10939 "Do not export to next AS (well-known community)\n"
10941 "Do not send outside local AS (well-known community)\n"
10942 "Do not advertise to any peer (well-known community)\n"
10943 "Do not export to next AS (well-known community)\n"
10945 "Do not send outside local AS (well-known community)\n"
10946 "Do not advertise to any peer (well-known community)\n"
10947 "Do not export to next AS (well-known community)\n"
10948 "Exact match of the communities")
10951 DEFUN (show_ipv6_mbgp_community
,
10952 show_ipv6_mbgp_community_cmd
,
10953 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10957 "Display routes matching the communities\n"
10959 "Do not send outside local AS (well-known community)\n"
10960 "Do not advertise to any peer (well-known community)\n"
10961 "Do not export to next AS (well-known community)\n")
10963 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10964 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10968 ALIAS (show_ipv6_mbgp_community
,
10969 show_ipv6_mbgp_community2_cmd
,
10970 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10974 "Display routes matching the communities\n"
10976 "Do not send outside local AS (well-known community)\n"
10977 "Do not advertise to any peer (well-known community)\n"
10978 "Do not export to next AS (well-known community)\n"
10980 "Do not send outside local AS (well-known community)\n"
10981 "Do not advertise to any peer (well-known community)\n"
10982 "Do not export to next AS (well-known community)\n")
10985 ALIAS (show_ipv6_mbgp_community
,
10986 show_ipv6_mbgp_community3_cmd
,
10987 "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)",
10991 "Display routes matching the communities\n"
10993 "Do not send outside local AS (well-known community)\n"
10994 "Do not advertise to any peer (well-known community)\n"
10995 "Do not export to next AS (well-known community)\n"
10997 "Do not send outside local AS (well-known community)\n"
10998 "Do not advertise to any peer (well-known community)\n"
10999 "Do not export to next AS (well-known community)\n"
11001 "Do not send outside local AS (well-known community)\n"
11002 "Do not advertise to any peer (well-known community)\n"
11003 "Do not export to next AS (well-known community)\n")
11006 ALIAS (show_ipv6_mbgp_community
,
11007 show_ipv6_mbgp_community4_cmd
,
11008 "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)",
11012 "Display routes matching the communities\n"
11014 "Do not send outside local AS (well-known community)\n"
11015 "Do not advertise to any peer (well-known community)\n"
11016 "Do not export to next AS (well-known community)\n"
11018 "Do not send outside local AS (well-known community)\n"
11019 "Do not advertise to any peer (well-known community)\n"
11020 "Do not export to next AS (well-known community)\n"
11022 "Do not send outside local AS (well-known community)\n"
11023 "Do not advertise to any peer (well-known community)\n"
11024 "Do not export to next AS (well-known community)\n"
11026 "Do not send outside local AS (well-known community)\n"
11027 "Do not advertise to any peer (well-known community)\n"
11028 "Do not export to next AS (well-known community)\n")
11031 DEFUN (show_ipv6_mbgp_community_exact
,
11032 show_ipv6_mbgp_community_exact_cmd
,
11033 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
11037 "Display routes matching the communities\n"
11039 "Do not send outside local AS (well-known community)\n"
11040 "Do not advertise to any peer (well-known community)\n"
11041 "Do not export to next AS (well-known community)\n"
11042 "Exact match of the communities")
11044 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11045 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
11049 ALIAS (show_ipv6_mbgp_community_exact
,
11050 show_ipv6_mbgp_community2_exact_cmd
,
11051 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11055 "Display routes matching the communities\n"
11057 "Do not send outside local AS (well-known community)\n"
11058 "Do not advertise to any peer (well-known community)\n"
11059 "Do not export to next AS (well-known community)\n"
11061 "Do not send outside local AS (well-known community)\n"
11062 "Do not advertise to any peer (well-known community)\n"
11063 "Do not export to next AS (well-known community)\n"
11064 "Exact match of the communities")
11067 ALIAS (show_ipv6_mbgp_community_exact
,
11068 show_ipv6_mbgp_community3_exact_cmd
,
11069 "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",
11073 "Display routes matching the communities\n"
11075 "Do not send outside local AS (well-known community)\n"
11076 "Do not advertise to any peer (well-known community)\n"
11077 "Do not export to next AS (well-known community)\n"
11079 "Do not send outside local AS (well-known community)\n"
11080 "Do not advertise to any peer (well-known community)\n"
11081 "Do not export to next AS (well-known community)\n"
11083 "Do not send outside local AS (well-known community)\n"
11084 "Do not advertise to any peer (well-known community)\n"
11085 "Do not export to next AS (well-known community)\n"
11086 "Exact match of the communities")
11089 ALIAS (show_ipv6_mbgp_community_exact
,
11090 show_ipv6_mbgp_community4_exact_cmd
,
11091 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11095 "Display routes matching the communities\n"
11097 "Do not send outside local AS (well-known community)\n"
11098 "Do not advertise to any peer (well-known community)\n"
11099 "Do not export to next AS (well-known community)\n"
11101 "Do not send outside local AS (well-known community)\n"
11102 "Do not advertise to any peer (well-known community)\n"
11103 "Do not export to next AS (well-known community)\n"
11105 "Do not send outside local AS (well-known community)\n"
11106 "Do not advertise to any peer (well-known community)\n"
11107 "Do not export to next AS (well-known community)\n"
11109 "Do not send outside local AS (well-known community)\n"
11110 "Do not advertise to any peer (well-known community)\n"
11111 "Do not export to next AS (well-known community)\n"
11112 "Exact match of the communities")
11113 #endif /* HAVE_IPV6 */
11116 bgp_show_community_list (struct vty
*vty
, const char *name
,
11117 const char *com
, int exact
,
11118 afi_t afi
, safi_t safi
)
11120 struct community_list
*list
;
11121 struct bgp
*bgp
= NULL
;
11123 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11125 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11126 return CMD_WARNING
;
11129 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
11132 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
11134 return CMD_WARNING
;
11137 return bgp_show (vty
, bgp
, afi
, safi
,
11138 (exact
? bgp_show_type_community_list_exact
:
11139 bgp_show_type_community_list
), list
, 0);
11142 DEFUN (show_ip_bgp_community_list
,
11143 show_ip_bgp_community_list_cmd
,
11144 "show ip bgp community-list (<1-500>|WORD)",
11148 "Display routes matching the community-list\n"
11149 "community-list number\n"
11150 "community-list name\n")
11152 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
11155 DEFUN (show_ip_bgp_instance_community_list
,
11156 show_ip_bgp_instance_community_list_cmd
,
11157 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
11161 BGP_INSTANCE_HELP_STR
11162 "Display routes matching the community-list\n"
11163 "community-list number\n"
11164 "community-list name\n")
11166 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
11169 DEFUN (show_ip_bgp_ipv4_community_list
,
11170 show_ip_bgp_ipv4_community_list_cmd
,
11171 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)",
11176 "Address Family modifier\n"
11177 "Address Family modifier\n"
11178 "Display routes matching the community-list\n"
11179 "community-list number\n"
11180 "community-list name\n")
11183 safi
= bgp_vty_safi_from_arg(argv
[0]);
11184 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, safi
);
11187 DEFUN (show_ip_bgp_community_list_exact
,
11188 show_ip_bgp_community_list_exact_cmd
,
11189 "show ip bgp community-list (<1-500>|WORD) exact-match",
11193 "Display routes matching the community-list\n"
11194 "community-list number\n"
11195 "community-list name\n"
11196 "Exact match of the communities\n")
11198 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
11201 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
11202 show_ip_bgp_ipv4_community_list_exact_cmd
,
11203 "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match",
11208 "Address Family modifier\n"
11209 "Address Family modifier\n"
11210 "Display routes matching the community-list\n"
11211 "community-list number\n"
11212 "community-list name\n"
11213 "Exact match of the communities\n")
11216 safi
= bgp_vty_safi_from_arg(argv
[0]);
11217 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, safi
);
11221 DEFUN (show_bgp_community_list
,
11222 show_bgp_community_list_cmd
,
11223 "show bgp community-list (<1-500>|WORD)",
11226 "Display routes matching the community-list\n"
11227 "community-list number\n"
11228 "community-list name\n")
11230 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11233 ALIAS (show_bgp_community_list
,
11234 show_bgp_ipv6_community_list_cmd
,
11235 "show bgp ipv6 community-list (<1-500>|WORD)",
11239 "Display routes matching the community-list\n"
11240 "community-list number\n"
11241 "community-list name\n")
11244 DEFUN (show_ipv6_bgp_community_list
,
11245 show_ipv6_bgp_community_list_cmd
,
11246 "show ipv6 bgp community-list WORD",
11250 "Display routes matching the community-list\n"
11251 "community-list name\n")
11253 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11254 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11258 DEFUN (show_ipv6_mbgp_community_list
,
11259 show_ipv6_mbgp_community_list_cmd
,
11260 "show ipv6 mbgp community-list WORD",
11264 "Display routes matching the community-list\n"
11265 "community-list name\n")
11267 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11268 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
11271 DEFUN (show_bgp_community_list_exact
,
11272 show_bgp_community_list_exact_cmd
,
11273 "show bgp community-list (<1-500>|WORD) exact-match",
11276 "Display routes matching the community-list\n"
11277 "community-list number\n"
11278 "community-list name\n"
11279 "Exact match of the communities\n")
11281 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11284 ALIAS (show_bgp_community_list_exact
,
11285 show_bgp_ipv6_community_list_exact_cmd
,
11286 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11290 "Display routes matching the community-list\n"
11291 "community-list number\n"
11292 "community-list name\n"
11293 "Exact match of the communities\n")
11296 DEFUN (show_ipv6_bgp_community_list_exact
,
11297 show_ipv6_bgp_community_list_exact_cmd
,
11298 "show ipv6 bgp community-list WORD exact-match",
11302 "Display routes matching the community-list\n"
11303 "community-list name\n"
11304 "Exact match of the communities\n")
11306 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11307 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11311 DEFUN (show_ipv6_mbgp_community_list_exact
,
11312 show_ipv6_mbgp_community_list_exact_cmd
,
11313 "show ipv6 mbgp community-list WORD exact-match",
11317 "Display routes matching the community-list\n"
11318 "community-list name\n"
11319 "Exact match of the communities\n")
11321 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11322 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
11324 #endif /* HAVE_IPV6 */
11327 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11328 const char *prefix
, afi_t afi
,
11329 safi_t safi
, enum bgp_show_type type
)
11333 struct bgp
*bgp
= NULL
;
11335 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11337 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11338 return CMD_WARNING
;
11343 ret
= str2prefix (prefix
, p
);
11346 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11347 return CMD_WARNING
;
11350 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11355 DEFUN (show_ip_bgp_prefix_longer
,
11356 show_ip_bgp_prefix_longer_cmd
,
11357 "show ip bgp A.B.C.D/M longer-prefixes",
11361 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11362 "Display route and more specific routes\n")
11364 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11365 bgp_show_type_prefix_longer
);
11368 DEFUN (show_ip_bgp_instance_prefix_longer
,
11369 show_ip_bgp_instance_prefix_longer_cmd
,
11370 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11374 BGP_INSTANCE_HELP_STR
11375 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11376 "Display route and more specific routes\n")
11378 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
11379 bgp_show_type_prefix_longer
);
11382 DEFUN (show_ip_bgp_flap_prefix_longer
,
11383 show_ip_bgp_flap_prefix_longer_cmd
,
11384 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11388 "Display flap statistics of routes\n"
11389 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11390 "Display route and more specific routes\n")
11392 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11393 bgp_show_type_flap_prefix_longer
);
11396 ALIAS (show_ip_bgp_flap_prefix_longer
,
11397 show_ip_bgp_damp_flap_prefix_longer_cmd
,
11398 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11402 "Display detailed information about dampening\n"
11403 "Display flap statistics of routes\n"
11404 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11405 "Display route and more specific routes\n")
11407 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11408 show_ip_bgp_ipv4_prefix_longer_cmd
,
11409 "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes",
11414 "Address Family modifier\n"
11415 "Address Family modifier\n"
11416 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11417 "Display route and more specific routes\n")
11420 safi
= bgp_vty_safi_from_arg(argv
[0]);
11421 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, safi
,
11422 bgp_show_type_prefix_longer
);
11425 DEFUN (show_ip_bgp_flap_address
,
11426 show_ip_bgp_flap_address_cmd
,
11427 "show ip bgp flap-statistics A.B.C.D",
11431 "Display flap statistics of routes\n"
11432 "Network in the BGP routing table to display\n")
11434 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11435 bgp_show_type_flap_address
);
11438 ALIAS (show_ip_bgp_flap_address
,
11439 show_ip_bgp_damp_flap_address_cmd
,
11440 "show ip bgp dampening flap-statistics A.B.C.D",
11444 "Display detailed information about dampening\n"
11445 "Display flap statistics of routes\n"
11446 "Network in the BGP routing table to display\n")
11448 DEFUN (show_ip_bgp_flap_prefix
,
11449 show_ip_bgp_flap_prefix_cmd
,
11450 "show ip bgp flap-statistics A.B.C.D/M",
11454 "Display flap statistics of routes\n"
11455 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11457 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11458 bgp_show_type_flap_prefix
);
11461 ALIAS (show_ip_bgp_flap_prefix
,
11462 show_ip_bgp_damp_flap_prefix_cmd
,
11463 "show ip bgp dampening flap-statistics A.B.C.D/M",
11467 "Display detailed information about dampening\n"
11468 "Display flap statistics of routes\n"
11469 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11472 DEFUN (show_bgp_prefix_longer
,
11473 show_bgp_prefix_longer_cmd
,
11474 "show bgp X:X::X:X/M longer-prefixes",
11477 "IPv6 prefix <network>/<length>\n"
11478 "Display route and more specific routes\n")
11480 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11481 bgp_show_type_prefix_longer
);
11484 ALIAS (show_bgp_prefix_longer
,
11485 show_bgp_ipv6_prefix_longer_cmd
,
11486 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11490 "IPv6 prefix <network>/<length>\n"
11491 "Display route and more specific routes\n")
11494 DEFUN (show_ipv6_bgp_prefix_longer
,
11495 show_ipv6_bgp_prefix_longer_cmd
,
11496 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11500 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11501 "Display route and more specific routes\n")
11503 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11504 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11505 bgp_show_type_prefix_longer
);
11509 DEFUN (show_ipv6_mbgp_prefix_longer
,
11510 show_ipv6_mbgp_prefix_longer_cmd
,
11511 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11515 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11516 "Display route and more specific routes\n")
11518 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11519 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11520 bgp_show_type_prefix_longer
);
11522 #endif /* HAVE_IPV6 */
11524 static struct peer
*
11525 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11526 const char *ip_str
, u_char use_json
)
11531 union sockunion su
;
11533 /* BGP structure lookup. */
11536 bgp
= bgp_lookup_by_name (view_name
);
11541 json_object
*json_no
= NULL
;
11542 json_no
= json_object_new_object();
11543 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11544 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11545 json_object_free(json_no
);
11548 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11554 bgp
= bgp_get_default ();
11559 json_object
*json_no
= NULL
;
11560 json_no
= json_object_new_object();
11561 json_object_string_add(json_no
, "warning", "No BGP process configured");
11562 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11563 json_object_free(json_no
);
11566 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11571 /* Get peer sockunion. */
11572 ret
= str2sockunion (ip_str
, &su
);
11575 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11578 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11584 json_object
*json_no
= NULL
;
11585 json_no
= json_object_new_object();
11586 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11587 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11588 json_object_free(json_no
);
11591 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11598 /* Peer structure lookup. */
11599 peer
= peer_lookup (bgp
, &su
);
11604 json_object
*json_no
= NULL
;
11605 json_no
= json_object_new_object();
11606 json_object_string_add(json_no
, "warning","No such neighbor");
11607 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11608 json_object_free(json_no
);
11611 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11620 BGP_STATS_MAXBITLEN
= 0,
11622 BGP_STATS_PREFIXES
,
11624 BGP_STATS_UNAGGREGATEABLE
,
11625 BGP_STATS_MAX_AGGREGATEABLE
,
11626 BGP_STATS_AGGREGATES
,
11628 BGP_STATS_ASPATH_COUNT
,
11629 BGP_STATS_ASPATH_MAXHOPS
,
11630 BGP_STATS_ASPATH_TOTHOPS
,
11631 BGP_STATS_ASPATH_MAXSIZE
,
11632 BGP_STATS_ASPATH_TOTSIZE
,
11633 BGP_STATS_ASN_HIGHEST
,
11637 static const char *table_stats_strs
[] =
11639 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11640 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11641 [BGP_STATS_RIB
] = "Total Advertisements",
11642 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11643 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11644 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11645 [BGP_STATS_SPACE
] = "Address space advertised",
11646 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11647 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11648 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11649 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11650 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11651 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11652 [BGP_STATS_MAX
] = NULL
,
11655 struct bgp_table_stats
11657 struct bgp_table
*table
;
11658 unsigned long long counts
[BGP_STATS_MAX
];
11662 #define TALLY_SIGFIG 100000
11663 static unsigned long
11664 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11666 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11667 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11668 unsigned long ret
= newtot
/ count
;
11670 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11678 bgp_table_stats_walker (struct thread
*t
)
11680 struct bgp_node
*rn
;
11681 struct bgp_node
*top
;
11682 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11683 unsigned int space
= 0;
11685 if (!(top
= bgp_table_top (ts
->table
)))
11688 switch (top
->p
.family
)
11691 space
= IPV4_MAX_BITLEN
;
11694 space
= IPV6_MAX_BITLEN
;
11698 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11700 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11702 struct bgp_info
*ri
;
11703 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11704 unsigned int rinum
= 0;
11712 ts
->counts
[BGP_STATS_PREFIXES
]++;
11713 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11716 ts
->counts
[BGP_STATS_AVGPLEN
]
11717 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11718 ts
->counts
[BGP_STATS_AVGPLEN
],
11722 /* check if the prefix is included by any other announcements */
11723 while (prn
&& !prn
->info
)
11724 prn
= bgp_node_parent_nolock (prn
);
11726 if (prn
== NULL
|| prn
== top
)
11728 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11729 /* announced address space */
11731 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11733 else if (prn
->info
)
11734 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11736 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11739 ts
->counts
[BGP_STATS_RIB
]++;
11742 (CHECK_FLAG (ri
->attr
->flag
,
11743 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11744 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11746 /* as-path stats */
11747 if (ri
->attr
&& ri
->attr
->aspath
)
11749 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11750 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11751 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11753 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11755 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11756 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11758 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11759 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11761 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11762 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11764 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11765 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11766 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11768 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11769 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11770 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11773 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11774 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11782 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11784 struct bgp_table_stats ts
;
11787 if (!bgp
->rib
[afi
][safi
])
11789 vty_out (vty
, "%% No RIB exists for the AFI(%d)/SAFI(%d)%s",
11790 afi
, safi
, VTY_NEWLINE
);
11791 return CMD_WARNING
;
11794 memset (&ts
, 0, sizeof (ts
));
11795 ts
.table
= bgp
->rib
[afi
][safi
];
11796 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11798 vty_out (vty
, "BGP %s RIB statistics%s%s",
11799 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11801 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11803 if (!table_stats_strs
[i
])
11809 case BGP_STATS_ASPATH_AVGHOPS
:
11810 case BGP_STATS_ASPATH_AVGSIZE
:
11811 case BGP_STATS_AVGPLEN
:
11812 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11813 vty_out (vty
, "%12.2f",
11814 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11817 case BGP_STATS_ASPATH_TOTHOPS
:
11818 case BGP_STATS_ASPATH_TOTSIZE
:
11819 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11820 vty_out (vty
, "%12.2f",
11822 (float)ts
.counts
[i
] /
11823 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11826 case BGP_STATS_TOTPLEN
:
11827 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11828 vty_out (vty
, "%12.2f",
11830 (float)ts
.counts
[i
] /
11831 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11834 case BGP_STATS_SPACE
:
11835 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11836 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11837 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11839 vty_out (vty
, "%30s: ", "%% announced ");
11840 vty_out (vty
, "%12.2f%s",
11841 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11842 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11844 vty_out (vty
, "%30s: ", "/8 equivalent ");
11845 vty_out (vty
, "%12.2f%s",
11846 (float)ts
.counts
[BGP_STATS_SPACE
] /
11847 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11849 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11851 vty_out (vty
, "%30s: ", "/24 equivalent ");
11852 vty_out (vty
, "%12.2f",
11853 (float)ts
.counts
[BGP_STATS_SPACE
] /
11854 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11857 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11858 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11861 vty_out (vty
, "%s", VTY_NEWLINE
);
11863 return CMD_SUCCESS
;
11867 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11868 const char *afi_str
, const char *safi_str
)
11875 bgp
= bgp_lookup_by_name (name
);
11877 bgp
= bgp_get_default ();
11881 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11882 return CMD_WARNING
;
11884 afi
= bgp_vty_afi_from_arg(afi_str
);
11885 if (afi
== AFI_MAX
)
11887 vty_out (vty
, "%% Invalid address family \"%s\"%s",
11888 afi_str
, VTY_NEWLINE
);
11889 return CMD_WARNING
;
11891 safi
= bgp_vty_safi_from_arg(safi_str
);
11892 if (safi
== SAFI_MAX
)
11894 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11895 safi_str
, VTY_NEWLINE
);
11896 return CMD_WARNING
;
11899 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11902 DEFUN (show_bgp_statistics
,
11903 show_bgp_statistics_cmd
,
11904 "show bgp "BGP_AFI_SAFI_CMD_STR
" statistics",
11907 BGP_AFI_SAFI_HELP_STR
11908 "BGP RIB advertisement statistics\n")
11910 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11913 DEFUN (show_bgp_statistics_view
,
11914 show_bgp_statistics_view_cmd
,
11915 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" statistics",
11918 BGP_INSTANCE_HELP_STR
11919 BGP_AFI_SAFI_HELP_STR
11920 "BGP RIB advertisement statistics\n")
11922 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11935 PCOUNT_PFCNT
, /* the figure we display to users */
11939 static const char *pcount_strs
[] =
11941 [PCOUNT_ADJ_IN
] = "Adj-in",
11942 [PCOUNT_DAMPED
] = "Damped",
11943 [PCOUNT_REMOVED
] = "Removed",
11944 [PCOUNT_HISTORY
] = "History",
11945 [PCOUNT_STALE
] = "Stale",
11946 [PCOUNT_VALID
] = "Valid",
11947 [PCOUNT_ALL
] = "All RIB",
11948 [PCOUNT_COUNTED
] = "PfxCt counted",
11949 [PCOUNT_PFCNT
] = "Useable",
11950 [PCOUNT_MAX
] = NULL
,
11953 struct peer_pcounts
11955 unsigned int count
[PCOUNT_MAX
];
11956 const struct peer
*peer
;
11957 const struct bgp_table
*table
;
11961 bgp_peer_count_walker (struct thread
*t
)
11963 struct bgp_node
*rn
;
11964 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11965 const struct peer
*peer
= pc
->peer
;
11967 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11969 struct bgp_adj_in
*ain
;
11970 struct bgp_info
*ri
;
11972 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11973 if (ain
->peer
== peer
)
11974 pc
->count
[PCOUNT_ADJ_IN
]++;
11976 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11978 char buf
[SU_ADDRSTRLEN
];
11980 if (ri
->peer
!= peer
)
11983 pc
->count
[PCOUNT_ALL
]++;
11985 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11986 pc
->count
[PCOUNT_DAMPED
]++;
11987 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11988 pc
->count
[PCOUNT_HISTORY
]++;
11989 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
11990 pc
->count
[PCOUNT_REMOVED
]++;
11991 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
11992 pc
->count
[PCOUNT_STALE
]++;
11993 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
11994 pc
->count
[PCOUNT_VALID
]++;
11995 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11996 pc
->count
[PCOUNT_PFCNT
]++;
11998 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
12000 pc
->count
[PCOUNT_COUNTED
]++;
12001 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12002 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
12004 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12005 buf
, SU_ADDRSTRLEN
),
12011 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
12012 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
12014 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
12015 buf
, SU_ADDRSTRLEN
),
12025 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
12027 struct peer_pcounts pcounts
= { .peer
= peer
};
12029 json_object
*json
= NULL
;
12030 json_object
*json_loop
= NULL
;
12034 json
= json_object_new_object();
12035 json_loop
= json_object_new_object();
12038 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
12039 || !peer
->bgp
->rib
[afi
][safi
])
12043 json_object_string_add(json
, "warning", "No such neighbor or address family");
12044 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12045 json_object_free(json
);
12048 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12050 return CMD_WARNING
;
12053 memset (&pcounts
, 0, sizeof(pcounts
));
12054 pcounts
.peer
= peer
;
12055 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
12057 /* in-place call via thread subsystem so as to record execution time
12058 * * stats for the thread-walk (i.e. ensure this can't be blamed on
12059 * * on just vty_read()).
12061 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
12065 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
12066 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
12067 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
12069 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12070 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
12072 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
12074 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12076 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
12077 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
12079 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12080 json_object_free(json
);
12085 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
12087 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
12088 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
12093 vty_out (vty
, "Prefix counts for %s, %s%s",
12094 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
12097 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
12098 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
12099 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
12101 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12102 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
12104 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12106 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
12107 peer
->host
, VTY_NEWLINE
);
12108 vty_out (vty
, "Please report this bug, with the above command output%s",
12113 return CMD_SUCCESS
;
12116 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
12117 show_ip_bgp_neighbor_prefix_counts_cmd
,
12118 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12122 "Detailed information on TCP and BGP neighbor connections\n"
12123 "Neighbor to display information about\n"
12124 "Neighbor to display information about\n"
12125 "Neighbor on bgp configured interface\n"
12126 "Display detailed prefix count information\n"
12127 "JavaScript Object Notation\n")
12130 u_char uj
= use_json(argc
, argv
);
12132 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12134 return CMD_WARNING
;
12136 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12139 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
12140 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
12141 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12145 BGP_INSTANCE_HELP_STR
12146 "Detailed information on TCP and BGP neighbor connections\n"
12147 "Neighbor to display information about\n"
12148 "Neighbor to display information about\n"
12149 "Neighbor on bgp configured interface\n"
12150 "Display detailed prefix count information\n"
12151 "JavaScript Object Notation\n")
12154 u_char uj
= use_json(argc
, argv
);
12156 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12158 return CMD_WARNING
;
12160 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12163 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
12164 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
12165 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12169 "Detailed information on TCP and BGP neighbor connections\n"
12170 "Neighbor to display information about\n"
12171 "Neighbor to display information about\n"
12172 "Neighbor on bgp configured interface\n"
12173 "Display detailed prefix count information\n"
12174 "JavaScript Object Notation\n")
12177 u_char uj
= use_json(argc
, argv
);
12179 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12181 return CMD_WARNING
;
12183 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12186 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
12187 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
12188 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12191 BGP_INSTANCE_HELP_STR
12193 "Detailed information on TCP and BGP neighbor connections\n"
12194 "Neighbor to display information about\n"
12195 "Neighbor to display information about\n"
12196 "Neighbor on bgp configured interface\n"
12197 "Display detailed prefix count information\n"
12198 "JavaScript Object Notation\n")
12201 u_char uj
= use_json(argc
, argv
);
12203 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12205 return CMD_WARNING
;
12207 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12210 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
12211 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
12212 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12217 "Address Family modifier\n"
12218 "Address Family modifier\n"
12219 "Detailed information on TCP and BGP neighbor connections\n"
12220 "Neighbor to display information about\n"
12221 "Neighbor to display information about\n"
12222 "Neighbor on bgp configured interface\n"
12223 "Display detailed prefix count information\n"
12224 "JavaScript Object Notation\n")
12227 u_char uj
= use_json(argc
, argv
);
12229 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12231 return CMD_WARNING
;
12234 safi
= bgp_vty_safi_from_arg(argv
[0]);
12235 return bgp_peer_counts (vty
, peer
, AFI_IP
, safi
, uj
);
12239 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12240 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
12242 struct bgp_table
*table
;
12243 struct bgp_adj_in
*ain
;
12244 struct bgp_adj_out
*adj
;
12245 unsigned long output_count
;
12246 unsigned long filtered_count
;
12247 struct bgp_node
*rn
;
12252 struct attr_extra extra
;
12254 struct update_subgroup
*subgrp
;
12255 json_object
*json_scode
= NULL
;
12256 json_object
*json_ocode
= NULL
;
12257 json_object
*json_ar
= NULL
;
12258 struct peer_af
*paf
;
12262 json_scode
= json_object_new_object();
12263 json_ocode
= json_object_new_object();
12264 json_ar
= json_object_new_object();
12266 json_object_string_add(json_scode
, "suppressed", "s");
12267 json_object_string_add(json_scode
, "damped", "d");
12268 json_object_string_add(json_scode
, "history", "h");
12269 json_object_string_add(json_scode
, "valid", "*");
12270 json_object_string_add(json_scode
, "best", ">");
12271 json_object_string_add(json_scode
, "multipath", "=");
12272 json_object_string_add(json_scode
, "internal", "i");
12273 json_object_string_add(json_scode
, "ribFailure", "r");
12274 json_object_string_add(json_scode
, "stale", "S");
12275 json_object_string_add(json_scode
, "removed", "R");
12277 json_object_string_add(json_ocode
, "igp", "i");
12278 json_object_string_add(json_ocode
, "egp", "e");
12279 json_object_string_add(json_ocode
, "incomplete", "?");
12288 json_object_string_add(json
, "alert", "no BGP");
12289 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12290 json_object_free(json
);
12293 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12297 table
= bgp
->rib
[afi
][safi
];
12299 output_count
= filtered_count
= 0;
12300 subgrp
= peer_subgroup(peer
, afi
, safi
);
12302 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12306 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12307 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12308 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12309 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12310 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12314 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12315 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12316 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12318 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12319 VTY_NEWLINE
, VTY_NEWLINE
);
12324 attr
.extra
= &extra
;
12325 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12329 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12331 if (ain
->peer
== peer
)
12337 json_object_int_add(json
, "bgpTableVersion", 0);
12338 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12339 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12340 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12344 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12345 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12346 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12353 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12358 bgp_attr_dup(&attr
, ain
->attr
);
12359 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12361 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12372 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12373 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12374 if (paf
->peer
== peer
)
12380 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12381 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12382 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12383 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12387 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12388 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12389 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12390 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12398 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12404 bgp_attr_dup(&attr
, adj
->attr
);
12405 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12406 if (ret
!= RMAP_DENY
)
12408 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12418 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12420 if (output_count
!= 0)
12423 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12425 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12426 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12430 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12431 json_object_free(json
);
12437 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12438 int in
, const char *rmap_name
, u_char use_json
)
12440 json_object
*json
= NULL
;
12443 json
= json_object_new_object();
12445 if (!peer
|| !peer
->afc
[afi
][safi
])
12449 json_object_string_add(json
, "warning", "No such neighbor or address family");
12450 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12451 json_object_free(json
);
12454 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12456 return CMD_WARNING
;
12459 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12463 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12464 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12465 json_object_free(json
);
12468 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12470 return CMD_WARNING
;
12473 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12475 return CMD_SUCCESS
;
12478 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12479 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12480 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12484 BGP_INSTANCE_HELP_STR
12485 "Detailed information on TCP and BGP neighbor connections\n"
12486 "Neighbor to display information about\n"
12487 "Neighbor to display information about\n"
12488 "Display the routes advertised to a BGP neighbor\n"
12489 "JavaScript Object Notation\n")
12492 u_char uj
= use_json(argc
, argv
);
12494 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12495 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12497 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12500 return CMD_WARNING
;
12502 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12505 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12506 show_ip_bgp_neighbor_advertised_route_cmd
,
12507 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12511 "Detailed information on TCP and BGP neighbor connections\n"
12512 "Neighbor to display information about\n"
12513 "Neighbor to display information about\n"
12514 "Neighbor on bgp configured interface\n"
12515 "Display the routes advertised to a BGP neighbor\n"
12516 "JavaScript Object Notation\n")
12520 const char *rmap_name
= NULL
;
12521 u_char uj
= use_json(argc
, argv
);
12523 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12526 return CMD_WARNING
;
12528 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12530 rmap_name
= argv
[1];
12532 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12535 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12536 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12537 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12541 "Detailed information on TCP and BGP neighbor connections\n"
12542 "Neighbor to display information about\n"
12543 "Neighbor to display information about\n"
12544 "Neighbor on bgp configured interface\n"
12545 "Display the routes advertised to a BGP neighbor\n"
12546 "JavaScript Object Notation\n")
12548 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12549 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12550 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12554 BGP_INSTANCE_HELP_STR
12555 "Detailed information on TCP and BGP neighbor connections\n"
12556 "Neighbor to display information about\n"
12557 "Neighbor to display information about\n"
12558 "Neighbor on bgp configured interface\n"
12559 "Display the routes advertised to a BGP neighbor\n"
12560 "JavaScript Object Notation\n")
12561 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12562 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12563 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12568 "Address Family modifier\n"
12569 "Address Family modifier\n"
12570 "Detailed information on TCP and BGP neighbor connections\n"
12571 "Neighbor to display information about\n"
12572 "Neighbor to display information about\n"
12573 "Neighbor on bgp configured interface\n"
12574 "Display the routes advertised to a BGP neighbor\n"
12575 "JavaScript Object Notation\n")
12578 const char *rmap_name
= NULL
;
12581 u_char uj
= use_json(argc
, argv
);
12583 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12585 return CMD_WARNING
;
12587 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12588 rmap_name
= argv
[2];
12590 safi
= bgp_vty_safi_from_arg(argv
[0]);
12591 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 0, rmap_name
, uj
);
12594 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12595 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12596 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12601 "Address Family modifier\n"
12602 "Address Family modifier\n"
12603 "Detailed information on TCP and BGP neighbor connections\n"
12604 "Neighbor to display information about\n"
12605 "Neighbor to display information about\n"
12606 "Neighbor on bgp configured interface\n"
12607 "Display the routes advertised to a BGP neighbor\n"
12608 "Route-map to control what is displayed\n"
12609 "JavaScript Object Notation\n")
12612 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12613 show_bgp_instance_neighbor_advertised_route_cmd
,
12614 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12617 BGP_INSTANCE_HELP_STR
12618 "Detailed information on TCP and BGP neighbor connections\n"
12619 "Neighbor to display information about\n"
12620 "Neighbor to display information about\n"
12621 "Neighbor on bgp configured interface\n"
12622 "Display the routes advertised to a BGP neighbor\n"
12623 "JavaScript Object Notation\n")
12626 u_char uj
= use_json(argc
, argv
);
12628 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12629 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12631 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12634 return CMD_WARNING
;
12636 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12639 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12640 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12641 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12644 BGP_INSTANCE_HELP_STR
12646 "Detailed information on TCP and BGP neighbor connections\n"
12647 "Neighbor to display information about\n"
12648 "Neighbor to display information about\n"
12649 "Neighbor on bgp configured interface\n"
12650 "Display the routes advertised to a BGP neighbor\n"
12651 "JavaScript Object Notation\n")
12653 DEFUN (show_bgp_neighbor_advertised_route
,
12654 show_bgp_neighbor_advertised_route_cmd
,
12655 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12658 "Detailed information on TCP and BGP neighbor connections\n"
12659 "Neighbor to display information about\n"
12660 "Neighbor to display information about\n"
12661 "Neighbor on bgp configured interface\n"
12662 "Display the routes advertised to a BGP neighbor\n"
12663 "JavaScript Object Notation\n")
12667 const char *rmap_name
= NULL
;
12668 u_char uj
= use_json(argc
, argv
);
12670 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12673 return CMD_WARNING
;
12675 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12676 rmap_name
= argv
[1];
12678 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12681 ALIAS (show_bgp_neighbor_advertised_route
,
12682 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12683 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12687 "Detailed information on TCP and BGP neighbor connections\n"
12688 "Neighbor to display information about\n"
12689 "Neighbor to display information about\n"
12690 "Neighbor on bgp configured interface\n"
12691 "Display the routes advertised to a BGP neighbor\n"
12692 "JavaScript Object Notation\n")
12695 ALIAS (show_bgp_neighbor_advertised_route
,
12696 ipv6_bgp_neighbor_advertised_route_cmd
,
12697 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12701 "Detailed information on TCP and BGP neighbor connections\n"
12702 "Neighbor to display information about\n"
12703 "Neighbor to display information about\n"
12704 "Neighbor on bgp configured interface\n"
12705 "Display the routes advertised to a BGP neighbor\n"
12706 "JavaScript Object Notation\n")
12709 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12710 ipv6_mbgp_neighbor_advertised_route_cmd
,
12711 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12715 "Detailed information on TCP and BGP neighbor connections\n"
12716 "Neighbor to display information about\n"
12717 "Neighbor to display information about\n"
12718 "Neighbor on bgp configured interface\n"
12719 "Neighbor on bgp configured interface\n"
12720 "Display the routes advertised to a BGP neighbor\n"
12721 "JavaScript Object Notation\n")
12724 u_char uj
= use_json(argc
, argv
);
12726 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12728 return CMD_WARNING
;
12730 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12731 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12733 #endif /* HAVE_IPV6 */
12735 DEFUN (show_bgp_instance_neighbor_received_routes
,
12736 show_bgp_instance_neighbor_received_routes_cmd
,
12737 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12740 BGP_INSTANCE_HELP_STR
12741 "Detailed information on TCP and BGP neighbor connections\n"
12742 "Neighbor to display information about\n"
12743 "Neighbor to display information about\n"
12744 "Neighbor on bgp configured interface\n"
12745 "Display the received routes from neighbor\n"
12746 "JavaScript Object Notation\n")
12749 u_char uj
= use_json(argc
, argv
);
12751 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12753 return CMD_WARNING
;
12755 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12758 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12759 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12760 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12764 BGP_INSTANCE_HELP_STR
12765 "Detailed information on TCP and BGP neighbor connections\n"
12766 "Neighbor to display information about\n"
12767 "Neighbor to display information about\n"
12768 "Neighbor on bgp configured interface\n"
12769 "Display the received routes from neighbor\n"
12770 "JavaScript Object Notation\n")
12773 u_char uj
= use_json(argc
, argv
);
12775 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12777 return CMD_WARNING
;
12779 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12782 ALIAS (show_bgp_instance_neighbor_received_routes
,
12783 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12784 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12787 BGP_INSTANCE_HELP_STR
12789 "Detailed information on TCP and BGP neighbor connections\n"
12790 "Neighbor to display information about\n"
12791 "Neighbor to display information about\n"
12792 "Neighbor on bgp configured interface\n"
12793 "Display the received routes from neighbor\n"
12794 "JavaScript Object Notation\n")
12796 DEFUN (show_ip_bgp_neighbor_received_routes
,
12797 show_ip_bgp_neighbor_received_routes_cmd
,
12798 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12802 "Detailed information on TCP and BGP neighbor connections\n"
12803 "Neighbor to display information about\n"
12804 "Neighbor to display information about\n"
12805 "Neighbor on bgp configured interface\n"
12806 "Display the received routes from neighbor\n"
12807 "JavaScript Object Notation\n")
12811 const char *rmap_name
= NULL
;
12812 u_char uj
= use_json(argc
, argv
);
12814 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12817 return CMD_WARNING
;
12819 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12820 rmap_name
= argv
[1];
12822 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12825 ALIAS (show_ip_bgp_neighbor_received_routes
,
12826 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12827 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12831 "Detailed information on TCP and BGP neighbor connections\n"
12832 "Neighbor to display information about\n"
12833 "Neighbor to display information about\n"
12834 "Neighbor on bgp configured interface\n"
12835 "Display the received routes from neighbor\n"
12836 "JavaScript Object Notation\n")
12838 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12839 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12840 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12844 BGP_INSTANCE_HELP_STR
12845 "Detailed information on TCP and BGP neighbor connections\n"
12846 "Neighbor to display information about\n"
12847 "Neighbor to display information about\n"
12848 "Neighbor on bgp configured interface\n"
12849 "Display the received routes from neighbor\n"
12850 "JavaScript Object Notation\n")
12852 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12853 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12854 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12859 "Address Family modifier\n"
12860 "Address Family modifier\n"
12861 "Detailed information on TCP and BGP neighbor connections\n"
12862 "Neighbor to display information about\n"
12863 "Neighbor to display information about\n"
12864 "Neighbor on bgp configured interface\n"
12865 "Display the received routes from neighbor\n"
12866 "JavaScript Object Notation\n")
12869 const char *rmap_name
= NULL
;
12871 u_char uj
= use_json(argc
, argv
);
12873 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12875 return CMD_WARNING
;
12877 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12878 rmap_name
= argv
[2];
12880 safi
= bgp_vty_safi_from_arg(argv
[0]);
12881 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 1, rmap_name
, uj
);
12884 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12885 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12886 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12891 "Address Family modifier\n"
12892 "Address Family modifier\n"
12893 "Detailed information on TCP and BGP neighbor connections\n"
12894 "Neighbor to display information about\n"
12895 "Neighbor to display information about\n"
12896 "Neighbor on bgp configured interface\n"
12897 "Display the received routes from neighbor\n"
12898 "JavaScript Object Notation\n")
12900 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12901 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12902 "show bgp " BGP_INSTANCE_CMD
" (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12905 BGP_INSTANCE_HELP_STR
12908 "Address family modifier\n"
12909 "Address family modifier\n"
12910 "Detailed information on TCP and BGP neighbor connections\n"
12911 "Neighbor to display information about\n"
12912 "Neighbor to display information about\n"
12913 "Neighbor on bgp configured interface\n"
12914 "Display the advertised routes to neighbor\n"
12915 "Display the received routes from neighbor\n"
12916 "JavaScript Object Notation\n")
12922 u_char uj
= use_json(argc
, argv
);
12924 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12927 return CMD_WARNING
;
12929 afi
= bgp_vty_safi_from_arg(argv
[2]);
12930 safi
= bgp_vty_safi_from_arg(argv
[3]);
12931 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12933 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12936 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12937 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12938 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12942 "Detailed information on TCP and BGP neighbor connections\n"
12943 "Neighbor to display information about\n"
12944 "Neighbor to display information about\n"
12945 "Neighbor on bgp configured interface\n"
12946 "Display information received from a BGP neighbor\n"
12947 "Display the prefixlist filter\n"
12948 "JavaScript Object Notation\n")
12951 union sockunion su
;
12954 u_char uj
= use_json(argc
, argv
);
12956 ret
= str2sockunion (argv
[0], &su
);
12959 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12964 json_object
*json_no
= NULL
;
12965 json_object
*json_sub
= NULL
;
12966 json_no
= json_object_new_object();
12967 json_sub
= json_object_new_object();
12968 json_object_string_add(json_no
, "warning", "Malformed address or name");
12969 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12970 json_object_object_add(json_no
, "detail", json_sub
);
12971 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12972 json_object_free(json_no
);
12975 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12976 return CMD_WARNING
;
12981 peer
= peer_lookup (NULL
, &su
);
12986 json_object
*json_no
= NULL
;
12987 json_no
= json_object_new_object();
12988 json_object_string_add(json_no
, "warning", "Peer not found");
12989 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12990 json_object_free(json_no
);
12993 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12994 return CMD_WARNING
;
12998 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12999 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13003 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
13004 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13010 json_object
*json_no
= NULL
;
13011 json_no
= json_object_new_object();
13012 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13013 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13014 json_object_free(json_no
);
13017 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13020 return CMD_SUCCESS
;
13023 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
13024 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
13025 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13030 "Address Family modifier\n"
13031 "Address Family modifier\n"
13032 "Detailed information on TCP and BGP neighbor connections\n"
13033 "Neighbor to display information about\n"
13034 "Neighbor to display information about\n"
13035 "Neighbor on bgp configured interface\n"
13036 "Display information received from a BGP neighbor\n"
13037 "Display the prefixlist filter\n"
13038 "JavaScript Object Notation\n")
13041 union sockunion su
;
13044 u_char uj
= use_json(argc
, argv
);
13046 ret
= str2sockunion (argv
[1], &su
);
13049 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
13054 json_object
*json_no
= NULL
;
13055 json_object
*json_sub
= NULL
;
13056 json_no
= json_object_new_object();
13057 json_sub
= json_object_new_object();
13058 json_object_string_add(json_no
, "warning", "Malformed address or name");
13059 json_object_string_add(json_sub
, "warningCause", argv
[1]);
13060 json_object_object_add(json_no
, "detail", json_sub
);
13061 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13062 json_object_free(json_no
);
13065 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
13066 return CMD_WARNING
;
13071 peer
= peer_lookup (NULL
, &su
);
13076 json_object
*json_no
= NULL
;
13077 json_no
= json_object_new_object();
13078 json_object_string_add(json_no
, "warning", "Peer not found");
13079 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13080 json_object_free(json_no
);
13083 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13084 return CMD_WARNING
;
13090 safi
= bgp_vty_safi_from_arg(argv
[0]);
13091 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, safi
);
13092 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13096 vty_out (vty
, "Address family: %s%s",
13097 afi_safi_print (AFI_IP
, safi
), VTY_NEWLINE
);
13098 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13104 json_object
*json_no
= NULL
;
13105 json_no
= json_object_new_object();
13106 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13107 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13108 json_object_free(json_no
);
13111 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13115 return CMD_SUCCESS
;
13118 DEFUN (show_bgp_neighbor_received_routes
,
13119 show_bgp_neighbor_received_routes_cmd
,
13120 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13123 "Detailed information on TCP and BGP neighbor connections\n"
13124 "Neighbor to display information about\n"
13125 "Neighbor to display information about\n"
13126 "Neighbor on bgp configured interface\n"
13127 "Display the received routes from neighbor\n"
13128 "JavaScript Object Notation\n")
13131 const char *rmap_name
= NULL
;
13132 u_char uj
= use_json(argc
, argv
);
13134 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13137 return CMD_WARNING
;
13139 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
13140 rmap_name
= argv
[1];
13142 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13145 ALIAS (show_bgp_neighbor_received_routes
,
13146 show_bgp_ipv6_neighbor_received_routes_cmd
,
13147 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13151 "Detailed information on TCP and BGP neighbor connections\n"
13152 "Neighbor to display information about\n"
13153 "Neighbor to display information about\n"
13154 "Neighbor on bgp configured interface\n"
13155 "Display the received routes from neighbor\n"
13156 "JavaScript Object Notation\n")
13158 DEFUN (show_bgp_neighbor_received_prefix_filter
,
13159 show_bgp_neighbor_received_prefix_filter_cmd
,
13160 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13163 "Detailed information on TCP and BGP neighbor connections\n"
13164 "Neighbor to display information about\n"
13165 "Neighbor to display information about\n"
13166 "Neighbor on bgp configured interface\n"
13167 "Display information received from a BGP neighbor\n"
13168 "Display the prefixlist filter\n"
13169 "JavaScript Object Notation\n")
13172 union sockunion su
;
13175 u_char uj
= use_json(argc
, argv
);
13177 ret
= str2sockunion (argv
[0], &su
);
13180 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13185 json_object
*json_no
= NULL
;
13186 json_object
*json_sub
= NULL
;
13187 json_no
= json_object_new_object();
13188 json_sub
= json_object_new_object();
13189 json_object_string_add(json_no
, "warning", "Malformed address or name");
13190 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13191 json_object_object_add(json_no
, "detail", json_sub
);
13192 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13193 json_object_free(json_no
);
13196 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13197 return CMD_WARNING
;
13202 peer
= peer_lookup (NULL
, &su
);
13207 json_object
*json_no
= NULL
;
13208 json_no
= json_object_new_object();
13209 json_object_string_add(json_no
, "warning", "No Peer");
13210 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13211 json_object_free(json_no
);
13214 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13215 return CMD_WARNING
;
13219 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13220 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13224 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13225 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13231 json_object
*json_no
= NULL
;
13232 json_no
= json_object_new_object();
13233 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13234 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13235 json_object_free(json_no
);
13238 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13241 return CMD_SUCCESS
;
13244 ALIAS (show_bgp_neighbor_received_prefix_filter
,
13245 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
13246 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13250 "Detailed information on TCP and BGP neighbor connections\n"
13251 "Neighbor to display information about\n"
13252 "Neighbor to display information about\n"
13253 "Neighbor on bgp configured interface\n"
13254 "Display information received from a BGP neighbor\n"
13255 "Display the prefixlist filter\n"
13256 "JavaScript Object Notation\n")
13259 ALIAS (show_bgp_neighbor_received_routes
,
13260 ipv6_bgp_neighbor_received_routes_cmd
,
13261 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13265 "Detailed information on TCP and BGP neighbor connections\n"
13266 "Neighbor to display information about\n"
13267 "Neighbor to display information about\n"
13268 "Neighbor on bgp configured interface\n"
13269 "Display the received routes from neighbor\n"
13270 "JavaScript Object Notation\n")
13273 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13274 ipv6_mbgp_neighbor_received_routes_cmd
,
13275 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13279 "Detailed information on TCP and BGP neighbor connections\n"
13280 "Neighbor to display information about\n"
13281 "Neighbor to display information about\n"
13282 "Neighbor on bgp configured interface\n"
13283 "Display the received routes from neighbor\n"
13284 "JavaScript Object Notation\n")
13287 u_char uj
= use_json(argc
, argv
);
13289 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13291 return CMD_WARNING
;
13293 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13294 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13297 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13298 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13299 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13302 BGP_INSTANCE_HELP_STR
13303 "Detailed information on TCP and BGP neighbor connections\n"
13304 "Neighbor to display information about\n"
13305 "Neighbor to display information about\n"
13306 "Neighbor on bgp configured interface\n"
13307 "Display information received from a BGP neighbor\n"
13308 "Display the prefixlist filter\n"
13309 "JavaScript Object Notation\n")
13312 union sockunion su
;
13316 u_char uj
= use_json(argc
, argv
);
13318 /* BGP structure lookup. */
13319 bgp
= bgp_lookup_by_name (argv
[1]);
13324 json_object
*json_no
= NULL
;
13325 json_no
= json_object_new_object();
13326 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13327 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13328 json_object_free(json_no
);
13331 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13332 return CMD_WARNING
;
13335 ret
= str2sockunion (argv
[2], &su
);
13338 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13343 json_object
*json_no
= NULL
;
13344 json_object
*json_sub
= NULL
;
13345 json_no
= json_object_new_object();
13346 json_sub
= json_object_new_object();
13347 json_object_string_add(json_no
, "warning", "Malformed address or name");
13348 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13349 json_object_object_add(json_no
, "detail", json_sub
);
13350 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13351 json_object_free(json_no
);
13354 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13355 return CMD_WARNING
;
13360 peer
= peer_lookup (bgp
, &su
);
13365 json_object
*json_no
= NULL
;
13366 json_no
= json_object_new_object();
13367 json_object_boolean_true_add(json_no
, "noPeer");
13368 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13369 json_object_free(json_no
);
13372 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13373 return CMD_WARNING
;
13378 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13379 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13383 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13384 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13387 return CMD_SUCCESS
;
13389 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13390 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13391 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13394 BGP_INSTANCE_HELP_STR
13396 "Detailed information on TCP and BGP neighbor connections\n"
13397 "Neighbor to display information about\n"
13398 "Neighbor to display information about\n"
13399 "Neighbor on bgp configured interface\n"
13400 "Display information received from a BGP neighbor\n"
13401 "Display the prefixlist filter\n"
13402 "JavaScript Object NOtation\n")
13403 #endif /* HAVE_IPV6 */
13406 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13407 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13409 if (! peer
|| ! peer
->afc
[afi
][safi
])
13413 json_object
*json_no
= NULL
;
13414 json_no
= json_object_new_object();
13415 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13416 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13417 json_object_free(json_no
);
13420 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13421 return CMD_WARNING
;
13424 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13427 DEFUN (show_ip_bgp_neighbor_routes
,
13428 show_ip_bgp_neighbor_routes_cmd
,
13429 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13433 "Detailed information on TCP and BGP neighbor connections\n"
13434 "Neighbor to display information about\n"
13435 "Neighbor to display information about\n"
13436 "Neighbor on bgp configured interface\n"
13437 "Display routes learned from neighbor\n"
13438 "JavaScript Object Notation\n")
13441 u_char uj
= use_json(argc
, argv
);
13443 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13445 return CMD_WARNING
;
13447 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13448 bgp_show_type_neighbor
, uj
);
13451 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13452 show_ip_bgp_instance_neighbor_routes_cmd
,
13453 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13457 BGP_INSTANCE_HELP_STR
13458 "Detailed information on TCP and BGP neighbor connections\n"
13459 "Neighbor to display information about\n"
13460 "Neighbor to display information about\n"
13461 "Neighbor on bgp configured interface\n"
13462 "Display routes learned from neighbor\n"
13463 "JavaScript Object Notation\n")
13466 u_char uj
= use_json(argc
, argv
);
13468 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13470 return CMD_WARNING
;
13472 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13473 bgp_show_type_neighbor
, uj
);
13476 DEFUN (show_ip_bgp_neighbor_flap
,
13477 show_ip_bgp_neighbor_flap_cmd
,
13478 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13482 "Detailed information on TCP and BGP neighbor connections\n"
13483 "Neighbor to display information about\n"
13484 "Neighbor to display information about\n"
13485 "Neighbor on bgp configured interface\n"
13486 "Display flap statistics of the routes learned from neighbor\n"
13487 "JavaScript Object Notation\n")
13490 u_char uj
= use_json(argc
, argv
);
13492 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13494 return CMD_WARNING
;
13496 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13497 bgp_show_type_flap_neighbor
, uj
);
13500 DEFUN (show_ip_bgp_neighbor_damp
,
13501 show_ip_bgp_neighbor_damp_cmd
,
13502 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13506 "Detailed information on TCP and BGP neighbor connections\n"
13507 "Neighbor to display information about\n"
13508 "Neighbor to display information about\n"
13509 "Neighbor on bgp configured interface\n"
13510 "Display the dampened routes received from neighbor\n"
13511 "JavaScript Object Notation\n")
13514 u_char uj
= use_json(argc
, argv
);
13516 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13518 return CMD_WARNING
;
13520 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13521 bgp_show_type_damp_neighbor
, uj
);
13524 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13525 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13526 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13531 "Address Family modifier\n"
13532 "Address Family modifier\n"
13533 "Detailed information on TCP and BGP neighbor connections\n"
13534 "Neighbor to display information about\n"
13535 "Neighbor to display information about\n"
13536 "Neighbor on bgp configured interface\n"
13537 "Display routes learned from neighbor\n"
13538 "JavaScript Object Notation\n")
13542 u_char uj
= use_json(argc
, argv
);
13544 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13546 return CMD_WARNING
;
13548 safi
= bgp_vty_safi_from_arg(argv
[0]);
13549 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, safi
,
13550 bgp_show_type_neighbor
, uj
);
13554 DEFUN (show_bgp_instance_neighbor_routes
,
13555 show_bgp_instance_neighbor_routes_cmd
,
13556 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13559 BGP_INSTANCE_HELP_STR
13560 "Detailed information on TCP and BGP neighbor connections\n"
13561 "Neighbor to display information about\n"
13562 "Neighbor to display information about\n"
13563 "Neighbor on bgp configured interface\n"
13564 "Display routes learned from neighbor\n"
13565 "JavaScript Object Notation\n")
13568 u_char uj
= use_json(argc
, argv
);
13570 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13572 return CMD_WARNING
;
13574 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13575 bgp_show_type_neighbor
, uj
);
13578 ALIAS (show_bgp_instance_neighbor_routes
,
13579 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13580 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13583 BGP_INSTANCE_HELP_STR
13585 "Detailed information on TCP and BGP neighbor connections\n"
13586 "Neighbor to display information about\n"
13587 "Neighbor to display information about\n"
13588 "Neighbor on bgp configured interface\n"
13589 "Display routes learned from neighbor\n"
13590 "JavaScript Object Notation\n")
13592 DEFUN (show_bgp_instance_neighbor_damp
,
13593 show_bgp_instance_neighbor_damp_cmd
,
13594 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13597 BGP_INSTANCE_HELP_STR
13598 "Detailed information on TCP and BGP neighbor connections\n"
13599 "Neighbor to display information about\n"
13600 "Neighbor to display information about\n"
13601 "Neighbor on bgp configured interface\n"
13602 "Display the dampened routes received from neighbor\n"
13603 "JavaScript Object Notation\n")
13606 u_char uj
= use_json(argc
, argv
);
13608 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13609 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13610 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13612 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13615 return CMD_WARNING
;
13617 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13618 bgp_show_type_damp_neighbor
, uj
);
13621 ALIAS (show_bgp_instance_neighbor_damp
,
13622 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13623 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13626 BGP_INSTANCE_HELP_STR
13628 "Detailed information on TCP and BGP neighbor connections\n"
13629 "Neighbor to display information about\n"
13630 "Neighbor to display information about\n"
13631 "Neighbor on bgp configured interface\n"
13632 "Display the dampened routes received from neighbor\n"
13633 "JavaScript Object Notation\n")
13635 DEFUN (show_bgp_instance_neighbor_flap
,
13636 show_bgp_instance_neighbor_flap_cmd
,
13637 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13640 BGP_INSTANCE_HELP_STR
13641 "Detailed information on TCP and BGP neighbor connections\n"
13642 "Neighbor to display information about\n"
13643 "Neighbor to display information about\n"
13644 "Neighbor on bgp configured interface\n"
13645 "Display flap statistics of the routes learned from neighbor\n"
13646 "JavaScript Object Notation\n")
13649 u_char uj
= use_json(argc
, argv
);
13651 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13652 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13653 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13655 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13658 return CMD_WARNING
;
13660 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13661 bgp_show_type_flap_neighbor
, uj
);
13664 ALIAS (show_bgp_instance_neighbor_flap
,
13665 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13666 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13669 BGP_INSTANCE_HELP_STR
13671 "Detailed information on TCP and BGP neighbor connections\n"
13672 "Neighbor to display information about\n"
13673 "Neighbor to display information about\n"
13674 "Neighbor on bgp configured interface\n"
13675 "Display flap statistics of the routes learned from neighbor\n"
13676 "JavaScript Object Notation\n")
13678 DEFUN (show_bgp_neighbor_routes
,
13679 show_bgp_neighbor_routes_cmd
,
13680 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13683 "Detailed information on TCP and BGP neighbor connections\n"
13684 "Neighbor to display information about\n"
13685 "Neighbor to display information about\n"
13686 "Neighbor on bgp configured interface\n"
13687 "Display routes learned from neighbor\n"
13688 "JavaScript Object Notation\n")
13691 u_char uj
= use_json(argc
, argv
);
13693 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13695 return CMD_WARNING
;
13697 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13698 bgp_show_type_neighbor
, uj
);
13702 ALIAS (show_bgp_neighbor_routes
,
13703 show_bgp_ipv6_neighbor_routes_cmd
,
13704 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13708 "Detailed information on TCP and BGP neighbor connections\n"
13709 "Neighbor to display information about\n"
13710 "Neighbor to display information about\n"
13711 "Neighbor on bgp configured interface\n"
13712 "Display routes learned from neighbor\n"
13713 "JavaScript Object Notation\n")
13716 ALIAS (show_bgp_neighbor_routes
,
13717 ipv6_bgp_neighbor_routes_cmd
,
13718 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13722 "Detailed information on TCP and BGP neighbor connections\n"
13723 "Neighbor to display information about\n"
13724 "Neighbor to display information about\n"
13725 "Neighbor on bgp configured interface\n"
13726 "Display routes learned from neighbor\n"
13727 "JavaScript Object Notation\n")
13730 DEFUN (ipv6_mbgp_neighbor_routes
,
13731 ipv6_mbgp_neighbor_routes_cmd
,
13732 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13736 "Detailed information on TCP and BGP neighbor connections\n"
13737 "Neighbor to display information about\n"
13738 "Neighbor to display information about\n"
13739 "Neighbor on bgp configured interface\n"
13740 "Display routes learned from neighbor\n"
13741 "JavaScript Object Notation\n")
13744 u_char uj
= use_json(argc
, argv
);
13746 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13748 return CMD_WARNING
;
13750 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13751 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13752 bgp_show_type_neighbor
, uj
);
13755 ALIAS (show_bgp_instance_neighbor_flap
,
13756 show_bgp_neighbor_flap_cmd
,
13757 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13760 "Detailed information on TCP and BGP neighbor connections\n"
13761 "Neighbor to display information about\n"
13762 "Neighbor to display information about\n"
13763 "Neighbor on bgp configured interface\n"
13764 "Display flap statistics of the routes learned from neighbor\n"
13765 "JavaScript Object Notation\n")
13767 ALIAS (show_bgp_instance_neighbor_flap
,
13768 show_bgp_ipv6_neighbor_flap_cmd
,
13769 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13773 "Detailed information on TCP and BGP neighbor connections\n"
13774 "Neighbor to display information about\n"
13775 "Neighbor to display information about\n"
13776 "Neighbor on bgp configured interface\n"
13777 "Display flap statistics of the routes learned from neighbor\n"
13778 "JavaScript Object Notation\n")
13780 ALIAS (show_bgp_instance_neighbor_damp
,
13781 show_bgp_neighbor_damp_cmd
,
13782 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13785 "Detailed information on TCP and BGP neighbor connections\n"
13786 "Neighbor to display information about\n"
13787 "Neighbor to display information about\n"
13788 "Neighbor on bgp configured interface\n"
13789 "Display the dampened routes received from neighbor\n"
13790 "JavaScript Object Notation\n")
13792 ALIAS (show_bgp_instance_neighbor_damp
,
13793 show_bgp_ipv6_neighbor_damp_cmd
,
13794 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13798 "Detailed information on TCP and BGP neighbor connections\n"
13799 "Neighbor to display information about\n"
13800 "Neighbor to display information about\n"
13801 "Neighbor on bgp configured interface\n"
13802 "Display the dampened routes received from neighbor\n"
13803 "JavaScript Object Notation\n")
13805 #endif /* HAVE_IPV6 */
13807 struct bgp_table
*bgp_distance_table
[AFI_MAX
][SAFI_MAX
];
13809 struct bgp_distance
13811 /* Distance value for the IP source prefix. */
13814 /* Name of the access-list to be matched. */
13818 static struct bgp_distance
*
13819 bgp_distance_new (void)
13821 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13825 bgp_distance_free (struct bgp_distance
*bdistance
)
13827 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13831 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13832 const char *ip_str
, const char *access_list_str
)
13839 struct bgp_node
*rn
;
13840 struct bgp_distance
*bdistance
;
13842 afi
= bgp_node_afi (vty
);
13843 safi
= bgp_node_safi (vty
);
13845 ret
= str2prefix (ip_str
, &p
);
13848 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13849 return CMD_WARNING
;
13852 distance
= atoi (distance_str
);
13854 /* Get BGP distance node. */
13855 rn
= bgp_node_get (bgp_distance_table
[afi
][safi
], (struct prefix
*) &p
);
13858 bdistance
= rn
->info
;
13859 bgp_unlock_node (rn
);
13863 bdistance
= bgp_distance_new ();
13864 rn
->info
= bdistance
;
13867 /* Set distance value. */
13868 bdistance
->distance
= distance
;
13870 /* Reset access-list configuration. */
13871 if (bdistance
->access_list
)
13873 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13874 bdistance
->access_list
= NULL
;
13876 if (access_list_str
)
13877 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13879 return CMD_SUCCESS
;
13883 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13884 const char *ip_str
, const char *access_list_str
)
13891 struct bgp_node
*rn
;
13892 struct bgp_distance
*bdistance
;
13894 afi
= bgp_node_afi (vty
);
13895 safi
= bgp_node_safi (vty
);
13897 ret
= str2prefix (ip_str
, &p
);
13900 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13901 return CMD_WARNING
;
13904 rn
= bgp_node_lookup (bgp_distance_table
[afi
][safi
], (struct prefix
*)&p
);
13907 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13908 return CMD_WARNING
;
13911 bdistance
= rn
->info
;
13912 distance
= atoi(distance_str
);
13914 if (bdistance
->distance
!= distance
)
13916 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13917 return CMD_WARNING
;
13920 if (bdistance
->access_list
)
13921 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13922 bgp_distance_free (bdistance
);
13925 bgp_unlock_node (rn
);
13926 bgp_unlock_node (rn
);
13928 return CMD_SUCCESS
;
13931 /* Apply BGP information to distance method. */
13933 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, afi_t afi
,
13934 safi_t safi
, struct bgp
*bgp
)
13936 struct bgp_node
*rn
;
13939 struct bgp_distance
*bdistance
;
13940 struct access_list
*alist
;
13941 struct bgp_static
*bgp_static
;
13946 peer
= rinfo
->peer
;
13948 /* Check source address. */
13949 sockunion2hostprefix (&peer
->su
, &q
);
13950 rn
= bgp_node_match (bgp_distance_table
[afi
][safi
], &q
);
13953 bdistance
= rn
->info
;
13954 bgp_unlock_node (rn
);
13956 if (bdistance
->access_list
)
13958 alist
= access_list_lookup (afi
, bdistance
->access_list
);
13959 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13960 return bdistance
->distance
;
13963 return bdistance
->distance
;
13966 /* Backdoor check. */
13967 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], p
);
13970 bgp_static
= rn
->info
;
13971 bgp_unlock_node (rn
);
13973 if (bgp_static
->backdoor
)
13975 if (bgp
->distance_local
[afi
][safi
])
13976 return bgp
->distance_local
[afi
][safi
];
13978 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13982 if (peer
->sort
== BGP_PEER_EBGP
)
13984 if (bgp
->distance_ebgp
[afi
][safi
])
13985 return bgp
->distance_ebgp
[afi
][safi
];
13986 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
13990 if (bgp
->distance_ibgp
[afi
][safi
])
13991 return bgp
->distance_ibgp
[afi
][safi
];
13992 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13996 DEFUN (bgp_distance
,
13998 "distance bgp <1-255> <1-255> <1-255>",
13999 "Define an administrative distance\n"
14001 "Distance for routes external to the AS\n"
14002 "Distance for routes internal to the AS\n"
14003 "Distance for local routes\n")
14010 afi
= bgp_node_afi (vty
);
14011 safi
= bgp_node_safi (vty
);
14013 bgp
->distance_ebgp
[afi
][safi
] = atoi (argv
[0]);
14014 bgp
->distance_ibgp
[afi
][safi
] = atoi (argv
[1]);
14015 bgp
->distance_local
[afi
][safi
] = atoi (argv
[2]);
14016 return CMD_SUCCESS
;
14019 DEFUN (no_bgp_distance
,
14020 no_bgp_distance_cmd
,
14021 "no distance bgp <1-255> <1-255> <1-255>",
14023 "Define an administrative distance\n"
14025 "Distance for routes external to the AS\n"
14026 "Distance for routes internal to the AS\n"
14027 "Distance for local routes\n")
14034 afi
= bgp_node_afi (vty
);
14035 safi
= bgp_node_safi (vty
);
14037 bgp
->distance_ebgp
[afi
][safi
] = 0;
14038 bgp
->distance_ibgp
[afi
][safi
] = 0;
14039 bgp
->distance_local
[afi
][safi
] = 0;
14040 return CMD_SUCCESS
;
14043 ALIAS (no_bgp_distance
,
14044 no_bgp_distance2_cmd
,
14047 "Define an administrative distance\n"
14050 DEFUN (bgp_distance_source
,
14051 bgp_distance_source_cmd
,
14052 "distance <1-255> A.B.C.D/M",
14053 "Define an administrative distance\n"
14054 "Administrative distance\n"
14055 "IP source prefix\n")
14057 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14058 return CMD_SUCCESS
;
14061 DEFUN (no_bgp_distance_source
,
14062 no_bgp_distance_source_cmd
,
14063 "no distance <1-255> A.B.C.D/M",
14065 "Define an administrative distance\n"
14066 "Administrative distance\n"
14067 "IP source prefix\n")
14069 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14070 return CMD_SUCCESS
;
14073 DEFUN (bgp_distance_source_access_list
,
14074 bgp_distance_source_access_list_cmd
,
14075 "distance <1-255> A.B.C.D/M WORD",
14076 "Define an administrative distance\n"
14077 "Administrative distance\n"
14078 "IP source prefix\n"
14079 "Access list name\n")
14081 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14082 return CMD_SUCCESS
;
14085 DEFUN (no_bgp_distance_source_access_list
,
14086 no_bgp_distance_source_access_list_cmd
,
14087 "no distance <1-255> A.B.C.D/M WORD",
14089 "Define an administrative distance\n"
14090 "Administrative distance\n"
14091 "IP source prefix\n"
14092 "Access list name\n")
14094 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14095 return CMD_SUCCESS
;
14098 DEFUN (ipv6_bgp_distance_source
,
14099 ipv6_bgp_distance_source_cmd
,
14100 "distance <1-255> X:X::X:X/M",
14101 "Define an administrative distance\n"
14102 "Administrative distance\n"
14103 "IP source prefix\n")
14105 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14106 return CMD_SUCCESS
;
14109 DEFUN (no_ipv6_bgp_distance_source
,
14110 no_ipv6_bgp_distance_source_cmd
,
14111 "no distance <1-255> X:X::X:X/M",
14113 "Define an administrative distance\n"
14114 "Administrative distance\n"
14115 "IP source prefix\n")
14117 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14118 return CMD_SUCCESS
;
14121 DEFUN (ipv6_bgp_distance_source_access_list
,
14122 ipv6_bgp_distance_source_access_list_cmd
,
14123 "distance <1-255> X:X::X:X/M WORD",
14124 "Define an administrative distance\n"
14125 "Administrative distance\n"
14126 "IP source prefix\n"
14127 "Access list name\n")
14129 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14130 return CMD_SUCCESS
;
14133 DEFUN (no_ipv6_bgp_distance_source_access_list
,
14134 no_ipv6_bgp_distance_source_access_list_cmd
,
14135 "no distance <1-255> X:X::X:X/M WORD",
14137 "Define an administrative distance\n"
14138 "Administrative distance\n"
14139 "IP source prefix\n"
14140 "Access list name\n")
14142 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14143 return CMD_SUCCESS
;
14146 DEFUN (bgp_damp_set
,
14148 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14149 "BGP Specific commands\n"
14150 "Enable route-flap dampening\n"
14151 "Half-life time for the penalty\n"
14152 "Value to start reusing a route\n"
14153 "Value to start suppressing a route\n"
14154 "Maximum duration to suppress a stable route\n")
14157 int half
= DEFAULT_HALF_LIFE
* 60;
14158 int reuse
= DEFAULT_REUSE
;
14159 int suppress
= DEFAULT_SUPPRESS
;
14160 int max
= 4 * half
;
14164 half
= atoi (argv
[0]) * 60;
14165 reuse
= atoi (argv
[1]);
14166 suppress
= atoi (argv
[2]);
14167 max
= atoi (argv
[3]) * 60;
14169 else if (argc
== 1)
14171 half
= atoi (argv
[0]) * 60;
14177 if (suppress
< reuse
)
14179 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
14184 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
14185 half
, reuse
, suppress
, max
);
14188 ALIAS (bgp_damp_set
,
14190 "bgp dampening <1-45>",
14191 "BGP Specific commands\n"
14192 "Enable route-flap dampening\n"
14193 "Half-life time for the penalty\n")
14195 ALIAS (bgp_damp_set
,
14198 "BGP Specific commands\n"
14199 "Enable route-flap dampening\n")
14201 DEFUN (bgp_damp_unset
,
14202 bgp_damp_unset_cmd
,
14203 "no bgp dampening",
14205 "BGP Specific commands\n"
14206 "Enable route-flap dampening\n")
14211 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
14214 ALIAS (bgp_damp_unset
,
14215 bgp_damp_unset2_cmd
,
14216 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14218 "BGP Specific commands\n"
14219 "Enable route-flap dampening\n"
14220 "Half-life time for the penalty\n"
14221 "Value to start reusing a route\n"
14222 "Value to start suppressing a route\n"
14223 "Maximum duration to suppress a stable route\n")
14225 ALIAS (bgp_damp_unset
,
14226 bgp_damp_unset3_cmd
,
14227 "no bgp dampening <1-45>",
14229 "BGP Specific commands\n"
14230 "Enable route-flap dampening\n"
14231 "Half-life time for the penalty\n")
14233 DEFUN (show_ip_bgp_dampened_paths
,
14234 show_ip_bgp_dampened_paths_cmd
,
14235 "show ip bgp dampened-paths",
14239 "Display paths suppressed due to dampening\n")
14241 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
14245 ALIAS (show_ip_bgp_dampened_paths
,
14246 show_ip_bgp_damp_dampened_paths_cmd
,
14247 "show ip bgp dampening dampened-paths",
14251 "Display detailed information about dampening\n"
14252 "Display paths suppressed due to dampening\n")
14254 DEFUN (show_ip_bgp_flap_statistics
,
14255 show_ip_bgp_flap_statistics_cmd
,
14256 "show ip bgp flap-statistics",
14260 "Display flap statistics of routes\n")
14262 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
14263 bgp_show_type_flap_statistics
, NULL
, 0);
14266 ALIAS (show_ip_bgp_flap_statistics
,
14267 show_ip_bgp_damp_flap_statistics_cmd
,
14268 "show ip bgp dampening flap-statistics",
14272 "Display detailed information about dampening\n"
14273 "Display flap statistics of routes\n")
14275 /* Display specified route of BGP table. */
14277 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
14278 const char *ip_str
, afi_t afi
, safi_t safi
,
14279 struct prefix_rd
*prd
, int prefix_check
)
14282 struct prefix match
;
14283 struct bgp_node
*rn
;
14284 struct bgp_node
*rm
;
14285 struct bgp_info
*ri
;
14286 struct bgp_info
*ri_temp
;
14288 struct bgp_table
*table
;
14290 /* BGP structure lookup. */
14293 bgp
= bgp_lookup_by_name (view_name
);
14296 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
14297 return CMD_WARNING
;
14302 bgp
= bgp_get_default ();
14305 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14306 return CMD_WARNING
;
14310 /* Check IP address argument. */
14311 ret
= str2prefix (ip_str
, &match
);
14314 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14315 return CMD_WARNING
;
14318 match
.family
= afi2family (afi
);
14320 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14322 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14324 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14327 if ((table
= rn
->info
) != NULL
)
14328 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14330 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14335 if (ri
->extra
&& ri
->extra
->damp_info
)
14337 ri_temp
= ri
->next
;
14338 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14346 bgp_unlock_node (rm
);
14352 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14354 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14359 if (ri
->extra
&& ri
->extra
->damp_info
)
14361 ri_temp
= ri
->next
;
14362 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14370 bgp_unlock_node (rn
);
14374 return CMD_SUCCESS
;
14377 DEFUN (clear_ip_bgp_dampening
,
14378 clear_ip_bgp_dampening_cmd
,
14379 "clear ip bgp dampening",
14383 "Clear route flap dampening information\n")
14385 bgp_damp_info_clean ();
14386 return CMD_SUCCESS
;
14389 DEFUN (clear_ip_bgp_dampening_prefix
,
14390 clear_ip_bgp_dampening_prefix_cmd
,
14391 "clear ip bgp dampening A.B.C.D/M",
14395 "Clear route flap dampening information\n"
14396 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14398 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14399 SAFI_UNICAST
, NULL
, 1);
14402 DEFUN (clear_ip_bgp_dampening_address
,
14403 clear_ip_bgp_dampening_address_cmd
,
14404 "clear ip bgp dampening A.B.C.D",
14408 "Clear route flap dampening information\n"
14409 "Network to clear damping information\n")
14411 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14412 SAFI_UNICAST
, NULL
, 0);
14415 DEFUN (clear_ip_bgp_dampening_address_mask
,
14416 clear_ip_bgp_dampening_address_mask_cmd
,
14417 "clear ip bgp dampening A.B.C.D A.B.C.D",
14421 "Clear route flap dampening information\n"
14422 "Network to clear damping information\n"
14426 char prefix_str
[BUFSIZ
];
14428 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14431 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14432 return CMD_WARNING
;
14435 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14436 SAFI_UNICAST
, NULL
, 0);
14439 /* also used for encap safi */
14441 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14442 afi_t afi
, safi_t safi
, int *write
)
14444 struct bgp_node
*prn
;
14445 struct bgp_node
*rn
;
14446 struct bgp_table
*table
;
14448 struct prefix_rd
*prd
;
14449 struct bgp_static
*bgp_static
;
14451 char buf
[SU_ADDRSTRLEN
];
14452 char rdbuf
[RD_ADDRSTRLEN
];
14454 /* Network configuration. */
14455 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14456 if ((table
= prn
->info
) != NULL
)
14457 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14458 if ((bgp_static
= rn
->info
) != NULL
)
14461 prd
= (struct prefix_rd
*) &prn
->p
;
14463 /* "address-family" display. */
14464 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14466 /* "network" configuration display. */
14467 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14468 label
= decode_label (bgp_static
->tag
);
14470 vty_out (vty
, " network %s/%d rd %s tag %d",
14471 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14474 vty_out (vty
, "%s", VTY_NEWLINE
);
14479 /* Configuration of static route announcement and aggregate
14482 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14483 afi_t afi
, safi_t safi
, int *write
)
14485 struct bgp_node
*rn
;
14487 struct bgp_static
*bgp_static
;
14488 struct bgp_aggregate
*bgp_aggregate
;
14489 char buf
[SU_ADDRSTRLEN
];
14491 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14492 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14494 /* Network configuration. */
14495 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14496 if ((bgp_static
= rn
->info
) != NULL
)
14500 /* "address-family" display. */
14501 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14503 /* "network" configuration display. */
14504 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14506 u_int32_t destination
;
14507 struct in_addr netmask
;
14509 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14510 masklen2ip (p
->prefixlen
, &netmask
);
14511 vty_out (vty
, " network %s",
14512 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14514 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14515 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14516 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14517 || p
->u
.prefix4
.s_addr
== 0)
14519 /* Natural mask is not display. */
14522 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14526 vty_out (vty
, " network %s/%d",
14527 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14531 if (bgp_static
->rmap
.name
)
14532 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14535 if (bgp_static
->backdoor
)
14536 vty_out (vty
, " backdoor");
14539 vty_out (vty
, "%s", VTY_NEWLINE
);
14542 /* Aggregate-address configuration. */
14543 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14544 if ((bgp_aggregate
= rn
->info
) != NULL
)
14548 /* "address-family" display. */
14549 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14551 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14553 struct in_addr netmask
;
14555 masklen2ip (p
->prefixlen
, &netmask
);
14556 vty_out (vty
, " aggregate-address %s %s",
14557 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14558 inet_ntoa (netmask
));
14562 vty_out (vty
, " aggregate-address %s/%d",
14563 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14567 if (bgp_aggregate
->as_set
)
14568 vty_out (vty
, " as-set");
14570 if (bgp_aggregate
->summary_only
)
14571 vty_out (vty
, " summary-only");
14573 vty_out (vty
, "%s", VTY_NEWLINE
);
14580 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
14581 safi_t safi
, int *write
)
14583 struct bgp_node
*rn
;
14584 struct bgp_distance
*bdistance
;
14586 /* Distance configuration. */
14587 if (bgp
->distance_ebgp
[afi
][safi
]
14588 && bgp
->distance_ibgp
[afi
][safi
]
14589 && bgp
->distance_local
[afi
][safi
]
14590 && (bgp
->distance_ebgp
[afi
][safi
] != ZEBRA_EBGP_DISTANCE_DEFAULT
14591 || bgp
->distance_ibgp
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
14592 || bgp
->distance_local
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
))
14594 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14595 vty_out (vty
, " distance bgp %d %d %d%s",
14596 bgp
->distance_ebgp
[afi
][safi
], bgp
->distance_ibgp
[afi
][safi
],
14597 bgp
->distance_local
[afi
][safi
], VTY_NEWLINE
);
14600 for (rn
= bgp_table_top (bgp_distance_table
[afi
][safi
]); rn
;
14601 rn
= bgp_route_next (rn
))
14602 if ((bdistance
= rn
->info
) != NULL
)
14604 char buf
[PREFIX_STRLEN
];
14606 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14607 vty_out (vty
, " distance %d %s %s%s", bdistance
->distance
,
14608 prefix2str (&rn
->p
, buf
, sizeof (buf
)),
14609 bdistance
->access_list
? bdistance
->access_list
: "",
14616 /* Allocate routing table structure and install commands. */
14618 bgp_route_init (void)
14623 /* Init BGP distance table. */
14624 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
14625 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
14626 bgp_distance_table
[afi
][safi
] = bgp_table_init (afi
, safi
);
14628 /* IPv4 BGP commands. */
14629 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14630 install_element (BGP_NODE
, &bgp_network_cmd
);
14631 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14632 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14633 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14634 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14635 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14636 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14637 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14638 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14639 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14640 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14641 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14642 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14643 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14644 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14645 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14646 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14647 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14648 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14650 install_element (BGP_NODE
, &aggregate_address_cmd
);
14651 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14652 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14653 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14654 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14655 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14656 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14657 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14658 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14659 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14660 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14661 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14662 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14663 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14664 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14665 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14666 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14667 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14668 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14669 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14671 /* IPv4 unicast configuration. */
14672 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14673 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14674 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14675 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14676 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14677 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14678 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14679 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14680 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14681 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14682 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14683 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14684 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14685 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14687 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14688 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14689 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14690 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14691 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14692 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14693 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14694 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14695 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14696 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14697 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14698 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14699 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14700 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14701 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14702 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14703 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14704 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14705 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14706 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14708 /* IPv4 multicast configuration. */
14709 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14710 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14711 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14712 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14713 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14714 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14715 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14716 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14717 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14718 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14719 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14720 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14721 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14722 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14723 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14724 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14725 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14726 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14727 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14728 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14729 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14730 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14731 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14732 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14733 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14734 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14735 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14736 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14737 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14738 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14739 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14740 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14741 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14742 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14744 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14745 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14746 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14747 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14748 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14749 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14750 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14751 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14752 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14753 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14754 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14755 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14756 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14757 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14758 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14759 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14760 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14761 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14762 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14763 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14765 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14766 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14767 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14768 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14769 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14770 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14771 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14772 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14773 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14774 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14775 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14776 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14777 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14778 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14779 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14780 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14781 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14782 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14783 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14784 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14785 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14786 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14787 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14788 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14789 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14790 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14791 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14792 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14793 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14794 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14795 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14796 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14797 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14798 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14799 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14800 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14801 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14802 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14803 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14804 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14805 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14806 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14807 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14808 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14809 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14810 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14811 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14812 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14813 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14814 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14815 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14816 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14817 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14818 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14819 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14820 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14821 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14822 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14823 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14824 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14825 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14826 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14827 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14828 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
14829 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14830 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
14831 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
14832 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14833 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14834 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14835 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14836 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14837 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14838 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14839 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14840 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14841 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14842 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14843 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14844 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14845 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14846 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14847 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14848 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14849 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14850 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14852 install_element (VIEW_NODE
, &show_bgp_ipv4_prefix_cmd
);
14853 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_route_cmd
);
14854 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_route_cmd
);
14855 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_prefix_cmd
);
14856 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_prefix_cmd
);
14858 /* BGP dampening clear commands */
14859 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14860 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14861 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14862 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14865 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14866 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14867 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14869 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14870 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14872 /* New config IPv6 BGP commands. */
14873 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14874 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14875 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14876 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14877 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14878 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14880 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14881 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14882 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14883 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14885 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14886 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14888 /* Old config IPv6 BGP commands. */
14889 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14890 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14892 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14893 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14894 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14895 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14897 install_element (VIEW_NODE
, &show_bgp_cmd
);
14898 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14899 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14900 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14901 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14902 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14903 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14904 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14905 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14906 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14907 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14908 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14909 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14910 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14911 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14912 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14913 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14914 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14915 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14916 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14917 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14918 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14919 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14920 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14921 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14922 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14923 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14924 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14925 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14926 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14927 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14928 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14929 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14930 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14931 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14932 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14933 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14934 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14935 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14936 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14937 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14938 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14939 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14940 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14941 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14942 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14943 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14944 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14945 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14946 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14947 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14948 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14949 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14950 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14951 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14952 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14953 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14954 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14955 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14956 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14957 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14958 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14959 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14960 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14961 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14962 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14963 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14964 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14965 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14966 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14967 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14968 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14969 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14970 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14971 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14972 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14973 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14974 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14975 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14976 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14977 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14978 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14979 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14980 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14981 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14982 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14983 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14984 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14985 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14986 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14987 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14988 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14991 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
14992 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
14993 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
14994 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
14997 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
14998 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
14999 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
15000 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
15001 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
15002 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
15003 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
15004 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
15005 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
15006 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
15007 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
15008 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
15009 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
15010 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
15011 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
15012 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
15013 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
15014 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
15015 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
15016 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
15017 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
15018 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
15019 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
15020 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
15021 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
15022 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
15023 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
15024 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
15025 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
15026 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
15027 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
15028 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
15029 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
15030 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
15031 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
15032 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
15035 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
15036 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
15039 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
15040 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
15043 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
15044 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
15045 #endif /* HAVE_IPV6 */
15047 install_element (BGP_NODE
, &bgp_distance_cmd
);
15048 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
15049 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
15050 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
15051 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
15052 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
15053 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
15054 install_element (BGP_IPV4_NODE
, &bgp_distance_cmd
);
15055 install_element (BGP_IPV4_NODE
, &no_bgp_distance_cmd
);
15056 install_element (BGP_IPV4_NODE
, &no_bgp_distance2_cmd
);
15057 install_element (BGP_IPV4_NODE
, &bgp_distance_source_cmd
);
15058 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_cmd
);
15059 install_element (BGP_IPV4_NODE
, &bgp_distance_source_access_list_cmd
);
15060 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_access_list_cmd
);
15061 install_element (BGP_IPV4M_NODE
, &bgp_distance_cmd
);
15062 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_cmd
);
15063 install_element (BGP_IPV4M_NODE
, &no_bgp_distance2_cmd
);
15064 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_cmd
);
15065 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_cmd
);
15066 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_access_list_cmd
);
15067 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_access_list_cmd
);
15068 install_element (BGP_IPV6_NODE
, &bgp_distance_cmd
);
15069 install_element (BGP_IPV6_NODE
, &no_bgp_distance_cmd
);
15070 install_element (BGP_IPV6_NODE
, &no_bgp_distance2_cmd
);
15071 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_cmd
);
15072 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15073 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15074 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15075 install_element (BGP_IPV6M_NODE
, &bgp_distance_cmd
);
15076 install_element (BGP_IPV6M_NODE
, &no_bgp_distance_cmd
);
15077 install_element (BGP_IPV6M_NODE
, &no_bgp_distance2_cmd
);
15078 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_cmd
);
15079 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15080 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15081 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15083 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15084 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15085 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15086 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15087 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15088 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15089 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15090 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15091 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15092 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15093 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15094 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15096 /* IPv4 Multicast Mode */
15097 install_element (BGP_IPV4M_NODE
, &bgp_damp_set_cmd
);
15098 install_element (BGP_IPV4M_NODE
, &bgp_damp_set2_cmd
);
15099 install_element (BGP_IPV4M_NODE
, &bgp_damp_set3_cmd
);
15100 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset_cmd
);
15101 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset2_cmd
);
15105 bgp_route_finish (void)
15110 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
15111 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
15113 bgp_table_unlock (bgp_distance_table
[afi
][safi
]);
15114 bgp_distance_table
[afi
][safi
] = NULL
;