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 && \
1439 (p->family == AF_INET6 || peer_cap_enhe(peer))) || \
1440 (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
1442 /* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
1443 * the peer (group) is configured to receive link-local nexthop unchanged
1444 * and it is available in the prefix OR we're not reflecting the route and
1445 * the peer (group) to whom we're going to announce is on a shared network
1446 * and this is either a self-originated route or the peer is EBGP.
1450 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
1451 if ((CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1452 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
) &&
1453 IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_local
)) ||
1454 (!reflect
&& peer
->shared_network
&&
1455 (from
== bgp
->peer_self
|| peer
->sort
== BGP_PEER_EBGP
)))
1457 attr
->extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
;
1460 /* Clear off link-local nexthop in source, whenever it is not needed to
1461 * ensure more prefixes share the same attribute for announcement.
1463 if (!(CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1464 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)))
1465 memset (&attr
->extra
->mp_nexthop_local
, 0, IPV6_MAX_BYTELEN
);
1467 #endif /* HAVE_IPV6 */
1469 bgp_peer_remove_private_as(bgp
, afi
, safi
, peer
, attr
);
1470 bgp_peer_as_override(bgp
, afi
, safi
, peer
, attr
);
1472 /* Route map & unsuppress-map apply. */
1473 if (ROUTE_MAP_OUT_NAME (filter
)
1474 || (ri
->extra
&& ri
->extra
->suppress
) )
1476 struct bgp_info info
;
1477 struct attr dummy_attr
;
1478 struct attr_extra dummy_extra
;
1480 dummy_attr
.extra
= &dummy_extra
;
1484 /* don't confuse inbound and outbound setting */
1485 RESET_FLAG(attr
->rmap_change_flags
);
1488 * The route reflector is not allowed to modify the attributes
1489 * of the reflected IBGP routes unless explicitly allowed.
1491 if ((from
->sort
== BGP_PEER_IBGP
&& peer
->sort
== BGP_PEER_IBGP
)
1492 && !bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
))
1494 bgp_attr_dup (&dummy_attr
, attr
);
1495 info
.attr
= &dummy_attr
;
1498 SET_FLAG (peer
->rmap_type
, PEER_RMAP_TYPE_OUT
);
1500 if (ri
->extra
&& ri
->extra
->suppress
)
1501 ret
= route_map_apply (UNSUPPRESS_MAP (filter
), p
, RMAP_BGP
, &info
);
1503 ret
= route_map_apply (ROUTE_MAP_OUT (filter
), p
, RMAP_BGP
, &info
);
1505 peer
->rmap_type
= 0;
1507 if (ret
== RMAP_DENYMATCH
)
1509 bgp_attr_flush (attr
);
1514 /* After route-map has been applied, we check to see if the nexthop to
1515 * be carried in the attribute (that is used for the announcement) can
1516 * be cleared off or not. We do this in all cases where we would be
1517 * setting the nexthop to "ourselves". For IPv6, we only need to consider
1518 * the global nexthop here; the link-local nexthop would have been cleared
1519 * already, and if not, it is required by the update formation code.
1520 * Also see earlier comments in this function.
1523 * If route-map has performed some operation on the nexthop or the peer
1524 * configuration says to pass it unchanged, we cannot reset the nexthop
1525 * here, so only attempt to do it if these aren't true. Note that the
1526 * route-map handler itself might have cleared the nexthop, if for example,
1527 * it is configured as 'peer-address'.
1529 if (!bgp_rmap_nhop_changed(attr
->rmap_change_flags
,
1530 riattr
->rmap_change_flags
) &&
1532 !CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_UNCHANGED
))
1534 /* We can reset the nexthop, if setting (or forcing) it to 'self' */
1535 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
) ||
1536 CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_FORCE_NEXTHOP_SELF
))
1539 CHECK_FLAG (peer
->af_flags
[afi
][safi
],
1540 PEER_FLAG_FORCE_NEXTHOP_SELF
))
1541 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ?
1542 AF_INET6
: p
->family
), attr
);
1544 else if (peer
->sort
== BGP_PEER_EBGP
)
1546 /* Can also reset the nexthop if announcing to EBGP, but only if
1547 * no peer in the subgroup is on a shared subnet.
1548 * Note: 3rd party nexthop currently implemented for IPv4 only.
1550 SUBGRP_FOREACH_PEER (subgrp
, paf
)
1552 if (bgp_multiaccess_check_v4 (riattr
->nexthop
, paf
->peer
))
1556 subgroup_announce_reset_nhop ((peer_cap_enhe(peer
) ? AF_INET6
: p
->family
), attr
);
1558 /* If IPv6/MP and nexthop does not have any override and happens to
1559 * be a link-local address, reset it so that we don't pass along the
1560 * source's link-local IPv6 address to recipients who may not be on
1561 * the same interface.
1563 if (p
->family
== AF_INET6
|| peer_cap_enhe(peer
))
1565 if (IN6_IS_ADDR_LINKLOCAL (&attr
->extra
->mp_nexthop_global
))
1566 subgroup_announce_reset_nhop (AF_INET6
, attr
);
1573 struct bgp_info_pair
1575 struct bgp_info
*old
;
1576 struct bgp_info
*new;
1580 bgp_best_selection (struct bgp
*bgp
, struct bgp_node
*rn
,
1581 struct bgp_maxpaths_cfg
*mpath_cfg
,
1582 struct bgp_info_pair
*result
)
1584 struct bgp_info
*new_select
;
1585 struct bgp_info
*old_select
;
1586 struct bgp_info
*ri
;
1587 struct bgp_info
*ri1
;
1588 struct bgp_info
*ri2
;
1589 struct bgp_info
*nextri
= NULL
;
1590 int paths_eq
, do_mpath
, debug
;
1591 struct list mp_list
;
1592 char pfx_buf
[PREFIX2STR_BUFFER
];
1593 char path_buf
[PATH_ADDPATH_STR_BUFFER
];
1595 bgp_mp_list_init (&mp_list
);
1596 do_mpath
= (mpath_cfg
->maxpaths_ebgp
> 1 || mpath_cfg
->maxpaths_ibgp
> 1);
1598 debug
= bgp_debug_bestpath(&rn
->p
);
1601 prefix2str (&rn
->p
, pfx_buf
, sizeof (pfx_buf
));
1603 /* bgp deterministic-med */
1605 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
))
1608 /* Clear BGP_INFO_DMED_SELECTED for all paths */
1609 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1610 bgp_info_unset_flag (rn
, ri1
, BGP_INFO_DMED_SELECTED
);
1612 for (ri1
= rn
->info
; ri1
; ri1
= ri1
->next
)
1614 if (CHECK_FLAG (ri1
->flags
, BGP_INFO_DMED_CHECK
))
1616 if (BGP_INFO_HOLDDOWN (ri1
))
1618 if (ri1
->peer
&& ri1
->peer
!= bgp
->peer_self
)
1619 if (ri1
->peer
->status
!= Established
)
1625 for (ri2
= ri1
->next
; ri2
; ri2
= ri2
->next
)
1627 if (CHECK_FLAG (ri2
->flags
, BGP_INFO_DMED_CHECK
))
1629 if (BGP_INFO_HOLDDOWN (ri2
))
1632 ri2
->peer
!= bgp
->peer_self
&&
1633 !CHECK_FLAG (ri2
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1634 if (ri2
->peer
->status
!= Established
)
1637 if (aspath_cmp_left (ri1
->attr
->aspath
, ri2
->attr
->aspath
)
1638 || aspath_cmp_left_confed (ri1
->attr
->aspath
,
1641 if (bgp_info_cmp (bgp
, ri2
, new_select
, &paths_eq
,
1642 mpath_cfg
, debug
, pfx_buf
))
1644 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1648 bgp_info_set_flag (rn
, ri2
, BGP_INFO_DMED_CHECK
);
1652 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_CHECK
);
1653 bgp_info_set_flag (rn
, new_select
, BGP_INFO_DMED_SELECTED
);
1657 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1658 zlog_debug("%s: %s is the bestpath from AS %d",
1659 pfx_buf
, path_buf
, aspath_get_first_as(new_select
->attr
->aspath
));
1664 /* Check old selected route and new selected route. */
1667 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1669 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
1672 if (BGP_INFO_HOLDDOWN (ri
))
1674 /* reap REMOVED routes, if needs be
1675 * selected route must stay for a while longer though
1677 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
1678 && (ri
!= old_select
))
1679 bgp_info_reap (rn
, ri
);
1685 ri
->peer
!= bgp
->peer_self
&&
1686 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1687 if (ri
->peer
->status
!= Established
)
1690 if (bgp_flag_check (bgp
, BGP_FLAG_DETERMINISTIC_MED
)
1691 && (! CHECK_FLAG (ri
->flags
, BGP_INFO_DMED_SELECTED
)))
1693 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1697 bgp_info_unset_flag (rn
, ri
, BGP_INFO_DMED_CHECK
);
1699 if (bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
))
1705 /* Now that we know which path is the bestpath see if any of the other paths
1706 * qualify as multipaths
1711 bgp_info_path_with_addpath_rx_str (new_select
, path_buf
);
1713 sprintf (path_buf
, "NONE");
1714 zlog_debug("%s: After path selection, newbest is %s oldbest was %s",
1716 old_select
? old_select
->peer
->host
: "NONE");
1719 if (do_mpath
&& new_select
)
1721 for (ri
= rn
->info
; (ri
!= NULL
) && (nextri
= ri
->next
, 1); ri
= nextri
)
1725 bgp_info_path_with_addpath_rx_str (ri
, path_buf
);
1727 if (ri
== new_select
)
1730 zlog_debug("%s: %s is the bestpath, add to the multipath list",
1732 bgp_mp_list_add (&mp_list
, ri
);
1736 if (BGP_INFO_HOLDDOWN (ri
))
1740 ri
->peer
!= bgp
->peer_self
&&
1741 !CHECK_FLAG (ri
->peer
->sflags
, PEER_STATUS_NSF_WAIT
))
1742 if (ri
->peer
->status
!= Established
)
1745 if (!bgp_info_nexthop_cmp (ri
, new_select
))
1748 zlog_debug("%s: %s has the same nexthop as the bestpath, skip it",
1753 bgp_info_cmp (bgp
, ri
, new_select
, &paths_eq
, mpath_cfg
, debug
, pfx_buf
);
1758 zlog_debug("%s: %s is equivalent to the bestpath, add to the multipath list",
1760 bgp_mp_list_add (&mp_list
, ri
);
1765 bgp_info_mpath_update (rn
, new_select
, old_select
, &mp_list
, mpath_cfg
);
1766 bgp_info_mpath_aggregate_update (new_select
, old_select
);
1767 bgp_mp_list_clear (&mp_list
);
1769 result
->old
= old_select
;
1770 result
->new = new_select
;
1776 * A new route/change in bestpath of an existing route. Evaluate the path
1777 * for advertisement to the subgroup.
1780 subgroup_process_announce_selected (struct update_subgroup
*subgrp
,
1781 struct bgp_info
*selected
,
1782 struct bgp_node
*rn
,
1783 u_int32_t addpath_tx_id
)
1786 struct peer
*onlypeer
;
1788 struct attr_extra extra
;
1793 afi
= SUBGRP_AFI(subgrp
);
1794 safi
= SUBGRP_SAFI(subgrp
);
1795 onlypeer
= ((SUBGRP_PCOUNT(subgrp
) == 1) ?
1796 (SUBGRP_PFIRST(subgrp
))->peer
: NULL
);
1798 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1799 if (onlypeer
&& CHECK_FLAG (onlypeer
->af_sflags
[afi
][safi
],
1800 PEER_STATUS_ORF_WAIT_REFRESH
))
1803 memset(&extra
, 0, sizeof(struct attr_extra
));
1804 /* It's initialized in bgp_announce_check() */
1805 attr
.extra
= &extra
;
1807 /* Announcement to the subgroup. If the route is filtered withdraw it. */
1810 if (subgroup_announce_check(selected
, subgrp
, p
, &attr
))
1811 bgp_adj_out_set_subgroup(rn
, subgrp
, &attr
, selected
);
1813 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, selected
->addpath_tx_id
);
1816 /* If selected is NULL we must withdraw the path using addpath_tx_id */
1819 bgp_adj_out_unset_subgroup(rn
, subgrp
, 1, addpath_tx_id
);
1826 * Clear IGP changed flag and attribute changed flag for a route (all paths).
1827 * This is called at the end of route processing.
1830 bgp_zebra_clear_route_change_flags (struct bgp_node
*rn
)
1832 struct bgp_info
*ri
;
1834 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
1836 if (BGP_INFO_HOLDDOWN (ri
))
1838 UNSET_FLAG (ri
->flags
, BGP_INFO_IGP_CHANGED
);
1839 UNSET_FLAG (ri
->flags
, BGP_INFO_ATTR_CHANGED
);
1844 * Has the route changed from the RIB's perspective? This is invoked only
1845 * if the route selection returns the same best route as earlier - to
1846 * determine if we need to update zebra or not.
1849 bgp_zebra_has_route_changed (struct bgp_node
*rn
, struct bgp_info
*selected
)
1851 struct bgp_info
*mpinfo
;
1853 /* If this is multipath, check all selected paths for any nexthop change or
1854 * attribute change. Some attribute changes (e.g., community) aren't of
1855 * relevance to the RIB, but we'll update zebra to ensure we handle the
1856 * case of BGP nexthop change. This is the behavior when the best path has
1857 * an attribute change anyway.
1859 if (CHECK_FLAG (selected
->flags
, BGP_INFO_IGP_CHANGED
) ||
1860 CHECK_FLAG (selected
->flags
, BGP_INFO_MULTIPATH_CHG
))
1863 /* If this is multipath, check all selected paths for any nexthop change */
1864 for (mpinfo
= bgp_info_mpath_first (selected
); mpinfo
;
1865 mpinfo
= bgp_info_mpath_next (mpinfo
))
1867 if (CHECK_FLAG (mpinfo
->flags
, BGP_INFO_IGP_CHANGED
)
1868 || CHECK_FLAG (mpinfo
->flags
, BGP_INFO_ATTR_CHANGED
))
1872 /* Nothing has changed from the RIB's perspective. */
1876 struct bgp_process_queue
1879 struct bgp_node
*rn
;
1884 static wq_item_status
1885 bgp_process_main (struct work_queue
*wq
, void *data
)
1887 struct bgp_process_queue
*pq
= data
;
1888 struct bgp
*bgp
= pq
->bgp
;
1889 struct bgp_node
*rn
= pq
->rn
;
1890 afi_t afi
= pq
->afi
;
1891 safi_t safi
= pq
->safi
;
1892 struct prefix
*p
= &rn
->p
;
1893 struct bgp_info
*new_select
;
1894 struct bgp_info
*old_select
;
1895 struct bgp_info_pair old_and_new
;
1897 /* Is it end of initial update? (after startup) */
1900 quagga_timestamp(3, bgp
->update_delay_zebra_resume_time
,
1901 sizeof(bgp
->update_delay_zebra_resume_time
));
1903 bgp
->main_zebra_update_hold
= 0;
1904 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1905 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1907 bgp_zebra_announce_table(bgp
, afi
, safi
);
1909 bgp
->main_peers_update_hold
= 0;
1911 bgp_start_routeadv(bgp
);
1915 /* Best path selection. */
1916 bgp_best_selection (bgp
, rn
, &bgp
->maxpaths
[afi
][safi
], &old_and_new
);
1917 old_select
= old_and_new
.old
;
1918 new_select
= old_and_new
.new;
1920 /* Nothing to do. */
1921 if (old_select
&& old_select
== new_select
&&
1922 !CHECK_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
) &&
1923 !CHECK_FLAG(old_select
->flags
, BGP_INFO_ATTR_CHANGED
) &&
1924 !bgp
->addpath_tx_used
[afi
][safi
])
1926 if (bgp_zebra_has_route_changed (rn
, old_select
))
1929 vnc_import_bgp_add_route(bgp
, p
, old_select
);
1930 vnc_import_bgp_exterior_add_route(bgp
, p
, old_select
);
1932 bgp_zebra_announce (p
, old_select
, bgp
, afi
, safi
);
1934 UNSET_FLAG (old_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1935 bgp_zebra_clear_route_change_flags (rn
);
1936 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
1940 /* If the user did "clear ip bgp prefix x.x.x.x" this flag will be set */
1941 UNSET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
1943 /* bestpath has changed; bump version */
1944 if (old_select
|| new_select
)
1946 bgp_bump_version(rn
);
1948 if (!bgp
->t_rmap_def_originate_eval
)
1951 THREAD_TIMER_ON(bm
->master
, bgp
->t_rmap_def_originate_eval
,
1952 update_group_refresh_default_originate_route_map
,
1953 bgp
, RMAP_DEFAULT_ORIGINATE_EVAL_TIMER
);
1958 bgp_info_unset_flag (rn
, old_select
, BGP_INFO_SELECTED
);
1961 bgp_info_set_flag (rn
, new_select
, BGP_INFO_SELECTED
);
1962 bgp_info_unset_flag (rn
, new_select
, BGP_INFO_ATTR_CHANGED
);
1963 UNSET_FLAG (new_select
->flags
, BGP_INFO_MULTIPATH_CHG
);
1967 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
1968 if (old_select
!= new_select
) {
1970 vnc_import_bgp_exterior_del_route(bgp
, p
, old_select
);
1971 vnc_import_bgp_del_route(bgp
, p
, old_select
);
1974 vnc_import_bgp_exterior_add_route(bgp
, p
, new_select
);
1975 vnc_import_bgp_add_route(bgp
, p
, new_select
);
1981 group_announce_route(bgp
, afi
, safi
, rn
, new_select
);
1984 if ((safi
== SAFI_UNICAST
|| safi
== SAFI_MULTICAST
) &&
1985 (bgp
->inst_type
!= BGP_INSTANCE_TYPE_VIEW
) &&
1986 !bgp_option_check (BGP_OPT_NO_FIB
))
1989 && new_select
->type
== ZEBRA_ROUTE_BGP
1990 && (new_select
->sub_type
== BGP_ROUTE_NORMAL
||
1991 new_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
1992 bgp_zebra_announce (p
, new_select
, bgp
, afi
, safi
);
1995 /* Withdraw the route from the kernel. */
1997 && old_select
->type
== ZEBRA_ROUTE_BGP
1998 && (old_select
->sub_type
== BGP_ROUTE_NORMAL
||
1999 old_select
->sub_type
== BGP_ROUTE_AGGREGATE
))
2000 bgp_zebra_withdraw (p
, old_select
, safi
);
2004 /* Clear any route change flags. */
2005 bgp_zebra_clear_route_change_flags (rn
);
2007 /* Reap old select bgp_info, if it has been removed */
2008 if (old_select
&& CHECK_FLAG (old_select
->flags
, BGP_INFO_REMOVED
))
2009 bgp_info_reap (rn
, old_select
);
2011 UNSET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2016 bgp_processq_del (struct work_queue
*wq
, void *data
)
2018 struct bgp_process_queue
*pq
= data
;
2019 struct bgp_table
*table
;
2021 bgp_unlock (pq
->bgp
);
2024 table
= bgp_node_table (pq
->rn
);
2025 bgp_unlock_node (pq
->rn
);
2026 bgp_table_unlock (table
);
2028 XFREE (MTYPE_BGP_PROCESS_QUEUE
, pq
);
2032 bgp_process_queue_init (void)
2034 if (!bm
->process_main_queue
)
2036 bm
->process_main_queue
2037 = work_queue_new (bm
->master
, "process_main_queue");
2039 if ( !bm
->process_main_queue
)
2041 zlog_err ("%s: Failed to allocate work queue", __func__
);
2046 bm
->process_main_queue
->spec
.workfunc
= &bgp_process_main
;
2047 bm
->process_main_queue
->spec
.del_item_data
= &bgp_processq_del
;
2048 bm
->process_main_queue
->spec
.max_retries
= 0;
2049 bm
->process_main_queue
->spec
.hold
= 50;
2050 /* Use a higher yield value of 50ms for main queue processing */
2051 bm
->process_main_queue
->spec
.yield
= 50 * 1000L;
2055 bgp_process (struct bgp
*bgp
, struct bgp_node
*rn
, afi_t afi
, safi_t safi
)
2057 struct bgp_process_queue
*pqnode
;
2059 /* already scheduled for processing? */
2060 if (CHECK_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
))
2063 if (bm
->process_main_queue
== NULL
)
2064 bgp_process_queue_init ();
2066 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2067 sizeof (struct bgp_process_queue
));
2071 /* all unlocked in bgp_processq_del */
2072 bgp_table_lock (bgp_node_table (rn
));
2073 pqnode
->rn
= bgp_lock_node (rn
);
2077 pqnode
->safi
= safi
;
2078 work_queue_add (bm
->process_main_queue
, pqnode
);
2079 SET_FLAG (rn
->flags
, BGP_NODE_PROCESS_SCHEDULED
);
2084 bgp_add_eoiu_mark (struct bgp
*bgp
)
2086 struct bgp_process_queue
*pqnode
;
2088 if (bm
->process_main_queue
== NULL
)
2089 bgp_process_queue_init ();
2091 pqnode
= XCALLOC (MTYPE_BGP_PROCESS_QUEUE
,
2092 sizeof (struct bgp_process_queue
));
2099 work_queue_add (bm
->process_main_queue
, pqnode
);
2103 bgp_maximum_prefix_restart_timer (struct thread
*thread
)
2107 peer
= THREAD_ARG (thread
);
2108 peer
->t_pmax_restart
= NULL
;
2110 if (bgp_debug_neighbor_events(peer
))
2111 zlog_debug ("%s Maximum-prefix restart timer expired, restore peering",
2114 peer_clear (peer
, NULL
);
2120 bgp_maximum_prefix_overflow (struct peer
*peer
, afi_t afi
,
2121 safi_t safi
, int always
)
2123 if (!CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
))
2126 if (peer
->pcount
[afi
][safi
] > peer
->pmax
[afi
][safi
])
2128 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
)
2132 zlog_info ("%%MAXPFXEXCEED: No. of %s prefix received from %s %ld exceed, "
2133 "limit %ld", afi_safi_print (afi
, safi
), peer
->host
,
2134 peer
->pcount
[afi
][safi
], peer
->pmax
[afi
][safi
]);
2135 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2137 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_WARNING
))
2143 if (safi
== SAFI_MPLS_VPN
)
2144 safi
= SAFI_MPLS_LABELED_VPN
;
2146 ndata
[0] = (afi
>> 8);
2149 ndata
[3] = (peer
->pmax
[afi
][safi
] >> 24);
2150 ndata
[4] = (peer
->pmax
[afi
][safi
] >> 16);
2151 ndata
[5] = (peer
->pmax
[afi
][safi
] >> 8);
2152 ndata
[6] = (peer
->pmax
[afi
][safi
]);
2154 SET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
2155 bgp_notify_send_with_data (peer
, BGP_NOTIFY_CEASE
,
2156 BGP_NOTIFY_CEASE_MAX_PREFIX
, ndata
, 7);
2159 /* Dynamic peers will just close their connection. */
2160 if (peer_dynamic_neighbor (peer
))
2163 /* restart timer start */
2164 if (peer
->pmax_restart
[afi
][safi
])
2166 peer
->v_pmax_restart
= peer
->pmax_restart
[afi
][safi
] * 60;
2168 if (bgp_debug_neighbor_events(peer
))
2169 zlog_debug ("%s Maximum-prefix restart timer started for %d secs",
2170 peer
->host
, peer
->v_pmax_restart
);
2172 BGP_TIMER_ON (peer
->t_pmax_restart
, bgp_maximum_prefix_restart_timer
,
2173 peer
->v_pmax_restart
);
2179 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_LIMIT
);
2181 if (peer
->pcount
[afi
][safi
] > (peer
->pmax
[afi
][safi
] * peer
->pmax_threshold
[afi
][safi
] / 100))
2183 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
)
2187 zlog_info ("%%MAXPFX: No. of %s prefix received from %s reaches %ld, max %ld",
2188 afi_safi_print (afi
, safi
), peer
->host
, peer
->pcount
[afi
][safi
],
2189 peer
->pmax
[afi
][safi
]);
2190 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2193 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_PREFIX_THRESHOLD
);
2197 /* Unconditionally remove the route from the RIB, without taking
2198 * damping into consideration (eg, because the session went down)
2201 bgp_rib_remove (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2202 afi_t afi
, safi_t safi
)
2204 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2206 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2207 bgp_info_delete (rn
, ri
); /* keep historical info */
2209 bgp_process (peer
->bgp
, rn
, afi
, safi
);
2213 bgp_rib_withdraw (struct bgp_node
*rn
, struct bgp_info
*ri
, struct peer
*peer
,
2214 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
)
2216 int status
= BGP_DAMP_NONE
;
2218 /* apply dampening, if result is suppressed, we'll be retaining
2219 * the bgp_info in the RIB for historical reference.
2221 if (CHECK_FLAG (peer
->bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2222 && peer
->sort
== BGP_PEER_EBGP
)
2223 if ( (status
= bgp_damp_withdraw (ri
, rn
, afi
, safi
, 0))
2224 == BGP_DAMP_SUPPRESSED
)
2226 bgp_aggregate_decrement (peer
->bgp
, &rn
->p
, ri
, afi
, safi
);
2231 if (safi
== SAFI_MPLS_VPN
) {
2232 struct bgp_node
*prn
= NULL
;
2233 struct bgp_table
*table
= NULL
;
2235 prn
= bgp_node_get(peer
->bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2237 table
= (struct bgp_table
*)(prn
->info
);
2239 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2246 bgp_unlock_node(prn
);
2248 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2249 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2251 vnc_import_bgp_del_route(peer
->bgp
, &rn
->p
, ri
);
2252 vnc_import_bgp_exterior_del_route(peer
->bgp
, &rn
->p
, ri
);
2256 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2259 static struct bgp_info
*
2260 info_make (int type
, int sub_type
, u_short instance
, struct peer
*peer
, struct attr
*attr
,
2261 struct bgp_node
*rn
)
2263 struct bgp_info
*new;
2265 /* Make new BGP info. */
2266 new = XCALLOC (MTYPE_BGP_ROUTE
, sizeof (struct bgp_info
));
2268 new->instance
= instance
;
2269 new->sub_type
= sub_type
;
2272 new->uptime
= bgp_clock ();
2274 new->addpath_tx_id
= ++peer
->bgp
->addpath_tx_id
;
2279 bgp_info_addpath_rx_str(u_int32_t addpath_id
, char *buf
)
2282 sprintf(buf
, " with addpath ID %d", addpath_id
);
2286 /* Check if received nexthop is valid or not. */
2288 bgp_update_martian_nexthop (struct bgp
*bgp
, afi_t afi
, safi_t safi
, struct attr
*attr
)
2290 struct attr_extra
*attre
= attr
->extra
;
2293 /* Only validated for unicast and multicast currently. */
2294 if (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
)
2297 /* If NEXT_HOP is present, validate it. */
2298 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP
))
2300 if (attr
->nexthop
.s_addr
== 0 ||
2301 IPV4_CLASS_DE (ntohl (attr
->nexthop
.s_addr
)) ||
2302 bgp_nexthop_self (bgp
, attr
))
2306 /* If MP_NEXTHOP is present, validate it. */
2307 /* Note: For IPv6 nexthops, we only validate the global (1st) nexthop;
2308 * there is code in bgp_attr.c to ignore the link-local (2nd) nexthop if
2309 * it is not an IPv6 link-local address.
2311 if (attre
&& attre
->mp_nexthop_len
)
2313 switch (attre
->mp_nexthop_len
)
2315 case BGP_ATTR_NHLEN_IPV4
:
2316 case BGP_ATTR_NHLEN_VPNV4
:
2317 ret
= (attre
->mp_nexthop_global_in
.s_addr
== 0 ||
2318 IPV4_CLASS_DE (ntohl (attre
->mp_nexthop_global_in
.s_addr
)));
2322 case BGP_ATTR_NHLEN_IPV6_GLOBAL
:
2323 case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
:
2324 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2325 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2326 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2328 #endif /* HAVE_IPV6 */
2340 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2341 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2342 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2346 int aspath_loop_count
= 0;
2347 struct bgp_node
*rn
;
2349 struct attr new_attr
;
2350 struct attr_extra new_extra
;
2351 struct attr
*attr_new
;
2352 struct bgp_info
*ri
;
2353 struct bgp_info
*new;
2355 char buf
[SU_ADDRSTRLEN
];
2358 int do_loop_check
= 1;
2360 int vnc_implicit_withdraw
= 0;
2363 memset (&new_attr
, 0, sizeof(struct attr
));
2364 memset (&new_extra
, 0, sizeof(struct attr_extra
));
2367 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2369 /* When peer's soft reconfiguration enabled. Record input packet in
2371 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2372 && peer
!= bgp
->peer_self
)
2373 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2375 /* Check previously received route. */
2376 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2377 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2378 ri
->addpath_rx_id
== addpath_id
)
2381 /* AS path local-as loop check. */
2382 if (peer
->change_local_as
)
2384 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2385 aspath_loop_count
= 1;
2387 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2389 reason
= "as-path contains our own AS;";
2394 /* If the peer is configured for "allowas-in origin" and the last ASN in the
2395 * as-path is our ASN then we do not need to call aspath_loop_check
2397 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN_ORIGIN
))
2398 if (aspath_get_last_as(attr
->aspath
) == bgp
->as
)
2401 /* AS path loop check. */
2404 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2405 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2406 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
) > peer
->allowas_in
[afi
][safi
]))
2408 reason
= "as-path contains our own AS;";
2413 /* Route reflector originator ID check. */
2414 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2415 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2417 reason
= "originator is us;";
2421 /* Route reflector cluster ID check. */
2422 if (bgp_cluster_filter (peer
, attr
))
2424 reason
= "reflected from the same cluster;";
2428 /* Apply incoming filter. */
2429 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2435 new_attr
.extra
= &new_extra
;
2436 bgp_attr_dup (&new_attr
, attr
);
2438 /* Apply incoming route-map.
2439 * NB: new_attr may now contain newly allocated values from route-map "set"
2440 * commands, so we need bgp_attr_flush in the error paths, until we intern
2441 * the attr (which takes over the memory references) */
2442 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2444 reason
= "route-map;";
2445 bgp_attr_flush (&new_attr
);
2449 /* next hop check. */
2450 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2452 reason
= "martian or self next-hop;";
2453 bgp_attr_flush (&new_attr
);
2457 attr_new
= bgp_attr_intern (&new_attr
);
2459 /* If the update is implicit withdraw. */
2462 ri
->uptime
= bgp_clock ();
2464 /* Same attribute comes in. */
2465 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2466 && attrhash_cmp (ri
->attr
, attr_new
))
2468 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2469 && peer
->sort
== BGP_PEER_EBGP
2470 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2472 if (bgp_debug_update(peer
, p
, NULL
, 1))
2474 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2475 zlog_debug ("%s rcvd %s/%d%s",
2477 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2478 p
->prefixlen
, buf2
);
2481 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2483 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2484 bgp_process (bgp
, rn
, afi
, safi
);
2487 else /* Duplicate - odd */
2489 if (bgp_debug_update(peer
, p
, NULL
, 1))
2491 if (!peer
->rcvd_attr_printed
)
2493 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2494 peer
->rcvd_attr_printed
= 1;
2497 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2498 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2500 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2501 p
->prefixlen
, buf2
);
2504 /* graceful restart STALE flag unset. */
2505 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2507 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2508 bgp_process (bgp
, rn
, afi
, safi
);
2512 bgp_unlock_node (rn
);
2513 bgp_attr_unintern (&attr_new
);
2518 /* Withdraw/Announce before we fully processed the withdraw */
2519 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2521 if (bgp_debug_update(peer
, p
, NULL
, 1))
2523 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2524 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2526 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2527 p
->prefixlen
, buf2
);
2529 bgp_info_restore (rn
, ri
);
2532 /* Received Logging. */
2533 if (bgp_debug_update(peer
, p
, NULL
, 1))
2535 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2536 zlog_debug ("%s rcvd %s/%d%s",
2538 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2539 p
->prefixlen
, buf2
);
2542 /* graceful restart STALE flag unset. */
2543 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2544 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2546 /* The attribute is changed. */
2547 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2549 /* implicit withdraw, decrement aggregate and pcount here.
2550 * only if update is accepted, they'll increment below.
2552 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2554 /* Update bgp route dampening information. */
2555 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2556 && peer
->sort
== BGP_PEER_EBGP
)
2558 /* This is implicit withdraw so we should update dampening
2560 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2561 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2564 if (safi
== SAFI_MPLS_VPN
) {
2565 struct bgp_node
*prn
= NULL
;
2566 struct bgp_table
*table
= NULL
;
2568 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2570 table
= (struct bgp_table
*)(prn
->info
);
2572 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2579 bgp_unlock_node(prn
);
2581 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2582 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2584 * Implicit withdraw case.
2586 ++vnc_implicit_withdraw
;
2587 vnc_import_bgp_del_route(bgp
, p
, ri
);
2588 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
2593 /* Update to new attribute. */
2594 bgp_attr_unintern (&ri
->attr
);
2595 ri
->attr
= attr_new
;
2597 /* Update MPLS tag. */
2598 if (safi
== SAFI_MPLS_VPN
)
2599 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2602 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
2604 if (vnc_implicit_withdraw
)
2607 * Add back the route with its new attributes (e.g., nexthop).
2608 * The route is still selected, until the route selection
2609 * queued by bgp_process actually runs. We have to make this
2610 * update to the VNC side immediately to avoid racing against
2611 * configuration changes (e.g., route-map changes) which
2612 * trigger re-importation of the entire RIB.
2614 vnc_import_bgp_add_route(bgp
, p
, ri
);
2615 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
2620 /* Update bgp route dampening information. */
2621 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2622 && peer
->sort
== BGP_PEER_EBGP
)
2624 /* Now we do normal update dampening. */
2625 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2626 if (ret
== BGP_DAMP_SUPPRESSED
)
2628 bgp_unlock_node (rn
);
2633 /* Nexthop reachability check. */
2634 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2636 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2637 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2638 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2643 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2644 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2647 if (BGP_DEBUG(nht
, NHT
))
2649 char buf1
[INET6_ADDRSTRLEN
];
2650 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2651 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2653 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2657 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2660 if (safi
== SAFI_MPLS_VPN
)
2662 struct bgp_node
*prn
= NULL
;
2663 struct bgp_table
*table
= NULL
;
2665 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2668 table
= (struct bgp_table
*)(prn
->info
);
2670 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2677 bgp_unlock_node(prn
);
2681 /* Process change. */
2682 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2684 bgp_process (bgp
, rn
, afi
, safi
);
2685 bgp_unlock_node (rn
);
2688 } // End of implicit withdraw
2690 /* Received Logging. */
2691 if (bgp_debug_update(peer
, p
, NULL
, 1))
2693 if (!peer
->rcvd_attr_printed
)
2695 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2696 peer
->rcvd_attr_printed
= 1;
2699 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2700 zlog_debug ("%s rcvd %s/%d%s",
2702 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2703 p
->prefixlen
, buf2
);
2706 /* Make new BGP info. */
2707 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2709 /* Update MPLS tag. */
2710 if (safi
== SAFI_MPLS_VPN
)
2711 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2713 /* Nexthop reachability check. */
2714 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2716 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2717 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2718 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2723 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2724 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2727 if (BGP_DEBUG(nht
, NHT
))
2729 char buf1
[INET6_ADDRSTRLEN
];
2730 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2731 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2733 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2737 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2740 new->addpath_rx_id
= addpath_id
;
2742 /* Increment prefix */
2743 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2745 /* Register new BGP information. */
2746 bgp_info_add (rn
, new);
2748 /* route_node_get lock */
2749 bgp_unlock_node (rn
);
2752 if (safi
== SAFI_MPLS_VPN
)
2754 struct bgp_node
*prn
= NULL
;
2755 struct bgp_table
*table
= NULL
;
2757 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2760 table
= (struct bgp_table
*)(prn
->info
);
2762 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2769 bgp_unlock_node(prn
);
2773 /* If maximum prefix count is configured and current prefix
2775 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2778 /* Process change. */
2779 bgp_process (bgp
, rn
, afi
, safi
);
2783 /* This BGP update is filtered. Log the reason then update BGP
2786 if (bgp_debug_update(peer
, p
, NULL
, 1))
2788 if (!peer
->rcvd_attr_printed
)
2790 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2791 peer
->rcvd_attr_printed
= 1;
2794 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2795 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2797 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2798 p
->prefixlen
, buf2
, reason
);
2802 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2804 bgp_unlock_node (rn
);
2810 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2811 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2812 struct prefix_rd
*prd
, u_char
*tag
)
2815 char buf
[SU_ADDRSTRLEN
];
2817 struct bgp_node
*rn
;
2818 struct bgp_info
*ri
;
2823 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2825 /* If peer is soft reconfiguration enabled. Record input packet for
2826 * further calculation.
2828 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2829 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2830 * the iteration over all RS clients.
2831 * Since we need to remove the entry from adj_in anyway, do that first and
2832 * if there was no entry, we don't need to do anything more.
2834 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2835 && peer
!= bgp
->peer_self
)
2836 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2838 if (bgp_debug_update (peer
, p
, NULL
, 1))
2839 zlog_debug ("%s withdrawing route %s/%d "
2840 "not in adj-in", peer
->host
,
2841 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2843 bgp_unlock_node (rn
);
2847 /* Lookup withdrawn route. */
2848 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2849 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2850 ri
->addpath_rx_id
== addpath_id
)
2854 if (bgp_debug_update(peer
, p
, NULL
, 1))
2856 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2857 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2859 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2860 p
->prefixlen
, buf2
);
2863 /* Withdraw specified route from routing table. */
2864 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2865 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
, prd
);
2866 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2867 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2868 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2871 /* Unlock bgp_node_get() lock. */
2872 bgp_unlock_node (rn
);
2878 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2880 struct update_subgroup
*subgrp
;
2881 subgrp
= peer_subgroup(peer
, afi
, safi
);
2882 subgroup_default_originate(subgrp
, withdraw
);
2887 * bgp_stop_announce_route_timer
2890 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2892 if (!paf
->t_announce_route
)
2895 THREAD_TIMER_OFF (paf
->t_announce_route
);
2899 * bgp_announce_route_timer_expired
2901 * Callback that is invoked when the route announcement timer for a
2905 bgp_announce_route_timer_expired (struct thread
*t
)
2907 struct peer_af
*paf
;
2910 paf
= THREAD_ARG (t
);
2913 assert (paf
->t_announce_route
);
2914 paf
->t_announce_route
= NULL
;
2916 if (peer
->status
!= Established
)
2919 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2922 peer_af_announce_route (paf
, 1);
2927 * bgp_announce_route
2929 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2932 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2934 struct peer_af
*paf
;
2935 struct update_subgroup
*subgrp
;
2937 paf
= peer_af_find (peer
, afi
, safi
);
2940 subgrp
= PAF_SUBGRP(paf
);
2943 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2944 * or a refresh has already been triggered.
2946 if (!subgrp
|| paf
->t_announce_route
)
2950 * Start a timer to stagger/delay the announce. This serves
2951 * two purposes - announcement can potentially be combined for
2952 * multiple peers and the announcement doesn't happen in the
2955 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2956 bgp_announce_route_timer_expired
, paf
,
2957 (subgrp
->peer_count
== 1) ?
2958 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2959 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2963 * Announce routes from all AF tables to a peer.
2965 * This should ONLY be called when there is a need to refresh the
2966 * routes to the peer based on a policy change for this peer alone
2967 * or a route refresh request received from the peer.
2968 * The operation will result in splitting the peer from its existing
2969 * subgroups and putting it in new subgroups.
2972 bgp_announce_route_all (struct peer
*peer
)
2977 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2978 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2979 bgp_announce_route (peer
, afi
, safi
);
2983 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2984 struct bgp_table
*table
, struct prefix_rd
*prd
)
2987 struct bgp_node
*rn
;
2988 struct bgp_adj_in
*ain
;
2991 table
= peer
->bgp
->rib
[afi
][safi
];
2993 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2994 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2996 if (ain
->peer
== peer
)
2998 struct bgp_info
*ri
= rn
->info
;
2999 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
3001 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
3002 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
3007 bgp_unlock_node (rn
);
3015 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3017 struct bgp_node
*rn
;
3018 struct bgp_table
*table
;
3020 if (peer
->status
!= Established
)
3023 if ((safi
!= SAFI_MPLS_VPN
) && (safi
!= SAFI_ENCAP
))
3024 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
3026 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3027 rn
= bgp_route_next (rn
))
3028 if ((table
= rn
->info
) != NULL
)
3030 struct prefix_rd prd
;
3031 prd
.family
= AF_UNSPEC
;
3033 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
3035 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
3040 struct bgp_clear_node_queue
3042 struct bgp_node
*rn
;
3045 static wq_item_status
3046 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
3048 struct bgp_clear_node_queue
*cnq
= data
;
3049 struct bgp_node
*rn
= cnq
->rn
;
3050 struct peer
*peer
= wq
->spec
.data
;
3051 struct bgp_info
*ri
;
3052 afi_t afi
= bgp_node_table (rn
)->afi
;
3053 safi_t safi
= bgp_node_table (rn
)->safi
;
3055 assert (rn
&& peer
);
3057 /* It is possible that we have multiple paths for a prefix from a peer
3058 * if that peer is using AddPath.
3060 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3061 if (ri
->peer
== peer
)
3063 /* graceful restart STALE flag set. */
3064 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
3065 && peer
->nsf
[afi
][safi
]
3066 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
3067 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
3068 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
3070 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3076 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
3078 struct bgp_clear_node_queue
*cnq
= data
;
3079 struct bgp_node
*rn
= cnq
->rn
;
3080 struct bgp_table
*table
= bgp_node_table (rn
);
3082 bgp_unlock_node (rn
);
3083 bgp_table_unlock (table
);
3084 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
3088 bgp_clear_node_complete (struct work_queue
*wq
)
3090 struct peer
*peer
= wq
->spec
.data
;
3092 /* Tickle FSM to start moving again */
3093 BGP_EVENT_ADD (peer
, Clearing_Completed
);
3095 peer_unlock (peer
); /* bgp_clear_route */
3099 bgp_clear_node_queue_init (struct peer
*peer
)
3101 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
3103 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
3104 #undef CLEAR_QUEUE_NAME_LEN
3106 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
3108 zlog_err ("%s: Failed to allocate work queue", __func__
);
3111 peer
->clear_node_queue
->spec
.hold
= 10;
3112 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
3113 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
3114 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
3115 peer
->clear_node_queue
->spec
.max_retries
= 0;
3117 /* we only 'lock' this peer reference when the queue is actually active */
3118 peer
->clear_node_queue
->spec
.data
= peer
;
3122 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3123 struct bgp_table
*table
)
3125 struct bgp_node
*rn
;
3126 int force
= bm
->process_main_queue
? 0 : 1;
3129 table
= peer
->bgp
->rib
[afi
][safi
];
3131 /* If still no table => afi/safi isn't configured at all or smth. */
3135 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3137 struct bgp_info
*ri
, *next
;
3138 struct bgp_adj_in
*ain
;
3139 struct bgp_adj_in
*ain_next
;
3141 /* XXX:TODO: This is suboptimal, every non-empty route_node is
3142 * queued for every clearing peer, regardless of whether it is
3143 * relevant to the peer at hand.
3145 * Overview: There are 3 different indices which need to be
3146 * scrubbed, potentially, when a peer is removed:
3148 * 1 peer's routes visible via the RIB (ie accepted routes)
3149 * 2 peer's routes visible by the (optional) peer's adj-in index
3150 * 3 other routes visible by the peer's adj-out index
3152 * 3 there is no hurry in scrubbing, once the struct peer is
3153 * removed from bgp->peer, we could just GC such deleted peer's
3154 * adj-outs at our leisure.
3156 * 1 and 2 must be 'scrubbed' in some way, at least made
3157 * invisible via RIB index before peer session is allowed to be
3158 * brought back up. So one needs to know when such a 'search' is
3163 * - there'd be a single global queue or a single RIB walker
3164 * - rather than tracking which route_nodes still need to be
3165 * examined on a peer basis, we'd track which peers still
3168 * Given that our per-peer prefix-counts now should be reliable,
3169 * this may actually be achievable. It doesn't seem to be a huge
3170 * problem at this time,
3172 * It is possible that we have multiple paths for a prefix from a peer
3173 * if that peer is using AddPath.
3178 ain_next
= ain
->next
;
3180 if (ain
->peer
== peer
)
3182 bgp_adj_in_remove (rn
, ain
);
3183 bgp_unlock_node (rn
);
3189 for (ri
= rn
->info
; ri
; ri
= next
)
3192 if (ri
->peer
!= peer
)
3196 bgp_info_reap (rn
, ri
);
3199 struct bgp_clear_node_queue
*cnq
;
3201 /* both unlocked in bgp_clear_node_queue_del */
3202 bgp_table_lock (bgp_node_table (rn
));
3204 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
3205 sizeof (struct bgp_clear_node_queue
));
3207 work_queue_add (peer
->clear_node_queue
, cnq
);
3216 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3218 struct bgp_node
*rn
;
3219 struct bgp_table
*table
;
3221 if (peer
->clear_node_queue
== NULL
)
3222 bgp_clear_node_queue_init (peer
);
3224 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3225 * Idle until it receives a Clearing_Completed event. This protects
3226 * against peers which flap faster than we can we clear, which could
3229 * a) race with routes from the new session being installed before
3230 * clear_route_node visits the node (to delete the route of that
3232 * b) resource exhaustion, clear_route_node likely leads to an entry
3233 * on the process_main queue. Fast-flapping could cause that queue
3237 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3238 * the unlock will happen upon work-queue completion; other wise, the
3239 * unlock happens at the end of this function.
3241 if (!peer
->clear_node_queue
->thread
)
3244 if (safi
!= SAFI_MPLS_VPN
&& safi
!= SAFI_ENCAP
)
3245 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
3247 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3248 rn
= bgp_route_next (rn
))
3249 if ((table
= rn
->info
) != NULL
)
3250 bgp_clear_route_table (peer
, afi
, safi
, table
);
3252 /* unlock if no nodes got added to the clear-node-queue. */
3253 if (!peer
->clear_node_queue
->thread
)
3259 bgp_clear_route_all (struct peer
*peer
)
3264 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3265 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3266 bgp_clear_route (peer
, afi
, safi
);
3269 rfapiProcessPeerDown(peer
);
3274 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3276 struct bgp_table
*table
;
3277 struct bgp_node
*rn
;
3278 struct bgp_adj_in
*ain
;
3279 struct bgp_adj_in
*ain_next
;
3281 table
= peer
->bgp
->rib
[afi
][safi
];
3283 /* It is possible that we have multiple paths for a prefix from a peer
3284 * if that peer is using AddPath.
3286 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3292 ain_next
= ain
->next
;
3294 if (ain
->peer
== peer
)
3296 bgp_adj_in_remove (rn
, ain
);
3297 bgp_unlock_node (rn
);
3306 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3308 struct bgp_node
*rn
;
3309 struct bgp_info
*ri
;
3310 struct bgp_table
*table
;
3312 table
= peer
->bgp
->rib
[afi
][safi
];
3314 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3316 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3317 if (ri
->peer
== peer
)
3319 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3320 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3327 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3329 struct bgp_node
*rn
;
3330 struct bgp_info
*ri
;
3331 struct bgp_info
*next
;
3333 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3334 for (ri
= rn
->info
; ri
; ri
= next
)
3337 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3338 && ri
->type
== ZEBRA_ROUTE_BGP
3339 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3340 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3343 if (table
->owner
&& table
->owner
->bgp
)
3344 vnc_import_bgp_del_route(table
->owner
->bgp
, &rn
->p
, ri
);
3346 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3347 bgp_info_reap (rn
, ri
);
3352 /* Delete all kernel routes. */
3354 bgp_cleanup_routes (struct bgp
*bgp
)
3358 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3360 struct bgp_node
*rn
;
3362 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3365 * VPN and ENCAP tables are two-level (RD is top level)
3367 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3368 rn
= bgp_route_next (rn
))
3372 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3373 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3375 bgp_unlock_node(rn
);
3379 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_ENCAP
]); rn
;
3380 rn
= bgp_route_next (rn
))
3384 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_ENCAP
);
3385 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3387 bgp_unlock_node(rn
);
3397 bgp_zclient_reset ();
3398 access_list_reset ();
3399 prefix_list_reset ();
3403 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3405 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3406 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3409 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3412 bgp_nlri_parse_ip (struct peer
*peer
, struct attr
*attr
,
3413 struct bgp_nlri
*packet
)
3422 int addpath_encoded
;
3423 u_int32_t addpath_id
;
3425 /* Check peer status. */
3426 if (peer
->status
!= Established
)
3430 lim
= pnt
+ packet
->length
;
3432 safi
= packet
->safi
;
3434 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3436 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3437 syntactic validity. If the field is syntactically incorrect,
3438 then the Error Subcode is set to Invalid Network Field. */
3439 for (; pnt
< lim
; pnt
+= psize
)
3441 /* Clear prefix structure. */
3442 memset (&p
, 0, sizeof (struct prefix
));
3444 if (addpath_encoded
)
3447 /* When packet overflow occurs return immediately. */
3448 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3451 addpath_id
= ntohl(*((uint32_t*) pnt
));
3452 pnt
+= BGP_ADDPATH_ID_LEN
;
3455 /* Fetch prefix length. */
3456 p
.prefixlen
= *pnt
++;
3457 /* afi/safi validity already verified by caller, bgp_update_receive */
3458 p
.family
= afi2family (afi
);
3460 /* Prefix length check. */
3461 if (p
.prefixlen
> prefix_blen (&p
) * 8)
3463 zlog_err("%s [Error] Update packet error (wrong perfix length %d for afi %u)",
3464 peer
->host
, p
.prefixlen
, packet
->afi
);
3468 /* Packet size overflow check. */
3469 psize
= PSIZE (p
.prefixlen
);
3471 /* When packet overflow occur return immediately. */
3472 if (pnt
+ psize
> lim
)
3474 zlog_err("%s [Error] Update packet error (prefix length %d overflows packet)",
3475 peer
->host
, p
.prefixlen
);
3479 /* Defensive coding, double-check the psize fits in a struct prefix */
3480 if (psize
> (ssize_t
) sizeof(p
.u
))
3482 zlog_err("%s [Error] Update packet error (prefix length %d too large for prefix storage %zu)",
3483 peer
->host
, p
.prefixlen
, sizeof(p
.u
));
3487 /* Fetch prefix from NLRI packet. */
3488 memcpy (&p
.u
.prefix
, pnt
, psize
);
3490 /* Check address. */
3491 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3493 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3495 /* From RFC4271 Section 6.3:
3497 * If a prefix in the NLRI field is semantically incorrect
3498 * (e.g., an unexpected multicast IP address), an error SHOULD
3499 * be logged locally, and the prefix SHOULD be ignored.
3501 zlog_err ("%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3502 peer
->host
, inet_ntoa (p
.u
.prefix4
));
3508 /* Check address. */
3509 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3511 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3515 zlog_err ("%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3516 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3520 if (IN6_IS_ADDR_MULTICAST (&p
.u
.prefix6
))
3524 zlog_err ("%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3525 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3530 #endif /* HAVE_IPV6 */
3532 /* Normal process. */
3534 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3535 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3537 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3538 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3540 /* Address family configuration mismatch or maximum-prefix count
3546 /* Packet length consistency check. */
3549 zlog_err ("%s [Error] Update packet error (prefix length mismatch with total length)",
3557 static struct bgp_static
*
3558 bgp_static_new (void)
3560 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3564 bgp_static_free (struct bgp_static
*bgp_static
)
3566 if (bgp_static
->rmap
.name
)
3567 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3568 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3572 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3573 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3575 struct bgp_node
*rn
;
3576 struct bgp_info
*ri
;
3577 struct bgp_info
*new;
3578 struct bgp_info info
;
3580 struct attr
*attr_new
;
3583 int vnc_implicit_withdraw
= 0;
3586 assert (bgp_static
);
3590 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3592 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3594 attr
.nexthop
= bgp_static
->igpnexthop
;
3595 attr
.med
= bgp_static
->igpmetric
;
3596 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3598 if (bgp_static
->atomic
)
3599 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3601 /* Apply route-map. */
3602 if (bgp_static
->rmap
.name
)
3604 struct attr attr_tmp
= attr
;
3605 info
.peer
= bgp
->peer_self
;
3606 info
.attr
= &attr_tmp
;
3608 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3610 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3612 bgp
->peer_self
->rmap_type
= 0;
3614 if (ret
== RMAP_DENYMATCH
)
3616 /* Free uninterned attribute. */
3617 bgp_attr_flush (&attr_tmp
);
3619 /* Unintern original. */
3620 aspath_unintern (&attr
.aspath
);
3621 bgp_attr_extra_free (&attr
);
3622 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3625 attr_new
= bgp_attr_intern (&attr_tmp
);
3628 attr_new
= bgp_attr_intern (&attr
);
3630 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3631 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3632 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3637 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3638 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3639 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3641 bgp_unlock_node (rn
);
3642 bgp_attr_unintern (&attr_new
);
3643 aspath_unintern (&attr
.aspath
);
3644 bgp_attr_extra_free (&attr
);
3649 /* The attribute is changed. */
3650 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3652 /* Rewrite BGP route information. */
3653 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3654 bgp_info_restore(rn
, ri
);
3656 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3658 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3660 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
3663 * Implicit withdraw case.
3664 * We have to do this before ri is changed
3666 ++vnc_implicit_withdraw
;
3667 vnc_import_bgp_del_route(bgp
, p
, ri
);
3668 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
3672 bgp_attr_unintern (&ri
->attr
);
3673 ri
->attr
= attr_new
;
3674 ri
->uptime
= bgp_clock ();
3676 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3678 if (vnc_implicit_withdraw
)
3680 vnc_import_bgp_add_route(bgp
, p
, ri
);
3681 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
3686 /* Nexthop reachability check. */
3687 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3689 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3690 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3693 if (BGP_DEBUG(nht
, NHT
))
3695 char buf1
[INET6_ADDRSTRLEN
];
3696 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3698 zlog_debug("%s(%s): Route not in table, not advertising",
3699 __FUNCTION__
, buf1
);
3701 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3706 /* Delete the NHT structure if any, if we're toggling between
3707 * enabling/disabling import check. We deregister the route
3708 * from NHT to avoid overloading NHT and the process interaction
3710 bgp_unlink_nexthop(ri
);
3711 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3713 /* Process change. */
3714 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3715 bgp_process (bgp
, rn
, afi
, safi
);
3716 bgp_unlock_node (rn
);
3717 aspath_unintern (&attr
.aspath
);
3718 bgp_attr_extra_free (&attr
);
3723 /* Make new BGP info. */
3724 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3726 /* Nexthop reachability check. */
3727 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3729 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3730 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3733 if (BGP_DEBUG(nht
, NHT
))
3735 char buf1
[INET6_ADDRSTRLEN
];
3736 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3738 zlog_debug("%s(%s): Route not in table, not advertising",
3739 __FUNCTION__
, buf1
);
3741 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3746 /* Delete the NHT structure if any, if we're toggling between
3747 * enabling/disabling import check. We deregister the route
3748 * from NHT to avoid overloading NHT and the process interaction
3750 bgp_unlink_nexthop(new);
3752 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3755 /* Aggregate address increment. */
3756 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3758 /* Register new BGP information. */
3759 bgp_info_add (rn
, new);
3761 /* route_node_get lock */
3762 bgp_unlock_node (rn
);
3764 /* Process change. */
3765 bgp_process (bgp
, rn
, afi
, safi
);
3767 /* Unintern original. */
3768 aspath_unintern (&attr
.aspath
);
3769 bgp_attr_extra_free (&attr
);
3773 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3774 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3776 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3780 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3783 struct bgp_node
*rn
;
3784 struct bgp_info
*ri
;
3786 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3788 /* Check selected route and self inserted route. */
3789 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3790 if (ri
->peer
== bgp
->peer_self
3791 && ri
->type
== ZEBRA_ROUTE_BGP
3792 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3795 /* Withdraw static BGP route from routing table. */
3798 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3799 bgp_unlink_nexthop(ri
);
3800 bgp_info_delete (rn
, ri
);
3801 bgp_process (bgp
, rn
, afi
, safi
);
3804 /* Unlock bgp_node_lookup. */
3805 bgp_unlock_node (rn
);
3809 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3812 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3813 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3815 struct bgp_node
*rn
;
3816 struct bgp_info
*ri
;
3818 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3820 /* Check selected route and self inserted route. */
3821 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3822 if (ri
->peer
== bgp
->peer_self
3823 && ri
->type
== ZEBRA_ROUTE_BGP
3824 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3827 /* Withdraw static BGP route from routing table. */
3831 rfapiProcessWithdraw(
3840 1); /* Kill, since it is an administrative change */
3842 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3843 bgp_info_delete (rn
, ri
);
3844 bgp_process (bgp
, rn
, afi
, safi
);
3847 /* Unlock bgp_node_lookup. */
3848 bgp_unlock_node (rn
);
3852 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3853 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3855 struct bgp_node
*rn
;
3856 struct bgp_info
*new;
3857 struct attr
*attr_new
;
3858 struct attr attr
= { 0 };
3859 struct bgp_info
*ri
;
3861 u_int32_t label
= 0;
3864 assert (bgp_static
);
3866 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3868 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3870 attr
.nexthop
= bgp_static
->igpnexthop
;
3871 attr
.med
= bgp_static
->igpmetric
;
3872 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3874 /* Apply route-map. */
3875 if (bgp_static
->rmap
.name
)
3877 struct attr attr_tmp
= attr
;
3878 struct bgp_info info
;
3881 info
.peer
= bgp
->peer_self
;
3882 info
.attr
= &attr_tmp
;
3884 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3886 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3888 bgp
->peer_self
->rmap_type
= 0;
3890 if (ret
== RMAP_DENYMATCH
)
3892 /* Free uninterned attribute. */
3893 bgp_attr_flush (&attr_tmp
);
3895 /* Unintern original. */
3896 aspath_unintern (&attr
.aspath
);
3897 bgp_attr_extra_free (&attr
);
3898 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3903 attr_new
= bgp_attr_intern (&attr_tmp
);
3907 attr_new
= bgp_attr_intern (&attr
);
3910 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3911 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3912 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3917 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3918 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3920 bgp_unlock_node (rn
);
3921 bgp_attr_unintern (&attr_new
);
3922 aspath_unintern (&attr
.aspath
);
3923 bgp_attr_extra_free (&attr
);
3928 /* The attribute is changed. */
3929 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3931 /* Rewrite BGP route information. */
3932 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3933 bgp_info_restore(rn
, ri
);
3935 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3936 bgp_attr_unintern (&ri
->attr
);
3937 ri
->attr
= attr_new
;
3938 ri
->uptime
= bgp_clock ();
3941 label
= decode_label (ri
->extra
->tag
);
3944 /* Process change. */
3945 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3946 bgp_process (bgp
, rn
, afi
, safi
);
3948 rfapiProcessUpdate(ri
->peer
, NULL
, p
, &bgp_static
->prd
,
3949 ri
->attr
, afi
, safi
,
3950 ri
->type
, ri
->sub_type
, &label
);
3952 bgp_unlock_node (rn
);
3953 aspath_unintern (&attr
.aspath
);
3954 bgp_attr_extra_free (&attr
);
3960 /* Make new BGP info. */
3961 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3963 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3964 new->extra
= bgp_info_extra_new();
3965 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
3967 label
= decode_label (bgp_static
->tag
);
3970 /* Aggregate address increment. */
3971 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3973 /* Register new BGP information. */
3974 bgp_info_add (rn
, new);
3976 /* route_node_get lock */
3977 bgp_unlock_node (rn
);
3979 /* Process change. */
3980 bgp_process (bgp
, rn
, afi
, safi
);
3983 rfapiProcessUpdate(new->peer
, NULL
, p
, &bgp_static
->prd
,
3984 new->attr
, afi
, safi
,
3985 new->type
, new->sub_type
, &label
);
3988 /* Unintern original. */
3989 aspath_unintern (&attr
.aspath
);
3990 bgp_attr_extra_free (&attr
);
3993 /* Configure static BGP network. When user don't run zebra, static
3994 route should be installed as valid. */
3996 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3997 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
4001 struct bgp_static
*bgp_static
;
4002 struct bgp_node
*rn
;
4003 u_char need_update
= 0;
4005 /* Convert IP prefix string to struct prefix. */
4006 ret
= str2prefix (ip_str
, &p
);
4009 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4013 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4015 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4019 #endif /* HAVE_IPV6 */
4023 /* Set BGP static route configuration. */
4024 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
4028 /* Configuration change. */
4029 bgp_static
= rn
->info
;
4031 /* Check previous routes are installed into BGP. */
4032 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
4035 bgp_static
->backdoor
= backdoor
;
4039 if (bgp_static
->rmap
.name
)
4040 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4041 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4042 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4046 if (bgp_static
->rmap
.name
)
4047 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4048 bgp_static
->rmap
.name
= NULL
;
4049 bgp_static
->rmap
.map
= NULL
;
4050 bgp_static
->valid
= 0;
4052 bgp_unlock_node (rn
);
4056 /* New configuration. */
4057 bgp_static
= bgp_static_new ();
4058 bgp_static
->backdoor
= backdoor
;
4059 bgp_static
->valid
= 0;
4060 bgp_static
->igpmetric
= 0;
4061 bgp_static
->igpnexthop
.s_addr
= 0;
4065 if (bgp_static
->rmap
.name
)
4066 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4067 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4068 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4070 rn
->info
= bgp_static
;
4073 bgp_static
->valid
= 1;
4075 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4077 if (! bgp_static
->backdoor
)
4078 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
4083 /* Configure static BGP network. */
4085 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4086 afi_t afi
, safi_t safi
)
4090 struct bgp_static
*bgp_static
;
4091 struct bgp_node
*rn
;
4093 /* Convert IP prefix string to struct prefix. */
4094 ret
= str2prefix (ip_str
, &p
);
4097 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4101 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4103 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4107 #endif /* HAVE_IPV6 */
4111 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
4114 vty_out (vty
, "%% Can't find specified static route configuration.%s",
4119 bgp_static
= rn
->info
;
4121 /* Update BGP RIB. */
4122 if (! bgp_static
->backdoor
)
4123 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4125 /* Clear configuration. */
4126 bgp_static_free (bgp_static
);
4128 bgp_unlock_node (rn
);
4129 bgp_unlock_node (rn
);
4135 bgp_static_add (struct bgp
*bgp
)
4139 struct bgp_node
*rn
;
4140 struct bgp_node
*rm
;
4141 struct bgp_table
*table
;
4142 struct bgp_static
*bgp_static
;
4144 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4145 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4146 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4147 if (rn
->info
!= NULL
)
4149 if (safi
== SAFI_MPLS_VPN
)
4153 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4155 bgp_static
= rn
->info
;
4156 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
4161 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
4166 /* Called from bgp_delete(). Delete all static routes from the BGP
4169 bgp_static_delete (struct bgp
*bgp
)
4173 struct bgp_node
*rn
;
4174 struct bgp_node
*rm
;
4175 struct bgp_table
*table
;
4176 struct bgp_static
*bgp_static
;
4178 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4179 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4180 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4181 if (rn
->info
!= NULL
)
4183 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4187 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4189 bgp_static
= rn
->info
;
4190 bgp_static_withdraw_safi (bgp
, &rm
->p
,
4192 (struct prefix_rd
*)&rn
->p
,
4194 bgp_static_free (bgp_static
);
4196 bgp_unlock_node (rn
);
4201 bgp_static
= rn
->info
;
4202 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
4203 bgp_static_free (bgp_static
);
4205 bgp_unlock_node (rn
);
4211 bgp_static_redo_import_check (struct bgp
*bgp
)
4215 struct bgp_node
*rn
;
4216 struct bgp_static
*bgp_static
;
4218 /* Use this flag to force reprocessing of the route */
4219 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4220 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4221 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4222 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4223 if (rn
->info
!= NULL
)
4225 bgp_static
= rn
->info
;
4226 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
4228 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4232 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
4234 struct bgp_table
*table
;
4235 struct bgp_node
*rn
;
4236 struct bgp_info
*ri
;
4238 table
= bgp
->rib
[afi
][safi
];
4239 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
4241 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4243 if (ri
->peer
== bgp
->peer_self
&&
4244 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
4245 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
4246 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
4247 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
4249 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4250 bgp_unlink_nexthop(ri
);
4251 bgp_info_delete (rn
, ri
);
4252 bgp_process (bgp
, rn
, afi
, safi
);
4259 * Purge all networks and redistributed routes from routing table.
4260 * Invoked upon the instance going down.
4263 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4268 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4269 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4270 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4275 * Currently this is used to set static routes for VPN and ENCAP.
4276 * I think it can probably be factored with bgp_static_set.
4279 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4280 const char *rd_str
, const char *tag_str
,
4281 const char *rmap_str
)
4285 struct prefix_rd prd
;
4287 struct bgp_node
*prn
;
4288 struct bgp_node
*rn
;
4289 struct bgp_table
*table
;
4290 struct bgp_static
*bgp_static
;
4295 ret
= str2prefix (ip_str
, &p
);
4298 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4303 ret
= str2prefix_rd (rd_str
, &prd
);
4306 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4310 ret
= str2tag (tag_str
, tag
);
4313 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4317 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4318 (struct prefix
*)&prd
);
4319 if (prn
->info
== NULL
)
4320 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4322 bgp_unlock_node (prn
);
4325 rn
= bgp_node_get (table
, &p
);
4329 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4330 bgp_unlock_node (rn
);
4334 /* New configuration. */
4335 bgp_static
= bgp_static_new ();
4336 bgp_static
->backdoor
= 0;
4337 bgp_static
->valid
= 0;
4338 bgp_static
->igpmetric
= 0;
4339 bgp_static
->igpnexthop
.s_addr
= 0;
4340 memcpy(bgp_static
->tag
, tag
, 3);
4341 bgp_static
->prd
= prd
;
4345 if (bgp_static
->rmap
.name
)
4346 free (bgp_static
->rmap
.name
);
4347 bgp_static
->rmap
.name
= strdup (rmap_str
);
4348 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4350 rn
->info
= bgp_static
;
4352 bgp_static
->valid
= 1;
4353 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4359 /* Configure static BGP network. */
4361 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4362 const char *rd_str
, const char *tag_str
)
4367 struct prefix_rd prd
;
4368 struct bgp_node
*prn
;
4369 struct bgp_node
*rn
;
4370 struct bgp_table
*table
;
4371 struct bgp_static
*bgp_static
;
4376 /* Convert IP prefix string to struct prefix. */
4377 ret
= str2prefix (ip_str
, &p
);
4380 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4385 ret
= str2prefix_rd (rd_str
, &prd
);
4388 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4392 ret
= str2tag (tag_str
, tag
);
4395 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4399 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4400 (struct prefix
*)&prd
);
4401 if (prn
->info
== NULL
)
4402 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4404 bgp_unlock_node (prn
);
4407 rn
= bgp_node_lookup (table
, &p
);
4411 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4413 bgp_static
= rn
->info
;
4414 bgp_static_free (bgp_static
);
4416 bgp_unlock_node (rn
);
4417 bgp_unlock_node (rn
);
4420 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4426 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4427 const char *rmap_name
)
4429 struct bgp_rmap
*rmap
;
4431 rmap
= &bgp
->table_map
[afi
][safi
];
4435 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4436 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4437 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4442 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4447 bgp_zebra_announce_table(bgp
, afi
, safi
);
4453 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4454 const char *rmap_name
)
4456 struct bgp_rmap
*rmap
;
4458 rmap
= &bgp
->table_map
[afi
][safi
];
4460 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4464 bgp_zebra_announce_table(bgp
, afi
, safi
);
4470 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4471 safi_t safi
, int *write
)
4473 if (bgp
->table_map
[afi
][safi
].name
)
4475 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4476 vty_out (vty
, " table-map %s%s",
4477 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4483 DEFUN (bgp_table_map
,
4486 "BGP table to RIB route download filter\n"
4487 "Name of the route map\n")
4489 return bgp_table_map_set (vty
, vty
->index
,
4490 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4492 DEFUN (no_bgp_table_map
,
4493 no_bgp_table_map_cmd
,
4494 "no table-map WORD",
4495 "BGP table to RIB route download filter\n"
4496 "Name of the route map\n")
4498 return bgp_table_map_unset (vty
, vty
->index
,
4499 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4504 "network A.B.C.D/M",
4505 "Specify a network to announce via BGP\n"
4506 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4508 return bgp_static_set (vty
, vty
->index
, argv
[0],
4509 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4512 DEFUN (bgp_network_route_map
,
4513 bgp_network_route_map_cmd
,
4514 "network A.B.C.D/M route-map WORD",
4515 "Specify a network to announce via BGP\n"
4516 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4517 "Route-map to modify the attributes\n"
4518 "Name of the route map\n")
4520 return bgp_static_set (vty
, vty
->index
, argv
[0],
4521 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4524 DEFUN (bgp_network_backdoor
,
4525 bgp_network_backdoor_cmd
,
4526 "network A.B.C.D/M backdoor",
4527 "Specify a network to announce via BGP\n"
4528 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4529 "Specify a BGP backdoor route\n")
4531 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4535 DEFUN (bgp_network_mask
,
4536 bgp_network_mask_cmd
,
4537 "network A.B.C.D mask A.B.C.D",
4538 "Specify a network to announce via BGP\n"
4544 char prefix_str
[BUFSIZ
];
4546 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4549 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4553 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4554 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4557 DEFUN (bgp_network_mask_route_map
,
4558 bgp_network_mask_route_map_cmd
,
4559 "network A.B.C.D mask A.B.C.D route-map WORD",
4560 "Specify a network to announce via BGP\n"
4564 "Route-map to modify the attributes\n"
4565 "Name of the route map\n")
4568 char prefix_str
[BUFSIZ
];
4570 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4573 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4577 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4578 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4581 DEFUN (bgp_network_mask_backdoor
,
4582 bgp_network_mask_backdoor_cmd
,
4583 "network A.B.C.D mask A.B.C.D backdoor",
4584 "Specify a network to announce via BGP\n"
4588 "Specify a BGP backdoor route\n")
4591 char prefix_str
[BUFSIZ
];
4593 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4596 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4600 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4604 DEFUN (bgp_network_mask_natural
,
4605 bgp_network_mask_natural_cmd
,
4607 "Specify a network to announce via BGP\n"
4611 char prefix_str
[BUFSIZ
];
4613 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4616 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4620 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4621 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4624 DEFUN (bgp_network_mask_natural_route_map
,
4625 bgp_network_mask_natural_route_map_cmd
,
4626 "network A.B.C.D route-map WORD",
4627 "Specify a network to announce via BGP\n"
4629 "Route-map to modify the attributes\n"
4630 "Name of the route map\n")
4633 char prefix_str
[BUFSIZ
];
4635 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4638 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4642 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4643 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4646 DEFUN (bgp_network_mask_natural_backdoor
,
4647 bgp_network_mask_natural_backdoor_cmd
,
4648 "network A.B.C.D backdoor",
4649 "Specify a network to announce via BGP\n"
4651 "Specify a BGP backdoor route\n")
4654 char prefix_str
[BUFSIZ
];
4656 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4659 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4663 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4667 DEFUN (no_bgp_network
,
4669 "no network A.B.C.D/M",
4671 "Specify a network to announce via BGP\n"
4672 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4674 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4675 bgp_node_safi (vty
));
4678 ALIAS (no_bgp_network
,
4679 no_bgp_network_route_map_cmd
,
4680 "no network A.B.C.D/M route-map WORD",
4682 "Specify a network to announce via BGP\n"
4683 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4684 "Route-map to modify the attributes\n"
4685 "Name of the route map\n")
4687 ALIAS (no_bgp_network
,
4688 no_bgp_network_backdoor_cmd
,
4689 "no network A.B.C.D/M backdoor",
4691 "Specify a network to announce via BGP\n"
4692 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4693 "Specify a BGP backdoor route\n")
4695 DEFUN (no_bgp_network_mask
,
4696 no_bgp_network_mask_cmd
,
4697 "no network A.B.C.D mask A.B.C.D",
4699 "Specify a network to announce via BGP\n"
4705 char prefix_str
[BUFSIZ
];
4707 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4710 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4714 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4715 bgp_node_safi (vty
));
4718 ALIAS (no_bgp_network_mask
,
4719 no_bgp_network_mask_route_map_cmd
,
4720 "no network A.B.C.D mask A.B.C.D route-map WORD",
4722 "Specify a network to announce via BGP\n"
4726 "Route-map to modify the attributes\n"
4727 "Name of the route map\n")
4729 ALIAS (no_bgp_network_mask
,
4730 no_bgp_network_mask_backdoor_cmd
,
4731 "no network A.B.C.D mask A.B.C.D backdoor",
4733 "Specify a network to announce via BGP\n"
4737 "Specify a BGP backdoor route\n")
4739 DEFUN (no_bgp_network_mask_natural
,
4740 no_bgp_network_mask_natural_cmd
,
4741 "no network A.B.C.D",
4743 "Specify a network to announce via BGP\n"
4747 char prefix_str
[BUFSIZ
];
4749 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4752 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4756 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4757 bgp_node_safi (vty
));
4760 ALIAS (no_bgp_network_mask_natural
,
4761 no_bgp_network_mask_natural_route_map_cmd
,
4762 "no network A.B.C.D route-map WORD",
4764 "Specify a network to announce via BGP\n"
4766 "Route-map to modify the attributes\n"
4767 "Name of the route map\n")
4769 ALIAS (no_bgp_network_mask_natural
,
4770 no_bgp_network_mask_natural_backdoor_cmd
,
4771 "no network A.B.C.D backdoor",
4773 "Specify a network to announce via BGP\n"
4775 "Specify a BGP backdoor route\n")
4778 DEFUN (ipv6_bgp_network
,
4779 ipv6_bgp_network_cmd
,
4780 "network X:X::X:X/M",
4781 "Specify a network to announce via BGP\n"
4782 "IPv6 prefix <network>/<length>\n")
4784 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4788 DEFUN (ipv6_bgp_network_route_map
,
4789 ipv6_bgp_network_route_map_cmd
,
4790 "network X:X::X:X/M route-map WORD",
4791 "Specify a network to announce via BGP\n"
4792 "IPv6 prefix <network>/<length>\n"
4793 "Route-map to modify the attributes\n"
4794 "Name of the route map\n")
4796 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4797 bgp_node_safi (vty
), argv
[1], 0);
4800 DEFUN (no_ipv6_bgp_network
,
4801 no_ipv6_bgp_network_cmd
,
4802 "no network X:X::X:X/M",
4804 "Specify a network to announce via BGP\n"
4805 "IPv6 prefix <network>/<length>\n")
4807 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4810 ALIAS (no_ipv6_bgp_network
,
4811 no_ipv6_bgp_network_route_map_cmd
,
4812 "no network X:X::X:X/M route-map WORD",
4814 "Specify a network to announce via BGP\n"
4815 "IPv6 prefix <network>/<length>\n"
4816 "Route-map to modify the attributes\n"
4817 "Name of the route map\n")
4819 ALIAS (ipv6_bgp_network
,
4820 old_ipv6_bgp_network_cmd
,
4821 "ipv6 bgp network X:X::X:X/M",
4824 "Specify a network to announce via BGP\n"
4825 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4827 ALIAS (no_ipv6_bgp_network
,
4828 old_no_ipv6_bgp_network_cmd
,
4829 "no ipv6 bgp network X:X::X:X/M",
4833 "Specify a network to announce via BGP\n"
4834 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4835 #endif /* HAVE_IPV6 */
4837 /* Aggreagete address:
4839 advertise-map Set condition to advertise attribute
4840 as-set Generate AS set path information
4841 attribute-map Set attributes of aggregate
4842 route-map Set parameters of aggregate
4843 summary-only Filter more specific routes from updates
4844 suppress-map Conditionally filter more specific routes from updates
4847 struct bgp_aggregate
4849 /* Summary-only flag. */
4850 u_char summary_only
;
4852 /* AS set generation. */
4855 /* Route-map for aggregated route. */
4856 struct route_map
*map
;
4858 /* Suppress-count. */
4859 unsigned long count
;
4861 /* SAFI configuration. */
4865 static struct bgp_aggregate
*
4866 bgp_aggregate_new (void)
4868 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4872 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4874 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4877 /* Update an aggregate as routes are added/removed from the BGP table */
4879 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4880 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4881 struct bgp_aggregate
*aggregate
)
4883 struct bgp_table
*table
;
4884 struct bgp_node
*top
;
4885 struct bgp_node
*rn
;
4887 struct aspath
*aspath
= NULL
;
4888 struct aspath
*asmerge
= NULL
;
4889 struct community
*community
= NULL
;
4890 struct community
*commerge
= NULL
;
4891 #if defined(AGGREGATE_NEXTHOP_CHECK)
4892 struct in_addr nexthop
;
4895 struct bgp_info
*ri
;
4896 struct bgp_info
*new;
4898 unsigned long match
= 0;
4899 u_char atomic_aggregate
= 0;
4901 /* Record adding route's nexthop and med. */
4904 #if defined(AGGREGATE_NEXTHOP_CHECK)
4905 nexthop
= rinew
->attr
->nexthop
;
4906 med
= rinew
->attr
->med
;
4910 /* ORIGIN attribute: If at least one route among routes that are
4911 aggregated has ORIGIN with the value INCOMPLETE, then the
4912 aggregated route must have the ORIGIN attribute with the value
4913 INCOMPLETE. Otherwise, if at least one route among routes that
4914 are aggregated has ORIGIN with the value EGP, then the aggregated
4915 route must have the origin attribute with the value EGP. In all
4916 other case the value of the ORIGIN attribute of the aggregated
4917 route is INTERNAL. */
4918 origin
= BGP_ORIGIN_IGP
;
4920 table
= bgp
->rib
[afi
][safi
];
4922 top
= bgp_node_get (table
, p
);
4923 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4924 if (rn
->p
.prefixlen
> p
->prefixlen
)
4928 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4930 if (BGP_INFO_HOLDDOWN (ri
))
4933 if (del
&& ri
== del
)
4936 if (! rinew
&& first
)
4938 #if defined(AGGREGATE_NEXTHOP_CHECK)
4939 nexthop
= ri
->attr
->nexthop
;
4940 med
= ri
->attr
->med
;
4945 #ifdef AGGREGATE_NEXTHOP_CHECK
4946 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4947 || ri
->attr
->med
!= med
)
4950 aspath_free (aspath
);
4952 community_free (community
);
4953 bgp_unlock_node (rn
);
4954 bgp_unlock_node (top
);
4957 #endif /* AGGREGATE_NEXTHOP_CHECK */
4959 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4960 atomic_aggregate
= 1;
4962 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4964 if (aggregate
->summary_only
)
4966 (bgp_info_extra_get (ri
))->suppress
++;
4967 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4973 if (origin
< ri
->attr
->origin
)
4974 origin
= ri
->attr
->origin
;
4976 if (aggregate
->as_set
)
4980 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4981 aspath_free (aspath
);
4985 aspath
= aspath_dup (ri
->attr
->aspath
);
4987 if (ri
->attr
->community
)
4991 commerge
= community_merge (community
,
4992 ri
->attr
->community
);
4993 community
= community_uniq_sort (commerge
);
4994 community_free (commerge
);
4997 community
= community_dup (ri
->attr
->community
);
5003 bgp_process (bgp
, rn
, afi
, safi
);
5005 bgp_unlock_node (top
);
5011 if (aggregate
->summary_only
)
5012 (bgp_info_extra_get (rinew
))->suppress
++;
5014 if (origin
< rinew
->attr
->origin
)
5015 origin
= rinew
->attr
->origin
;
5017 if (aggregate
->as_set
)
5021 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
5022 aspath_free (aspath
);
5026 aspath
= aspath_dup (rinew
->attr
->aspath
);
5028 if (rinew
->attr
->community
)
5032 commerge
= community_merge (community
,
5033 rinew
->attr
->community
);
5034 community
= community_uniq_sort (commerge
);
5035 community_free (commerge
);
5038 community
= community_dup (rinew
->attr
->community
);
5043 if (aggregate
->count
> 0)
5045 rn
= bgp_node_get (table
, p
);
5046 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5047 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5049 atomic_aggregate
), rn
);
5050 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5052 bgp_info_add (rn
, new);
5053 bgp_unlock_node (rn
);
5054 bgp_process (bgp
, rn
, afi
, safi
);
5059 aspath_free (aspath
);
5061 community_free (community
);
5065 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
5066 struct bgp_aggregate
*);
5069 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
5070 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
5072 struct bgp_node
*child
;
5073 struct bgp_node
*rn
;
5074 struct bgp_aggregate
*aggregate
;
5075 struct bgp_table
*table
;
5077 /* MPLS-VPN aggregation is not yet supported. */
5078 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5081 table
= bgp
->aggregate
[afi
][safi
];
5083 /* No aggregates configured. */
5084 if (bgp_table_top_nolock (table
) == NULL
)
5087 if (p
->prefixlen
== 0)
5090 if (BGP_INFO_HOLDDOWN (ri
))
5093 child
= bgp_node_get (table
, p
);
5095 /* Aggregate address configuration check. */
5096 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5097 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5099 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5100 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
5102 bgp_unlock_node (child
);
5106 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
5107 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
5109 struct bgp_node
*child
;
5110 struct bgp_node
*rn
;
5111 struct bgp_aggregate
*aggregate
;
5112 struct bgp_table
*table
;
5114 /* MPLS-VPN aggregation is not yet supported. */
5115 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5118 table
= bgp
->aggregate
[afi
][safi
];
5120 /* No aggregates configured. */
5121 if (bgp_table_top_nolock (table
) == NULL
)
5124 if (p
->prefixlen
== 0)
5127 child
= bgp_node_get (table
, p
);
5129 /* Aggregate address configuration check. */
5130 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5131 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5133 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5134 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
5136 bgp_unlock_node (child
);
5139 /* Called via bgp_aggregate_set when the user configures aggregate-address */
5141 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
5142 struct bgp_aggregate
*aggregate
)
5144 struct bgp_table
*table
;
5145 struct bgp_node
*top
;
5146 struct bgp_node
*rn
;
5147 struct bgp_info
*new;
5148 struct bgp_info
*ri
;
5149 unsigned long match
;
5150 u_char origin
= BGP_ORIGIN_IGP
;
5151 struct aspath
*aspath
= NULL
;
5152 struct aspath
*asmerge
= NULL
;
5153 struct community
*community
= NULL
;
5154 struct community
*commerge
= NULL
;
5155 u_char atomic_aggregate
= 0;
5157 table
= bgp
->rib
[afi
][safi
];
5160 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5162 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5165 /* If routes exists below this node, generate aggregate routes. */
5166 top
= bgp_node_get (table
, p
);
5167 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5168 if (rn
->p
.prefixlen
> p
->prefixlen
)
5172 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5174 if (BGP_INFO_HOLDDOWN (ri
))
5177 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5178 atomic_aggregate
= 1;
5180 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5182 /* summary-only aggregate route suppress aggregated
5183 route announcement. */
5184 if (aggregate
->summary_only
)
5186 (bgp_info_extra_get (ri
))->suppress
++;
5187 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5191 /* If at least one route among routes that are aggregated has
5192 * ORIGIN with the value INCOMPLETE, then the aggregated route
5193 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5194 * Otherwise, if at least one route among routes that are
5195 * aggregated has ORIGIN with the value EGP, then the aggregated
5196 * route MUST have the ORIGIN attribute with the value EGP.
5198 if (origin
< ri
->attr
->origin
)
5199 origin
= ri
->attr
->origin
;
5201 /* as-set aggregate route generate origin, as path,
5202 community aggregation. */
5203 if (aggregate
->as_set
)
5207 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5208 aspath_free (aspath
);
5212 aspath
= aspath_dup (ri
->attr
->aspath
);
5214 if (ri
->attr
->community
)
5218 commerge
= community_merge (community
,
5219 ri
->attr
->community
);
5220 community
= community_uniq_sort (commerge
);
5221 community_free (commerge
);
5224 community
= community_dup (ri
->attr
->community
);
5231 /* If this node is suppressed, process the change. */
5233 bgp_process (bgp
, rn
, afi
, safi
);
5235 bgp_unlock_node (top
);
5237 /* Add aggregate route to BGP table. */
5238 if (aggregate
->count
)
5240 rn
= bgp_node_get (table
, p
);
5241 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5242 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5244 atomic_aggregate
), rn
);
5245 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5247 bgp_info_add (rn
, new);
5248 bgp_unlock_node (rn
);
5250 /* Process change. */
5251 bgp_process (bgp
, rn
, afi
, safi
);
5256 aspath_free (aspath
);
5258 community_free (community
);
5263 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5264 safi_t safi
, struct bgp_aggregate
*aggregate
)
5266 struct bgp_table
*table
;
5267 struct bgp_node
*top
;
5268 struct bgp_node
*rn
;
5269 struct bgp_info
*ri
;
5270 unsigned long match
;
5272 table
= bgp
->rib
[afi
][safi
];
5274 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5276 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5279 /* If routes exists below this node, generate aggregate routes. */
5280 top
= bgp_node_get (table
, p
);
5281 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5282 if (rn
->p
.prefixlen
> p
->prefixlen
)
5286 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5288 if (BGP_INFO_HOLDDOWN (ri
))
5291 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5293 if (aggregate
->summary_only
&& ri
->extra
)
5295 ri
->extra
->suppress
--;
5297 if (ri
->extra
->suppress
== 0)
5299 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5307 /* If this node was suppressed, process the change. */
5309 bgp_process (bgp
, rn
, afi
, safi
);
5311 bgp_unlock_node (top
);
5313 /* Delete aggregate route from BGP table. */
5314 rn
= bgp_node_get (table
, p
);
5316 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5317 if (ri
->peer
== bgp
->peer_self
5318 && ri
->type
== ZEBRA_ROUTE_BGP
5319 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5322 /* Withdraw static BGP route from routing table. */
5325 bgp_info_delete (rn
, ri
);
5326 bgp_process (bgp
, rn
, afi
, safi
);
5329 /* Unlock bgp_node_lookup. */
5330 bgp_unlock_node (rn
);
5333 /* Aggregate route attribute. */
5334 #define AGGREGATE_SUMMARY_ONLY 1
5335 #define AGGREGATE_AS_SET 1
5338 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5339 afi_t afi
, safi_t safi
)
5343 struct bgp_node
*rn
;
5345 struct bgp_aggregate
*aggregate
;
5347 /* Convert string to prefix structure. */
5348 ret
= str2prefix (prefix_str
, &p
);
5351 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5356 /* Get BGP structure. */
5359 /* Old configuration check. */
5360 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5363 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5368 aggregate
= rn
->info
;
5369 if (aggregate
->safi
& SAFI_UNICAST
)
5370 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5371 if (aggregate
->safi
& SAFI_MULTICAST
)
5372 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5374 /* Unlock aggregate address configuration. */
5376 bgp_aggregate_free (aggregate
);
5377 bgp_unlock_node (rn
);
5378 bgp_unlock_node (rn
);
5384 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5385 afi_t afi
, safi_t safi
,
5386 u_char summary_only
, u_char as_set
)
5390 struct bgp_node
*rn
;
5392 struct bgp_aggregate
*aggregate
;
5394 /* Convert string to prefix structure. */
5395 ret
= str2prefix (prefix_str
, &p
);
5398 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5403 /* Get BGP structure. */
5406 /* Old configuration check. */
5407 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5411 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5412 /* try to remove the old entry */
5413 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5416 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5417 bgp_unlock_node (rn
);
5422 /* Make aggregate address structure. */
5423 aggregate
= bgp_aggregate_new ();
5424 aggregate
->summary_only
= summary_only
;
5425 aggregate
->as_set
= as_set
;
5426 aggregate
->safi
= safi
;
5427 rn
->info
= aggregate
;
5429 /* Aggregate address insert into BGP routing table. */
5430 if (safi
& SAFI_UNICAST
)
5431 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5432 if (safi
& SAFI_MULTICAST
)
5433 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5438 DEFUN (aggregate_address
,
5439 aggregate_address_cmd
,
5440 "aggregate-address A.B.C.D/M",
5441 "Configure BGP aggregate entries\n"
5442 "Aggregate prefix\n")
5444 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5447 DEFUN (aggregate_address_mask
,
5448 aggregate_address_mask_cmd
,
5449 "aggregate-address A.B.C.D A.B.C.D",
5450 "Configure BGP aggregate entries\n"
5451 "Aggregate address\n"
5455 char prefix_str
[BUFSIZ
];
5457 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5461 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5465 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5469 DEFUN (aggregate_address_summary_only
,
5470 aggregate_address_summary_only_cmd
,
5471 "aggregate-address A.B.C.D/M summary-only",
5472 "Configure BGP aggregate entries\n"
5473 "Aggregate prefix\n"
5474 "Filter more specific routes from updates\n")
5476 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5477 AGGREGATE_SUMMARY_ONLY
, 0);
5480 DEFUN (aggregate_address_mask_summary_only
,
5481 aggregate_address_mask_summary_only_cmd
,
5482 "aggregate-address A.B.C.D A.B.C.D summary-only",
5483 "Configure BGP aggregate entries\n"
5484 "Aggregate address\n"
5486 "Filter more specific routes from updates\n")
5489 char prefix_str
[BUFSIZ
];
5491 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5495 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5499 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5500 AGGREGATE_SUMMARY_ONLY
, 0);
5503 DEFUN (aggregate_address_as_set
,
5504 aggregate_address_as_set_cmd
,
5505 "aggregate-address A.B.C.D/M as-set",
5506 "Configure BGP aggregate entries\n"
5507 "Aggregate prefix\n"
5508 "Generate AS set path information\n")
5510 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5511 0, AGGREGATE_AS_SET
);
5514 DEFUN (aggregate_address_mask_as_set
,
5515 aggregate_address_mask_as_set_cmd
,
5516 "aggregate-address A.B.C.D A.B.C.D as-set",
5517 "Configure BGP aggregate entries\n"
5518 "Aggregate address\n"
5520 "Generate AS set path information\n")
5523 char prefix_str
[BUFSIZ
];
5525 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5529 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5533 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5534 0, AGGREGATE_AS_SET
);
5538 DEFUN (aggregate_address_as_set_summary
,
5539 aggregate_address_as_set_summary_cmd
,
5540 "aggregate-address A.B.C.D/M as-set summary-only",
5541 "Configure BGP aggregate entries\n"
5542 "Aggregate prefix\n"
5543 "Generate AS set path information\n"
5544 "Filter more specific routes from updates\n")
5546 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5547 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5550 ALIAS (aggregate_address_as_set_summary
,
5551 aggregate_address_summary_as_set_cmd
,
5552 "aggregate-address A.B.C.D/M summary-only as-set",
5553 "Configure BGP aggregate entries\n"
5554 "Aggregate prefix\n"
5555 "Filter more specific routes from updates\n"
5556 "Generate AS set path information\n")
5558 DEFUN (aggregate_address_mask_as_set_summary
,
5559 aggregate_address_mask_as_set_summary_cmd
,
5560 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5561 "Configure BGP aggregate entries\n"
5562 "Aggregate address\n"
5564 "Generate AS set path information\n"
5565 "Filter more specific routes from updates\n")
5568 char prefix_str
[BUFSIZ
];
5570 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5574 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5578 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5579 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5582 ALIAS (aggregate_address_mask_as_set_summary
,
5583 aggregate_address_mask_summary_as_set_cmd
,
5584 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5585 "Configure BGP aggregate entries\n"
5586 "Aggregate address\n"
5588 "Filter more specific routes from updates\n"
5589 "Generate AS set path information\n")
5591 DEFUN (no_aggregate_address
,
5592 no_aggregate_address_cmd
,
5593 "no aggregate-address A.B.C.D/M",
5595 "Configure BGP aggregate entries\n"
5596 "Aggregate prefix\n")
5598 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5601 ALIAS (no_aggregate_address
,
5602 no_aggregate_address_summary_only_cmd
,
5603 "no aggregate-address A.B.C.D/M summary-only",
5605 "Configure BGP aggregate entries\n"
5606 "Aggregate prefix\n"
5607 "Filter more specific routes from updates\n")
5609 ALIAS (no_aggregate_address
,
5610 no_aggregate_address_as_set_cmd
,
5611 "no aggregate-address A.B.C.D/M as-set",
5613 "Configure BGP aggregate entries\n"
5614 "Aggregate prefix\n"
5615 "Generate AS set path information\n")
5617 ALIAS (no_aggregate_address
,
5618 no_aggregate_address_as_set_summary_cmd
,
5619 "no aggregate-address A.B.C.D/M as-set summary-only",
5621 "Configure BGP aggregate entries\n"
5622 "Aggregate prefix\n"
5623 "Generate AS set path information\n"
5624 "Filter more specific routes from updates\n")
5626 ALIAS (no_aggregate_address
,
5627 no_aggregate_address_summary_as_set_cmd
,
5628 "no aggregate-address A.B.C.D/M summary-only as-set",
5630 "Configure BGP aggregate entries\n"
5631 "Aggregate prefix\n"
5632 "Filter more specific routes from updates\n"
5633 "Generate AS set path information\n")
5635 DEFUN (no_aggregate_address_mask
,
5636 no_aggregate_address_mask_cmd
,
5637 "no aggregate-address A.B.C.D A.B.C.D",
5639 "Configure BGP aggregate entries\n"
5640 "Aggregate address\n"
5644 char prefix_str
[BUFSIZ
];
5646 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5650 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5654 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5657 ALIAS (no_aggregate_address_mask
,
5658 no_aggregate_address_mask_summary_only_cmd
,
5659 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5661 "Configure BGP aggregate entries\n"
5662 "Aggregate address\n"
5664 "Filter more specific routes from updates\n")
5666 ALIAS (no_aggregate_address_mask
,
5667 no_aggregate_address_mask_as_set_cmd
,
5668 "no aggregate-address A.B.C.D A.B.C.D as-set",
5670 "Configure BGP aggregate entries\n"
5671 "Aggregate address\n"
5673 "Generate AS set path information\n")
5675 ALIAS (no_aggregate_address_mask
,
5676 no_aggregate_address_mask_as_set_summary_cmd
,
5677 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5679 "Configure BGP aggregate entries\n"
5680 "Aggregate address\n"
5682 "Generate AS set path information\n"
5683 "Filter more specific routes from updates\n")
5685 ALIAS (no_aggregate_address_mask
,
5686 no_aggregate_address_mask_summary_as_set_cmd
,
5687 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5689 "Configure BGP aggregate entries\n"
5690 "Aggregate address\n"
5692 "Filter more specific routes from updates\n"
5693 "Generate AS set path information\n")
5696 DEFUN (ipv6_aggregate_address
,
5697 ipv6_aggregate_address_cmd
,
5698 "aggregate-address X:X::X:X/M",
5699 "Configure BGP aggregate entries\n"
5700 "Aggregate prefix\n")
5702 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5705 DEFUN (ipv6_aggregate_address_summary_only
,
5706 ipv6_aggregate_address_summary_only_cmd
,
5707 "aggregate-address X:X::X:X/M summary-only",
5708 "Configure BGP aggregate entries\n"
5709 "Aggregate prefix\n"
5710 "Filter more specific routes from updates\n")
5712 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5713 AGGREGATE_SUMMARY_ONLY
, 0);
5716 DEFUN (no_ipv6_aggregate_address
,
5717 no_ipv6_aggregate_address_cmd
,
5718 "no aggregate-address X:X::X:X/M",
5720 "Configure BGP aggregate entries\n"
5721 "Aggregate prefix\n")
5723 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5726 DEFUN (no_ipv6_aggregate_address_summary_only
,
5727 no_ipv6_aggregate_address_summary_only_cmd
,
5728 "no aggregate-address X:X::X:X/M summary-only",
5730 "Configure BGP aggregate entries\n"
5731 "Aggregate prefix\n"
5732 "Filter more specific routes from updates\n")
5734 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5737 ALIAS (ipv6_aggregate_address
,
5738 old_ipv6_aggregate_address_cmd
,
5739 "ipv6 bgp aggregate-address X:X::X:X/M",
5742 "Configure BGP aggregate entries\n"
5743 "Aggregate prefix\n")
5745 ALIAS (ipv6_aggregate_address_summary_only
,
5746 old_ipv6_aggregate_address_summary_only_cmd
,
5747 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5750 "Configure BGP aggregate entries\n"
5751 "Aggregate prefix\n"
5752 "Filter more specific routes from updates\n")
5754 ALIAS (no_ipv6_aggregate_address
,
5755 old_no_ipv6_aggregate_address_cmd
,
5756 "no ipv6 bgp aggregate-address X:X::X:X/M",
5760 "Configure BGP aggregate entries\n"
5761 "Aggregate prefix\n")
5763 ALIAS (no_ipv6_aggregate_address_summary_only
,
5764 old_no_ipv6_aggregate_address_summary_only_cmd
,
5765 "no ipv6 bgp 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")
5772 #endif /* HAVE_IPV6 */
5774 /* Redistribute route treatment. */
5776 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5777 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5778 u_int32_t metric
, u_char type
, u_short instance
, route_tag_t tag
)
5780 struct bgp_info
*new;
5781 struct bgp_info
*bi
;
5782 struct bgp_info info
;
5783 struct bgp_node
*bn
;
5785 struct attr
*new_attr
;
5788 struct bgp_redist
*red
;
5790 /* Make default attribute. */
5791 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5793 attr
.nexthop
= *nexthop
;
5794 attr
.nh_ifindex
= ifindex
;
5799 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5800 extra
->mp_nexthop_global
= *nexthop6
;
5801 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5806 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5807 attr
.extra
->tag
= tag
;
5809 afi
= family2afi (p
->family
);
5811 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5814 struct attr attr_new
;
5815 struct attr_extra extra_new
;
5817 /* Copy attribute for modification. */
5818 attr_new
.extra
= &extra_new
;
5819 bgp_attr_dup (&attr_new
, &attr
);
5821 if (red
->redist_metric_flag
)
5822 attr_new
.med
= red
->redist_metric
;
5824 /* Apply route-map. */
5827 info
.peer
= bgp
->peer_self
;
5828 info
.attr
= &attr_new
;
5830 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5832 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5834 bgp
->peer_self
->rmap_type
= 0;
5836 if (ret
== RMAP_DENYMATCH
)
5838 /* Free uninterned attribute. */
5839 bgp_attr_flush (&attr_new
);
5841 /* Unintern original. */
5842 aspath_unintern (&attr
.aspath
);
5843 bgp_attr_extra_free (&attr
);
5844 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5849 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5850 afi
, SAFI_UNICAST
, p
, NULL
);
5852 new_attr
= bgp_attr_intern (&attr_new
);
5854 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5855 if (bi
->peer
== bgp
->peer_self
5856 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5861 /* Ensure the (source route) type is updated. */
5863 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5864 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5866 bgp_attr_unintern (&new_attr
);
5867 aspath_unintern (&attr
.aspath
);
5868 bgp_attr_extra_free (&attr
);
5869 bgp_unlock_node (bn
);
5874 /* The attribute is changed. */
5875 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5877 /* Rewrite BGP route information. */
5878 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5879 bgp_info_restore(bn
, bi
);
5881 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5882 bgp_attr_unintern (&bi
->attr
);
5883 bi
->attr
= new_attr
;
5884 bi
->uptime
= bgp_clock ();
5886 /* Process change. */
5887 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5888 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5889 bgp_unlock_node (bn
);
5890 aspath_unintern (&attr
.aspath
);
5891 bgp_attr_extra_free (&attr
);
5896 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5898 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5900 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5901 bgp_info_add (bn
, new);
5902 bgp_unlock_node (bn
);
5903 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5906 /* Unintern original. */
5907 aspath_unintern (&attr
.aspath
);
5908 bgp_attr_extra_free (&attr
);
5912 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5915 struct bgp_node
*rn
;
5916 struct bgp_info
*ri
;
5917 struct bgp_redist
*red
;
5919 afi
= family2afi (p
->family
);
5921 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5924 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5926 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5927 if (ri
->peer
== bgp
->peer_self
5928 && ri
->type
== type
)
5933 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5934 bgp_info_delete (rn
, ri
);
5935 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5937 bgp_unlock_node (rn
);
5941 /* Withdraw specified route type's route. */
5943 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5945 struct bgp_node
*rn
;
5946 struct bgp_info
*ri
;
5947 struct bgp_table
*table
;
5949 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5951 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5953 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5954 if (ri
->peer
== bgp
->peer_self
5956 && ri
->instance
== instance
)
5961 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5962 bgp_info_delete (rn
, ri
);
5963 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5968 /* Static function to display route. */
5970 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5973 u_int32_t destination
;
5976 if (p
->family
== AF_INET
)
5978 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5979 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5981 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5982 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5983 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5984 || p
->u
.prefix4
.s_addr
== 0)
5986 /* When mask is natural, mask is not displayed. */
5989 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5992 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5997 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
5999 vty_out (vty
, "%*s", len
, " ");
6002 enum bgp_display_type
6007 /* Print the short form route status for a bgp_info */
6009 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
6010 json_object
*json_path
)
6015 /* Route status display. */
6016 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6017 json_object_boolean_true_add(json_path
, "removed");
6019 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6020 json_object_boolean_true_add(json_path
, "stale");
6022 if (binfo
->extra
&& binfo
->extra
->suppress
)
6023 json_object_boolean_true_add(json_path
, "suppressed");
6025 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6026 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6027 json_object_boolean_true_add(json_path
, "valid");
6030 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6031 json_object_boolean_true_add(json_path
, "history");
6033 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6034 json_object_boolean_true_add(json_path
, "damped");
6036 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6037 json_object_boolean_true_add(json_path
, "bestpath");
6039 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6040 json_object_boolean_true_add(json_path
, "multipath");
6042 /* Internal route. */
6043 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6044 json_object_string_add(json_path
, "pathFrom", "internal");
6046 json_object_string_add(json_path
, "pathFrom", "external");
6051 /* Route status display. */
6052 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6054 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6056 else if (binfo
->extra
&& binfo
->extra
->suppress
)
6058 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6059 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6065 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6067 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6069 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6071 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6076 /* Internal route. */
6077 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6083 /* called from terminal list command */
6085 route_vty_out (struct vty
*vty
, struct prefix
*p
,
6086 struct bgp_info
*binfo
, int display
, safi_t safi
,
6087 json_object
*json_paths
)
6090 json_object
*json_path
= NULL
;
6091 json_object
*json_nexthops
= NULL
;
6092 json_object
*json_nexthop_global
= NULL
;
6093 json_object
*json_nexthop_ll
= NULL
;
6096 json_path
= json_object_new_object();
6098 /* short status lead text */
6099 route_vty_short_status_out (vty
, binfo
, json_path
);
6103 /* print prefix and mask */
6105 route_vty_out_route (p
, vty
);
6107 vty_out (vty
, "%*s", 17, " ");
6110 /* Print attribute */
6115 * For ENCAP routes, nexthop address family is not
6116 * neccessarily the same as the prefix address family.
6117 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
6119 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
6124 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
6129 vty_out (vty
, "%s", inet_ntop(af
,
6130 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
6134 vty_out (vty
, "%s", inet_ntop(af
,
6135 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
6147 else if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6151 json_nexthop_global
= json_object_new_object();
6153 if (safi
== SAFI_MPLS_VPN
)
6154 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6156 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6158 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6159 json_object_boolean_true_add(json_nexthop_global
, "used");
6163 if (safi
== SAFI_MPLS_VPN
)
6164 vty_out (vty
, "%-16s",
6165 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6167 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6172 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6179 json_nexthop_global
= json_object_new_object();
6180 json_object_string_add(json_nexthop_global
, "ip",
6181 inet_ntop (AF_INET6
,
6182 &attr
->extra
->mp_nexthop_global
,
6184 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6185 json_object_string_add(json_nexthop_global
, "scope", "global");
6187 /* We display both LL & GL if both have been received */
6188 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
6190 json_nexthop_ll
= json_object_new_object();
6191 json_object_string_add(json_nexthop_ll
, "ip",
6192 inet_ntop (AF_INET6
,
6193 &attr
->extra
->mp_nexthop_local
,
6195 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6196 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6198 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
6199 &attr
->extra
->mp_nexthop_local
) != 0) &&
6200 !attr
->extra
->mp_nexthop_prefer_global
)
6201 json_object_boolean_true_add(json_nexthop_ll
, "used");
6203 json_object_boolean_true_add(json_nexthop_global
, "used");
6206 json_object_boolean_true_add(json_nexthop_global
, "used");
6210 /* Display LL if LL/Global both in table unless prefer-global is set */
6211 if (((attr
->extra
->mp_nexthop_len
== 32) &&
6212 !attr
->extra
->mp_nexthop_prefer_global
) ||
6213 (binfo
->peer
->conf_if
))
6215 if (binfo
->peer
->conf_if
)
6217 len
= vty_out (vty
, "%s",
6218 binfo
->peer
->conf_if
);
6219 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6222 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6224 vty_out (vty
, "%*s", len
, " ");
6228 len
= vty_out (vty
, "%s",
6229 inet_ntop (AF_INET6
,
6230 &attr
->extra
->mp_nexthop_local
,
6235 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6237 vty_out (vty
, "%*s", len
, " ");
6242 len
= vty_out (vty
, "%s",
6243 inet_ntop (AF_INET6
,
6244 &attr
->extra
->mp_nexthop_global
,
6249 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6251 vty_out (vty
, "%*s", len
, " ");
6257 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6259 json_object_int_add(json_path
, "med", attr
->med
);
6261 vty_out (vty
, "%10u", attr
->med
);
6267 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6269 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6271 vty_out (vty
, "%7u", attr
->local_pref
);
6279 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6281 json_object_int_add(json_path
, "weight", 0);
6284 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6288 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6295 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6297 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6302 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6304 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6309 json_object_string_add(json_path
, "alert", "No attributes");
6311 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6316 if (json_nexthop_global
|| json_nexthop_ll
)
6318 json_nexthops
= json_object_new_array();
6320 if (json_nexthop_global
)
6321 json_object_array_add(json_nexthops
, json_nexthop_global
);
6323 if (json_nexthop_ll
)
6324 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6326 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6329 json_object_array_add(json_paths
, json_path
);
6333 vty_out (vty
, "%s", VTY_NEWLINE
);
6335 /* prints an additional line, indented, with VNC info, if present */
6336 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
6337 rfapi_vty_out_vncinfo(vty
, p
, binfo
, safi
);
6342 /* called from terminal list command */
6344 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6345 u_char use_json
, json_object
*json_ar
)
6347 json_object
*json_status
= NULL
;
6348 json_object
*json_net
= NULL
;
6350 /* Route status display. */
6353 json_status
= json_object_new_object();
6354 json_net
= json_object_new_object();
6363 /* print prefix and mask */
6365 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6367 route_vty_out_route (p
, vty
);
6369 /* Print attribute */
6374 if (p
->family
== AF_INET
&&
6375 (safi
== SAFI_MPLS_VPN
||
6376 safi
== SAFI_ENCAP
||
6377 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6379 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6380 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6382 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6385 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6389 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6392 #endif /* HAVE_IPV6 */
6394 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6395 json_object_int_add(json_net
, "metric", attr
->med
);
6397 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6398 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6401 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6403 json_object_int_add(json_net
, "weight", 0);
6407 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6410 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6414 if (p
->family
== AF_INET
&&
6415 (safi
== SAFI_MPLS_VPN
||
6416 safi
== SAFI_ENCAP
||
6417 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6420 (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
))
6421 vty_out (vty
, "%-16s",
6422 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6424 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6427 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6433 len
= vty_out (vty
, "%s",
6434 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6441 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6443 vty_out (vty
, "%*s", len
, " ");
6445 #endif /* HAVE_IPV6 */
6446 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6447 vty_out (vty
, "%10u", attr
->med
);
6451 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6452 vty_out (vty
, "%7u", attr
->local_pref
);
6456 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6460 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6463 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6468 json_object_boolean_true_add(json_status
, "*");
6469 json_object_boolean_true_add(json_status
, ">");
6470 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6471 char buf_cut
[BUFSIZ
];
6472 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6475 vty_out (vty
, "%s", VTY_NEWLINE
);
6479 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6480 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6482 json_object
*json_out
= NULL
;
6484 u_int32_t label
= 0;
6490 json_out
= json_object_new_object();
6492 /* short status lead text */
6493 route_vty_short_status_out (vty
, binfo
, json_out
);
6495 /* print prefix and mask */
6499 route_vty_out_route (p
, vty
);
6501 vty_out (vty
, "%*s", 17, " ");
6504 /* Print attribute */
6508 if (p
->family
== AF_INET
6509 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6511 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6514 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6516 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6521 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6523 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6527 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6529 assert (attr
->extra
);
6533 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6536 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6537 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6540 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6543 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6547 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6549 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6551 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6552 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6555 vty_out (vty
, "%s(%s)",
6556 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6558 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6563 #endif /* HAVE_IPV6 */
6566 label
= decode_label (binfo
->extra
->tag
);
6571 json_object_int_add(json_out
, "notag", label
);
6572 json_object_array_add(json
, json_out
);
6576 vty_out (vty
, "notag/%d", label
);
6577 vty_out (vty
, "%s", VTY_NEWLINE
);
6581 /* dampening route */
6583 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6584 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6588 char timebuf
[BGP_UPTIME_LEN
];
6590 /* short status lead text */
6591 route_vty_short_status_out (vty
, binfo
, json
);
6593 /* print prefix and mask */
6597 route_vty_out_route (p
, vty
);
6599 vty_out (vty
, "%*s", 17, " ");
6602 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6607 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6612 json_object_int_add(json
, "peerHost", len
);
6614 vty_out (vty
, "%*s", len
, " ");
6618 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6620 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6622 /* Print attribute */
6630 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6632 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6637 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6639 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6642 vty_out (vty
, "%s", VTY_NEWLINE
);
6647 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6648 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6651 struct bgp_damp_info
*bdi
;
6652 char timebuf
[BGP_UPTIME_LEN
];
6658 bdi
= binfo
->extra
->damp_info
;
6660 /* short status lead text */
6661 route_vty_short_status_out (vty
, binfo
, json
);
6663 /* print prefix and mask */
6667 route_vty_out_route (p
, vty
);
6669 vty_out (vty
, "%*s", 17, " ");
6672 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6677 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6682 json_object_int_add(json
, "peerHost", len
);
6684 vty_out (vty
, "%*s", len
, " ");
6687 len
= vty_out (vty
, "%d", bdi
->flap
);
6697 json_object_int_add(json
, "bdiFlap", len
);
6699 vty_out (vty
, "%*s", len
, " ");
6703 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6705 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6706 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6708 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6709 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6712 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6714 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6719 vty_out (vty
, "%*s ", 8, " ");
6722 /* Print attribute */
6730 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6732 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6737 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6739 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6742 vty_out (vty
, "%s", VTY_NEWLINE
);
6746 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6747 const char *header
, json_object
*json_adv_to
)
6749 char buf1
[INET6_ADDRSTRLEN
];
6750 json_object
*json_peer
= NULL
;
6754 /* 'advertised-to' is a dictionary of peers we have advertised this
6755 * prefix too. The key is the peer's IP or swpX, the value is the
6756 * hostname if we know it and "" if not.
6758 json_peer
= json_object_new_object();
6761 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6764 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6766 json_object_object_add(json_adv_to
,
6767 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6774 vty_out (vty
, "%s", header
);
6778 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6781 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6783 vty_out (vty
, " %s(%s)", peer
->hostname
,
6784 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6789 vty_out (vty
, " %s", peer
->conf_if
);
6791 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6797 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6798 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6799 json_object
*json_paths
)
6801 char buf
[INET6_ADDRSTRLEN
];
6804 int sockunion_vty_out (struct vty
*, union sockunion
*);
6805 #ifdef HAVE_CLOCK_MONOTONIC
6808 json_object
*json_bestpath
= NULL
;
6809 json_object
*json_cluster_list
= NULL
;
6810 json_object
*json_cluster_list_list
= NULL
;
6811 json_object
*json_ext_community
= NULL
;
6812 json_object
*json_last_update
= NULL
;
6813 json_object
*json_nexthop_global
= NULL
;
6814 json_object
*json_nexthop_ll
= NULL
;
6815 json_object
*json_nexthops
= NULL
;
6816 json_object
*json_path
= NULL
;
6817 json_object
*json_peer
= NULL
;
6818 json_object
*json_string
= NULL
;
6819 json_object
*json_adv_to
= NULL
;
6821 struct listnode
*node
, *nnode
;
6823 int addpath_capable
;
6825 unsigned int first_as
;
6829 json_path
= json_object_new_object();
6830 json_peer
= json_object_new_object();
6831 json_nexthop_global
= json_object_new_object();
6838 /* Line1 display AS-path, Aggregator */
6843 json_object_lock(attr
->aspath
->json
);
6844 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6848 if (attr
->aspath
->segments
)
6849 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6851 vty_out (vty
, " Local");
6855 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6858 json_object_boolean_true_add(json_path
, "removed");
6860 vty_out (vty
, ", (removed)");
6863 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6866 json_object_boolean_true_add(json_path
, "stale");
6868 vty_out (vty
, ", (stale)");
6871 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6875 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6876 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6880 vty_out (vty
, ", (aggregated by %u %s)",
6881 attr
->extra
->aggregator_as
,
6882 inet_ntoa (attr
->extra
->aggregator_addr
));
6886 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6889 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6891 vty_out (vty
, ", (Received from a RR-client)");
6894 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6897 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6899 vty_out (vty
, ", (Received from a RS-client)");
6902 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6905 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6907 vty_out (vty
, ", (history entry)");
6909 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6912 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6914 vty_out (vty
, ", (suppressed due to dampening)");
6918 vty_out (vty
, "%s", VTY_NEWLINE
);
6920 /* Line2 display Next-hop, Neighbor, Router-id */
6921 /* Display the nexthop */
6922 if (p
->family
== AF_INET
&&
6923 (safi
== SAFI_MPLS_VPN
||
6924 safi
== SAFI_ENCAP
||
6925 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6927 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6930 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6932 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6937 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6939 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6943 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6947 assert (attr
->extra
);
6950 json_object_string_add(json_nexthop_global
, "ip",
6951 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6952 buf
, INET6_ADDRSTRLEN
));
6953 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6954 json_object_string_add(json_nexthop_global
, "scope", "global");
6958 vty_out (vty
, " %s",
6959 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6960 buf
, INET6_ADDRSTRLEN
));
6964 /* Display the IGP cost or 'inaccessible' */
6965 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6968 json_object_boolean_false_add(json_nexthop_global
, "accessible");
6970 vty_out (vty
, " (inaccessible)");
6974 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6977 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
6979 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
6982 /* IGP cost is 0, display this only for json */
6986 json_object_int_add(json_nexthop_global
, "metric", 0);
6990 json_object_boolean_true_add(json_nexthop_global
, "accessible");
6993 /* Display peer "from" output */
6994 /* This path was originated locally */
6995 if (binfo
->peer
== bgp
->peer_self
)
6998 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
7001 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
7003 vty_out (vty
, " from 0.0.0.0 ");
7008 json_object_string_add(json_peer
, "peerId", "::");
7010 vty_out (vty
, " from :: ");
7014 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
7016 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
7019 /* We RXed this path from one of our peers */
7025 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7026 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7028 if (binfo
->peer
->hostname
)
7029 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
7031 if (binfo
->peer
->domainname
)
7032 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
7034 if (binfo
->peer
->conf_if
)
7035 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
7039 if (binfo
->peer
->conf_if
)
7041 if (binfo
->peer
->hostname
&&
7042 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7043 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7044 binfo
->peer
->conf_if
);
7046 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
7050 if (binfo
->peer
->hostname
&&
7051 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7052 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7055 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7058 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7059 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
7061 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7066 vty_out (vty
, "%s", VTY_NEWLINE
);
7068 /* display the link-local nexthop */
7069 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
7073 json_nexthop_ll
= json_object_new_object();
7074 json_object_string_add(json_nexthop_ll
, "ip",
7075 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7076 buf
, INET6_ADDRSTRLEN
));
7077 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
7078 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
7080 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
7082 if (!attr
->extra
->mp_nexthop_prefer_global
)
7083 json_object_boolean_true_add(json_nexthop_ll
, "used");
7085 json_object_boolean_true_add(json_nexthop_global
, "used");
7089 vty_out (vty
, " (%s) %s%s",
7090 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7091 buf
, INET6_ADDRSTRLEN
),
7092 attr
->extra
->mp_nexthop_prefer_global
?
7093 "(prefer-global)" : "(used)",
7097 /* If we do not have a link-local nexthop then we must flag the global as "used" */
7101 json_object_boolean_true_add(json_nexthop_global
, "used");
7104 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
7106 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
7108 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
7110 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
7113 json_object_int_add(json_path
, "med", attr
->med
);
7115 vty_out (vty
, ", metric %u", attr
->med
);
7118 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
7121 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
7123 vty_out (vty
, ", localpref %u", attr
->local_pref
);
7128 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
7130 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
7133 if (attr
->extra
&& attr
->extra
->weight
!= 0)
7136 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
7138 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
7141 if (attr
->extra
&& attr
->extra
->tag
!= 0)
7144 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
7146 vty_out (vty
, ", tag %"ROUTE_TAG_PRI
, attr
->extra
->tag
);
7149 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7152 json_object_boolean_false_add(json_path
, "valid");
7154 vty_out (vty
, ", invalid");
7156 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
7159 json_object_boolean_true_add(json_path
, "valid");
7161 vty_out (vty
, ", valid");
7164 if (binfo
->peer
!= bgp
->peer_self
)
7166 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
7168 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7171 json_object_string_add(json_peer
, "type", "confed-internal");
7173 vty_out (vty
, ", confed-internal");
7178 json_object_string_add(json_peer
, "type", "internal");
7180 vty_out (vty
, ", internal");
7185 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
7188 json_object_string_add(json_peer
, "type", "confed-external");
7190 vty_out (vty
, ", confed-external");
7195 json_object_string_add(json_peer
, "type", "external");
7197 vty_out (vty
, ", external");
7201 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
7205 json_object_boolean_true_add(json_path
, "aggregated");
7206 json_object_boolean_true_add(json_path
, "local");
7210 vty_out (vty
, ", aggregated, local");
7213 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
7216 json_object_boolean_true_add(json_path
, "sourced");
7218 vty_out (vty
, ", sourced");
7224 json_object_boolean_true_add(json_path
, "sourced");
7225 json_object_boolean_true_add(json_path
, "local");
7229 vty_out (vty
, ", sourced, local");
7233 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7236 json_object_boolean_true_add(json_path
, "atomicAggregate");
7238 vty_out (vty
, ", atomic-aggregate");
7241 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7242 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7243 bgp_info_mpath_count (binfo
)))
7246 json_object_boolean_true_add(json_path
, "multipath");
7248 vty_out (vty
, ", multipath");
7251 // Mark the bestpath(s)
7252 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7254 first_as
= aspath_get_first_as(attr
->aspath
);
7259 json_bestpath
= json_object_new_object();
7260 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7265 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7267 vty_out (vty
, ", bestpath-from-AS Local");
7271 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7276 json_bestpath
= json_object_new_object();
7277 json_object_boolean_true_add(json_bestpath
, "overall");
7280 vty_out (vty
, ", best");
7284 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7287 vty_out (vty
, "%s", VTY_NEWLINE
);
7289 /* Line 4 display Community */
7290 if (attr
->community
)
7294 json_object_lock(attr
->community
->json
);
7295 json_object_object_add(json_path
, "community", attr
->community
->json
);
7299 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7304 /* Line 5 display Extended-community */
7305 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7309 json_ext_community
= json_object_new_object();
7310 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7311 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7315 vty_out (vty
, " Extended Community: %s%s",
7316 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7320 /* Line 6 display Originator, Cluster-id */
7321 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7322 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7324 assert (attr
->extra
);
7325 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7328 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7330 vty_out (vty
, " Originator: %s",
7331 inet_ntoa (attr
->extra
->originator_id
));
7334 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7340 json_cluster_list
= json_object_new_object();
7341 json_cluster_list_list
= json_object_new_array();
7343 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7345 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7346 json_object_array_add(json_cluster_list_list
, json_string
);
7349 /* struct cluster_list does not have "str" variable like
7350 * aspath and community do. Add this someday if someone
7352 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7354 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7355 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7359 vty_out (vty
, ", Cluster list: ");
7361 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7363 vty_out (vty
, "%s ",
7364 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7370 vty_out (vty
, "%s", VTY_NEWLINE
);
7373 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7374 bgp_damp_info_vty (vty
, binfo
, json_path
);
7376 /* Line 7 display Addpath IDs */
7377 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7381 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7382 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7386 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7387 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7392 /* If we used addpath to TX a non-bestpath we need to display
7393 * "Advertised to" on a path-by-path basis */
7394 if (bgp
->addpath_tx_used
[afi
][safi
])
7398 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7400 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7401 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7403 if ((addpath_capable
&& has_adj
) ||
7404 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7406 if (json_path
&& !json_adv_to
)
7407 json_adv_to
= json_object_new_object();
7409 route_vty_out_advertised_to(vty
, peer
, &first
,
7419 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7426 vty_out (vty
, "%s", VTY_NEWLINE
);
7431 /* Line 8 display Uptime */
7432 #ifdef HAVE_CLOCK_MONOTONIC
7433 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7436 json_last_update
= json_object_new_object();
7437 json_object_int_add(json_last_update
, "epoch", tbuf
);
7438 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7439 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7442 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7446 json_last_update
= json_object_new_object();
7447 json_object_int_add(json_last_update
, "epoch", tbuf
);
7448 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7449 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7452 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7453 #endif /* HAVE_CLOCK_MONOTONIC */
7456 /* We've constructed the json object for this path, add it to the json
7461 if (json_nexthop_global
|| json_nexthop_ll
)
7463 json_nexthops
= json_object_new_array();
7465 if (json_nexthop_global
)
7466 json_object_array_add(json_nexthops
, json_nexthop_global
);
7468 if (json_nexthop_ll
)
7469 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7471 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7474 json_object_object_add(json_path
, "peer", json_peer
);
7475 json_object_array_add(json_paths
, json_path
);
7478 vty_out (vty
, "%s", VTY_NEWLINE
);
7481 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7482 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7483 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7487 bgp_show_type_normal
,
7488 bgp_show_type_regexp
,
7489 bgp_show_type_prefix_list
,
7490 bgp_show_type_filter_list
,
7491 bgp_show_type_route_map
,
7492 bgp_show_type_neighbor
,
7493 bgp_show_type_cidr_only
,
7494 bgp_show_type_prefix_longer
,
7495 bgp_show_type_community_all
,
7496 bgp_show_type_community
,
7497 bgp_show_type_community_exact
,
7498 bgp_show_type_community_list
,
7499 bgp_show_type_community_list_exact
,
7500 bgp_show_type_flap_statistics
,
7501 bgp_show_type_flap_address
,
7502 bgp_show_type_flap_prefix
,
7503 bgp_show_type_flap_cidr_only
,
7504 bgp_show_type_flap_regexp
,
7505 bgp_show_type_flap_filter_list
,
7506 bgp_show_type_flap_prefix_list
,
7507 bgp_show_type_flap_prefix_longer
,
7508 bgp_show_type_flap_route_map
,
7509 bgp_show_type_flap_neighbor
,
7510 bgp_show_type_dampend_paths
,
7511 bgp_show_type_damp_neighbor
7515 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7516 const char *prefix_list_str
, afi_t afi
,
7517 safi_t safi
, enum bgp_show_type type
);
7519 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7520 const char *filter
, afi_t afi
,
7521 safi_t safi
, enum bgp_show_type type
);
7523 bgp_show_route_map (struct vty
*vty
, const char *name
,
7524 const char *rmap_str
, afi_t afi
,
7525 safi_t safi
, enum bgp_show_type type
);
7527 bgp_show_community_list (struct vty
*vty
, const char *name
,
7528 const char *com
, int exact
,
7529 afi_t afi
, safi_t safi
);
7531 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7532 const char *prefix
, afi_t afi
,
7533 safi_t safi
, enum bgp_show_type type
);
7536 bgp_show_table (struct vty
*vty
, struct bgp
*bgp
, struct bgp_table
*table
,
7537 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7539 struct bgp_info
*ri
;
7540 struct bgp_node
*rn
;
7543 unsigned long output_count
;
7544 unsigned long total_count
;
7548 json_object
*json_paths
= NULL
;
7553 vty_out (vty
, "{ \"vrfId\": %d, \"vrfName\": \"%s\", \"tableVersion\": %" PRId64
", \"routerId\": \"%s\", \"routes\": { ",
7554 bgp
->vrf_id
== VRF_UNKNOWN
? -1 : bgp
->vrf_id
,
7555 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
? "Default" : bgp
->name
,
7556 table
->version
, inet_ntoa (bgp
->router_id
));
7557 json_paths
= json_object_new_object();
7560 /* This is first entry point, so reset total line. */
7564 /* Start processing of routes. */
7565 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7566 if (rn
->info
!= NULL
)
7569 if (!first
&& use_json
)
7574 json_paths
= json_object_new_array();
7578 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7581 if (type
== bgp_show_type_flap_statistics
7582 || type
== bgp_show_type_flap_address
7583 || type
== bgp_show_type_flap_prefix
7584 || type
== bgp_show_type_flap_cidr_only
7585 || type
== bgp_show_type_flap_regexp
7586 || type
== bgp_show_type_flap_filter_list
7587 || type
== bgp_show_type_flap_prefix_list
7588 || type
== bgp_show_type_flap_prefix_longer
7589 || type
== bgp_show_type_flap_route_map
7590 || type
== bgp_show_type_flap_neighbor
7591 || type
== bgp_show_type_dampend_paths
7592 || type
== bgp_show_type_damp_neighbor
)
7594 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7597 if (type
== bgp_show_type_regexp
7598 || type
== bgp_show_type_flap_regexp
)
7600 regex_t
*regex
= output_arg
;
7602 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7605 if (type
== bgp_show_type_prefix_list
7606 || type
== bgp_show_type_flap_prefix_list
)
7608 struct prefix_list
*plist
= output_arg
;
7610 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7613 if (type
== bgp_show_type_filter_list
7614 || type
== bgp_show_type_flap_filter_list
)
7616 struct as_list
*as_list
= output_arg
;
7618 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7621 if (type
== bgp_show_type_route_map
7622 || type
== bgp_show_type_flap_route_map
)
7624 struct route_map
*rmap
= output_arg
;
7625 struct bgp_info binfo
;
7626 struct attr dummy_attr
;
7627 struct attr_extra dummy_extra
;
7630 dummy_attr
.extra
= &dummy_extra
;
7631 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7633 binfo
.peer
= ri
->peer
;
7634 binfo
.attr
= &dummy_attr
;
7636 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7637 if (ret
== RMAP_DENYMATCH
)
7640 if (type
== bgp_show_type_neighbor
7641 || type
== bgp_show_type_flap_neighbor
7642 || type
== bgp_show_type_damp_neighbor
)
7644 union sockunion
*su
= output_arg
;
7646 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7649 if (type
== bgp_show_type_cidr_only
7650 || type
== bgp_show_type_flap_cidr_only
)
7652 u_int32_t destination
;
7654 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7655 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7657 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7659 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7662 if (type
== bgp_show_type_prefix_longer
7663 || type
== bgp_show_type_flap_prefix_longer
)
7665 struct prefix
*p
= output_arg
;
7667 if (! prefix_match (p
, &rn
->p
))
7670 if (type
== bgp_show_type_community_all
)
7672 if (! ri
->attr
->community
)
7675 if (type
== bgp_show_type_community
)
7677 struct community
*com
= output_arg
;
7679 if (! ri
->attr
->community
||
7680 ! community_match (ri
->attr
->community
, com
))
7683 if (type
== bgp_show_type_community_exact
)
7685 struct community
*com
= output_arg
;
7687 if (! ri
->attr
->community
||
7688 ! community_cmp (ri
->attr
->community
, com
))
7691 if (type
== bgp_show_type_community_list
)
7693 struct community_list
*list
= output_arg
;
7695 if (! community_list_match (ri
->attr
->community
, list
))
7698 if (type
== bgp_show_type_community_list_exact
)
7700 struct community_list
*list
= output_arg
;
7702 if (! community_list_exact_match (ri
->attr
->community
, list
))
7705 if (type
== bgp_show_type_flap_address
7706 || type
== bgp_show_type_flap_prefix
)
7708 struct prefix
*p
= output_arg
;
7710 if (! prefix_match (&rn
->p
, p
))
7713 if (type
== bgp_show_type_flap_prefix
)
7714 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7717 if (type
== bgp_show_type_dampend_paths
7718 || type
== bgp_show_type_damp_neighbor
)
7720 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7721 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7725 if (!use_json
&& header
)
7727 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
7728 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7729 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7730 if (type
== bgp_show_type_dampend_paths
7731 || type
== bgp_show_type_damp_neighbor
)
7732 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7733 else if (type
== bgp_show_type_flap_statistics
7734 || type
== bgp_show_type_flap_address
7735 || type
== bgp_show_type_flap_prefix
7736 || type
== bgp_show_type_flap_cidr_only
7737 || type
== bgp_show_type_flap_regexp
7738 || type
== bgp_show_type_flap_filter_list
7739 || type
== bgp_show_type_flap_prefix_list
7740 || type
== bgp_show_type_flap_prefix_longer
7741 || type
== bgp_show_type_flap_route_map
7742 || type
== bgp_show_type_flap_neighbor
)
7743 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7745 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7749 if (type
== bgp_show_type_dampend_paths
7750 || type
== bgp_show_type_damp_neighbor
)
7751 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7752 else if (type
== bgp_show_type_flap_statistics
7753 || type
== bgp_show_type_flap_address
7754 || type
== bgp_show_type_flap_prefix
7755 || type
== bgp_show_type_flap_cidr_only
7756 || type
== bgp_show_type_flap_regexp
7757 || type
== bgp_show_type_flap_filter_list
7758 || type
== bgp_show_type_flap_prefix_list
7759 || type
== bgp_show_type_flap_prefix_longer
7760 || type
== bgp_show_type_flap_route_map
7761 || type
== bgp_show_type_flap_neighbor
)
7762 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7764 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7774 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7775 vty_out (vty
, "\"%s\": ", buf2
);
7776 vty_out (vty
, "%s", json_object_to_json_string (json_paths
));
7777 json_object_free (json_paths
);
7786 json_object_free (json_paths
);
7787 vty_out (vty
, " } }%s", VTY_NEWLINE
);
7791 /* No route is displayed */
7792 if (output_count
== 0)
7794 if (type
== bgp_show_type_normal
)
7795 vty_out (vty
, "No BGP prefixes displayed, %ld exist%s", total_count
, VTY_NEWLINE
);
7798 vty_out (vty
, "%sDisplayed %ld routes and %ld total paths%s",
7799 VTY_NEWLINE
, output_count
, total_count
, VTY_NEWLINE
);
7806 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7807 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7809 struct bgp_table
*table
;
7813 bgp
= bgp_get_default ();
7819 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7823 table
= bgp
->rib
[afi
][safi
];
7825 return bgp_show_table (vty
, bgp
, table
, type
, output_arg
,
7830 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7833 struct listnode
*node
, *nnode
;
7835 struct bgp_table
*table
;
7839 vty_out (vty
, "{%s", VTY_NEWLINE
);
7841 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7846 vty_out (vty
, ",%s", VTY_NEWLINE
);
7850 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7851 ? "Default" : bgp
->name
);
7855 vty_out (vty
, "%sInstance %s:%s",
7857 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7858 ? "Default" : bgp
->name
,
7861 table
= bgp
->rib
[afi
][safi
];
7862 bgp_show_table (vty
, bgp
, table
,
7863 bgp_show_type_normal
, NULL
, use_json
);
7868 vty_out (vty
, "}%s", VTY_NEWLINE
);
7871 /* Header of detailed BGP route information */
7873 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7874 struct bgp_node
*rn
,
7875 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7878 struct bgp_info
*ri
;
7881 struct listnode
*node
, *nnode
;
7882 char buf1
[INET6_ADDRSTRLEN
];
7883 char buf2
[INET6_ADDRSTRLEN
];
7888 int no_advertise
= 0;
7891 json_object
*json_adv_to
= NULL
;
7897 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7898 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7902 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7903 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7904 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7905 safi
== SAFI_MPLS_VPN
? ":" : "",
7906 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7907 p
->prefixlen
, VTY_NEWLINE
);
7910 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7913 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7916 if (ri
->extra
&& ri
->extra
->suppress
)
7918 if (ri
->attr
->community
!= NULL
)
7920 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7922 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7924 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7932 vty_out (vty
, "Paths: (%d available", count
);
7935 vty_out (vty
, ", best #%d", best
);
7936 if (safi
== SAFI_UNICAST
)
7937 vty_out (vty
, ", table %s",
7938 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7939 ? "Default-IP-Routing-Table" : bgp
->name
);
7942 vty_out (vty
, ", no best path");
7945 vty_out (vty
, ", not advertised to any peer");
7947 vty_out (vty
, ", not advertised to EBGP peer");
7949 vty_out (vty
, ", not advertised outside local AS");
7952 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7953 vty_out (vty
, ")%s", VTY_NEWLINE
);
7956 /* If we are not using addpath then we can display Advertised to and that will
7957 * show what peers we advertised the bestpath to. If we are using addpath
7958 * though then we must display Advertised to on a path-by-path basis. */
7959 if (!bgp
->addpath_tx_used
[afi
][safi
])
7961 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7963 if (bgp_adj_out_lookup (peer
, rn
, 0))
7965 if (json
&& !json_adv_to
)
7966 json_adv_to
= json_object_new_object();
7968 route_vty_out_advertised_to(vty
, peer
, &first
,
7969 " Advertised to non peer-group peers:\n ",
7978 json_object_object_add(json
, "advertisedTo", json_adv_to
);
7984 vty_out (vty
, " Not advertised to any peer");
7985 vty_out (vty
, "%s", VTY_NEWLINE
);
7990 /* Display specified route of BGP table. */
7992 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
7993 struct bgp_table
*rib
, const char *ip_str
,
7994 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7995 int prefix_check
, enum bgp_path_type pathtype
,
8001 struct prefix match
;
8002 struct bgp_node
*rn
;
8003 struct bgp_node
*rm
;
8004 struct bgp_info
*ri
;
8005 struct bgp_table
*table
;
8006 json_object
*json
= NULL
;
8007 json_object
*json_paths
= NULL
;
8009 /* Check IP address argument. */
8010 ret
= str2prefix (ip_str
, &match
);
8013 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
8017 match
.family
= afi2family (afi
);
8021 json
= json_object_new_object();
8022 json_paths
= json_object_new_array();
8025 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
8027 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
8029 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
8032 if ((table
= rn
->info
) != NULL
)
8036 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
8038 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
8040 bgp_unlock_node (rm
);
8044 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
8048 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
8049 AFI_IP
, safi
, json
);
8054 if (pathtype
== BGP_PATH_ALL
||
8055 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8056 (pathtype
== BGP_PATH_MULTIPATH
&&
8057 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8058 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
8061 bgp_unlock_node (rm
);
8070 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
8072 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
8074 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8078 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
8083 if (pathtype
== BGP_PATH_ALL
||
8084 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8085 (pathtype
== BGP_PATH_MULTIPATH
&&
8086 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8087 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
8091 bgp_unlock_node (rn
);
8098 json_object_object_add(json
, "paths", json_paths
);
8100 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
8101 json_object_free(json
);
8107 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
8115 /* Display specified route of Main RIB */
8117 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
8118 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8119 int prefix_check
, enum bgp_path_type pathtype
,
8124 /* BGP structure lookup. */
8127 bgp
= bgp_lookup_by_name (view_name
);
8130 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
8136 bgp
= bgp_get_default ();
8139 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8144 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
8145 afi
, safi
, prd
, prefix_check
, pathtype
,
8149 /* BGP route print out function. */
8152 "show ip bgp {json}",
8156 "JavaScript Object Notation\n")
8158 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8161 DEFUN (show_ip_bgp_ipv4
,
8162 show_ip_bgp_ipv4_cmd
,
8163 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" {json}",
8169 "JavaScript Object Notation\n")
8171 u_char uj
= use_json(argc
, argv
);
8173 return bgp_show (vty
, NULL
, AFI_IP
,
8174 bgp_vty_safi_from_arg(argv
[0]),
8175 bgp_show_type_normal
, NULL
, uj
);
8178 ALIAS (show_ip_bgp_ipv4
,
8179 show_bgp_ipv4_safi_cmd
,
8180 "show bgp ipv4 "BGP_SAFI_CMD_STR
" {json}",
8185 "JavaScript Object Notation\n")
8187 DEFUN (show_ip_bgp_route
,
8188 show_ip_bgp_route_cmd
,
8189 "show ip bgp A.B.C.D {json}",
8193 "Network in the BGP routing table to display\n"
8194 "JavaScript Object Notation\n")
8196 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8199 DEFUN (show_ip_bgp_route_pathtype
,
8200 show_ip_bgp_route_pathtype_cmd
,
8201 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
8205 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8206 "Display only the bestpath\n"
8207 "Display only multipaths\n"
8208 "JavaScript Object Notation\n")
8210 u_char uj
= use_json(argc
, argv
);
8212 if (strncmp (argv
[1], "b", 1) == 0)
8213 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8215 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8218 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
8219 show_bgp_ipv4_safi_route_pathtype_cmd
,
8220 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D (bestpath|multipath) {json}",
8223 BGP_AFI_SAFI_HELP_STR
8224 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8225 "Display only the bestpath\n"
8226 "Display only multipaths\n"
8227 "JavaScript Object Notation\n")
8229 u_char uj
= use_json(argc
, argv
);
8231 if (strncmp (argv
[2], "b", 1) == 0)
8232 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8233 bgp_vty_safi_from_arg(argv
[0]),
8234 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8236 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8237 bgp_vty_safi_from_arg(argv
[0]),
8238 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8241 DEFUN (show_bgp_ipv4_prefix
,
8242 show_bgp_ipv4_prefix_cmd
,
8243 "show bgp ipv4 A.B.C.D/M {json}",
8247 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8250 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8253 DEFUN (show_bgp_ipv6_route
,
8254 show_bgp_ipv6_route_cmd
,
8255 "show bgp ipv6 X:X::X:X {json}",
8259 "Network in the BGP routing table to display\n"
8262 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8265 DEFUN (show_bgp_ipv6_prefix
,
8266 show_bgp_ipv6_prefix_cmd
,
8267 "show bgp ipv6 X:X::X:X/M {json}",
8271 "IPv6 prefix <network>/<length>\n"
8274 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
,argv
));
8277 DEFUN (show_ip_bgp_ipv4_route
,
8278 show_ip_bgp_ipv4_route_cmd
,
8279 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8283 BGP_AFI_SAFI_HELP_STR
8284 "Network in the BGP routing table to display\n"
8285 "JavaScript Object Notation\n")
8287 u_char uj
= use_json(argc
, argv
);
8289 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8290 bgp_vty_safi_from_arg(argv
[0]),
8291 NULL
, 0, BGP_PATH_ALL
, uj
);
8294 ALIAS (show_ip_bgp_ipv4_route
,
8295 show_bgp_ipv4_safi_route_cmd
,
8296 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8299 BGP_AFI_SAFI_HELP_STR
8300 "Network in the BGP routing table to display\n"
8301 "JavaScript Object Notation\n")
8303 DEFUN (show_bgp_ipv4_safi_rd_route
,
8304 show_bgp_ipv4_safi_rd_route_cmd
,
8305 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8309 "Address Family Modifier\n"
8310 "Address Family Modifier\n"
8311 "Display information for a route distinguisher\n"
8312 "ENCAP Route Distinguisher\n"
8313 "Network in the BGP routing table to display\n")
8316 struct prefix_rd prd
;
8319 if (bgp_parse_safi(argv
[0], &safi
)) {
8320 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8323 ret
= str2prefix_rd (argv
[1], &prd
);
8326 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8329 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8332 DEFUN (show_bgp_ipv6_safi_rd_route
,
8333 show_bgp_ipv6_safi_rd_route_cmd
,
8334 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
8338 "Address Family Modifier\n"
8339 "Address Family Modifier\n"
8340 "Display information for a route distinguisher\n"
8341 "ENCAP Route Distinguisher\n"
8342 "Network in the BGP routing table to display\n")
8345 struct prefix_rd prd
;
8348 if (bgp_parse_safi(argv
[0], &safi
)) {
8349 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8352 ret
= str2prefix_rd (argv
[1], &prd
);
8355 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8358 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, SAFI_ENCAP
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8362 DEFUN (show_bgp_ipv4_safi_rd_prefix
,
8363 show_bgp_ipv4_safi_rd_prefix_cmd
,
8364 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8368 "Address Family Modifier\n"
8369 "Address Family Modifier\n"
8370 "Display information for a route distinguisher\n"
8371 "ENCAP Route Distinguisher\n"
8372 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8375 struct prefix_rd prd
;
8378 if (bgp_parse_safi(argv
[0], &safi
)) {
8379 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8383 ret
= str2prefix_rd (argv
[1], &prd
);
8386 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8389 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8392 DEFUN (show_bgp_ipv6_safi_rd_prefix
,
8393 show_bgp_ipv6_safi_rd_prefix_cmd
,
8394 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M {json}",
8398 "Address Family Modifier\n"
8399 "Address Family Modifier\n"
8400 "Display information for a route distinguisher\n"
8401 "ENCAP Route Distinguisher\n"
8402 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8405 struct prefix_rd prd
;
8408 if (bgp_parse_safi(argv
[0], &safi
)) {
8409 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8413 ret
= str2prefix_rd (argv
[1], &prd
);
8416 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8419 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8422 DEFUN (show_ip_bgp_prefix
,
8423 show_ip_bgp_prefix_cmd
,
8424 "show ip bgp A.B.C.D/M {json}",
8428 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8429 "JavaScript Object Notation\n")
8431 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8434 DEFUN (show_ip_bgp_prefix_pathtype
,
8435 show_ip_bgp_prefix_pathtype_cmd
,
8436 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8440 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8441 "Display only the bestpath\n"
8442 "Display only multipaths\n"
8443 "JavaScript Object Notation\n")
8445 u_char uj
= use_json(argc
, argv
);
8446 if (strncmp (argv
[1], "b", 1) == 0)
8447 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8449 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8452 DEFUN (show_ip_bgp_ipv4_prefix
,
8453 show_ip_bgp_ipv4_prefix_cmd
,
8454 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8458 BGP_AFI_SAFI_HELP_STR
8459 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8460 "JavaScript Object Notation\n")
8462 u_char uj
= use_json(argc
, argv
);
8464 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8465 bgp_vty_safi_from_arg(argv
[0]),
8466 NULL
, 1, BGP_PATH_ALL
, uj
);
8469 ALIAS (show_ip_bgp_ipv4_prefix
,
8470 show_bgp_ipv4_safi_prefix_cmd
,
8471 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8474 BGP_AFI_SAFI_HELP_STR
8475 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8476 "JavaScript Object Notation\n")
8478 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8479 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8480 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8484 BGP_AFI_SAFI_HELP_STR
8485 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8486 "Display only the bestpath\n"
8487 "Display only multipaths\n"
8488 "JavaScript Object Notation\n")
8490 u_char uj
= use_json(argc
, argv
);
8492 if (strncmp (argv
[2], "b", 1) == 0)
8493 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8494 bgp_vty_safi_from_arg(argv
[0]),
8495 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8497 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8498 bgp_vty_safi_from_arg(argv
[0]),
8499 NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8502 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8503 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8504 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8507 BGP_AFI_SAFI_HELP_STR
8508 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8509 "Display only the bestpath\n"
8510 "Display only multipaths\n"
8511 "JavaScript Object Notation\n")
8514 DEFUN (show_ip_bgp_view
,
8515 show_ip_bgp_instance_cmd
,
8516 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8520 BGP_INSTANCE_HELP_STR
8521 "JavaScript Object Notation\n")
8525 /* BGP structure lookup. */
8526 bgp
= bgp_lookup_by_name (argv
[1]);
8529 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8533 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8536 DEFUN (show_ip_bgp_instance_all
,
8537 show_ip_bgp_instance_all_cmd
,
8538 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8542 BGP_INSTANCE_ALL_HELP_STR
8543 "JavaScript Object Notation\n")
8545 u_char uj
= use_json(argc
, argv
);
8547 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8551 DEFUN (show_ip_bgp_instance_route
,
8552 show_ip_bgp_instance_route_cmd
,
8553 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8557 BGP_INSTANCE_HELP_STR
8558 "Network in the BGP routing table to display\n"
8559 "JavaScript Object Notation\n")
8561 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8564 DEFUN (show_ip_bgp_instance_route_pathtype
,
8565 show_ip_bgp_instance_route_pathtype_cmd
,
8566 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8570 BGP_INSTANCE_HELP_STR
8571 "Network in the BGP routing table to display\n"
8572 "Display only the bestpath\n"
8573 "Display only multipaths\n"
8574 "JavaScript Object Notation\n")
8576 u_char uj
= use_json(argc
, argv
);
8578 if (strncmp (argv
[3], "b", 1) == 0)
8579 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8581 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8584 DEFUN (show_ip_bgp_instance_prefix
,
8585 show_ip_bgp_instance_prefix_cmd
,
8586 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8590 BGP_INSTANCE_HELP_STR
8591 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8592 "JavaScript Object Notation\n")
8594 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8597 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8598 show_ip_bgp_instance_prefix_pathtype_cmd
,
8599 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8603 BGP_INSTANCE_HELP_STR
8604 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8605 "Display only the bestpath\n"
8606 "Display only multipaths\n"
8607 "JavaScript Object Notation\n")
8609 u_char uj
= use_json(argc
, argv
);
8610 if (strncmp (argv
[3], "b", 1) == 0)
8611 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8613 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8622 "JavaScript Object Notation\n")
8624 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8625 NULL
, use_json(argc
, argv
));
8630 "show bgp ipv6 {json}",
8634 "JavaScript Object Notation\n")
8636 DEFUN (show_bgp_ipv6_safi
,
8637 show_bgp_ipv6_safi_cmd
,
8638 "show bgp ipv6 "BGP_SAFI_CMD_STR
" {json}",
8643 "JavaScript Object Notation\n")
8645 u_char uj
= use_json(argc
, argv
);
8647 return bgp_show (vty
, NULL
, AFI_IP6
,
8648 bgp_vty_safi_from_arg(argv
[0]),
8649 bgp_show_type_normal
, NULL
, uj
);
8653 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8655 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8656 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8657 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8661 DEFUN (show_ipv6_bgp
,
8663 "show ipv6 bgp {json}",
8667 "JavaScript Object Notation\n")
8669 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8670 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8671 NULL
, use_json(argc
, argv
));
8674 DEFUN (show_bgp_route
,
8676 "show bgp X:X::X:X {json}",
8679 "Network in the BGP routing table to display\n"
8680 "JavaScript Object Notation\n")
8682 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8685 DEFUN (show_bgp_ipv6_safi_route
,
8686 show_bgp_ipv6_safi_route_cmd
,
8687 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X {json}",
8690 BGP_AFI_SAFI_HELP_STR
8691 "Network in the BGP routing table to display\n"
8692 "JavaScript Object Notation\n")
8694 u_char uj
= use_json(argc
, argv
);
8696 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8697 bgp_vty_safi_from_arg(argv
[0]),
8698 NULL
, 0, BGP_PATH_ALL
, uj
);
8701 DEFUN (show_bgp_route_pathtype
,
8702 show_bgp_route_pathtype_cmd
,
8703 "show bgp X:X::X:X (bestpath|multipath) {json}",
8706 "Network in the BGP routing table to display\n"
8707 "Display only the bestpath\n"
8708 "Display only multipaths\n"
8709 "JavaScript Object Notation\n")
8711 u_char uj
= use_json(argc
, argv
);
8712 if (strncmp (argv
[1], "b", 1) == 0)
8713 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8715 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8718 ALIAS (show_bgp_route_pathtype
,
8719 show_bgp_ipv6_route_pathtype_cmd
,
8720 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8724 "Network in the BGP routing table to display\n"
8725 "Display only the bestpath\n"
8726 "Display only multipaths\n"
8727 "JavaScript Object Notation\n")
8729 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8730 show_bgp_ipv6_safi_route_pathtype_cmd
,
8731 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X (bestpath|multipath) {json}",
8734 BGP_AFI_SAFI_HELP_STR
8735 "Network in the BGP routing table to display\n"
8736 "Display only the bestpath\n"
8737 "Display only multipaths\n"
8738 "JavaScript Object Notation\n")
8740 u_char uj
= use_json(argc
, argv
);
8741 if (strncmp (argv
[2], "b", 1) == 0)
8742 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8743 bgp_vty_safi_from_arg(argv
[0]),
8744 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8746 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8747 bgp_vty_safi_from_arg(argv
[0]),
8748 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8752 DEFUN (show_ipv6_bgp_route
,
8753 show_ipv6_bgp_route_cmd
,
8754 "show ipv6 bgp X:X::X:X {json}",
8758 "Network in the BGP routing table to display\n"
8759 "JavaScript Object Notation\n")
8761 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8762 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8765 DEFUN (show_bgp_prefix
,
8766 show_bgp_prefix_cmd
,
8767 "show bgp X:X::X:X/M {json}",
8770 "IPv6 prefix <network>/<length>\n"
8771 "JavaScript Object Notation\n")
8773 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8776 DEFUN (show_bgp_ipv6_safi_prefix
,
8777 show_bgp_ipv6_safi_prefix_cmd
,
8778 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M {json}",
8781 BGP_AFI_SAFI_HELP_STR
8782 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8783 "JavaScript Object Notation\n")
8785 u_char uj
= use_json(argc
, argv
);
8787 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8788 bgp_vty_safi_from_arg(argv
[0]),
8789 NULL
, 1, BGP_PATH_ALL
, uj
);
8792 DEFUN (show_bgp_prefix_pathtype
,
8793 show_bgp_prefix_pathtype_cmd
,
8794 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8797 "IPv6 prefix <network>/<length>\n"
8798 "Display only the bestpath\n"
8799 "Display only multipaths\n"
8800 "JavaScript Object Notation\n")
8802 u_char uj
= use_json(argc
, argv
);
8803 if (strncmp (argv
[1], "b", 1) == 0)
8804 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8806 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8809 ALIAS (show_bgp_prefix_pathtype
,
8810 show_bgp_ipv6_prefix_pathtype_cmd
,
8811 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8815 "IPv6 prefix <network>/<length>\n"
8816 "Display only the bestpath\n"
8817 "Display only multipaths\n"
8818 "JavaScript Object Notation\n")
8820 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8821 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8822 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M (bestpath|multipath) {json}",
8825 BGP_AFI_SAFI_HELP_STR
8826 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8827 "Display only the bestpath\n"
8828 "Display only multipaths\n"
8829 "JavaScript Object Notation\n")
8831 u_char uj
= use_json(argc
, argv
);
8832 if (strncmp (argv
[2], "b", 1) == 0)
8833 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8834 bgp_vty_safi_from_arg(argv
[0]),
8835 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8837 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8838 bgp_vty_safi_from_arg(argv
[0]), NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8842 DEFUN (show_ipv6_bgp_prefix
,
8843 show_ipv6_bgp_prefix_cmd
,
8844 "show ipv6 bgp X:X::X:X/M {json}",
8848 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8849 "JavaScript Object Notation\n")
8851 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8852 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8855 DEFUN (show_bgp_view
,
8856 show_bgp_instance_cmd
,
8857 "show bgp " BGP_INSTANCE_CMD
" {json}",
8860 BGP_INSTANCE_HELP_STR
8861 "JavaScript Object Notation\n")
8865 /* BGP structure lookup. */
8866 bgp
= bgp_lookup_by_name (argv
[1]);
8869 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8873 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8876 DEFUN (show_bgp_instance_all
,
8877 show_bgp_instance_all_cmd
,
8878 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8881 BGP_INSTANCE_ALL_HELP_STR
8882 "JavaScript Object Notation\n")
8884 u_char uj
= use_json(argc
, argv
);
8886 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8890 ALIAS (show_bgp_view
,
8891 show_bgp_instance_ipv6_cmd
,
8892 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8895 BGP_INSTANCE_HELP_STR
8897 "JavaScript Object Notation\n")
8899 DEFUN (show_bgp_instance_route
,
8900 show_bgp_instance_route_cmd
,
8901 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8904 BGP_INSTANCE_HELP_STR
8905 "Network in the BGP routing table to display\n"
8906 "JavaScript Object Notation\n")
8908 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8911 ALIAS (show_bgp_instance_route
,
8912 show_bgp_instance_ipv6_route_cmd
,
8913 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8916 BGP_INSTANCE_HELP_STR
8918 "Network in the BGP routing table to display\n"
8919 "JavaScript Object Notation\n")
8921 DEFUN (show_bgp_instance_route_pathtype
,
8922 show_bgp_instance_route_pathtype_cmd
,
8923 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8926 BGP_INSTANCE_HELP_STR
8927 "Network in the BGP routing table to display\n"
8928 "Display only the bestpath\n"
8929 "Display only multipaths\n"
8930 "JavaScript Object Notation\n")
8932 u_char uj
= use_json(argc
, argv
);
8933 if (strncmp (argv
[3], "b", 1) == 0)
8934 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8936 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8939 ALIAS (show_bgp_instance_route_pathtype
,
8940 show_bgp_instance_ipv6_route_pathtype_cmd
,
8941 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
8944 BGP_INSTANCE_HELP_STR
8946 "Network in the BGP routing table to display\n"
8947 "Display only the bestpath\n"
8948 "Display only multipaths\n"
8949 "JavaScript Object Notation\n")
8951 DEFUN (show_bgp_instance_prefix
,
8952 show_bgp_instance_prefix_cmd
,
8953 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
8956 BGP_INSTANCE_HELP_STR
8957 "IPv6 prefix <network>/<length>\n"
8958 "JavaScript Object Notation\n")
8960 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8963 ALIAS (show_bgp_instance_prefix
,
8964 show_bgp_instance_ipv6_prefix_cmd
,
8965 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
8968 BGP_INSTANCE_HELP_STR
8970 "IPv6 prefix <network>/<length>\n"
8971 "JavaScript Object Notation\n")
8973 DEFUN (show_bgp_instance_prefix_pathtype
,
8974 show_bgp_instance_prefix_pathtype_cmd
,
8975 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
8978 BGP_INSTANCE_HELP_STR
8979 "IPv6 prefix <network>/<length>\n"
8980 "Display only the bestpath\n"
8981 "Display only multipaths\n"
8982 "JavaScript Object Notation\n")
8984 u_char uj
= use_json(argc
, argv
);
8985 if (strncmp (argv
[3], "b", 1) == 0)
8986 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8988 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8991 ALIAS (show_bgp_instance_prefix_pathtype
,
8992 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
8993 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8996 BGP_INSTANCE_HELP_STR
8998 "IPv6 prefix <network>/<length>\n"
8999 "Display only the bestpath\n"
9000 "Display only multipaths\n"
9001 "JavaScript Object Notation\n")
9003 DEFUN (show_bgp_instance_prefix_list
,
9004 show_bgp_instance_prefix_list_cmd
,
9005 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9008 BGP_INSTANCE_HELP_STR
9009 "Display routes conforming to the prefix-list\n"
9010 "IPv6 prefix-list name\n")
9012 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9013 bgp_show_type_prefix_list
);
9016 ALIAS (show_bgp_instance_prefix_list
,
9017 show_bgp_instance_ipv6_prefix_list_cmd
,
9018 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
9021 BGP_INSTANCE_HELP_STR
9023 "Display routes conforming to the prefix-list\n"
9024 "IPv6 prefix-list name\n")
9026 DEFUN (show_bgp_instance_filter_list
,
9027 show_bgp_instance_filter_list_cmd
,
9028 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9031 BGP_INSTANCE_HELP_STR
9032 "Display routes conforming to the filter-list\n"
9033 "Regular expression access list name\n")
9035 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9036 bgp_show_type_filter_list
);
9039 ALIAS (show_bgp_instance_filter_list
,
9040 show_bgp_instance_ipv6_filter_list_cmd
,
9041 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
9044 BGP_INSTANCE_HELP_STR
9046 "Display routes conforming to the filter-list\n"
9047 "Regular expression access list name\n")
9049 DEFUN (show_bgp_instance_route_map
,
9050 show_bgp_instance_route_map_cmd
,
9051 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
9054 BGP_INSTANCE_HELP_STR
9055 "Display routes matching the route-map\n"
9056 "A route-map to match on\n")
9058 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9059 bgp_show_type_route_map
);
9062 ALIAS (show_bgp_instance_route_map
,
9063 show_bgp_instance_ipv6_route_map_cmd
,
9064 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
9067 BGP_INSTANCE_HELP_STR
9069 "Display routes matching the route-map\n"
9070 "A route-map to match on\n")
9072 DEFUN (show_bgp_instance_community_list
,
9073 show_bgp_instance_community_list_cmd
,
9074 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
9077 BGP_INSTANCE_HELP_STR
9078 "Display routes matching the community-list\n"
9079 "community-list number\n"
9080 "community-list name\n")
9082 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
9085 ALIAS (show_bgp_instance_community_list
,
9086 show_bgp_instance_ipv6_community_list_cmd
,
9087 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
9090 BGP_INSTANCE_HELP_STR
9092 "Display routes matching the community-list\n"
9093 "community-list number\n"
9094 "community-list name\n")
9096 DEFUN (show_bgp_instance_prefix_longer
,
9097 show_bgp_instance_prefix_longer_cmd
,
9098 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
9101 BGP_INSTANCE_HELP_STR
9102 "IPv6 prefix <network>/<length>\n"
9103 "Display route and more specific routes\n")
9105 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9106 bgp_show_type_prefix_longer
);
9109 ALIAS (show_bgp_instance_prefix_longer
,
9110 show_bgp_instance_ipv6_prefix_longer_cmd
,
9111 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
9114 BGP_INSTANCE_HELP_STR
9116 "IPv6 prefix <network>/<length>\n"
9117 "Display route and more specific routes\n")
9120 DEFUN (show_ipv6_mbgp
,
9122 "show ipv6 mbgp {json}",
9126 "JavaScript Object Notation\n")
9128 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9129 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
9130 NULL
, use_json(argc
, argv
));
9134 DEFUN (show_ipv6_mbgp_route
,
9135 show_ipv6_mbgp_route_cmd
,
9136 "show ipv6 mbgp X:X::X:X {json}",
9140 "Network in the MBGP routing table to display\n"
9141 "JavaScript Object Notation\n")
9143 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9144 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9148 DEFUN (show_ipv6_mbgp_prefix
,
9149 show_ipv6_mbgp_prefix_cmd
,
9150 "show ipv6 mbgp X:X::X:X/M {json}",
9154 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9155 "JavaScript Object Notation\n")
9157 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9158 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9164 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
9165 safi_t safi
, enum bgp_show_type type
)
9175 b
= buffer_new (1024);
9176 for (i
= 0; i
< argc
; i
++)
9179 buffer_putc (b
, ' ');
9182 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9187 buffer_putstr (b
, argv
[i
]);
9189 buffer_putc (b
, '\0');
9191 regstr
= buffer_getstr (b
);
9194 regex
= bgp_regcomp (regstr
);
9195 XFREE(MTYPE_TMP
, regstr
);
9198 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
9203 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
9204 bgp_regex_free (regex
);
9208 DEFUN (show_ip_bgp_regexp
,
9209 show_ip_bgp_regexp_cmd
,
9210 "show ip bgp regexp .LINE",
9214 "Display routes matching the AS path regular expression\n"
9215 "A regular-expression to match the BGP AS paths\n")
9217 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9218 bgp_show_type_regexp
);
9221 DEFUN (show_ip_bgp_flap_regexp
,
9222 show_ip_bgp_flap_regexp_cmd
,
9223 "show ip bgp flap-statistics regexp .LINE",
9227 "Display flap statistics of routes\n"
9228 "Display routes matching the AS path regular expression\n"
9229 "A regular-expression to match the BGP AS paths\n")
9231 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9232 bgp_show_type_flap_regexp
);
9235 ALIAS (show_ip_bgp_flap_regexp
,
9236 show_ip_bgp_damp_flap_regexp_cmd
,
9237 "show ip bgp dampening flap-statistics regexp .LINE",
9241 "Display detailed information about dampening\n"
9242 "Display flap statistics of routes\n"
9243 "Display routes matching the AS path regular expression\n"
9244 "A regular-expression to match the BGP AS paths\n")
9246 DEFUN (show_ip_bgp_ipv4_regexp
,
9247 show_ip_bgp_ipv4_regexp_cmd
,
9248 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" regexp .LINE",
9254 "Display routes matching the AS path regular expression\n"
9255 "A regular-expression to match the BGP AS paths\n")
9258 safi
= bgp_vty_safi_from_arg(argv
[0]);
9259 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, safi
,
9260 bgp_show_type_regexp
);
9264 DEFUN (show_bgp_regexp
,
9265 show_bgp_regexp_cmd
,
9266 "show bgp regexp .LINE",
9269 "Display routes matching the AS path regular expression\n"
9270 "A regular-expression to match the BGP AS paths\n")
9272 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9273 bgp_show_type_regexp
);
9276 ALIAS (show_bgp_regexp
,
9277 show_bgp_ipv6_regexp_cmd
,
9278 "show bgp ipv6 regexp .LINE",
9282 "Display routes matching the AS path regular expression\n"
9283 "A regular-expression to match the BGP AS paths\n")
9286 DEFUN (show_ipv6_bgp_regexp
,
9287 show_ipv6_bgp_regexp_cmd
,
9288 "show ipv6 bgp regexp .LINE",
9292 "Display routes matching the AS path regular expression\n"
9293 "A regular-expression to match the BGP AS paths\n")
9295 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9296 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9297 bgp_show_type_regexp
);
9301 DEFUN (show_ipv6_mbgp_regexp
,
9302 show_ipv6_mbgp_regexp_cmd
,
9303 "show ipv6 mbgp regexp .LINE",
9307 "Display routes matching the AS path regular expression\n"
9308 "A regular-expression to match the MBGP AS paths\n")
9310 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9311 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9312 bgp_show_type_regexp
);
9314 #endif /* HAVE_IPV6 */
9317 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9318 const char *prefix_list_str
, afi_t afi
,
9319 safi_t safi
, enum bgp_show_type type
)
9321 struct prefix_list
*plist
;
9322 struct bgp
*bgp
= NULL
;
9324 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9326 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9330 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9333 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9334 prefix_list_str
, VTY_NEWLINE
);
9338 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9341 DEFUN (show_ip_bgp_prefix_list
,
9342 show_ip_bgp_prefix_list_cmd
,
9343 "show ip bgp prefix-list WORD",
9347 "Display routes conforming to the prefix-list\n"
9348 "IP prefix-list name\n")
9350 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9351 bgp_show_type_prefix_list
);
9354 DEFUN (show_ip_bgp_instance_prefix_list
,
9355 show_ip_bgp_instance_prefix_list_cmd
,
9356 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9360 BGP_INSTANCE_HELP_STR
9361 "Display routes conforming to the prefix-list\n"
9362 "IP prefix-list name\n")
9364 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9365 bgp_show_type_prefix_list
);
9368 DEFUN (show_ip_bgp_flap_prefix_list
,
9369 show_ip_bgp_flap_prefix_list_cmd
,
9370 "show ip bgp flap-statistics prefix-list WORD",
9374 "Display flap statistics of routes\n"
9375 "Display routes conforming to the prefix-list\n"
9376 "IP prefix-list name\n")
9378 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9379 bgp_show_type_flap_prefix_list
);
9382 ALIAS (show_ip_bgp_flap_prefix_list
,
9383 show_ip_bgp_damp_flap_prefix_list_cmd
,
9384 "show ip bgp dampening flap-statistics prefix-list WORD",
9388 "Display detailed information about dampening\n"
9389 "Display flap statistics of routes\n"
9390 "Display routes conforming to the prefix-list\n"
9391 "IP prefix-list name\n")
9393 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9394 show_ip_bgp_ipv4_prefix_list_cmd
,
9395 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" prefix-list WORD",
9401 "Display routes conforming to the prefix-list\n"
9402 "IP prefix-list name\n")
9405 safi
= bgp_vty_safi_from_arg(argv
[0]);
9406 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9407 bgp_show_type_prefix_list
);
9411 DEFUN (show_bgp_prefix_list
,
9412 show_bgp_prefix_list_cmd
,
9413 "show bgp prefix-list WORD",
9416 "Display routes conforming to the prefix-list\n"
9417 "IPv6 prefix-list name\n")
9419 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9420 bgp_show_type_prefix_list
);
9423 ALIAS (show_bgp_prefix_list
,
9424 show_bgp_ipv6_prefix_list_cmd
,
9425 "show bgp ipv6 prefix-list WORD",
9429 "Display routes conforming to the prefix-list\n"
9430 "IPv6 prefix-list name\n")
9433 DEFUN (show_ipv6_bgp_prefix_list
,
9434 show_ipv6_bgp_prefix_list_cmd
,
9435 "show ipv6 bgp prefix-list WORD",
9439 "Display routes matching the prefix-list\n"
9440 "IPv6 prefix-list name\n")
9442 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9443 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9444 bgp_show_type_prefix_list
);
9448 DEFUN (show_ipv6_mbgp_prefix_list
,
9449 show_ipv6_mbgp_prefix_list_cmd
,
9450 "show ipv6 mbgp prefix-list WORD",
9454 "Display routes matching the prefix-list\n"
9455 "IPv6 prefix-list name\n")
9457 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9458 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9459 bgp_show_type_prefix_list
);
9461 #endif /* HAVE_IPV6 */
9464 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9465 const char *filter
, afi_t afi
,
9466 safi_t safi
, enum bgp_show_type type
)
9468 struct as_list
*as_list
;
9469 struct bgp
*bgp
= NULL
;
9471 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9473 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9477 as_list
= as_list_lookup (filter
);
9478 if (as_list
== NULL
)
9480 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9484 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9487 DEFUN (show_ip_bgp_filter_list
,
9488 show_ip_bgp_filter_list_cmd
,
9489 "show ip bgp filter-list WORD",
9493 "Display routes conforming to the filter-list\n"
9494 "Regular expression access list name\n")
9496 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9497 bgp_show_type_filter_list
);
9500 DEFUN (show_ip_bgp_instance_filter_list
,
9501 show_ip_bgp_instance_filter_list_cmd
,
9502 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9506 BGP_INSTANCE_HELP_STR
9507 "Display routes conforming to the filter-list\n"
9508 "Regular expression access list name\n")
9510 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9511 bgp_show_type_filter_list
);
9514 DEFUN (show_ip_bgp_flap_filter_list
,
9515 show_ip_bgp_flap_filter_list_cmd
,
9516 "show ip bgp flap-statistics filter-list WORD",
9520 "Display flap statistics of routes\n"
9521 "Display routes conforming to the filter-list\n"
9522 "Regular expression access list name\n")
9524 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9525 bgp_show_type_flap_filter_list
);
9528 ALIAS (show_ip_bgp_flap_filter_list
,
9529 show_ip_bgp_damp_flap_filter_list_cmd
,
9530 "show ip bgp dampening flap-statistics filter-list WORD",
9534 "Display detailed information about dampening\n"
9535 "Display flap statistics of routes\n"
9536 "Display routes conforming to the filter-list\n"
9537 "Regular expression access list name\n")
9539 DEFUN (show_ip_bgp_ipv4_filter_list
,
9540 show_ip_bgp_ipv4_filter_list_cmd
,
9541 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" filter-list WORD",
9547 "Display routes conforming to the filter-list\n"
9548 "Regular expression access list name\n")
9551 safi
= bgp_vty_safi_from_arg(argv
[0]);
9552 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9553 bgp_show_type_filter_list
);
9557 DEFUN (show_bgp_filter_list
,
9558 show_bgp_filter_list_cmd
,
9559 "show bgp filter-list WORD",
9562 "Display routes conforming to the filter-list\n"
9563 "Regular expression access list name\n")
9565 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9566 bgp_show_type_filter_list
);
9569 ALIAS (show_bgp_filter_list
,
9570 show_bgp_ipv6_filter_list_cmd
,
9571 "show bgp ipv6 filter-list WORD",
9575 "Display routes conforming to the filter-list\n"
9576 "Regular expression access list name\n")
9579 DEFUN (show_ipv6_bgp_filter_list
,
9580 show_ipv6_bgp_filter_list_cmd
,
9581 "show ipv6 bgp filter-list WORD",
9585 "Display routes conforming to the filter-list\n"
9586 "Regular expression access list name\n")
9588 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9589 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9590 bgp_show_type_filter_list
);
9594 DEFUN (show_ipv6_mbgp_filter_list
,
9595 show_ipv6_mbgp_filter_list_cmd
,
9596 "show ipv6 mbgp filter-list WORD",
9600 "Display routes conforming to the filter-list\n"
9601 "Regular expression access list name\n")
9603 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9604 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9605 bgp_show_type_filter_list
);
9607 #endif /* HAVE_IPV6 */
9609 DEFUN (show_ip_bgp_dampening_info
,
9610 show_ip_bgp_dampening_params_cmd
,
9611 "show ip bgp dampening parameters",
9615 "Display detailed information about dampening\n"
9616 "Display detail of configured dampening parameters\n")
9618 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9622 DEFUN (show_ip_bgp_ipv4_dampening_parameters
,
9623 show_ip_bgp_ipv4_dampening_parameters_cmd
,
9624 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" dampening parameters",
9630 "Display detailed information about dampening\n"
9631 "Display detail of configured dampening parameters\n")
9634 safi
= bgp_vty_safi_from_arg(argv
[0]);
9635 return bgp_show_dampening_parameters (vty
, AFI_IP
, safi
);
9639 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats
,
9640 show_ip_bgp_ipv4_dampening_flap_stats_cmd
,
9641 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" dampening flap-statistics",
9647 "Display detailed information about dampening\n"
9648 "Display flap statistics of routes\n")
9651 safi
= bgp_vty_safi_from_arg(argv
[0]);
9652 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9653 bgp_show_type_flap_statistics
, NULL
, 0);
9656 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths
,
9657 show_ip_bgp_ipv4_dampening_dampd_paths_cmd
,
9658 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" dampening dampened-paths",
9664 "Display detailed information about dampening\n"
9665 "Display paths suppressed due to dampening\n")
9668 safi
= bgp_vty_safi_from_arg(argv
[0]);
9669 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9670 bgp_show_type_dampend_paths
, NULL
, 0);
9674 bgp_show_route_map (struct vty
*vty
, const char *name
,
9675 const char *rmap_str
, afi_t afi
,
9676 safi_t safi
, enum bgp_show_type type
)
9678 struct route_map
*rmap
;
9679 struct bgp
*bgp
= NULL
;
9681 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9683 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9687 rmap
= route_map_lookup_by_name (rmap_str
);
9690 vty_out (vty
, "%% %s is not a valid route-map name%s",
9691 rmap_str
, VTY_NEWLINE
);
9695 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9698 DEFUN (show_ip_bgp_route_map
,
9699 show_ip_bgp_route_map_cmd
,
9700 "show ip bgp route-map WORD",
9704 "Display routes matching the route-map\n"
9705 "A route-map to match on\n")
9707 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9708 bgp_show_type_route_map
);
9711 DEFUN (show_ip_bgp_instance_route_map
,
9712 show_ip_bgp_instance_route_map_cmd
,
9713 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9717 BGP_INSTANCE_HELP_STR
9718 "Display routes matching the route-map\n"
9719 "A route-map to match on\n")
9721 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9722 bgp_show_type_route_map
);
9725 DEFUN (show_ip_bgp_flap_route_map
,
9726 show_ip_bgp_flap_route_map_cmd
,
9727 "show ip bgp flap-statistics route-map WORD",
9731 "Display flap statistics of routes\n"
9732 "Display routes matching the route-map\n"
9733 "A route-map to match on\n")
9735 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9736 bgp_show_type_flap_route_map
);
9739 ALIAS (show_ip_bgp_flap_route_map
,
9740 show_ip_bgp_damp_flap_route_map_cmd
,
9741 "show ip bgp dampening flap-statistics route-map WORD",
9745 "Display detailed information about dampening\n"
9746 "Display flap statistics of routes\n"
9747 "Display routes matching the route-map\n"
9748 "A route-map to match on\n")
9750 DEFUN (show_ip_bgp_ipv4_route_map
,
9751 show_ip_bgp_ipv4_route_map_cmd
,
9752 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" route-map WORD",
9758 "Display routes matching the route-map\n"
9759 "A route-map to match on\n")
9762 safi
= bgp_vty_safi_from_arg(argv
[0]);
9763 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9764 bgp_show_type_route_map
);
9767 DEFUN (show_bgp_route_map
,
9768 show_bgp_route_map_cmd
,
9769 "show bgp route-map WORD",
9772 "Display routes matching the route-map\n"
9773 "A route-map to match on\n")
9775 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9776 bgp_show_type_route_map
);
9779 ALIAS (show_bgp_route_map
,
9780 show_bgp_ipv6_route_map_cmd
,
9781 "show bgp ipv6 route-map WORD",
9785 "Display routes matching the route-map\n"
9786 "A route-map to match on\n")
9788 DEFUN (show_ip_bgp_cidr_only
,
9789 show_ip_bgp_cidr_only_cmd
,
9790 "show ip bgp cidr-only",
9794 "Display only routes with non-natural netmasks\n")
9796 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9797 bgp_show_type_cidr_only
, NULL
, 0);
9800 DEFUN (show_ip_bgp_flap_cidr_only
,
9801 show_ip_bgp_flap_cidr_only_cmd
,
9802 "show ip bgp flap-statistics cidr-only",
9806 "Display flap statistics of routes\n"
9807 "Display only routes with non-natural netmasks\n")
9809 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9810 bgp_show_type_flap_cidr_only
, NULL
, 0);
9813 ALIAS (show_ip_bgp_flap_cidr_only
,
9814 show_ip_bgp_damp_flap_cidr_only_cmd
,
9815 "show ip bgp dampening flap-statistics cidr-only",
9819 "Display detailed information about dampening\n"
9820 "Display flap statistics of routes\n"
9821 "Display only routes with non-natural netmasks\n")
9823 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9824 show_ip_bgp_ipv4_cidr_only_cmd
,
9825 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" cidr-only",
9831 "Display only routes with non-natural netmasks\n")
9834 safi
= bgp_vty_safi_from_arg(argv
[0]);
9835 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9836 bgp_show_type_cidr_only
, NULL
, 0);
9839 DEFUN (show_ip_bgp_community_all
,
9840 show_ip_bgp_community_all_cmd
,
9841 "show ip bgp community",
9845 "Display routes matching the communities\n")
9847 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9848 bgp_show_type_community_all
, NULL
, 0);
9851 DEFUN (show_ip_bgp_ipv4_community_all
,
9852 show_ip_bgp_ipv4_community_all_cmd
,
9853 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community",
9859 "Display routes matching the communities\n")
9862 safi
= bgp_vty_safi_from_arg(argv
[0]);
9863 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9864 bgp_show_type_community_all
, NULL
, 0);
9868 DEFUN (show_bgp_community_all
,
9869 show_bgp_community_all_cmd
,
9870 "show bgp community",
9873 "Display routes matching the communities\n")
9875 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9876 bgp_show_type_community_all
, NULL
, 0);
9879 ALIAS (show_bgp_community_all
,
9880 show_bgp_ipv6_community_all_cmd
,
9881 "show bgp ipv6 community",
9885 "Display routes matching the communities\n")
9888 DEFUN (show_ipv6_bgp_community_all
,
9889 show_ipv6_bgp_community_all_cmd
,
9890 "show ipv6 bgp community",
9894 "Display routes matching the communities\n")
9896 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9897 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9898 bgp_show_type_community_all
, NULL
, 0);
9902 DEFUN (show_ipv6_mbgp_community_all
,
9903 show_ipv6_mbgp_community_all_cmd
,
9904 "show ipv6 mbgp community",
9908 "Display routes matching the communities\n")
9910 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9911 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9912 bgp_show_type_community_all
, NULL
, 0);
9914 #endif /* HAVE_IPV6 */
9917 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9918 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9920 struct community
*com
;
9927 /* BGP structure lookup */
9930 bgp
= bgp_lookup_by_name (view_name
);
9933 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
9939 bgp
= bgp_get_default ();
9942 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9947 b
= buffer_new (1024);
9948 for (i
= 0; i
< argc
; i
++)
9951 buffer_putc (b
, ' ');
9954 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9959 buffer_putstr (b
, argv
[i
]);
9961 buffer_putc (b
, '\0');
9963 str
= buffer_getstr (b
);
9966 com
= community_str2com (str
);
9967 XFREE (MTYPE_TMP
, str
);
9970 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
9974 return bgp_show (vty
, bgp
, afi
, safi
,
9975 (exact
? bgp_show_type_community_exact
:
9976 bgp_show_type_community
), com
, 0);
9979 DEFUN (show_ip_bgp_community
,
9980 show_ip_bgp_community_cmd
,
9981 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9985 "Display routes matching the communities\n"
9987 "Do not send outside local AS (well-known community)\n"
9988 "Do not advertise to any peer (well-known community)\n"
9989 "Do not export to next AS (well-known community)\n")
9991 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9994 ALIAS (show_ip_bgp_community
,
9995 show_ip_bgp_community2_cmd
,
9996 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10000 "Display routes matching the communities\n"
10002 "Do not send outside local AS (well-known community)\n"
10003 "Do not advertise to any peer (well-known community)\n"
10004 "Do not export to next AS (well-known community)\n"
10006 "Do not send outside local AS (well-known community)\n"
10007 "Do not advertise to any peer (well-known community)\n"
10008 "Do not export to next AS (well-known community)\n")
10010 ALIAS (show_ip_bgp_community
,
10011 show_ip_bgp_community3_cmd
,
10012 "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)",
10016 "Display routes matching the communities\n"
10018 "Do not send outside local AS (well-known community)\n"
10019 "Do not advertise to any peer (well-known community)\n"
10020 "Do not export to next AS (well-known community)\n"
10022 "Do not send outside local AS (well-known community)\n"
10023 "Do not advertise to any peer (well-known community)\n"
10024 "Do not export to next AS (well-known community)\n"
10026 "Do not send outside local AS (well-known community)\n"
10027 "Do not advertise to any peer (well-known community)\n"
10028 "Do not export to next AS (well-known community)\n")
10030 ALIAS (show_ip_bgp_community
,
10031 show_ip_bgp_community4_cmd
,
10032 "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)",
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 "Do not send outside local AS (well-known community)\n"
10043 "Do not advertise to any peer (well-known community)\n"
10044 "Do not export to next AS (well-known community)\n"
10046 "Do not send outside local AS (well-known community)\n"
10047 "Do not advertise to any peer (well-known community)\n"
10048 "Do not export to next AS (well-known community)\n"
10050 "Do not send outside local AS (well-known community)\n"
10051 "Do not advertise to any peer (well-known community)\n"
10052 "Do not export to next AS (well-known community)\n")
10054 DEFUN (show_ip_bgp_ipv4_community
,
10055 show_ip_bgp_ipv4_community_cmd
,
10056 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export)",
10062 "Display routes matching the communities\n"
10064 "Do not send outside local AS (well-known community)\n"
10065 "Do not advertise to any peer (well-known community)\n"
10066 "Do not export to next AS (well-known community)\n")
10069 safi
= bgp_vty_safi_from_arg(argv
[0]);
10070 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, safi
);
10073 ALIAS (show_ip_bgp_ipv4_community
,
10074 show_ip_bgp_ipv4_community2_cmd
,
10075 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10081 "Display routes matching the communities\n"
10083 "Do not send outside local AS (well-known community)\n"
10084 "Do not advertise to any peer (well-known community)\n"
10085 "Do not export to next AS (well-known community)\n"
10087 "Do not send outside local AS (well-known community)\n"
10088 "Do not advertise to any peer (well-known community)\n"
10089 "Do not export to next AS (well-known community)\n")
10091 ALIAS (show_ip_bgp_ipv4_community
,
10092 show_ip_bgp_ipv4_community3_cmd
,
10093 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" 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)",
10099 "Display routes matching the communities\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 "Do not send outside local AS (well-known community)\n"
10106 "Do not advertise to any peer (well-known community)\n"
10107 "Do not export to next AS (well-known community)\n"
10109 "Do not send outside local AS (well-known community)\n"
10110 "Do not advertise to any peer (well-known community)\n"
10111 "Do not export to next AS (well-known community)\n")
10113 ALIAS (show_ip_bgp_ipv4_community
,
10114 show_ip_bgp_ipv4_community4_cmd
,
10115 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" 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)",
10121 "Display routes matching the communities\n"
10123 "Do not send outside local AS (well-known community)\n"
10124 "Do not advertise to any peer (well-known community)\n"
10125 "Do not export to next AS (well-known community)\n"
10127 "Do not send outside local AS (well-known community)\n"
10128 "Do not advertise to any peer (well-known community)\n"
10129 "Do not export to next AS (well-known community)\n"
10131 "Do not send outside local AS (well-known community)\n"
10132 "Do not advertise to any peer (well-known community)\n"
10133 "Do not export to next AS (well-known community)\n"
10135 "Do not send outside local AS (well-known community)\n"
10136 "Do not advertise to any peer (well-known community)\n"
10137 "Do not export to next AS (well-known community)\n")
10139 DEFUN (show_bgp_instance_afi_safi_community_all
,
10140 show_bgp_instance_afi_safi_community_all_cmd
,
10141 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" community",
10144 BGP_INSTANCE_HELP_STR
10145 BGP_AFI_SAFI_HELP_STR
10146 "Display routes matching the communities\n")
10152 /* BGP structure lookup. */
10153 bgp
= bgp_lookup_by_name (argv
[1]);
10156 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
10157 return CMD_WARNING
;
10160 afi
= bgp_vty_safi_from_arg(argv
[2]);
10161 safi
= bgp_vty_safi_from_arg(argv
[3]);
10162 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
10165 DEFUN (show_bgp_instance_afi_safi_community
,
10166 show_bgp_instance_afi_safi_community_cmd
,
10167 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export)",
10170 BGP_INSTANCE_HELP_STR
10173 "Address family modifier\n"
10174 "Address family modifier\n"
10175 "Display routes matching the communities\n"
10177 "Do not send outside local AS (well-known community)\n"
10178 "Do not advertise to any peer (well-known community)\n"
10179 "Do not export to next AS (well-known community)\n")
10184 afi
= bgp_vty_safi_from_arg(argv
[2]);
10185 safi
= bgp_vty_safi_from_arg(argv
[3]);
10186 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
10189 ALIAS (show_bgp_instance_afi_safi_community
,
10190 show_bgp_instance_afi_safi_community2_cmd
,
10191 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10194 BGP_INSTANCE_HELP_STR
10197 "Address family modifier\n"
10198 "Address family modifier\n"
10199 "Display routes matching the communities\n"
10201 "Do not send outside local AS (well-known community)\n"
10202 "Do not advertise to any peer (well-known community)\n"
10203 "Do not export to next AS (well-known community)\n"
10205 "Do not send outside local AS (well-known community)\n"
10206 "Do not advertise to any peer (well-known community)\n"
10207 "Do not export to next AS (well-known community)\n")
10209 ALIAS (show_bgp_instance_afi_safi_community
,
10210 show_bgp_instance_afi_safi_community3_cmd
,
10211 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" 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)",
10214 BGP_INSTANCE_HELP_STR
10217 "Address family modifier\n"
10218 "Address family modifier\n"
10219 "Display routes matching the communities\n"
10221 "Do not send outside local AS (well-known community)\n"
10222 "Do not advertise to any peer (well-known community)\n"
10223 "Do not export to next AS (well-known community)\n"
10225 "Do not send outside local AS (well-known community)\n"
10226 "Do not advertise to any peer (well-known community)\n"
10227 "Do not export to next AS (well-known community)\n"
10229 "Do not send outside local AS (well-known community)\n"
10230 "Do not advertise to any peer (well-known community)\n"
10231 "Do not export to next AS (well-known community)\n")
10233 ALIAS (show_bgp_instance_afi_safi_community
,
10234 show_bgp_instance_afi_safi_community4_cmd
,
10235 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" 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)",
10238 BGP_INSTANCE_HELP_STR
10241 "Address family modifier\n"
10242 "Address family modifier\n"
10243 "Display routes matching the communities\n"
10245 "Do not send outside local AS (well-known community)\n"
10246 "Do not advertise to any peer (well-known community)\n"
10247 "Do not export to next AS (well-known community)\n"
10249 "Do not send outside local AS (well-known community)\n"
10250 "Do not advertise to any peer (well-known community)\n"
10251 "Do not export to next AS (well-known community)\n"
10253 "Do not send outside local AS (well-known community)\n"
10254 "Do not advertise to any peer (well-known community)\n"
10255 "Do not export to next AS (well-known community)\n"
10257 "Do not send outside local AS (well-known community)\n"
10258 "Do not advertise to any peer (well-known community)\n"
10259 "Do not export to next AS (well-known community)\n")
10261 DEFUN (show_ip_bgp_community_exact
,
10262 show_ip_bgp_community_exact_cmd
,
10263 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10267 "Display routes matching the communities\n"
10269 "Do not send outside local AS (well-known community)\n"
10270 "Do not advertise to any peer (well-known community)\n"
10271 "Do not export to next AS (well-known community)\n"
10272 "Exact match of the communities")
10274 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10277 ALIAS (show_ip_bgp_community_exact
,
10278 show_ip_bgp_community2_exact_cmd
,
10279 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10283 "Display routes matching the communities\n"
10285 "Do not send outside local AS (well-known community)\n"
10286 "Do not advertise to any peer (well-known community)\n"
10287 "Do not export to next AS (well-known community)\n"
10289 "Do not send outside local AS (well-known community)\n"
10290 "Do not advertise to any peer (well-known community)\n"
10291 "Do not export to next AS (well-known community)\n"
10292 "Exact match of the communities")
10294 ALIAS (show_ip_bgp_community_exact
,
10295 show_ip_bgp_community3_exact_cmd
,
10296 "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",
10300 "Display routes matching the communities\n"
10302 "Do not send outside local AS (well-known community)\n"
10303 "Do not advertise to any peer (well-known community)\n"
10304 "Do not export to next AS (well-known community)\n"
10306 "Do not send outside local AS (well-known community)\n"
10307 "Do not advertise to any peer (well-known community)\n"
10308 "Do not export to next AS (well-known community)\n"
10310 "Do not send outside local AS (well-known community)\n"
10311 "Do not advertise to any peer (well-known community)\n"
10312 "Do not export to next AS (well-known community)\n"
10313 "Exact match of the communities")
10315 ALIAS (show_ip_bgp_community_exact
,
10316 show_ip_bgp_community4_exact_cmd
,
10317 "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",
10321 "Display routes matching the communities\n"
10323 "Do not send outside local AS (well-known community)\n"
10324 "Do not advertise to any peer (well-known community)\n"
10325 "Do not export to next AS (well-known community)\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"
10331 "Do not send outside local AS (well-known community)\n"
10332 "Do not advertise to any peer (well-known community)\n"
10333 "Do not export to next AS (well-known community)\n"
10335 "Do not send outside local AS (well-known community)\n"
10336 "Do not advertise to any peer (well-known community)\n"
10337 "Do not export to next AS (well-known community)\n"
10338 "Exact match of the communities")
10340 DEFUN (show_ip_bgp_ipv4_community_exact
,
10341 show_ip_bgp_ipv4_community_exact_cmd
,
10342 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10348 "Display routes matching the communities\n"
10350 "Do not send outside local AS (well-known community)\n"
10351 "Do not advertise to any peer (well-known community)\n"
10352 "Do not export to next AS (well-known community)\n"
10353 "Exact match of the communities")
10356 safi
= bgp_vty_safi_from_arg(argv
[0]);
10357 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, safi
);
10360 ALIAS (show_ip_bgp_ipv4_community_exact
,
10361 show_ip_bgp_ipv4_community2_exact_cmd
,
10362 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10368 "Display routes matching the communities\n"
10370 "Do not send outside local AS (well-known community)\n"
10371 "Do not advertise to any peer (well-known community)\n"
10372 "Do not export to next AS (well-known community)\n"
10374 "Do not send outside local AS (well-known community)\n"
10375 "Do not advertise to any peer (well-known community)\n"
10376 "Do not export to next AS (well-known community)\n"
10377 "Exact match of the communities")
10379 ALIAS (show_ip_bgp_ipv4_community_exact
,
10380 show_ip_bgp_ipv4_community3_exact_cmd
,
10381 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" 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",
10387 "Display routes matching the communities\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"
10397 "Do not send outside local AS (well-known community)\n"
10398 "Do not advertise to any peer (well-known community)\n"
10399 "Do not export to next AS (well-known community)\n"
10400 "Exact match of the communities")
10402 ALIAS (show_ip_bgp_ipv4_community_exact
,
10403 show_ip_bgp_ipv4_community4_exact_cmd
,
10404 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" 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",
10410 "Display routes matching the communities\n"
10412 "Do not send outside local AS (well-known community)\n"
10413 "Do not advertise to any peer (well-known community)\n"
10414 "Do not export to next AS (well-known community)\n"
10416 "Do not send outside local AS (well-known community)\n"
10417 "Do not advertise to any peer (well-known community)\n"
10418 "Do not export to next AS (well-known community)\n"
10420 "Do not send outside local AS (well-known community)\n"
10421 "Do not advertise to any peer (well-known community)\n"
10422 "Do not export to next AS (well-known community)\n"
10424 "Do not send outside local AS (well-known community)\n"
10425 "Do not advertise to any peer (well-known community)\n"
10426 "Do not export to next AS (well-known community)\n"
10427 "Exact match of the communities")
10430 DEFUN (show_bgp_community
,
10431 show_bgp_community_cmd
,
10432 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10435 "Display routes matching the communities\n"
10437 "Do not send outside local AS (well-known community)\n"
10438 "Do not advertise to any peer (well-known community)\n"
10439 "Do not export to next AS (well-known community)\n")
10441 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10444 ALIAS (show_bgp_community
,
10445 show_bgp_ipv6_community_cmd
,
10446 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10450 "Display routes matching the communities\n"
10452 "Do not send outside local AS (well-known community)\n"
10453 "Do not advertise to any peer (well-known community)\n"
10454 "Do not export to next AS (well-known community)\n")
10456 ALIAS (show_bgp_community
,
10457 show_bgp_community2_cmd
,
10458 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10461 "Display routes matching the communities\n"
10463 "Do not send outside local AS (well-known community)\n"
10464 "Do not advertise to any peer (well-known community)\n"
10465 "Do not export to next AS (well-known community)\n"
10467 "Do not send outside local AS (well-known community)\n"
10468 "Do not advertise to any peer (well-known community)\n"
10469 "Do not export to next AS (well-known community)\n")
10471 ALIAS (show_bgp_community
,
10472 show_bgp_ipv6_community2_cmd
,
10473 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10477 "Display routes matching the communities\n"
10479 "Do not send outside local AS (well-known community)\n"
10480 "Do not advertise to any peer (well-known community)\n"
10481 "Do not export to next AS (well-known community)\n"
10483 "Do not send outside local AS (well-known community)\n"
10484 "Do not advertise to any peer (well-known community)\n"
10485 "Do not export to next AS (well-known community)\n")
10487 ALIAS (show_bgp_community
,
10488 show_bgp_community3_cmd
,
10489 "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)",
10492 "Display routes matching the communities\n"
10494 "Do not send outside local AS (well-known community)\n"
10495 "Do not advertise to any peer (well-known community)\n"
10496 "Do not export to next AS (well-known community)\n"
10498 "Do not send outside local AS (well-known community)\n"
10499 "Do not advertise to any peer (well-known community)\n"
10500 "Do not export to next AS (well-known community)\n"
10502 "Do not send outside local AS (well-known community)\n"
10503 "Do not advertise to any peer (well-known community)\n"
10504 "Do not export to next AS (well-known community)\n")
10506 ALIAS (show_bgp_community
,
10507 show_bgp_ipv6_community3_cmd
,
10508 "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)",
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 "Do not send outside local AS (well-known community)\n"
10519 "Do not advertise to any peer (well-known community)\n"
10520 "Do not export to next AS (well-known community)\n"
10522 "Do not send outside local AS (well-known community)\n"
10523 "Do not advertise to any peer (well-known community)\n"
10524 "Do not export to next AS (well-known community)\n")
10526 ALIAS (show_bgp_community
,
10527 show_bgp_community4_cmd
,
10528 "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)",
10531 "Display routes matching the communities\n"
10533 "Do not send outside local AS (well-known community)\n"
10534 "Do not advertise to any peer (well-known community)\n"
10535 "Do not export to next AS (well-known community)\n"
10537 "Do not send outside local AS (well-known community)\n"
10538 "Do not advertise to any peer (well-known community)\n"
10539 "Do not export to next AS (well-known community)\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_ipv6_community4_cmd
,
10551 "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)",
10555 "Display routes matching the communities\n"
10557 "Do not send outside local AS (well-known community)\n"
10558 "Do not advertise to any peer (well-known community)\n"
10559 "Do not export to next AS (well-known community)\n"
10561 "Do not send outside local AS (well-known community)\n"
10562 "Do not advertise to any peer (well-known community)\n"
10563 "Do not export to next AS (well-known community)\n"
10565 "Do not send outside local AS (well-known community)\n"
10566 "Do not advertise to any peer (well-known community)\n"
10567 "Do not export to next AS (well-known community)\n"
10569 "Do not send outside local AS (well-known community)\n"
10570 "Do not advertise to any peer (well-known community)\n"
10571 "Do not export to next AS (well-known community)\n")
10574 DEFUN (show_ipv6_bgp_community
,
10575 show_ipv6_bgp_community_cmd
,
10576 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10580 "Display routes matching the communities\n"
10582 "Do not send outside local AS (well-known community)\n"
10583 "Do not advertise to any peer (well-known community)\n"
10584 "Do not export to next AS (well-known community)\n")
10586 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10587 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10591 ALIAS (show_ipv6_bgp_community
,
10592 show_ipv6_bgp_community2_cmd
,
10593 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10597 "Display routes matching the communities\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")
10608 ALIAS (show_ipv6_bgp_community
,
10609 show_ipv6_bgp_community3_cmd
,
10610 "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)",
10614 "Display routes matching the communities\n"
10616 "Do not send outside local AS (well-known community)\n"
10617 "Do not advertise to any peer (well-known community)\n"
10618 "Do not export to next AS (well-known community)\n"
10620 "Do not send outside local AS (well-known community)\n"
10621 "Do not advertise to any peer (well-known community)\n"
10622 "Do not export to next AS (well-known community)\n"
10624 "Do not send outside local AS (well-known community)\n"
10625 "Do not advertise to any peer (well-known community)\n"
10626 "Do not export to next AS (well-known community)\n")
10629 ALIAS (show_ipv6_bgp_community
,
10630 show_ipv6_bgp_community4_cmd
,
10631 "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)",
10635 "Display routes matching the communities\n"
10637 "Do not send outside local AS (well-known community)\n"
10638 "Do not advertise to any peer (well-known community)\n"
10639 "Do not export to next AS (well-known community)\n"
10641 "Do not send outside local AS (well-known community)\n"
10642 "Do not advertise to any peer (well-known community)\n"
10643 "Do not export to next AS (well-known community)\n"
10645 "Do not send outside local AS (well-known community)\n"
10646 "Do not advertise to any peer (well-known community)\n"
10647 "Do not export to next AS (well-known community)\n"
10649 "Do not send outside local AS (well-known community)\n"
10650 "Do not advertise to any peer (well-known community)\n"
10651 "Do not export to next AS (well-known community)\n")
10653 DEFUN (show_bgp_community_exact
,
10654 show_bgp_community_exact_cmd
,
10655 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10658 "Display routes matching the communities\n"
10660 "Do not send outside local AS (well-known community)\n"
10661 "Do not advertise to any peer (well-known community)\n"
10662 "Do not export to next AS (well-known community)\n"
10663 "Exact match of the communities")
10665 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10668 ALIAS (show_bgp_community_exact
,
10669 show_bgp_ipv6_community_exact_cmd
,
10670 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10674 "Display routes matching the communities\n"
10676 "Do not send outside local AS (well-known community)\n"
10677 "Do not advertise to any peer (well-known community)\n"
10678 "Do not export to next AS (well-known community)\n"
10679 "Exact match of the communities")
10681 ALIAS (show_bgp_community_exact
,
10682 show_bgp_community2_exact_cmd
,
10683 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10686 "Display routes matching the communities\n"
10688 "Do not send outside local AS (well-known community)\n"
10689 "Do not advertise to any peer (well-known community)\n"
10690 "Do not export to next AS (well-known community)\n"
10692 "Do not send outside local AS (well-known community)\n"
10693 "Do not advertise to any peer (well-known community)\n"
10694 "Do not export to next AS (well-known community)\n"
10695 "Exact match of the communities")
10697 ALIAS (show_bgp_community_exact
,
10698 show_bgp_ipv6_community2_exact_cmd
,
10699 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10703 "Display routes matching the communities\n"
10705 "Do not send outside local AS (well-known community)\n"
10706 "Do not advertise to any peer (well-known community)\n"
10707 "Do not export to next AS (well-known community)\n"
10709 "Do not send outside local AS (well-known community)\n"
10710 "Do not advertise to any peer (well-known community)\n"
10711 "Do not export to next AS (well-known community)\n"
10712 "Exact match of the communities")
10714 ALIAS (show_bgp_community_exact
,
10715 show_bgp_community3_exact_cmd
,
10716 "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",
10719 "Display routes matching the communities\n"
10721 "Do not send outside local AS (well-known community)\n"
10722 "Do not advertise to any peer (well-known community)\n"
10723 "Do not export to next AS (well-known community)\n"
10725 "Do not send outside local AS (well-known community)\n"
10726 "Do not advertise to any peer (well-known community)\n"
10727 "Do not export to next AS (well-known community)\n"
10729 "Do not send outside local AS (well-known community)\n"
10730 "Do not advertise to any peer (well-known community)\n"
10731 "Do not export to next AS (well-known community)\n"
10732 "Exact match of the communities")
10734 ALIAS (show_bgp_community_exact
,
10735 show_bgp_ipv6_community3_exact_cmd
,
10736 "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",
10740 "Display routes matching the communities\n"
10742 "Do not send outside local AS (well-known community)\n"
10743 "Do not advertise to any peer (well-known community)\n"
10744 "Do not export to next AS (well-known community)\n"
10746 "Do not send outside local AS (well-known community)\n"
10747 "Do not advertise to any peer (well-known community)\n"
10748 "Do not export to next AS (well-known community)\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"
10753 "Exact match of the communities")
10755 ALIAS (show_bgp_community_exact
,
10756 show_bgp_community4_exact_cmd
,
10757 "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",
10760 "Display routes matching the communities\n"
10762 "Do not send outside local AS (well-known community)\n"
10763 "Do not advertise to any peer (well-known community)\n"
10764 "Do not export to next AS (well-known community)\n"
10766 "Do not send outside local AS (well-known community)\n"
10767 "Do not advertise to any peer (well-known community)\n"
10768 "Do not export to next AS (well-known community)\n"
10770 "Do not send outside local AS (well-known community)\n"
10771 "Do not advertise to any peer (well-known community)\n"
10772 "Do not export to next AS (well-known community)\n"
10774 "Do not send outside local AS (well-known community)\n"
10775 "Do not advertise to any peer (well-known community)\n"
10776 "Do not export to next AS (well-known community)\n"
10777 "Exact match of the communities")
10779 ALIAS (show_bgp_community_exact
,
10780 show_bgp_ipv6_community4_exact_cmd
,
10781 "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",
10785 "Display routes matching the communities\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"
10795 "Do not send outside local AS (well-known community)\n"
10796 "Do not advertise to any peer (well-known community)\n"
10797 "Do not export to next AS (well-known community)\n"
10799 "Do not send outside local AS (well-known community)\n"
10800 "Do not advertise to any peer (well-known community)\n"
10801 "Do not export to next AS (well-known community)\n"
10802 "Exact match of the communities")
10805 DEFUN (show_ipv6_bgp_community_exact
,
10806 show_ipv6_bgp_community_exact_cmd
,
10807 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10811 "Display routes matching the communities\n"
10813 "Do not send outside local AS (well-known community)\n"
10814 "Do not advertise to any peer (well-known community)\n"
10815 "Do not export to next AS (well-known community)\n"
10816 "Exact match of the communities")
10818 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10819 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10823 ALIAS (show_ipv6_bgp_community_exact
,
10824 show_ipv6_bgp_community2_exact_cmd
,
10825 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10829 "Display routes matching the communities\n"
10831 "Do not send outside local AS (well-known community)\n"
10832 "Do not advertise to any peer (well-known community)\n"
10833 "Do not export to next AS (well-known community)\n"
10835 "Do not send outside local AS (well-known community)\n"
10836 "Do not advertise to any peer (well-known community)\n"
10837 "Do not export to next AS (well-known community)\n"
10838 "Exact match of the communities")
10841 ALIAS (show_ipv6_bgp_community_exact
,
10842 show_ipv6_bgp_community3_exact_cmd
,
10843 "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",
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"
10860 "Exact match of the communities")
10863 ALIAS (show_ipv6_bgp_community_exact
,
10864 show_ipv6_bgp_community4_exact_cmd
,
10865 "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",
10869 "Display routes matching the communities\n"
10871 "Do not send outside local AS (well-known community)\n"
10872 "Do not advertise to any peer (well-known community)\n"
10873 "Do not export to next AS (well-known community)\n"
10875 "Do not send outside local AS (well-known community)\n"
10876 "Do not advertise to any peer (well-known community)\n"
10877 "Do not export to next AS (well-known community)\n"
10879 "Do not send outside local AS (well-known community)\n"
10880 "Do not advertise to any peer (well-known community)\n"
10881 "Do not export to next AS (well-known community)\n"
10883 "Do not send outside local AS (well-known community)\n"
10884 "Do not advertise to any peer (well-known community)\n"
10885 "Do not export to next AS (well-known community)\n"
10886 "Exact match of the communities")
10889 DEFUN (show_ipv6_mbgp_community
,
10890 show_ipv6_mbgp_community_cmd
,
10891 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10895 "Display routes matching the communities\n"
10897 "Do not send outside local AS (well-known community)\n"
10898 "Do not advertise to any peer (well-known community)\n"
10899 "Do not export to next AS (well-known community)\n")
10901 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10902 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10906 ALIAS (show_ipv6_mbgp_community
,
10907 show_ipv6_mbgp_community2_cmd
,
10908 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10912 "Display routes matching the communities\n"
10914 "Do not send outside local AS (well-known community)\n"
10915 "Do not advertise to any peer (well-known community)\n"
10916 "Do not export to next AS (well-known community)\n"
10918 "Do not send outside local AS (well-known community)\n"
10919 "Do not advertise to any peer (well-known community)\n"
10920 "Do not export to next AS (well-known community)\n")
10923 ALIAS (show_ipv6_mbgp_community
,
10924 show_ipv6_mbgp_community3_cmd
,
10925 "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)",
10929 "Display routes matching the communities\n"
10931 "Do not send outside local AS (well-known community)\n"
10932 "Do not advertise to any peer (well-known community)\n"
10933 "Do not export to next AS (well-known community)\n"
10935 "Do not send outside local AS (well-known community)\n"
10936 "Do not advertise to any peer (well-known community)\n"
10937 "Do not export to next AS (well-known community)\n"
10939 "Do not send outside local AS (well-known community)\n"
10940 "Do not advertise to any peer (well-known community)\n"
10941 "Do not export to next AS (well-known community)\n")
10944 ALIAS (show_ipv6_mbgp_community
,
10945 show_ipv6_mbgp_community4_cmd
,
10946 "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)",
10950 "Display routes matching the communities\n"
10952 "Do not send outside local AS (well-known community)\n"
10953 "Do not advertise to any peer (well-known community)\n"
10954 "Do not export to next AS (well-known community)\n"
10956 "Do not send outside local AS (well-known community)\n"
10957 "Do not advertise to any peer (well-known community)\n"
10958 "Do not export to next AS (well-known community)\n"
10960 "Do not send outside local AS (well-known community)\n"
10961 "Do not advertise to any peer (well-known community)\n"
10962 "Do not export to next AS (well-known community)\n"
10964 "Do not send outside local AS (well-known community)\n"
10965 "Do not advertise to any peer (well-known community)\n"
10966 "Do not export to next AS (well-known community)\n")
10969 DEFUN (show_ipv6_mbgp_community_exact
,
10970 show_ipv6_mbgp_community_exact_cmd
,
10971 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10975 "Display routes matching the communities\n"
10977 "Do not send outside local AS (well-known community)\n"
10978 "Do not advertise to any peer (well-known community)\n"
10979 "Do not export to next AS (well-known community)\n"
10980 "Exact match of the communities")
10982 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10983 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
10987 ALIAS (show_ipv6_mbgp_community_exact
,
10988 show_ipv6_mbgp_community2_exact_cmd
,
10989 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10993 "Display routes matching the communities\n"
10995 "Do not send outside local AS (well-known community)\n"
10996 "Do not advertise to any peer (well-known community)\n"
10997 "Do not export to next AS (well-known community)\n"
10999 "Do not send outside local AS (well-known community)\n"
11000 "Do not advertise to any peer (well-known community)\n"
11001 "Do not export to next AS (well-known community)\n"
11002 "Exact match of the communities")
11005 ALIAS (show_ipv6_mbgp_community_exact
,
11006 show_ipv6_mbgp_community3_exact_cmd
,
11007 "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",
11011 "Display routes matching the communities\n"
11013 "Do not send outside local AS (well-known community)\n"
11014 "Do not advertise to any peer (well-known community)\n"
11015 "Do not export to next AS (well-known community)\n"
11017 "Do not send outside local AS (well-known community)\n"
11018 "Do not advertise to any peer (well-known community)\n"
11019 "Do not export to next AS (well-known community)\n"
11021 "Do not send outside local AS (well-known community)\n"
11022 "Do not advertise to any peer (well-known community)\n"
11023 "Do not export to next AS (well-known community)\n"
11024 "Exact match of the communities")
11027 ALIAS (show_ipv6_mbgp_community_exact
,
11028 show_ipv6_mbgp_community4_exact_cmd
,
11029 "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",
11033 "Display routes matching the communities\n"
11035 "Do not send outside local AS (well-known community)\n"
11036 "Do not advertise to any peer (well-known community)\n"
11037 "Do not export to next AS (well-known community)\n"
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"
11043 "Do not send outside local AS (well-known community)\n"
11044 "Do not advertise to any peer (well-known community)\n"
11045 "Do not export to next AS (well-known community)\n"
11047 "Do not send outside local AS (well-known community)\n"
11048 "Do not advertise to any peer (well-known community)\n"
11049 "Do not export to next AS (well-known community)\n"
11050 "Exact match of the communities")
11051 #endif /* HAVE_IPV6 */
11054 bgp_show_community_list (struct vty
*vty
, const char *name
,
11055 const char *com
, int exact
,
11056 afi_t afi
, safi_t safi
)
11058 struct community_list
*list
;
11059 struct bgp
*bgp
= NULL
;
11061 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11063 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11064 return CMD_WARNING
;
11067 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
11070 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
11072 return CMD_WARNING
;
11075 return bgp_show (vty
, bgp
, afi
, safi
,
11076 (exact
? bgp_show_type_community_list_exact
:
11077 bgp_show_type_community_list
), list
, 0);
11080 DEFUN (show_ip_bgp_community_list
,
11081 show_ip_bgp_community_list_cmd
,
11082 "show ip bgp community-list (<1-500>|WORD)",
11086 "Display routes matching the community-list\n"
11087 "community-list number\n"
11088 "community-list name\n")
11090 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
11093 DEFUN (show_ip_bgp_instance_community_list
,
11094 show_ip_bgp_instance_community_list_cmd
,
11095 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
11099 BGP_INSTANCE_HELP_STR
11100 "Display routes matching the community-list\n"
11101 "community-list number\n"
11102 "community-list name\n")
11104 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
11107 DEFUN (show_ip_bgp_ipv4_community_list
,
11108 show_ip_bgp_ipv4_community_list_cmd
,
11109 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community-list (<1-500>|WORD)",
11115 "Display routes matching the community-list\n"
11116 "community-list number\n"
11117 "community-list name\n")
11120 safi
= bgp_vty_safi_from_arg(argv
[0]);
11121 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, safi
);
11124 DEFUN (show_ip_bgp_community_list_exact
,
11125 show_ip_bgp_community_list_exact_cmd
,
11126 "show ip bgp community-list (<1-500>|WORD) exact-match",
11130 "Display routes matching the community-list\n"
11131 "community-list number\n"
11132 "community-list name\n"
11133 "Exact match of the communities\n")
11135 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
11138 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
11139 show_ip_bgp_ipv4_community_list_exact_cmd
,
11140 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community-list (<1-500>|WORD) exact-match",
11146 "Display routes matching the community-list\n"
11147 "community-list number\n"
11148 "community-list name\n"
11149 "Exact match of the communities\n")
11152 safi
= bgp_vty_safi_from_arg(argv
[0]);
11153 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, safi
);
11157 DEFUN (show_bgp_community_list
,
11158 show_bgp_community_list_cmd
,
11159 "show bgp community-list (<1-500>|WORD)",
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
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11169 ALIAS (show_bgp_community_list
,
11170 show_bgp_ipv6_community_list_cmd
,
11171 "show bgp ipv6 community-list (<1-500>|WORD)",
11175 "Display routes matching the community-list\n"
11176 "community-list number\n"
11177 "community-list name\n")
11180 DEFUN (show_ipv6_bgp_community_list
,
11181 show_ipv6_bgp_community_list_cmd
,
11182 "show ipv6 bgp community-list WORD",
11186 "Display routes matching the community-list\n"
11187 "community-list name\n")
11189 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11190 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11194 DEFUN (show_ipv6_mbgp_community_list
,
11195 show_ipv6_mbgp_community_list_cmd
,
11196 "show ipv6 mbgp community-list WORD",
11200 "Display routes matching the community-list\n"
11201 "community-list name\n")
11203 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11204 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
11207 DEFUN (show_bgp_community_list_exact
,
11208 show_bgp_community_list_exact_cmd
,
11209 "show bgp community-list (<1-500>|WORD) exact-match",
11212 "Display routes matching the community-list\n"
11213 "community-list number\n"
11214 "community-list name\n"
11215 "Exact match of the communities\n")
11217 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11220 ALIAS (show_bgp_community_list_exact
,
11221 show_bgp_ipv6_community_list_exact_cmd
,
11222 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11226 "Display routes matching the community-list\n"
11227 "community-list number\n"
11228 "community-list name\n"
11229 "Exact match of the communities\n")
11232 DEFUN (show_ipv6_bgp_community_list_exact
,
11233 show_ipv6_bgp_community_list_exact_cmd
,
11234 "show ipv6 bgp community-list WORD exact-match",
11238 "Display routes matching the community-list\n"
11239 "community-list name\n"
11240 "Exact match of the communities\n")
11242 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11243 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11247 DEFUN (show_ipv6_mbgp_community_list_exact
,
11248 show_ipv6_mbgp_community_list_exact_cmd
,
11249 "show ipv6 mbgp community-list WORD exact-match",
11253 "Display routes matching the community-list\n"
11254 "community-list name\n"
11255 "Exact match of the communities\n")
11257 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11258 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
11260 #endif /* HAVE_IPV6 */
11263 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11264 const char *prefix
, afi_t afi
,
11265 safi_t safi
, enum bgp_show_type type
)
11269 struct bgp
*bgp
= NULL
;
11271 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11273 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11274 return CMD_WARNING
;
11279 ret
= str2prefix (prefix
, p
);
11282 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11283 return CMD_WARNING
;
11286 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11291 DEFUN (show_ip_bgp_prefix_longer
,
11292 show_ip_bgp_prefix_longer_cmd
,
11293 "show ip bgp A.B.C.D/M longer-prefixes",
11297 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11298 "Display route and more specific routes\n")
11300 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11301 bgp_show_type_prefix_longer
);
11304 DEFUN (show_ip_bgp_instance_prefix_longer
,
11305 show_ip_bgp_instance_prefix_longer_cmd
,
11306 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11310 BGP_INSTANCE_HELP_STR
11311 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11312 "Display route and more specific routes\n")
11314 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
11315 bgp_show_type_prefix_longer
);
11318 DEFUN (show_ip_bgp_flap_prefix_longer
,
11319 show_ip_bgp_flap_prefix_longer_cmd
,
11320 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11324 "Display flap statistics of routes\n"
11325 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11326 "Display route and more specific routes\n")
11328 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11329 bgp_show_type_flap_prefix_longer
);
11332 ALIAS (show_ip_bgp_flap_prefix_longer
,
11333 show_ip_bgp_damp_flap_prefix_longer_cmd
,
11334 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11338 "Display detailed information about dampening\n"
11339 "Display flap statistics of routes\n"
11340 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11341 "Display route and more specific routes\n")
11343 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11344 show_ip_bgp_ipv4_prefix_longer_cmd
,
11345 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M longer-prefixes",
11351 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11352 "Display route and more specific routes\n")
11355 safi
= bgp_vty_safi_from_arg(argv
[0]);
11356 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, safi
,
11357 bgp_show_type_prefix_longer
);
11360 DEFUN (show_ip_bgp_flap_address
,
11361 show_ip_bgp_flap_address_cmd
,
11362 "show ip bgp flap-statistics A.B.C.D",
11366 "Display flap statistics of routes\n"
11367 "Network in the BGP routing table to display\n")
11369 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11370 bgp_show_type_flap_address
);
11373 ALIAS (show_ip_bgp_flap_address
,
11374 show_ip_bgp_damp_flap_address_cmd
,
11375 "show ip bgp dampening flap-statistics A.B.C.D",
11379 "Display detailed information about dampening\n"
11380 "Display flap statistics of routes\n"
11381 "Network in the BGP routing table to display\n")
11383 DEFUN (show_ip_bgp_flap_prefix
,
11384 show_ip_bgp_flap_prefix_cmd
,
11385 "show ip bgp flap-statistics A.B.C.D/M",
11389 "Display flap statistics of routes\n"
11390 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11392 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11393 bgp_show_type_flap_prefix
);
11396 ALIAS (show_ip_bgp_flap_prefix
,
11397 show_ip_bgp_damp_flap_prefix_cmd
,
11398 "show ip bgp dampening flap-statistics A.B.C.D/M",
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")
11407 DEFUN (show_bgp_prefix_longer
,
11408 show_bgp_prefix_longer_cmd
,
11409 "show bgp X:X::X:X/M longer-prefixes",
11412 "IPv6 prefix <network>/<length>\n"
11413 "Display route and more specific routes\n")
11415 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11416 bgp_show_type_prefix_longer
);
11419 ALIAS (show_bgp_prefix_longer
,
11420 show_bgp_ipv6_prefix_longer_cmd
,
11421 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11425 "IPv6 prefix <network>/<length>\n"
11426 "Display route and more specific routes\n")
11429 DEFUN (show_ipv6_bgp_prefix_longer
,
11430 show_ipv6_bgp_prefix_longer_cmd
,
11431 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11435 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11436 "Display route and more specific routes\n")
11438 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11439 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11440 bgp_show_type_prefix_longer
);
11444 DEFUN (show_ipv6_mbgp_prefix_longer
,
11445 show_ipv6_mbgp_prefix_longer_cmd
,
11446 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11450 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11451 "Display route and more specific routes\n")
11453 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11454 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11455 bgp_show_type_prefix_longer
);
11457 #endif /* HAVE_IPV6 */
11459 static struct peer
*
11460 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11461 const char *ip_str
, u_char use_json
)
11466 union sockunion su
;
11468 /* BGP structure lookup. */
11471 bgp
= bgp_lookup_by_name (view_name
);
11476 json_object
*json_no
= NULL
;
11477 json_no
= json_object_new_object();
11478 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11479 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11480 json_object_free(json_no
);
11483 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11489 bgp
= bgp_get_default ();
11494 json_object
*json_no
= NULL
;
11495 json_no
= json_object_new_object();
11496 json_object_string_add(json_no
, "warning", "No BGP process configured");
11497 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11498 json_object_free(json_no
);
11501 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11506 /* Get peer sockunion. */
11507 ret
= str2sockunion (ip_str
, &su
);
11510 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11513 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11519 json_object
*json_no
= NULL
;
11520 json_no
= json_object_new_object();
11521 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11522 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11523 json_object_free(json_no
);
11526 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11533 /* Peer structure lookup. */
11534 peer
= peer_lookup (bgp
, &su
);
11539 json_object
*json_no
= NULL
;
11540 json_no
= json_object_new_object();
11541 json_object_string_add(json_no
, "warning","No such neighbor");
11542 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11543 json_object_free(json_no
);
11546 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11555 BGP_STATS_MAXBITLEN
= 0,
11557 BGP_STATS_PREFIXES
,
11559 BGP_STATS_UNAGGREGATEABLE
,
11560 BGP_STATS_MAX_AGGREGATEABLE
,
11561 BGP_STATS_AGGREGATES
,
11563 BGP_STATS_ASPATH_COUNT
,
11564 BGP_STATS_ASPATH_MAXHOPS
,
11565 BGP_STATS_ASPATH_TOTHOPS
,
11566 BGP_STATS_ASPATH_MAXSIZE
,
11567 BGP_STATS_ASPATH_TOTSIZE
,
11568 BGP_STATS_ASN_HIGHEST
,
11572 static const char *table_stats_strs
[] =
11574 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11575 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11576 [BGP_STATS_RIB
] = "Total Advertisements",
11577 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11578 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11579 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11580 [BGP_STATS_SPACE
] = "Address space advertised",
11581 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11582 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11583 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11584 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11585 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11586 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11587 [BGP_STATS_MAX
] = NULL
,
11590 struct bgp_table_stats
11592 struct bgp_table
*table
;
11593 unsigned long long counts
[BGP_STATS_MAX
];
11597 #define TALLY_SIGFIG 100000
11598 static unsigned long
11599 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11601 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11602 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11603 unsigned long ret
= newtot
/ count
;
11605 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11613 bgp_table_stats_walker (struct thread
*t
)
11615 struct bgp_node
*rn
;
11616 struct bgp_node
*top
;
11617 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11618 unsigned int space
= 0;
11620 if (!(top
= bgp_table_top (ts
->table
)))
11623 switch (top
->p
.family
)
11626 space
= IPV4_MAX_BITLEN
;
11629 space
= IPV6_MAX_BITLEN
;
11633 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11635 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11637 struct bgp_info
*ri
;
11638 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11639 unsigned int rinum
= 0;
11647 ts
->counts
[BGP_STATS_PREFIXES
]++;
11648 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11651 ts
->counts
[BGP_STATS_AVGPLEN
]
11652 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11653 ts
->counts
[BGP_STATS_AVGPLEN
],
11657 /* check if the prefix is included by any other announcements */
11658 while (prn
&& !prn
->info
)
11659 prn
= bgp_node_parent_nolock (prn
);
11661 if (prn
== NULL
|| prn
== top
)
11663 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11664 /* announced address space */
11666 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11668 else if (prn
->info
)
11669 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11671 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11674 ts
->counts
[BGP_STATS_RIB
]++;
11677 (CHECK_FLAG (ri
->attr
->flag
,
11678 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11679 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11681 /* as-path stats */
11682 if (ri
->attr
&& ri
->attr
->aspath
)
11684 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11685 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11686 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11688 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11690 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11691 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11693 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11694 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11696 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11697 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11699 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11700 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11701 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11703 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11704 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11705 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11708 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11709 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11717 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11719 struct bgp_table_stats ts
;
11722 if (!bgp
->rib
[afi
][safi
])
11724 vty_out (vty
, "%% No RIB exists for the AFI(%d)/SAFI(%d)%s",
11725 afi
, safi
, VTY_NEWLINE
);
11726 return CMD_WARNING
;
11729 memset (&ts
, 0, sizeof (ts
));
11730 ts
.table
= bgp
->rib
[afi
][safi
];
11731 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11733 vty_out (vty
, "BGP %s RIB statistics%s%s",
11734 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11736 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11738 if (!table_stats_strs
[i
])
11744 case BGP_STATS_ASPATH_AVGHOPS
:
11745 case BGP_STATS_ASPATH_AVGSIZE
:
11746 case BGP_STATS_AVGPLEN
:
11747 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11748 vty_out (vty
, "%12.2f",
11749 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11752 case BGP_STATS_ASPATH_TOTHOPS
:
11753 case BGP_STATS_ASPATH_TOTSIZE
:
11754 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11755 vty_out (vty
, "%12.2f",
11757 (float)ts
.counts
[i
] /
11758 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11761 case BGP_STATS_TOTPLEN
:
11762 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11763 vty_out (vty
, "%12.2f",
11765 (float)ts
.counts
[i
] /
11766 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11769 case BGP_STATS_SPACE
:
11770 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11771 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11772 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11774 vty_out (vty
, "%30s: ", "%% announced ");
11775 vty_out (vty
, "%12.2f%s",
11776 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11777 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11779 vty_out (vty
, "%30s: ", "/8 equivalent ");
11780 vty_out (vty
, "%12.2f%s",
11781 (float)ts
.counts
[BGP_STATS_SPACE
] /
11782 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11784 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11786 vty_out (vty
, "%30s: ", "/24 equivalent ");
11787 vty_out (vty
, "%12.2f",
11788 (float)ts
.counts
[BGP_STATS_SPACE
] /
11789 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11792 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11793 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11796 vty_out (vty
, "%s", VTY_NEWLINE
);
11798 return CMD_SUCCESS
;
11802 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11803 const char *afi_str
, const char *safi_str
)
11810 bgp
= bgp_lookup_by_name (name
);
11812 bgp
= bgp_get_default ();
11816 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11817 return CMD_WARNING
;
11819 afi
= bgp_vty_afi_from_arg(afi_str
);
11820 if (afi
== AFI_MAX
)
11822 vty_out (vty
, "%% Invalid address family \"%s\"%s",
11823 afi_str
, VTY_NEWLINE
);
11824 return CMD_WARNING
;
11826 safi
= bgp_vty_safi_from_arg(safi_str
);
11827 if (safi
== SAFI_MAX
)
11829 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11830 safi_str
, VTY_NEWLINE
);
11831 return CMD_WARNING
;
11834 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11837 DEFUN (show_bgp_statistics
,
11838 show_bgp_statistics_cmd
,
11839 "show bgp "BGP_AFI_SAFI_CMD_STR
" statistics",
11842 BGP_INSTANCE_HELP_STR
11843 "BGP RIB advertisement statistics\n")
11845 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11848 DEFUN (show_bgp_statistics_view
,
11849 show_bgp_statistics_view_cmd
,
11850 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" statistics",
11853 BGP_INSTANCE_HELP_STR
11854 BGP_AFI_SAFI_HELP_STR
11855 "BGP RIB advertisement statistics\n")
11857 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11870 PCOUNT_PFCNT
, /* the figure we display to users */
11874 static const char *pcount_strs
[] =
11876 [PCOUNT_ADJ_IN
] = "Adj-in",
11877 [PCOUNT_DAMPED
] = "Damped",
11878 [PCOUNT_REMOVED
] = "Removed",
11879 [PCOUNT_HISTORY
] = "History",
11880 [PCOUNT_STALE
] = "Stale",
11881 [PCOUNT_VALID
] = "Valid",
11882 [PCOUNT_ALL
] = "All RIB",
11883 [PCOUNT_COUNTED
] = "PfxCt counted",
11884 [PCOUNT_PFCNT
] = "Useable",
11885 [PCOUNT_MAX
] = NULL
,
11888 struct peer_pcounts
11890 unsigned int count
[PCOUNT_MAX
];
11891 const struct peer
*peer
;
11892 const struct bgp_table
*table
;
11896 bgp_peer_count_walker (struct thread
*t
)
11898 struct bgp_node
*rn
;
11899 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11900 const struct peer
*peer
= pc
->peer
;
11902 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11904 struct bgp_adj_in
*ain
;
11905 struct bgp_info
*ri
;
11907 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11908 if (ain
->peer
== peer
)
11909 pc
->count
[PCOUNT_ADJ_IN
]++;
11911 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11913 char buf
[SU_ADDRSTRLEN
];
11915 if (ri
->peer
!= peer
)
11918 pc
->count
[PCOUNT_ALL
]++;
11920 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11921 pc
->count
[PCOUNT_DAMPED
]++;
11922 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11923 pc
->count
[PCOUNT_HISTORY
]++;
11924 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
11925 pc
->count
[PCOUNT_REMOVED
]++;
11926 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
11927 pc
->count
[PCOUNT_STALE
]++;
11928 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
11929 pc
->count
[PCOUNT_VALID
]++;
11930 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11931 pc
->count
[PCOUNT_PFCNT
]++;
11933 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
11935 pc
->count
[PCOUNT_COUNTED
]++;
11936 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11937 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
11939 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11940 buf
, SU_ADDRSTRLEN
),
11946 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11947 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
11949 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11950 buf
, SU_ADDRSTRLEN
),
11960 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
11962 struct peer_pcounts pcounts
= { .peer
= peer
};
11964 json_object
*json
= NULL
;
11965 json_object
*json_loop
= NULL
;
11969 json
= json_object_new_object();
11970 json_loop
= json_object_new_object();
11973 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
11974 || !peer
->bgp
->rib
[afi
][safi
])
11978 json_object_string_add(json
, "warning", "No such neighbor or address family");
11979 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
11980 json_object_free(json
);
11983 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11985 return CMD_WARNING
;
11988 memset (&pcounts
, 0, sizeof(pcounts
));
11989 pcounts
.peer
= peer
;
11990 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
11992 /* in-place call via thread subsystem so as to record execution time
11993 * * stats for the thread-walk (i.e. ensure this can't be blamed on
11994 * * on just vty_read()).
11996 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
12000 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
12001 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
12002 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
12004 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12005 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
12007 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
12009 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12011 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
12012 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
12014 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12015 json_object_free(json
);
12020 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
12022 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
12023 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
12028 vty_out (vty
, "Prefix counts for %s, %s%s",
12029 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
12032 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
12033 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
12034 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
12036 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12037 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
12039 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12041 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
12042 peer
->host
, VTY_NEWLINE
);
12043 vty_out (vty
, "Please report this bug, with the above command output%s",
12048 return CMD_SUCCESS
;
12051 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
12052 show_ip_bgp_neighbor_prefix_counts_cmd
,
12053 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12057 "Detailed information on TCP and BGP neighbor connections\n"
12058 "Neighbor to display information about\n"
12059 "Neighbor to display information about\n"
12060 "Neighbor on bgp configured interface\n"
12061 "Display detailed prefix count information\n"
12062 "JavaScript Object Notation\n")
12065 u_char uj
= use_json(argc
, argv
);
12067 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12069 return CMD_WARNING
;
12071 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12074 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
12075 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
12076 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12080 BGP_INSTANCE_HELP_STR
12081 "Detailed information on TCP and BGP neighbor connections\n"
12082 "Neighbor to display information about\n"
12083 "Neighbor to display information about\n"
12084 "Neighbor on bgp configured interface\n"
12085 "Display detailed prefix count information\n"
12086 "JavaScript Object Notation\n")
12089 u_char uj
= use_json(argc
, argv
);
12091 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12093 return CMD_WARNING
;
12095 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12098 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
12099 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
12100 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12104 "Detailed information on TCP and BGP neighbor connections\n"
12105 "Neighbor to display information about\n"
12106 "Neighbor to display information about\n"
12107 "Neighbor on bgp configured interface\n"
12108 "Display detailed prefix count information\n"
12109 "JavaScript Object Notation\n")
12112 u_char uj
= use_json(argc
, argv
);
12114 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12116 return CMD_WARNING
;
12118 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12121 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
12122 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
12123 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12126 BGP_INSTANCE_HELP_STR
12128 "Detailed information on TCP and BGP neighbor connections\n"
12129 "Neighbor to display information about\n"
12130 "Neighbor to display information about\n"
12131 "Neighbor on bgp configured interface\n"
12132 "Display detailed prefix count information\n"
12133 "JavaScript Object Notation\n")
12136 u_char uj
= use_json(argc
, argv
);
12138 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12140 return CMD_WARNING
;
12142 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12145 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
12146 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
12147 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12153 "Detailed information on TCP and BGP neighbor connections\n"
12154 "Neighbor to display information about\n"
12155 "Neighbor to display information about\n"
12156 "Neighbor on bgp configured interface\n"
12157 "Display detailed prefix count information\n"
12158 "JavaScript Object Notation\n")
12161 u_char uj
= use_json(argc
, argv
);
12163 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12165 return CMD_WARNING
;
12168 safi
= bgp_vty_safi_from_arg(argv
[0]);
12169 return bgp_peer_counts (vty
, peer
, AFI_IP
, safi
, uj
);
12173 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12174 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
12176 struct bgp_table
*table
;
12177 struct bgp_adj_in
*ain
;
12178 struct bgp_adj_out
*adj
;
12179 unsigned long output_count
;
12180 unsigned long filtered_count
;
12181 struct bgp_node
*rn
;
12186 struct attr_extra extra
;
12188 struct update_subgroup
*subgrp
;
12189 json_object
*json_scode
= NULL
;
12190 json_object
*json_ocode
= NULL
;
12191 json_object
*json_ar
= NULL
;
12192 struct peer_af
*paf
;
12196 json_scode
= json_object_new_object();
12197 json_ocode
= json_object_new_object();
12198 json_ar
= json_object_new_object();
12200 json_object_string_add(json_scode
, "suppressed", "s");
12201 json_object_string_add(json_scode
, "damped", "d");
12202 json_object_string_add(json_scode
, "history", "h");
12203 json_object_string_add(json_scode
, "valid", "*");
12204 json_object_string_add(json_scode
, "best", ">");
12205 json_object_string_add(json_scode
, "multipath", "=");
12206 json_object_string_add(json_scode
, "internal", "i");
12207 json_object_string_add(json_scode
, "ribFailure", "r");
12208 json_object_string_add(json_scode
, "stale", "S");
12209 json_object_string_add(json_scode
, "removed", "R");
12211 json_object_string_add(json_ocode
, "igp", "i");
12212 json_object_string_add(json_ocode
, "egp", "e");
12213 json_object_string_add(json_ocode
, "incomplete", "?");
12222 json_object_string_add(json
, "alert", "no BGP");
12223 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12224 json_object_free(json
);
12227 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12231 table
= bgp
->rib
[afi
][safi
];
12233 output_count
= filtered_count
= 0;
12234 subgrp
= peer_subgroup(peer
, afi
, safi
);
12236 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12240 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12241 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12242 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12243 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12244 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12248 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12249 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12250 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12252 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12253 VTY_NEWLINE
, VTY_NEWLINE
);
12258 attr
.extra
= &extra
;
12259 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12263 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12265 if (ain
->peer
== peer
)
12271 json_object_int_add(json
, "bgpTableVersion", 0);
12272 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12273 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12274 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12278 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12279 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12280 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12287 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12292 bgp_attr_dup(&attr
, ain
->attr
);
12293 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12295 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12306 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12307 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12308 if (paf
->peer
== peer
)
12314 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12315 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12316 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12317 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12321 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12322 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12323 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12324 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12332 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12338 bgp_attr_dup(&attr
, adj
->attr
);
12339 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12340 if (ret
!= RMAP_DENY
)
12342 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12352 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12354 if (output_count
!= 0)
12357 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12359 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12360 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12364 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12365 json_object_free(json
);
12371 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12372 int in
, const char *rmap_name
, u_char use_json
)
12374 json_object
*json
= NULL
;
12377 json
= json_object_new_object();
12379 if (!peer
|| !peer
->afc
[afi
][safi
])
12383 json_object_string_add(json
, "warning", "No such neighbor or address family");
12384 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12385 json_object_free(json
);
12388 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12390 return CMD_WARNING
;
12393 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12397 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12398 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12399 json_object_free(json
);
12402 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12404 return CMD_WARNING
;
12407 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12409 return CMD_SUCCESS
;
12412 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12413 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12414 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12418 BGP_INSTANCE_HELP_STR
12419 "Detailed information on TCP and BGP neighbor connections\n"
12420 "Neighbor to display information about\n"
12421 "Neighbor to display information about\n"
12422 "Display the routes advertised to a BGP neighbor\n"
12423 "JavaScript Object Notation\n")
12426 u_char uj
= use_json(argc
, argv
);
12428 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12429 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12431 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12434 return CMD_WARNING
;
12436 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12439 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12440 show_ip_bgp_neighbor_advertised_route_cmd
,
12441 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12445 "Detailed information on TCP and BGP neighbor connections\n"
12446 "Neighbor to display information about\n"
12447 "Neighbor to display information about\n"
12448 "Neighbor on bgp configured interface\n"
12449 "Display the routes advertised to a BGP neighbor\n"
12450 "JavaScript Object Notation\n")
12454 const char *rmap_name
= NULL
;
12455 u_char uj
= use_json(argc
, argv
);
12457 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12460 return CMD_WARNING
;
12462 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12464 rmap_name
= argv
[1];
12466 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12469 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12470 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12471 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12475 "Detailed information on TCP and BGP neighbor connections\n"
12476 "Neighbor to display information about\n"
12477 "Neighbor to display information about\n"
12478 "Neighbor on bgp configured interface\n"
12479 "Display the routes advertised to a BGP neighbor\n"
12480 "JavaScript Object Notation\n")
12482 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12483 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12484 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12488 BGP_INSTANCE_HELP_STR
12489 "Detailed information on TCP and BGP neighbor connections\n"
12490 "Neighbor to display information about\n"
12491 "Neighbor to display information about\n"
12492 "Neighbor on bgp configured interface\n"
12493 "Display the routes advertised to a BGP neighbor\n"
12494 "JavaScript Object Notation\n")
12495 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12496 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12497 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12503 "Detailed information on TCP and BGP neighbor connections\n"
12504 "Neighbor to display information about\n"
12505 "Neighbor to display information about\n"
12506 "Neighbor on bgp configured interface\n"
12507 "Display the routes advertised to a BGP neighbor\n"
12508 "JavaScript Object Notation\n")
12511 const char *rmap_name
= NULL
;
12514 u_char uj
= use_json(argc
, argv
);
12516 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12518 return CMD_WARNING
;
12520 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12521 rmap_name
= argv
[2];
12523 safi
= bgp_vty_safi_from_arg(argv
[0]);
12524 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 0, rmap_name
, uj
);
12527 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12528 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12529 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12535 "Detailed information on TCP and BGP neighbor connections\n"
12536 "Neighbor to display information about\n"
12537 "Neighbor to display information about\n"
12538 "Neighbor on bgp configured interface\n"
12539 "Display the routes advertised to a BGP neighbor\n"
12540 "Route-map to control what is displayed\n"
12541 "JavaScript Object Notation\n")
12544 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12545 show_bgp_instance_neighbor_advertised_route_cmd
,
12546 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12549 BGP_INSTANCE_HELP_STR
12550 "Detailed information on TCP and BGP neighbor connections\n"
12551 "Neighbor to display information about\n"
12552 "Neighbor to display information about\n"
12553 "Neighbor on bgp configured interface\n"
12554 "Display the routes advertised to a BGP neighbor\n"
12555 "JavaScript Object Notation\n")
12558 u_char uj
= use_json(argc
, argv
);
12560 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12561 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12563 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12566 return CMD_WARNING
;
12568 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12571 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12572 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12573 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12576 BGP_INSTANCE_HELP_STR
12578 "Detailed information on TCP and BGP neighbor connections\n"
12579 "Neighbor to display information about\n"
12580 "Neighbor to display information about\n"
12581 "Neighbor on bgp configured interface\n"
12582 "Display the routes advertised to a BGP neighbor\n"
12583 "JavaScript Object Notation\n")
12585 DEFUN (show_bgp_neighbor_advertised_route
,
12586 show_bgp_neighbor_advertised_route_cmd
,
12587 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12590 "Detailed information on TCP and BGP neighbor connections\n"
12591 "Neighbor to display information about\n"
12592 "Neighbor to display information about\n"
12593 "Neighbor on bgp configured interface\n"
12594 "Display the routes advertised to a BGP neighbor\n"
12595 "JavaScript Object Notation\n")
12599 const char *rmap_name
= NULL
;
12600 u_char uj
= use_json(argc
, argv
);
12602 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12605 return CMD_WARNING
;
12607 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12608 rmap_name
= argv
[1];
12610 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12613 ALIAS (show_bgp_neighbor_advertised_route
,
12614 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12615 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12619 "Detailed information on TCP and BGP neighbor connections\n"
12620 "Neighbor to display information about\n"
12621 "Neighbor to display information about\n"
12622 "Neighbor on bgp configured interface\n"
12623 "Display the routes advertised to a BGP neighbor\n"
12624 "JavaScript Object Notation\n")
12627 ALIAS (show_bgp_neighbor_advertised_route
,
12628 ipv6_bgp_neighbor_advertised_route_cmd
,
12629 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12633 "Detailed information on TCP and BGP neighbor connections\n"
12634 "Neighbor to display information about\n"
12635 "Neighbor to display information about\n"
12636 "Neighbor on bgp configured interface\n"
12637 "Display the routes advertised to a BGP neighbor\n"
12638 "JavaScript Object Notation\n")
12641 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12642 ipv6_mbgp_neighbor_advertised_route_cmd
,
12643 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12647 "Detailed information on TCP and BGP neighbor connections\n"
12648 "Neighbor to display information about\n"
12649 "Neighbor to display information about\n"
12650 "Neighbor on bgp configured interface\n"
12651 "Neighbor on bgp configured interface\n"
12652 "Display the routes advertised to a BGP neighbor\n"
12653 "JavaScript Object Notation\n")
12656 u_char uj
= use_json(argc
, argv
);
12658 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12660 return CMD_WARNING
;
12662 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12663 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12665 #endif /* HAVE_IPV6 */
12667 DEFUN (show_bgp_instance_neighbor_received_routes
,
12668 show_bgp_instance_neighbor_received_routes_cmd
,
12669 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12672 BGP_INSTANCE_HELP_STR
12673 "Detailed information on TCP and BGP neighbor connections\n"
12674 "Neighbor to display information about\n"
12675 "Neighbor to display information about\n"
12676 "Neighbor on bgp configured interface\n"
12677 "Display the received routes from neighbor\n"
12678 "JavaScript Object Notation\n")
12681 u_char uj
= use_json(argc
, argv
);
12683 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12685 return CMD_WARNING
;
12687 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12690 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12691 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12692 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12696 BGP_INSTANCE_HELP_STR
12697 "Detailed information on TCP and BGP neighbor connections\n"
12698 "Neighbor to display information about\n"
12699 "Neighbor to display information about\n"
12700 "Neighbor on bgp configured interface\n"
12701 "Display the received routes from neighbor\n"
12702 "JavaScript Object Notation\n")
12705 u_char uj
= use_json(argc
, argv
);
12707 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12709 return CMD_WARNING
;
12711 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12714 ALIAS (show_bgp_instance_neighbor_received_routes
,
12715 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12716 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12719 BGP_INSTANCE_HELP_STR
12721 "Detailed information on TCP and BGP neighbor connections\n"
12722 "Neighbor to display information about\n"
12723 "Neighbor to display information about\n"
12724 "Neighbor on bgp configured interface\n"
12725 "Display the received routes from neighbor\n"
12726 "JavaScript Object Notation\n")
12728 DEFUN (show_ip_bgp_neighbor_received_routes
,
12729 show_ip_bgp_neighbor_received_routes_cmd
,
12730 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12734 "Detailed information on TCP and BGP neighbor connections\n"
12735 "Neighbor to display information about\n"
12736 "Neighbor to display information about\n"
12737 "Neighbor on bgp configured interface\n"
12738 "Display the received routes from neighbor\n"
12739 "JavaScript Object Notation\n")
12743 const char *rmap_name
= NULL
;
12744 u_char uj
= use_json(argc
, argv
);
12746 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12749 return CMD_WARNING
;
12751 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12752 rmap_name
= argv
[1];
12754 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12757 ALIAS (show_ip_bgp_neighbor_received_routes
,
12758 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12759 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12763 "Detailed information on TCP and BGP neighbor connections\n"
12764 "Neighbor to display information about\n"
12765 "Neighbor to display information about\n"
12766 "Neighbor on bgp configured interface\n"
12767 "Display the received routes from neighbor\n"
12768 "JavaScript Object Notation\n")
12770 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12771 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12772 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12776 BGP_INSTANCE_HELP_STR
12777 "Detailed information on TCP and BGP neighbor connections\n"
12778 "Neighbor to display information about\n"
12779 "Neighbor to display information about\n"
12780 "Neighbor on bgp configured interface\n"
12781 "Display the received routes from neighbor\n"
12782 "JavaScript Object Notation\n")
12784 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12785 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12786 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12792 "Detailed information on TCP and BGP neighbor connections\n"
12793 "Neighbor to display information about\n"
12794 "Neighbor to display information about\n"
12795 "Neighbor on bgp configured interface\n"
12796 "Display the received routes from neighbor\n"
12797 "JavaScript Object Notation\n")
12800 const char *rmap_name
= NULL
;
12802 u_char uj
= use_json(argc
, argv
);
12804 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12806 return CMD_WARNING
;
12808 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12809 rmap_name
= argv
[2];
12811 safi
= bgp_vty_safi_from_arg(argv
[0]);
12812 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 1, rmap_name
, uj
);
12815 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12816 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12817 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12823 "Detailed information on TCP and BGP neighbor connections\n"
12824 "Neighbor to display information about\n"
12825 "Neighbor to display information about\n"
12826 "Neighbor on bgp configured interface\n"
12827 "Display the received routes from neighbor\n"
12828 "JavaScript Object Notation\n")
12830 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12831 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12832 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}",
12835 BGP_INSTANCE_HELP_STR
12836 BGP_AFI_SAFI_HELP_STR
12837 "Detailed information on TCP and BGP neighbor connections\n"
12838 "Neighbor to display information about\n"
12839 "Neighbor to display information about\n"
12840 "Neighbor on bgp configured interface\n"
12841 "Display the advertised routes to neighbor\n"
12842 "Display the received routes from neighbor\n"
12843 "JavaScript Object Notation\n")
12849 u_char uj
= use_json(argc
, argv
);
12851 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12854 return CMD_WARNING
;
12856 afi
= bgp_vty_safi_from_arg(argv
[2]);
12857 safi
= bgp_vty_safi_from_arg(argv
[3]);
12858 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12860 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12863 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12864 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12865 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12869 "Detailed information on TCP and BGP neighbor connections\n"
12870 "Neighbor to display information about\n"
12871 "Neighbor to display information about\n"
12872 "Neighbor on bgp configured interface\n"
12873 "Display information received from a BGP neighbor\n"
12874 "Display the prefixlist filter\n"
12875 "JavaScript Object Notation\n")
12878 union sockunion su
;
12881 u_char uj
= use_json(argc
, argv
);
12883 ret
= str2sockunion (argv
[0], &su
);
12886 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12891 json_object
*json_no
= NULL
;
12892 json_object
*json_sub
= NULL
;
12893 json_no
= json_object_new_object();
12894 json_sub
= json_object_new_object();
12895 json_object_string_add(json_no
, "warning", "Malformed address or name");
12896 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12897 json_object_object_add(json_no
, "detail", json_sub
);
12898 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12899 json_object_free(json_no
);
12902 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12903 return CMD_WARNING
;
12908 peer
= peer_lookup (NULL
, &su
);
12913 json_object
*json_no
= NULL
;
12914 json_no
= json_object_new_object();
12915 json_object_string_add(json_no
, "warning", "Peer not found");
12916 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12917 json_object_free(json_no
);
12920 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12921 return CMD_WARNING
;
12925 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12926 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12930 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12931 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12937 json_object
*json_no
= NULL
;
12938 json_no
= json_object_new_object();
12939 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12940 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12941 json_object_free(json_no
);
12944 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12947 return CMD_SUCCESS
;
12950 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
12951 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
12952 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12958 "Detailed information on TCP and BGP neighbor connections\n"
12959 "Neighbor to display information about\n"
12960 "Neighbor to display information about\n"
12961 "Neighbor on bgp configured interface\n"
12962 "Display information received from a BGP neighbor\n"
12963 "Display the prefixlist filter\n"
12964 "JavaScript Object Notation\n")
12967 union sockunion su
;
12970 u_char uj
= use_json(argc
, argv
);
12972 ret
= str2sockunion (argv
[1], &su
);
12975 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
12980 json_object
*json_no
= NULL
;
12981 json_object
*json_sub
= NULL
;
12982 json_no
= json_object_new_object();
12983 json_sub
= json_object_new_object();
12984 json_object_string_add(json_no
, "warning", "Malformed address or name");
12985 json_object_string_add(json_sub
, "warningCause", argv
[1]);
12986 json_object_object_add(json_no
, "detail", json_sub
);
12987 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12988 json_object_free(json_no
);
12991 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
12992 return CMD_WARNING
;
12997 peer
= peer_lookup (NULL
, &su
);
13002 json_object
*json_no
= NULL
;
13003 json_no
= json_object_new_object();
13004 json_object_string_add(json_no
, "warning", "Peer not found");
13005 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13006 json_object_free(json_no
);
13009 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13010 return CMD_WARNING
;
13016 safi
= bgp_vty_safi_from_arg(argv
[0]);
13017 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, safi
);
13018 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13022 vty_out (vty
, "Address family: %s%s",
13023 afi_safi_print (AFI_IP
, safi
), VTY_NEWLINE
);
13024 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13030 json_object
*json_no
= NULL
;
13031 json_no
= json_object_new_object();
13032 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13033 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13034 json_object_free(json_no
);
13037 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13041 return CMD_SUCCESS
;
13044 DEFUN (show_bgp_neighbor_received_routes
,
13045 show_bgp_neighbor_received_routes_cmd
,
13046 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13049 "Detailed information on TCP and BGP neighbor connections\n"
13050 "Neighbor to display information about\n"
13051 "Neighbor to display information about\n"
13052 "Neighbor on bgp configured interface\n"
13053 "Display the received routes from neighbor\n"
13054 "JavaScript Object Notation\n")
13057 const char *rmap_name
= NULL
;
13058 u_char uj
= use_json(argc
, argv
);
13060 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13063 return CMD_WARNING
;
13065 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
13066 rmap_name
= argv
[1];
13068 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13071 ALIAS (show_bgp_neighbor_received_routes
,
13072 show_bgp_ipv6_neighbor_received_routes_cmd
,
13073 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13077 "Detailed information on TCP and BGP neighbor connections\n"
13078 "Neighbor to display information about\n"
13079 "Neighbor to display information about\n"
13080 "Neighbor on bgp configured interface\n"
13081 "Display the received routes from neighbor\n"
13082 "JavaScript Object Notation\n")
13084 DEFUN (show_bgp_neighbor_received_prefix_filter
,
13085 show_bgp_neighbor_received_prefix_filter_cmd
,
13086 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13089 "Detailed information on TCP and BGP neighbor connections\n"
13090 "Neighbor to display information about\n"
13091 "Neighbor to display information about\n"
13092 "Neighbor on bgp configured interface\n"
13093 "Display information received from a BGP neighbor\n"
13094 "Display the prefixlist filter\n"
13095 "JavaScript Object Notation\n")
13098 union sockunion su
;
13101 u_char uj
= use_json(argc
, argv
);
13103 ret
= str2sockunion (argv
[0], &su
);
13106 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13111 json_object
*json_no
= NULL
;
13112 json_object
*json_sub
= NULL
;
13113 json_no
= json_object_new_object();
13114 json_sub
= json_object_new_object();
13115 json_object_string_add(json_no
, "warning", "Malformed address or name");
13116 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13117 json_object_object_add(json_no
, "detail", json_sub
);
13118 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13119 json_object_free(json_no
);
13122 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13123 return CMD_WARNING
;
13128 peer
= peer_lookup (NULL
, &su
);
13133 json_object
*json_no
= NULL
;
13134 json_no
= json_object_new_object();
13135 json_object_string_add(json_no
, "warning", "No Peer");
13136 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13137 json_object_free(json_no
);
13140 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13141 return CMD_WARNING
;
13145 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13146 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13150 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13151 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13157 json_object
*json_no
= NULL
;
13158 json_no
= json_object_new_object();
13159 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13160 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13161 json_object_free(json_no
);
13164 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13167 return CMD_SUCCESS
;
13170 ALIAS (show_bgp_neighbor_received_prefix_filter
,
13171 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
13172 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13176 "Detailed information on TCP and BGP neighbor connections\n"
13177 "Neighbor to display information about\n"
13178 "Neighbor to display information about\n"
13179 "Neighbor on bgp configured interface\n"
13180 "Display information received from a BGP neighbor\n"
13181 "Display the prefixlist filter\n"
13182 "JavaScript Object Notation\n")
13185 ALIAS (show_bgp_neighbor_received_routes
,
13186 ipv6_bgp_neighbor_received_routes_cmd
,
13187 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13191 "Detailed information on TCP and BGP neighbor connections\n"
13192 "Neighbor to display information about\n"
13193 "Neighbor to display information about\n"
13194 "Neighbor on bgp configured interface\n"
13195 "Display the received routes from neighbor\n"
13196 "JavaScript Object Notation\n")
13199 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13200 ipv6_mbgp_neighbor_received_routes_cmd
,
13201 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13205 "Detailed information on TCP and BGP neighbor connections\n"
13206 "Neighbor to display information about\n"
13207 "Neighbor to display information about\n"
13208 "Neighbor on bgp configured interface\n"
13209 "Display the received routes from neighbor\n"
13210 "JavaScript Object Notation\n")
13213 u_char uj
= use_json(argc
, argv
);
13215 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13217 return CMD_WARNING
;
13219 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13220 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13223 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13224 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13225 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13228 BGP_INSTANCE_HELP_STR
13229 "Detailed information on TCP and BGP neighbor connections\n"
13230 "Neighbor to display information about\n"
13231 "Neighbor to display information about\n"
13232 "Neighbor on bgp configured interface\n"
13233 "Display information received from a BGP neighbor\n"
13234 "Display the prefixlist filter\n"
13235 "JavaScript Object Notation\n")
13238 union sockunion su
;
13242 u_char uj
= use_json(argc
, argv
);
13244 /* BGP structure lookup. */
13245 bgp
= bgp_lookup_by_name (argv
[1]);
13250 json_object
*json_no
= NULL
;
13251 json_no
= json_object_new_object();
13252 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13253 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13254 json_object_free(json_no
);
13257 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13258 return CMD_WARNING
;
13261 ret
= str2sockunion (argv
[2], &su
);
13264 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13269 json_object
*json_no
= NULL
;
13270 json_object
*json_sub
= NULL
;
13271 json_no
= json_object_new_object();
13272 json_sub
= json_object_new_object();
13273 json_object_string_add(json_no
, "warning", "Malformed address or name");
13274 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13275 json_object_object_add(json_no
, "detail", json_sub
);
13276 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13277 json_object_free(json_no
);
13280 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13281 return CMD_WARNING
;
13286 peer
= peer_lookup (bgp
, &su
);
13291 json_object
*json_no
= NULL
;
13292 json_no
= json_object_new_object();
13293 json_object_boolean_true_add(json_no
, "noPeer");
13294 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13295 json_object_free(json_no
);
13298 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13299 return CMD_WARNING
;
13304 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13305 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13309 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13310 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13313 return CMD_SUCCESS
;
13315 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13316 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13317 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13320 BGP_INSTANCE_HELP_STR
13322 "Detailed information on TCP and BGP neighbor connections\n"
13323 "Neighbor to display information about\n"
13324 "Neighbor to display information about\n"
13325 "Neighbor on bgp configured interface\n"
13326 "Display information received from a BGP neighbor\n"
13327 "Display the prefixlist filter\n"
13328 "JavaScript Object NOtation\n")
13329 #endif /* HAVE_IPV6 */
13332 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13333 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13335 if (! peer
|| ! peer
->afc
[afi
][safi
])
13339 json_object
*json_no
= NULL
;
13340 json_no
= json_object_new_object();
13341 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13342 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13343 json_object_free(json_no
);
13346 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13347 return CMD_WARNING
;
13350 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13353 DEFUN (show_ip_bgp_neighbor_routes
,
13354 show_ip_bgp_neighbor_routes_cmd
,
13355 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13359 "Detailed information on TCP and BGP neighbor connections\n"
13360 "Neighbor to display information about\n"
13361 "Neighbor to display information about\n"
13362 "Neighbor on bgp configured interface\n"
13363 "Display routes learned from neighbor\n"
13364 "JavaScript Object Notation\n")
13367 u_char uj
= use_json(argc
, argv
);
13369 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13371 return CMD_WARNING
;
13373 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13374 bgp_show_type_neighbor
, uj
);
13377 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13378 show_ip_bgp_instance_neighbor_routes_cmd
,
13379 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13383 BGP_INSTANCE_HELP_STR
13384 "Detailed information on TCP and BGP neighbor connections\n"
13385 "Neighbor to display information about\n"
13386 "Neighbor to display information about\n"
13387 "Neighbor on bgp configured interface\n"
13388 "Display routes learned from neighbor\n"
13389 "JavaScript Object Notation\n")
13392 u_char uj
= use_json(argc
, argv
);
13394 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13396 return CMD_WARNING
;
13398 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13399 bgp_show_type_neighbor
, uj
);
13402 DEFUN (show_ip_bgp_neighbor_flap
,
13403 show_ip_bgp_neighbor_flap_cmd
,
13404 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13408 "Detailed information on TCP and BGP neighbor connections\n"
13409 "Neighbor to display information about\n"
13410 "Neighbor to display information about\n"
13411 "Neighbor on bgp configured interface\n"
13412 "Display flap statistics of the routes learned from neighbor\n"
13413 "JavaScript Object Notation\n")
13416 u_char uj
= use_json(argc
, argv
);
13418 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13420 return CMD_WARNING
;
13422 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13423 bgp_show_type_flap_neighbor
, uj
);
13426 DEFUN (show_ip_bgp_neighbor_damp
,
13427 show_ip_bgp_neighbor_damp_cmd
,
13428 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13432 "Detailed information on TCP and BGP neighbor connections\n"
13433 "Neighbor to display information about\n"
13434 "Neighbor to display information about\n"
13435 "Neighbor on bgp configured interface\n"
13436 "Display the dampened routes received from neighbor\n"
13437 "JavaScript Object Notation\n")
13440 u_char uj
= use_json(argc
, argv
);
13442 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13444 return CMD_WARNING
;
13446 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13447 bgp_show_type_damp_neighbor
, uj
);
13450 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13451 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13452 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
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")
13467 u_char uj
= use_json(argc
, argv
);
13469 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13471 return CMD_WARNING
;
13473 safi
= bgp_vty_safi_from_arg(argv
[0]);
13474 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, safi
,
13475 bgp_show_type_neighbor
, uj
);
13479 DEFUN (show_bgp_instance_neighbor_routes
,
13480 show_bgp_instance_neighbor_routes_cmd
,
13481 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13484 BGP_INSTANCE_HELP_STR
13485 "Detailed information on TCP and BGP neighbor connections\n"
13486 "Neighbor to display information about\n"
13487 "Neighbor to display information about\n"
13488 "Neighbor on bgp configured interface\n"
13489 "Display routes learned from neighbor\n"
13490 "JavaScript Object Notation\n")
13493 u_char uj
= use_json(argc
, argv
);
13495 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13497 return CMD_WARNING
;
13499 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13500 bgp_show_type_neighbor
, uj
);
13503 ALIAS (show_bgp_instance_neighbor_routes
,
13504 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13505 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13508 BGP_INSTANCE_HELP_STR
13510 "Detailed information on TCP and BGP neighbor connections\n"
13511 "Neighbor to display information about\n"
13512 "Neighbor to display information about\n"
13513 "Neighbor on bgp configured interface\n"
13514 "Display routes learned from neighbor\n"
13515 "JavaScript Object Notation\n")
13517 DEFUN (show_bgp_instance_neighbor_damp
,
13518 show_bgp_instance_neighbor_damp_cmd
,
13519 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13522 BGP_INSTANCE_HELP_STR
13523 "Detailed information on TCP and BGP neighbor connections\n"
13524 "Neighbor to display information about\n"
13525 "Neighbor to display information about\n"
13526 "Neighbor on bgp configured interface\n"
13527 "Display the dampened routes received from neighbor\n"
13528 "JavaScript Object Notation\n")
13531 u_char uj
= use_json(argc
, argv
);
13533 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13534 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13535 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13537 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13540 return CMD_WARNING
;
13542 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13543 bgp_show_type_damp_neighbor
, uj
);
13546 ALIAS (show_bgp_instance_neighbor_damp
,
13547 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13548 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13551 BGP_INSTANCE_HELP_STR
13553 "Detailed information on TCP and BGP neighbor connections\n"
13554 "Neighbor to display information about\n"
13555 "Neighbor to display information about\n"
13556 "Neighbor on bgp configured interface\n"
13557 "Display the dampened routes received from neighbor\n"
13558 "JavaScript Object Notation\n")
13560 DEFUN (show_bgp_instance_neighbor_flap
,
13561 show_bgp_instance_neighbor_flap_cmd
,
13562 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13565 BGP_INSTANCE_HELP_STR
13566 "Detailed information on TCP and BGP neighbor connections\n"
13567 "Neighbor to display information about\n"
13568 "Neighbor to display information about\n"
13569 "Neighbor on bgp configured interface\n"
13570 "Display flap statistics of the routes learned from neighbor\n"
13571 "JavaScript Object Notation\n")
13574 u_char uj
= use_json(argc
, argv
);
13576 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13577 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13578 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13580 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13583 return CMD_WARNING
;
13585 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13586 bgp_show_type_flap_neighbor
, uj
);
13589 ALIAS (show_bgp_instance_neighbor_flap
,
13590 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13591 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13594 BGP_INSTANCE_HELP_STR
13596 "Detailed information on TCP and BGP neighbor connections\n"
13597 "Neighbor to display information about\n"
13598 "Neighbor to display information about\n"
13599 "Neighbor on bgp configured interface\n"
13600 "Display flap statistics of the routes learned from neighbor\n"
13601 "JavaScript Object Notation\n")
13603 DEFUN (show_bgp_neighbor_routes
,
13604 show_bgp_neighbor_routes_cmd
,
13605 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13608 "Detailed information on TCP and BGP neighbor connections\n"
13609 "Neighbor to display information about\n"
13610 "Neighbor to display information about\n"
13611 "Neighbor on bgp configured interface\n"
13612 "Display routes learned from neighbor\n"
13613 "JavaScript Object Notation\n")
13616 u_char uj
= use_json(argc
, argv
);
13618 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13620 return CMD_WARNING
;
13622 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13623 bgp_show_type_neighbor
, uj
);
13627 ALIAS (show_bgp_neighbor_routes
,
13628 show_bgp_ipv6_neighbor_routes_cmd
,
13629 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13633 "Detailed information on TCP and BGP neighbor connections\n"
13634 "Neighbor to display information about\n"
13635 "Neighbor to display information about\n"
13636 "Neighbor on bgp configured interface\n"
13637 "Display routes learned from neighbor\n"
13638 "JavaScript Object Notation\n")
13641 ALIAS (show_bgp_neighbor_routes
,
13642 ipv6_bgp_neighbor_routes_cmd
,
13643 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13647 "Detailed information on TCP and BGP neighbor connections\n"
13648 "Neighbor to display information about\n"
13649 "Neighbor to display information about\n"
13650 "Neighbor on bgp configured interface\n"
13651 "Display routes learned from neighbor\n"
13652 "JavaScript Object Notation\n")
13655 DEFUN (ipv6_mbgp_neighbor_routes
,
13656 ipv6_mbgp_neighbor_routes_cmd
,
13657 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13661 "Detailed information on TCP and BGP neighbor connections\n"
13662 "Neighbor to display information about\n"
13663 "Neighbor to display information about\n"
13664 "Neighbor on bgp configured interface\n"
13665 "Display routes learned from neighbor\n"
13666 "JavaScript Object Notation\n")
13669 u_char uj
= use_json(argc
, argv
);
13671 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13673 return CMD_WARNING
;
13675 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13676 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13677 bgp_show_type_neighbor
, uj
);
13680 ALIAS (show_bgp_instance_neighbor_flap
,
13681 show_bgp_neighbor_flap_cmd
,
13682 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13685 "Detailed information on TCP and BGP neighbor connections\n"
13686 "Neighbor to display information about\n"
13687 "Neighbor to display information about\n"
13688 "Neighbor on bgp configured interface\n"
13689 "Display flap statistics of the routes learned from neighbor\n"
13690 "JavaScript Object Notation\n")
13692 ALIAS (show_bgp_instance_neighbor_flap
,
13693 show_bgp_ipv6_neighbor_flap_cmd
,
13694 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13698 "Detailed information on TCP and BGP neighbor connections\n"
13699 "Neighbor to display information about\n"
13700 "Neighbor to display information about\n"
13701 "Neighbor on bgp configured interface\n"
13702 "Display flap statistics of the routes learned from neighbor\n"
13703 "JavaScript Object Notation\n")
13705 ALIAS (show_bgp_instance_neighbor_damp
,
13706 show_bgp_neighbor_damp_cmd
,
13707 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13710 "Detailed information on TCP and BGP neighbor connections\n"
13711 "Neighbor to display information about\n"
13712 "Neighbor to display information about\n"
13713 "Neighbor on bgp configured interface\n"
13714 "Display the dampened routes received from neighbor\n"
13715 "JavaScript Object Notation\n")
13717 ALIAS (show_bgp_instance_neighbor_damp
,
13718 show_bgp_ipv6_neighbor_damp_cmd
,
13719 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13723 "Detailed information on TCP and BGP neighbor connections\n"
13724 "Neighbor to display information about\n"
13725 "Neighbor to display information about\n"
13726 "Neighbor on bgp configured interface\n"
13727 "Display the dampened routes received from neighbor\n"
13728 "JavaScript Object Notation\n")
13730 #endif /* HAVE_IPV6 */
13732 struct bgp_table
*bgp_distance_table
[AFI_MAX
][SAFI_MAX
];
13734 struct bgp_distance
13736 /* Distance value for the IP source prefix. */
13739 /* Name of the access-list to be matched. */
13743 static struct bgp_distance
*
13744 bgp_distance_new (void)
13746 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13750 bgp_distance_free (struct bgp_distance
*bdistance
)
13752 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13756 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13757 const char *ip_str
, const char *access_list_str
)
13764 struct bgp_node
*rn
;
13765 struct bgp_distance
*bdistance
;
13767 afi
= bgp_node_afi (vty
);
13768 safi
= bgp_node_safi (vty
);
13770 ret
= str2prefix (ip_str
, &p
);
13773 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13774 return CMD_WARNING
;
13777 distance
= atoi (distance_str
);
13779 /* Get BGP distance node. */
13780 rn
= bgp_node_get (bgp_distance_table
[afi
][safi
], (struct prefix
*) &p
);
13783 bdistance
= rn
->info
;
13784 bgp_unlock_node (rn
);
13788 bdistance
= bgp_distance_new ();
13789 rn
->info
= bdistance
;
13792 /* Set distance value. */
13793 bdistance
->distance
= distance
;
13795 /* Reset access-list configuration. */
13796 if (bdistance
->access_list
)
13798 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13799 bdistance
->access_list
= NULL
;
13801 if (access_list_str
)
13802 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13804 return CMD_SUCCESS
;
13808 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13809 const char *ip_str
, const char *access_list_str
)
13816 struct bgp_node
*rn
;
13817 struct bgp_distance
*bdistance
;
13819 afi
= bgp_node_afi (vty
);
13820 safi
= bgp_node_safi (vty
);
13822 ret
= str2prefix (ip_str
, &p
);
13825 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13826 return CMD_WARNING
;
13829 rn
= bgp_node_lookup (bgp_distance_table
[afi
][safi
], (struct prefix
*)&p
);
13832 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13833 return CMD_WARNING
;
13836 bdistance
= rn
->info
;
13837 distance
= atoi(distance_str
);
13839 if (bdistance
->distance
!= distance
)
13841 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13842 return CMD_WARNING
;
13845 if (bdistance
->access_list
)
13846 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13847 bgp_distance_free (bdistance
);
13850 bgp_unlock_node (rn
);
13851 bgp_unlock_node (rn
);
13853 return CMD_SUCCESS
;
13856 /* Apply BGP information to distance method. */
13858 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, afi_t afi
,
13859 safi_t safi
, struct bgp
*bgp
)
13861 struct bgp_node
*rn
;
13864 struct bgp_distance
*bdistance
;
13865 struct access_list
*alist
;
13866 struct bgp_static
*bgp_static
;
13871 peer
= rinfo
->peer
;
13873 /* Check source address. */
13874 sockunion2hostprefix (&peer
->su
, &q
);
13875 rn
= bgp_node_match (bgp_distance_table
[afi
][safi
], &q
);
13878 bdistance
= rn
->info
;
13879 bgp_unlock_node (rn
);
13881 if (bdistance
->access_list
)
13883 alist
= access_list_lookup (afi
, bdistance
->access_list
);
13884 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13885 return bdistance
->distance
;
13888 return bdistance
->distance
;
13891 /* Backdoor check. */
13892 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], p
);
13895 bgp_static
= rn
->info
;
13896 bgp_unlock_node (rn
);
13898 if (bgp_static
->backdoor
)
13900 if (bgp
->distance_local
[afi
][safi
])
13901 return bgp
->distance_local
[afi
][safi
];
13903 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13907 if (peer
->sort
== BGP_PEER_EBGP
)
13909 if (bgp
->distance_ebgp
[afi
][safi
])
13910 return bgp
->distance_ebgp
[afi
][safi
];
13911 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
13915 if (bgp
->distance_ibgp
[afi
][safi
])
13916 return bgp
->distance_ibgp
[afi
][safi
];
13917 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13921 DEFUN (bgp_distance
,
13923 "distance bgp <1-255> <1-255> <1-255>",
13924 "Define an administrative distance\n"
13926 "Distance for routes external to the AS\n"
13927 "Distance for routes internal to the AS\n"
13928 "Distance for local routes\n")
13935 afi
= bgp_node_afi (vty
);
13936 safi
= bgp_node_safi (vty
);
13938 bgp
->distance_ebgp
[afi
][safi
] = atoi (argv
[0]);
13939 bgp
->distance_ibgp
[afi
][safi
] = atoi (argv
[1]);
13940 bgp
->distance_local
[afi
][safi
] = atoi (argv
[2]);
13941 return CMD_SUCCESS
;
13944 DEFUN (no_bgp_distance
,
13945 no_bgp_distance_cmd
,
13946 "no distance bgp <1-255> <1-255> <1-255>",
13948 "Define an administrative distance\n"
13950 "Distance for routes external to the AS\n"
13951 "Distance for routes internal to the AS\n"
13952 "Distance for local routes\n")
13959 afi
= bgp_node_afi (vty
);
13960 safi
= bgp_node_safi (vty
);
13962 bgp
->distance_ebgp
[afi
][safi
] = 0;
13963 bgp
->distance_ibgp
[afi
][safi
] = 0;
13964 bgp
->distance_local
[afi
][safi
] = 0;
13965 return CMD_SUCCESS
;
13968 ALIAS (no_bgp_distance
,
13969 no_bgp_distance2_cmd
,
13972 "Define an administrative distance\n"
13975 DEFUN (bgp_distance_source
,
13976 bgp_distance_source_cmd
,
13977 "distance <1-255> A.B.C.D/M",
13978 "Define an administrative distance\n"
13979 "Administrative distance\n"
13980 "IP source prefix\n")
13982 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
13983 return CMD_SUCCESS
;
13986 DEFUN (no_bgp_distance_source
,
13987 no_bgp_distance_source_cmd
,
13988 "no distance <1-255> A.B.C.D/M",
13990 "Define an administrative distance\n"
13991 "Administrative distance\n"
13992 "IP source prefix\n")
13994 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
13995 return CMD_SUCCESS
;
13998 DEFUN (bgp_distance_source_access_list
,
13999 bgp_distance_source_access_list_cmd
,
14000 "distance <1-255> A.B.C.D/M WORD",
14001 "Define an administrative distance\n"
14002 "Administrative distance\n"
14003 "IP source prefix\n"
14004 "Access list name\n")
14006 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14007 return CMD_SUCCESS
;
14010 DEFUN (no_bgp_distance_source_access_list
,
14011 no_bgp_distance_source_access_list_cmd
,
14012 "no distance <1-255> A.B.C.D/M WORD",
14014 "Define an administrative distance\n"
14015 "Administrative distance\n"
14016 "IP source prefix\n"
14017 "Access list name\n")
14019 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14020 return CMD_SUCCESS
;
14023 DEFUN (ipv6_bgp_distance_source
,
14024 ipv6_bgp_distance_source_cmd
,
14025 "distance <1-255> X:X::X:X/M",
14026 "Define an administrative distance\n"
14027 "Administrative distance\n"
14028 "IP source prefix\n")
14030 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14031 return CMD_SUCCESS
;
14034 DEFUN (no_ipv6_bgp_distance_source
,
14035 no_ipv6_bgp_distance_source_cmd
,
14036 "no distance <1-255> X:X::X:X/M",
14038 "Define an administrative distance\n"
14039 "Administrative distance\n"
14040 "IP source prefix\n")
14042 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14043 return CMD_SUCCESS
;
14046 DEFUN (ipv6_bgp_distance_source_access_list
,
14047 ipv6_bgp_distance_source_access_list_cmd
,
14048 "distance <1-255> X:X::X:X/M WORD",
14049 "Define an administrative distance\n"
14050 "Administrative distance\n"
14051 "IP source prefix\n"
14052 "Access list name\n")
14054 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14055 return CMD_SUCCESS
;
14058 DEFUN (no_ipv6_bgp_distance_source_access_list
,
14059 no_ipv6_bgp_distance_source_access_list_cmd
,
14060 "no distance <1-255> X:X::X:X/M WORD",
14062 "Define an administrative distance\n"
14063 "Administrative distance\n"
14064 "IP source prefix\n"
14065 "Access list name\n")
14067 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14068 return CMD_SUCCESS
;
14071 DEFUN (bgp_damp_set
,
14073 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14074 "BGP Specific commands\n"
14075 "Enable route-flap dampening\n"
14076 "Half-life time for the penalty\n"
14077 "Value to start reusing a route\n"
14078 "Value to start suppressing a route\n"
14079 "Maximum duration to suppress a stable route\n")
14082 int half
= DEFAULT_HALF_LIFE
* 60;
14083 int reuse
= DEFAULT_REUSE
;
14084 int suppress
= DEFAULT_SUPPRESS
;
14085 int max
= 4 * half
;
14089 half
= atoi (argv
[0]) * 60;
14090 reuse
= atoi (argv
[1]);
14091 suppress
= atoi (argv
[2]);
14092 max
= atoi (argv
[3]) * 60;
14094 else if (argc
== 1)
14096 half
= atoi (argv
[0]) * 60;
14102 if (suppress
< reuse
)
14104 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
14109 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
14110 half
, reuse
, suppress
, max
);
14113 ALIAS (bgp_damp_set
,
14115 "bgp dampening <1-45>",
14116 "BGP Specific commands\n"
14117 "Enable route-flap dampening\n"
14118 "Half-life time for the penalty\n")
14120 ALIAS (bgp_damp_set
,
14123 "BGP Specific commands\n"
14124 "Enable route-flap dampening\n")
14126 DEFUN (bgp_damp_unset
,
14127 bgp_damp_unset_cmd
,
14128 "no bgp dampening",
14130 "BGP Specific commands\n"
14131 "Enable route-flap dampening\n")
14136 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
14139 ALIAS (bgp_damp_unset
,
14140 bgp_damp_unset2_cmd
,
14141 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14143 "BGP Specific commands\n"
14144 "Enable route-flap dampening\n"
14145 "Half-life time for the penalty\n"
14146 "Value to start reusing a route\n"
14147 "Value to start suppressing a route\n"
14148 "Maximum duration to suppress a stable route\n")
14150 ALIAS (bgp_damp_unset
,
14151 bgp_damp_unset3_cmd
,
14152 "no bgp dampening <1-45>",
14154 "BGP Specific commands\n"
14155 "Enable route-flap dampening\n"
14156 "Half-life time for the penalty\n")
14158 DEFUN (show_ip_bgp_dampened_paths
,
14159 show_ip_bgp_dampened_paths_cmd
,
14160 "show ip bgp dampened-paths",
14164 "Display paths suppressed due to dampening\n")
14166 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
14170 ALIAS (show_ip_bgp_dampened_paths
,
14171 show_ip_bgp_damp_dampened_paths_cmd
,
14172 "show ip bgp dampening dampened-paths",
14176 "Display detailed information about dampening\n"
14177 "Display paths suppressed due to dampening\n")
14179 DEFUN (show_ip_bgp_flap_statistics
,
14180 show_ip_bgp_flap_statistics_cmd
,
14181 "show ip bgp flap-statistics",
14185 "Display flap statistics of routes\n")
14187 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
14188 bgp_show_type_flap_statistics
, NULL
, 0);
14191 ALIAS (show_ip_bgp_flap_statistics
,
14192 show_ip_bgp_damp_flap_statistics_cmd
,
14193 "show ip bgp dampening flap-statistics",
14197 "Display detailed information about dampening\n"
14198 "Display flap statistics of routes\n")
14200 /* Display specified route of BGP table. */
14202 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
14203 const char *ip_str
, afi_t afi
, safi_t safi
,
14204 struct prefix_rd
*prd
, int prefix_check
)
14207 struct prefix match
;
14208 struct bgp_node
*rn
;
14209 struct bgp_node
*rm
;
14210 struct bgp_info
*ri
;
14211 struct bgp_info
*ri_temp
;
14213 struct bgp_table
*table
;
14215 /* BGP structure lookup. */
14218 bgp
= bgp_lookup_by_name (view_name
);
14221 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
14222 return CMD_WARNING
;
14227 bgp
= bgp_get_default ();
14230 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14231 return CMD_WARNING
;
14235 /* Check IP address argument. */
14236 ret
= str2prefix (ip_str
, &match
);
14239 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14240 return CMD_WARNING
;
14243 match
.family
= afi2family (afi
);
14245 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14247 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14249 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14252 if ((table
= rn
->info
) != NULL
)
14253 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14255 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14260 if (ri
->extra
&& ri
->extra
->damp_info
)
14262 ri_temp
= ri
->next
;
14263 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14271 bgp_unlock_node (rm
);
14277 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14279 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14284 if (ri
->extra
&& ri
->extra
->damp_info
)
14286 ri_temp
= ri
->next
;
14287 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14295 bgp_unlock_node (rn
);
14299 return CMD_SUCCESS
;
14302 DEFUN (clear_ip_bgp_dampening
,
14303 clear_ip_bgp_dampening_cmd
,
14304 "clear ip bgp dampening",
14308 "Clear route flap dampening information\n")
14310 bgp_damp_info_clean ();
14311 return CMD_SUCCESS
;
14314 DEFUN (clear_ip_bgp_dampening_prefix
,
14315 clear_ip_bgp_dampening_prefix_cmd
,
14316 "clear ip bgp dampening A.B.C.D/M",
14320 "Clear route flap dampening information\n"
14321 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14323 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14324 SAFI_UNICAST
, NULL
, 1);
14327 DEFUN (clear_ip_bgp_dampening_address
,
14328 clear_ip_bgp_dampening_address_cmd
,
14329 "clear ip bgp dampening A.B.C.D",
14333 "Clear route flap dampening information\n"
14334 "Network to clear damping information\n")
14336 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14337 SAFI_UNICAST
, NULL
, 0);
14340 DEFUN (clear_ip_bgp_dampening_address_mask
,
14341 clear_ip_bgp_dampening_address_mask_cmd
,
14342 "clear ip bgp dampening A.B.C.D A.B.C.D",
14346 "Clear route flap dampening information\n"
14347 "Network to clear damping information\n"
14351 char prefix_str
[BUFSIZ
];
14353 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14356 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14357 return CMD_WARNING
;
14360 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14361 SAFI_UNICAST
, NULL
, 0);
14364 /* also used for encap safi */
14366 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14367 afi_t afi
, safi_t safi
, int *write
)
14369 struct bgp_node
*prn
;
14370 struct bgp_node
*rn
;
14371 struct bgp_table
*table
;
14373 struct prefix_rd
*prd
;
14374 struct bgp_static
*bgp_static
;
14376 char buf
[SU_ADDRSTRLEN
];
14377 char rdbuf
[RD_ADDRSTRLEN
];
14379 /* Network configuration. */
14380 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14381 if ((table
= prn
->info
) != NULL
)
14382 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14383 if ((bgp_static
= rn
->info
) != NULL
)
14386 prd
= (struct prefix_rd
*) &prn
->p
;
14388 /* "address-family" display. */
14389 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14391 /* "network" configuration display. */
14392 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14393 label
= decode_label (bgp_static
->tag
);
14395 vty_out (vty
, " network %s/%d rd %s tag %d",
14396 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14399 vty_out (vty
, "%s", VTY_NEWLINE
);
14404 /* Configuration of static route announcement and aggregate
14407 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14408 afi_t afi
, safi_t safi
, int *write
)
14410 struct bgp_node
*rn
;
14412 struct bgp_static
*bgp_static
;
14413 struct bgp_aggregate
*bgp_aggregate
;
14414 char buf
[SU_ADDRSTRLEN
];
14416 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14417 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14419 /* Network configuration. */
14420 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14421 if ((bgp_static
= rn
->info
) != NULL
)
14425 /* "address-family" display. */
14426 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14428 /* "network" configuration display. */
14429 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14431 u_int32_t destination
;
14432 struct in_addr netmask
;
14434 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14435 masklen2ip (p
->prefixlen
, &netmask
);
14436 vty_out (vty
, " network %s",
14437 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14439 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14440 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14441 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14442 || p
->u
.prefix4
.s_addr
== 0)
14444 /* Natural mask is not display. */
14447 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14451 vty_out (vty
, " network %s/%d",
14452 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14456 if (bgp_static
->rmap
.name
)
14457 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14460 if (bgp_static
->backdoor
)
14461 vty_out (vty
, " backdoor");
14464 vty_out (vty
, "%s", VTY_NEWLINE
);
14467 /* Aggregate-address configuration. */
14468 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14469 if ((bgp_aggregate
= rn
->info
) != NULL
)
14473 /* "address-family" display. */
14474 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14476 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14478 struct in_addr netmask
;
14480 masklen2ip (p
->prefixlen
, &netmask
);
14481 vty_out (vty
, " aggregate-address %s %s",
14482 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14483 inet_ntoa (netmask
));
14487 vty_out (vty
, " aggregate-address %s/%d",
14488 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14492 if (bgp_aggregate
->as_set
)
14493 vty_out (vty
, " as-set");
14495 if (bgp_aggregate
->summary_only
)
14496 vty_out (vty
, " summary-only");
14498 vty_out (vty
, "%s", VTY_NEWLINE
);
14505 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
14506 safi_t safi
, int *write
)
14508 struct bgp_node
*rn
;
14509 struct bgp_distance
*bdistance
;
14511 /* Distance configuration. */
14512 if (bgp
->distance_ebgp
[afi
][safi
]
14513 && bgp
->distance_ibgp
[afi
][safi
]
14514 && bgp
->distance_local
[afi
][safi
]
14515 && (bgp
->distance_ebgp
[afi
][safi
] != ZEBRA_EBGP_DISTANCE_DEFAULT
14516 || bgp
->distance_ibgp
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
14517 || bgp
->distance_local
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
))
14519 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14520 vty_out (vty
, " distance bgp %d %d %d%s",
14521 bgp
->distance_ebgp
[afi
][safi
], bgp
->distance_ibgp
[afi
][safi
],
14522 bgp
->distance_local
[afi
][safi
], VTY_NEWLINE
);
14525 for (rn
= bgp_table_top (bgp_distance_table
[afi
][safi
]); rn
;
14526 rn
= bgp_route_next (rn
))
14527 if ((bdistance
= rn
->info
) != NULL
)
14529 char buf
[PREFIX_STRLEN
];
14531 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14532 vty_out (vty
, " distance %d %s %s%s", bdistance
->distance
,
14533 prefix2str (&rn
->p
, buf
, sizeof (buf
)),
14534 bdistance
->access_list
? bdistance
->access_list
: "",
14541 /* Allocate routing table structure and install commands. */
14543 bgp_route_init (void)
14548 /* Init BGP distance table. */
14549 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
14550 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
14551 bgp_distance_table
[afi
][safi
] = bgp_table_init (afi
, safi
);
14553 /* IPv4 BGP commands. */
14554 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14555 install_element (BGP_NODE
, &bgp_network_cmd
);
14556 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14557 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14558 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14559 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14560 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14561 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14562 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14563 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14564 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14565 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14566 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14567 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14568 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14569 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14570 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14571 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14572 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14573 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14575 install_element (BGP_NODE
, &aggregate_address_cmd
);
14576 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14577 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14578 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14579 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14580 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14581 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14582 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14583 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14584 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14585 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14586 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14587 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14588 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14589 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14590 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14591 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14592 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14593 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14594 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14596 /* IPv4 unicast configuration. */
14597 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14598 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14599 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14600 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14601 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14602 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14603 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14604 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14605 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14606 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14607 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14608 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14609 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14610 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14612 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14613 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14614 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14615 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14616 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14617 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14618 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14619 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14620 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14621 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14622 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14623 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14624 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14625 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14626 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14627 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14628 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14629 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14630 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14631 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14633 /* IPv4 multicast configuration. */
14634 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14635 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14636 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14637 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14638 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14639 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14640 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14641 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14642 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14643 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14644 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14645 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14646 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14647 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14648 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14649 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14650 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14651 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14652 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14653 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14654 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14655 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14656 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14657 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14658 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14659 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14660 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14661 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14662 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14663 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14664 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14665 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14666 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14667 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14669 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14670 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14671 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14672 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14673 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14674 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14675 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14676 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14677 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14678 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14679 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14680 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14681 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14682 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14683 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14684 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14685 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14686 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14687 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14688 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14690 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14691 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14692 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14693 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14694 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14695 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14696 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14697 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14698 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14699 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14700 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14701 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14702 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14703 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14704 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14705 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14706 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14707 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14708 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14709 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14710 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14711 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14712 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14713 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14714 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14715 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14716 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14717 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14718 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14719 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14720 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14721 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14722 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14723 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14724 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14725 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14726 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14727 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14728 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14729 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14730 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14731 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14732 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14733 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14734 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14735 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14736 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14737 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14738 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14739 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14740 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14741 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14742 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14743 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14744 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14745 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14746 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14747 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14748 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14749 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14750 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14751 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14752 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14753 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
14754 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14755 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
14756 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
14757 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14758 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14759 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14760 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14761 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14762 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14763 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14764 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14765 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14766 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14767 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14768 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14769 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14770 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14771 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14772 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14773 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14774 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14775 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14777 install_element (VIEW_NODE
, &show_bgp_ipv4_prefix_cmd
);
14778 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_route_cmd
);
14779 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_route_cmd
);
14780 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_prefix_cmd
);
14781 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_prefix_cmd
);
14783 /* BGP dampening clear commands */
14784 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14785 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14786 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14787 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14790 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14791 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14792 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14794 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14795 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14797 /* New config IPv6 BGP commands. */
14798 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14799 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14800 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14801 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14802 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14803 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14805 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14806 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14807 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14808 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14810 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14811 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14813 /* Old config IPv6 BGP commands. */
14814 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14815 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14817 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14818 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14819 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14820 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14822 install_element (VIEW_NODE
, &show_bgp_cmd
);
14823 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14824 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14825 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14826 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14827 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14828 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14829 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14830 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14831 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14832 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14833 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14834 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14835 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14836 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14837 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14838 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14839 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14840 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14841 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14842 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14843 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14844 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14845 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14846 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14847 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14848 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14849 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14850 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14851 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14852 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14853 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14854 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14855 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14856 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14857 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14858 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14859 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14860 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14861 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14862 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14863 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14864 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14865 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14866 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14867 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14868 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14869 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14870 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14871 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14872 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14873 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14874 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14875 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14876 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14877 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14878 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14879 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14880 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14881 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14882 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14883 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14884 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14885 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14886 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14887 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14888 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14889 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14890 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14891 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14892 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14893 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14894 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14895 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14896 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14897 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14898 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14899 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14900 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14901 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14902 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14903 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14904 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14905 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14906 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14907 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14908 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14909 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14910 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14911 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14912 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14913 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14916 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
14917 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
14918 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
14919 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
14922 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
14923 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
14924 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
14925 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
14926 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14927 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14928 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
14929 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
14930 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
14931 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
14932 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
14933 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14934 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14935 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14936 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14937 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
14938 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14939 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14940 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
14941 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
14942 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14943 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14944 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14945 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14946 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14947 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
14948 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
14949 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
14950 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
14951 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14952 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14953 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14954 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
14955 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
14956 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
14957 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14960 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14961 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14964 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14965 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14968 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14969 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14970 #endif /* HAVE_IPV6 */
14972 install_element (BGP_NODE
, &bgp_distance_cmd
);
14973 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
14974 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
14975 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
14976 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
14977 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
14978 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
14979 install_element (BGP_IPV4_NODE
, &bgp_distance_cmd
);
14980 install_element (BGP_IPV4_NODE
, &no_bgp_distance_cmd
);
14981 install_element (BGP_IPV4_NODE
, &no_bgp_distance2_cmd
);
14982 install_element (BGP_IPV4_NODE
, &bgp_distance_source_cmd
);
14983 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_cmd
);
14984 install_element (BGP_IPV4_NODE
, &bgp_distance_source_access_list_cmd
);
14985 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_access_list_cmd
);
14986 install_element (BGP_IPV4M_NODE
, &bgp_distance_cmd
);
14987 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_cmd
);
14988 install_element (BGP_IPV4M_NODE
, &no_bgp_distance2_cmd
);
14989 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_cmd
);
14990 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_cmd
);
14991 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_access_list_cmd
);
14992 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_access_list_cmd
);
14993 install_element (BGP_IPV6_NODE
, &bgp_distance_cmd
);
14994 install_element (BGP_IPV6_NODE
, &no_bgp_distance_cmd
);
14995 install_element (BGP_IPV6_NODE
, &no_bgp_distance2_cmd
);
14996 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_cmd
);
14997 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_cmd
);
14998 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
14999 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15000 install_element (BGP_IPV6M_NODE
, &bgp_distance_cmd
);
15001 install_element (BGP_IPV6M_NODE
, &no_bgp_distance_cmd
);
15002 install_element (BGP_IPV6M_NODE
, &no_bgp_distance2_cmd
);
15003 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_cmd
);
15004 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15005 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15006 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15008 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15009 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15010 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15011 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15012 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15013 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15014 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15015 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15016 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15017 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15018 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15019 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15021 /* IPv4 Multicast Mode */
15022 install_element (BGP_IPV4M_NODE
, &bgp_damp_set_cmd
);
15023 install_element (BGP_IPV4M_NODE
, &bgp_damp_set2_cmd
);
15024 install_element (BGP_IPV4M_NODE
, &bgp_damp_set3_cmd
);
15025 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset_cmd
);
15026 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset2_cmd
);
15030 bgp_route_finish (void)
15035 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
15036 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
15038 bgp_table_unlock (bgp_distance_table
[afi
][safi
]);
15039 bgp_distance_table
[afi
][safi
] = NULL
;