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 case BGP_ATTR_NHLEN_VPNV6_GLOBAL
:
2325 ret
= (IN6_IS_ADDR_UNSPECIFIED(&attre
->mp_nexthop_global
) ||
2326 IN6_IS_ADDR_LOOPBACK(&attre
->mp_nexthop_global
) ||
2327 IN6_IS_ADDR_MULTICAST(&attre
->mp_nexthop_global
));
2329 #endif /* HAVE_IPV6 */
2341 bgp_update (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2342 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
,
2343 int sub_type
, struct prefix_rd
*prd
, u_char
*tag
,
2347 int aspath_loop_count
= 0;
2348 struct bgp_node
*rn
;
2350 struct attr new_attr
;
2351 struct attr_extra new_extra
;
2352 struct attr
*attr_new
;
2353 struct bgp_info
*ri
;
2354 struct bgp_info
*new;
2356 char buf
[SU_ADDRSTRLEN
];
2359 int do_loop_check
= 1;
2361 int vnc_implicit_withdraw
= 0;
2364 memset (&new_attr
, 0, sizeof(struct attr
));
2365 memset (&new_extra
, 0, sizeof(struct attr_extra
));
2368 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2370 /* When peer's soft reconfiguration enabled. Record input packet in
2372 if (! soft_reconfig
&& CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2373 && peer
!= bgp
->peer_self
)
2374 bgp_adj_in_set (rn
, peer
, attr
, addpath_id
);
2376 /* Check previously received route. */
2377 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2378 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2379 ri
->addpath_rx_id
== addpath_id
)
2382 /* AS path local-as loop check. */
2383 if (peer
->change_local_as
)
2385 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
2386 aspath_loop_count
= 1;
2388 if (aspath_loop_check (attr
->aspath
, peer
->change_local_as
) > aspath_loop_count
)
2390 reason
= "as-path contains our own AS;";
2395 /* If the peer is configured for "allowas-in origin" and the last ASN in the
2396 * as-path is our ASN then we do not need to call aspath_loop_check
2398 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_ALLOWAS_IN_ORIGIN
))
2399 if (aspath_get_last_as(attr
->aspath
) == bgp
->as
)
2402 /* AS path loop check. */
2405 if (aspath_loop_check (attr
->aspath
, bgp
->as
) > peer
->allowas_in
[afi
][safi
]
2406 || (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2407 && aspath_loop_check(attr
->aspath
, bgp
->confed_id
) > peer
->allowas_in
[afi
][safi
]))
2409 reason
= "as-path contains our own AS;";
2414 /* Route reflector originator ID check. */
2415 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID
)
2416 && IPV4_ADDR_SAME (&bgp
->router_id
, &attr
->extra
->originator_id
))
2418 reason
= "originator is us;";
2422 /* Route reflector cluster ID check. */
2423 if (bgp_cluster_filter (peer
, attr
))
2425 reason
= "reflected from the same cluster;";
2429 /* Apply incoming filter. */
2430 if (bgp_input_filter (peer
, p
, attr
, afi
, safi
) == FILTER_DENY
)
2436 new_attr
.extra
= &new_extra
;
2437 bgp_attr_dup (&new_attr
, attr
);
2439 /* Apply incoming route-map.
2440 * NB: new_attr may now contain newly allocated values from route-map "set"
2441 * commands, so we need bgp_attr_flush in the error paths, until we intern
2442 * the attr (which takes over the memory references) */
2443 if (bgp_input_modifier (peer
, p
, &new_attr
, afi
, safi
, NULL
) == RMAP_DENY
)
2445 reason
= "route-map;";
2446 bgp_attr_flush (&new_attr
);
2450 /* next hop check. */
2451 if (bgp_update_martian_nexthop (bgp
, afi
, safi
, &new_attr
))
2453 reason
= "martian or self next-hop;";
2454 bgp_attr_flush (&new_attr
);
2458 attr_new
= bgp_attr_intern (&new_attr
);
2460 /* If the update is implicit withdraw. */
2463 ri
->uptime
= bgp_clock ();
2465 /* Same attribute comes in. */
2466 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
)
2467 && attrhash_cmp (ri
->attr
, attr_new
))
2469 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2470 && peer
->sort
== BGP_PEER_EBGP
2471 && CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2473 if (bgp_debug_update(peer
, p
, NULL
, 1))
2475 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2476 zlog_debug ("%s rcvd %s/%d%s",
2478 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2479 p
->prefixlen
, buf2
);
2482 if (bgp_damp_update (ri
, rn
, afi
, safi
) != BGP_DAMP_SUPPRESSED
)
2484 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2485 bgp_process (bgp
, rn
, afi
, safi
);
2488 else /* Duplicate - odd */
2490 if (bgp_debug_update(peer
, p
, NULL
, 1))
2492 if (!peer
->rcvd_attr_printed
)
2494 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2495 peer
->rcvd_attr_printed
= 1;
2498 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2499 zlog_debug ("%s rcvd %s/%d%s...duplicate ignored",
2501 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2502 p
->prefixlen
, buf2
);
2505 /* graceful restart STALE flag unset. */
2506 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2508 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2509 bgp_process (bgp
, rn
, afi
, safi
);
2513 bgp_unlock_node (rn
);
2514 bgp_attr_unintern (&attr_new
);
2519 /* Withdraw/Announce before we fully processed the withdraw */
2520 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
2522 if (bgp_debug_update(peer
, p
, NULL
, 1))
2524 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2525 zlog_debug ("%s rcvd %s/%d%s, flapped quicker than processing",
2527 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2528 p
->prefixlen
, buf2
);
2530 bgp_info_restore (rn
, ri
);
2533 /* Received Logging. */
2534 if (bgp_debug_update(peer
, p
, NULL
, 1))
2536 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2537 zlog_debug ("%s rcvd %s/%d%s",
2539 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2540 p
->prefixlen
, buf2
);
2543 /* graceful restart STALE flag unset. */
2544 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
2545 bgp_info_unset_flag (rn
, ri
, BGP_INFO_STALE
);
2547 /* The attribute is changed. */
2548 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
2550 /* implicit withdraw, decrement aggregate and pcount here.
2551 * only if update is accepted, they'll increment below.
2553 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
2555 /* Update bgp route dampening information. */
2556 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2557 && peer
->sort
== BGP_PEER_EBGP
)
2559 /* This is implicit withdraw so we should update dampening
2561 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2562 bgp_damp_withdraw (ri
, rn
, afi
, safi
, 1);
2565 if (safi
== SAFI_MPLS_VPN
) {
2566 struct bgp_node
*prn
= NULL
;
2567 struct bgp_table
*table
= NULL
;
2569 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2571 table
= (struct bgp_table
*)(prn
->info
);
2573 vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
2580 bgp_unlock_node(prn
);
2582 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
)) {
2583 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) {
2585 * Implicit withdraw case.
2587 ++vnc_implicit_withdraw
;
2588 vnc_import_bgp_del_route(bgp
, p
, ri
);
2589 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
2594 /* Update to new attribute. */
2595 bgp_attr_unintern (&ri
->attr
);
2596 ri
->attr
= attr_new
;
2598 /* Update MPLS tag. */
2599 if (safi
== SAFI_MPLS_VPN
)
2600 memcpy ((bgp_info_extra_get (ri
))->tag
, tag
, 3);
2603 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
2605 if (vnc_implicit_withdraw
)
2608 * Add back the route with its new attributes (e.g., nexthop).
2609 * The route is still selected, until the route selection
2610 * queued by bgp_process actually runs. We have to make this
2611 * update to the VNC side immediately to avoid racing against
2612 * configuration changes (e.g., route-map changes) which
2613 * trigger re-importation of the entire RIB.
2615 vnc_import_bgp_add_route(bgp
, p
, ri
);
2616 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
2621 /* Update bgp route dampening information. */
2622 if (CHECK_FLAG (bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
)
2623 && peer
->sort
== BGP_PEER_EBGP
)
2625 /* Now we do normal update dampening. */
2626 ret
= bgp_damp_update (ri
, rn
, afi
, safi
);
2627 if (ret
== BGP_DAMP_SUPPRESSED
)
2629 bgp_unlock_node (rn
);
2634 /* Nexthop reachability check. */
2635 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2637 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2638 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2639 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2644 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, connected
))
2645 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2648 if (BGP_DEBUG(nht
, NHT
))
2650 char buf1
[INET6_ADDRSTRLEN
];
2651 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2652 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2654 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
2658 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
2661 if (safi
== SAFI_MPLS_VPN
)
2663 struct bgp_node
*prn
= NULL
;
2664 struct bgp_table
*table
= NULL
;
2666 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2669 table
= (struct bgp_table
*)(prn
->info
);
2671 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2678 bgp_unlock_node(prn
);
2682 /* Process change. */
2683 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
2685 bgp_process (bgp
, rn
, afi
, safi
);
2686 bgp_unlock_node (rn
);
2689 } // End of implicit withdraw
2691 /* Received Logging. */
2692 if (bgp_debug_update(peer
, p
, NULL
, 1))
2694 if (!peer
->rcvd_attr_printed
)
2696 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2697 peer
->rcvd_attr_printed
= 1;
2700 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2701 zlog_debug ("%s rcvd %s/%d%s",
2703 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2704 p
->prefixlen
, buf2
);
2707 /* Make new BGP info. */
2708 new = info_make(type
, sub_type
, 0, peer
, attr_new
, rn
);
2710 /* Update MPLS tag. */
2711 if (safi
== SAFI_MPLS_VPN
)
2712 memcpy ((bgp_info_extra_get (new))->tag
, tag
, 3);
2714 /* Nexthop reachability check. */
2715 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)
2717 if (peer
->sort
== BGP_PEER_EBGP
&& peer
->ttl
== 1 &&
2718 ! CHECK_FLAG (peer
->flags
, PEER_FLAG_DISABLE_CONNECTED_CHECK
)
2719 && ! bgp_flag_check(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
2724 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, connected
))
2725 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2728 if (BGP_DEBUG(nht
, NHT
))
2730 char buf1
[INET6_ADDRSTRLEN
];
2731 inet_ntop(AF_INET
, (const void *)&attr_new
->nexthop
, buf1
, INET6_ADDRSTRLEN
);
2732 zlog_debug("%s(%s): NH unresolved", __FUNCTION__
, buf1
);
2734 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
2738 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
2741 new->addpath_rx_id
= addpath_id
;
2743 /* Increment prefix */
2744 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
2746 /* Register new BGP information. */
2747 bgp_info_add (rn
, new);
2749 /* route_node_get lock */
2750 bgp_unlock_node (rn
);
2753 if (safi
== SAFI_MPLS_VPN
)
2755 struct bgp_node
*prn
= NULL
;
2756 struct bgp_table
*table
= NULL
;
2758 prn
= bgp_node_get(bgp
->rib
[afi
][safi
], (struct prefix
*) prd
);
2761 table
= (struct bgp_table
*)(prn
->info
);
2763 vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
2770 bgp_unlock_node(prn
);
2774 /* If maximum prefix count is configured and current prefix
2776 if (bgp_maximum_prefix_overflow (peer
, afi
, safi
, 0))
2779 /* Process change. */
2780 bgp_process (bgp
, rn
, afi
, safi
);
2784 /* This BGP update is filtered. Log the reason then update BGP
2787 if (bgp_debug_update(peer
, p
, NULL
, 1))
2789 if (!peer
->rcvd_attr_printed
)
2791 zlog_debug ("%s rcvd UPDATE w/ attr: %s", peer
->host
, peer
->rcvd_attr_str
);
2792 peer
->rcvd_attr_printed
= 1;
2795 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2796 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- DENIED due to: %s",
2798 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2799 p
->prefixlen
, buf2
, reason
);
2803 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
2805 bgp_unlock_node (rn
);
2811 bgp_withdraw (struct peer
*peer
, struct prefix
*p
, u_int32_t addpath_id
,
2812 struct attr
*attr
, afi_t afi
, safi_t safi
, int type
, int sub_type
,
2813 struct prefix_rd
*prd
, u_char
*tag
)
2816 char buf
[SU_ADDRSTRLEN
];
2818 struct bgp_node
*rn
;
2819 struct bgp_info
*ri
;
2824 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
2826 /* If peer is soft reconfiguration enabled. Record input packet for
2827 * further calculation.
2829 * Cisco IOS 12.4(24)T4 on session establishment sends withdraws for all
2830 * routes that are filtered. This tanks out Quagga RS pretty badly due to
2831 * the iteration over all RS clients.
2832 * Since we need to remove the entry from adj_in anyway, do that first and
2833 * if there was no entry, we don't need to do anything more.
2835 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
)
2836 && peer
!= bgp
->peer_self
)
2837 if (!bgp_adj_in_unset (rn
, peer
, addpath_id
))
2839 if (bgp_debug_update (peer
, p
, NULL
, 1))
2840 zlog_debug ("%s withdrawing route %s/%d "
2841 "not in adj-in", peer
->host
,
2842 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2844 bgp_unlock_node (rn
);
2848 /* Lookup withdrawn route. */
2849 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
2850 if (ri
->peer
== peer
&& ri
->type
== type
&& ri
->sub_type
== sub_type
&&
2851 ri
->addpath_rx_id
== addpath_id
)
2855 if (bgp_debug_update(peer
, p
, NULL
, 1))
2857 bgp_info_addpath_rx_str(addpath_id
, buf2
);
2858 zlog_debug ("%s rcvd UPDATE about %s/%d%s -- withdrawn",
2860 inet_ntop(p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2861 p
->prefixlen
, buf2
);
2864 /* Withdraw specified route from routing table. */
2865 if (ri
&& ! CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
2866 bgp_rib_withdraw (rn
, ri
, peer
, afi
, safi
, prd
);
2867 else if (bgp_debug_update(peer
, p
, NULL
, 1))
2868 zlog_debug ("%s Can't find the route %s/%d", peer
->host
,
2869 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
2872 /* Unlock bgp_node_get() lock. */
2873 bgp_unlock_node (rn
);
2879 bgp_default_originate (struct peer
*peer
, afi_t afi
, safi_t safi
, int withdraw
)
2881 struct update_subgroup
*subgrp
;
2882 subgrp
= peer_subgroup(peer
, afi
, safi
);
2883 subgroup_default_originate(subgrp
, withdraw
);
2888 * bgp_stop_announce_route_timer
2891 bgp_stop_announce_route_timer (struct peer_af
*paf
)
2893 if (!paf
->t_announce_route
)
2896 THREAD_TIMER_OFF (paf
->t_announce_route
);
2900 * bgp_announce_route_timer_expired
2902 * Callback that is invoked when the route announcement timer for a
2906 bgp_announce_route_timer_expired (struct thread
*t
)
2908 struct peer_af
*paf
;
2911 paf
= THREAD_ARG (t
);
2914 assert (paf
->t_announce_route
);
2915 paf
->t_announce_route
= NULL
;
2917 if (peer
->status
!= Established
)
2920 if (!peer
->afc_nego
[paf
->afi
][paf
->safi
])
2923 peer_af_announce_route (paf
, 1);
2928 * bgp_announce_route
2930 * *Triggers* announcement of routes of a given AFI/SAFI to a peer.
2933 bgp_announce_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
2935 struct peer_af
*paf
;
2936 struct update_subgroup
*subgrp
;
2938 paf
= peer_af_find (peer
, afi
, safi
);
2941 subgrp
= PAF_SUBGRP(paf
);
2944 * Ignore if subgroup doesn't exist (implies AF is not negotiated)
2945 * or a refresh has already been triggered.
2947 if (!subgrp
|| paf
->t_announce_route
)
2951 * Start a timer to stagger/delay the announce. This serves
2952 * two purposes - announcement can potentially be combined for
2953 * multiple peers and the announcement doesn't happen in the
2956 THREAD_TIMER_MSEC_ON (bm
->master
, paf
->t_announce_route
,
2957 bgp_announce_route_timer_expired
, paf
,
2958 (subgrp
->peer_count
== 1) ?
2959 BGP_ANNOUNCE_ROUTE_SHORT_DELAY_MS
:
2960 BGP_ANNOUNCE_ROUTE_DELAY_MS
);
2964 * Announce routes from all AF tables to a peer.
2966 * This should ONLY be called when there is a need to refresh the
2967 * routes to the peer based on a policy change for this peer alone
2968 * or a route refresh request received from the peer.
2969 * The operation will result in splitting the peer from its existing
2970 * subgroups and putting it in new subgroups.
2973 bgp_announce_route_all (struct peer
*peer
)
2978 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
2979 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
2980 bgp_announce_route (peer
, afi
, safi
);
2984 bgp_soft_reconfig_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
2985 struct bgp_table
*table
, struct prefix_rd
*prd
)
2988 struct bgp_node
*rn
;
2989 struct bgp_adj_in
*ain
;
2992 table
= peer
->bgp
->rib
[afi
][safi
];
2994 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
2995 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
2997 if (ain
->peer
== peer
)
2999 struct bgp_info
*ri
= rn
->info
;
3000 u_char
*tag
= (ri
&& ri
->extra
) ? ri
->extra
->tag
: NULL
;
3002 ret
= bgp_update (peer
, &rn
->p
, ain
->addpath_rx_id
, ain
->attr
,
3003 afi
, safi
, ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
,
3008 bgp_unlock_node (rn
);
3016 bgp_soft_reconfig_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3018 struct bgp_node
*rn
;
3019 struct bgp_table
*table
;
3021 if (peer
->status
!= Established
)
3024 if ((safi
!= SAFI_MPLS_VPN
) && (safi
!= SAFI_ENCAP
))
3025 bgp_soft_reconfig_table (peer
, afi
, safi
, NULL
, NULL
);
3027 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3028 rn
= bgp_route_next (rn
))
3029 if ((table
= rn
->info
) != NULL
)
3031 struct prefix_rd prd
;
3032 prd
.family
= AF_UNSPEC
;
3034 memcpy(&prd
.val
, rn
->p
.u
.val
, 8);
3036 bgp_soft_reconfig_table (peer
, afi
, safi
, table
, &prd
);
3041 struct bgp_clear_node_queue
3043 struct bgp_node
*rn
;
3046 static wq_item_status
3047 bgp_clear_route_node (struct work_queue
*wq
, void *data
)
3049 struct bgp_clear_node_queue
*cnq
= data
;
3050 struct bgp_node
*rn
= cnq
->rn
;
3051 struct peer
*peer
= wq
->spec
.data
;
3052 struct bgp_info
*ri
;
3053 afi_t afi
= bgp_node_table (rn
)->afi
;
3054 safi_t safi
= bgp_node_table (rn
)->safi
;
3056 assert (rn
&& peer
);
3058 /* It is possible that we have multiple paths for a prefix from a peer
3059 * if that peer is using AddPath.
3061 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3062 if (ri
->peer
== peer
)
3064 /* graceful restart STALE flag set. */
3065 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_NSF_WAIT
)
3066 && peer
->nsf
[afi
][safi
]
3067 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
)
3068 && ! CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
3069 bgp_info_set_flag (rn
, ri
, BGP_INFO_STALE
);
3071 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3077 bgp_clear_node_queue_del (struct work_queue
*wq
, void *data
)
3079 struct bgp_clear_node_queue
*cnq
= data
;
3080 struct bgp_node
*rn
= cnq
->rn
;
3081 struct bgp_table
*table
= bgp_node_table (rn
);
3083 bgp_unlock_node (rn
);
3084 bgp_table_unlock (table
);
3085 XFREE (MTYPE_BGP_CLEAR_NODE_QUEUE
, cnq
);
3089 bgp_clear_node_complete (struct work_queue
*wq
)
3091 struct peer
*peer
= wq
->spec
.data
;
3093 /* Tickle FSM to start moving again */
3094 BGP_EVENT_ADD (peer
, Clearing_Completed
);
3096 peer_unlock (peer
); /* bgp_clear_route */
3100 bgp_clear_node_queue_init (struct peer
*peer
)
3102 char wname
[sizeof("clear xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx")];
3104 snprintf (wname
, sizeof(wname
), "clear %s", peer
->host
);
3105 #undef CLEAR_QUEUE_NAME_LEN
3107 if ( (peer
->clear_node_queue
= work_queue_new (bm
->master
, wname
)) == NULL
)
3109 zlog_err ("%s: Failed to allocate work queue", __func__
);
3112 peer
->clear_node_queue
->spec
.hold
= 10;
3113 peer
->clear_node_queue
->spec
.workfunc
= &bgp_clear_route_node
;
3114 peer
->clear_node_queue
->spec
.del_item_data
= &bgp_clear_node_queue_del
;
3115 peer
->clear_node_queue
->spec
.completion_func
= &bgp_clear_node_complete
;
3116 peer
->clear_node_queue
->spec
.max_retries
= 0;
3118 /* we only 'lock' this peer reference when the queue is actually active */
3119 peer
->clear_node_queue
->spec
.data
= peer
;
3123 bgp_clear_route_table (struct peer
*peer
, afi_t afi
, safi_t safi
,
3124 struct bgp_table
*table
)
3126 struct bgp_node
*rn
;
3127 int force
= bm
->process_main_queue
? 0 : 1;
3130 table
= peer
->bgp
->rib
[afi
][safi
];
3132 /* If still no table => afi/safi isn't configured at all or smth. */
3136 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3138 struct bgp_info
*ri
, *next
;
3139 struct bgp_adj_in
*ain
;
3140 struct bgp_adj_in
*ain_next
;
3142 /* XXX:TODO: This is suboptimal, every non-empty route_node is
3143 * queued for every clearing peer, regardless of whether it is
3144 * relevant to the peer at hand.
3146 * Overview: There are 3 different indices which need to be
3147 * scrubbed, potentially, when a peer is removed:
3149 * 1 peer's routes visible via the RIB (ie accepted routes)
3150 * 2 peer's routes visible by the (optional) peer's adj-in index
3151 * 3 other routes visible by the peer's adj-out index
3153 * 3 there is no hurry in scrubbing, once the struct peer is
3154 * removed from bgp->peer, we could just GC such deleted peer's
3155 * adj-outs at our leisure.
3157 * 1 and 2 must be 'scrubbed' in some way, at least made
3158 * invisible via RIB index before peer session is allowed to be
3159 * brought back up. So one needs to know when such a 'search' is
3164 * - there'd be a single global queue or a single RIB walker
3165 * - rather than tracking which route_nodes still need to be
3166 * examined on a peer basis, we'd track which peers still
3169 * Given that our per-peer prefix-counts now should be reliable,
3170 * this may actually be achievable. It doesn't seem to be a huge
3171 * problem at this time,
3173 * It is possible that we have multiple paths for a prefix from a peer
3174 * if that peer is using AddPath.
3179 ain_next
= ain
->next
;
3181 if (ain
->peer
== peer
)
3183 bgp_adj_in_remove (rn
, ain
);
3184 bgp_unlock_node (rn
);
3190 for (ri
= rn
->info
; ri
; ri
= next
)
3193 if (ri
->peer
!= peer
)
3197 bgp_info_reap (rn
, ri
);
3200 struct bgp_clear_node_queue
*cnq
;
3202 /* both unlocked in bgp_clear_node_queue_del */
3203 bgp_table_lock (bgp_node_table (rn
));
3205 cnq
= XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE
,
3206 sizeof (struct bgp_clear_node_queue
));
3208 work_queue_add (peer
->clear_node_queue
, cnq
);
3217 bgp_clear_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3219 struct bgp_node
*rn
;
3220 struct bgp_table
*table
;
3222 if (peer
->clear_node_queue
== NULL
)
3223 bgp_clear_node_queue_init (peer
);
3225 /* bgp_fsm.c keeps sessions in state Clearing, not transitioning to
3226 * Idle until it receives a Clearing_Completed event. This protects
3227 * against peers which flap faster than we can we clear, which could
3230 * a) race with routes from the new session being installed before
3231 * clear_route_node visits the node (to delete the route of that
3233 * b) resource exhaustion, clear_route_node likely leads to an entry
3234 * on the process_main queue. Fast-flapping could cause that queue
3238 /* lock peer in assumption that clear-node-queue will get nodes; if so,
3239 * the unlock will happen upon work-queue completion; other wise, the
3240 * unlock happens at the end of this function.
3242 if (!peer
->clear_node_queue
->thread
)
3245 if (safi
!= SAFI_MPLS_VPN
&& safi
!= SAFI_ENCAP
)
3246 bgp_clear_route_table (peer
, afi
, safi
, NULL
);
3248 for (rn
= bgp_table_top (peer
->bgp
->rib
[afi
][safi
]); rn
;
3249 rn
= bgp_route_next (rn
))
3250 if ((table
= rn
->info
) != NULL
)
3251 bgp_clear_route_table (peer
, afi
, safi
, table
);
3253 /* unlock if no nodes got added to the clear-node-queue. */
3254 if (!peer
->clear_node_queue
->thread
)
3260 bgp_clear_route_all (struct peer
*peer
)
3265 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
3266 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
3267 bgp_clear_route (peer
, afi
, safi
);
3270 rfapiProcessPeerDown(peer
);
3275 bgp_clear_adj_in (struct peer
*peer
, afi_t afi
, safi_t safi
)
3277 struct bgp_table
*table
;
3278 struct bgp_node
*rn
;
3279 struct bgp_adj_in
*ain
;
3280 struct bgp_adj_in
*ain_next
;
3282 table
= peer
->bgp
->rib
[afi
][safi
];
3284 /* It is possible that we have multiple paths for a prefix from a peer
3285 * if that peer is using AddPath.
3287 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3293 ain_next
= ain
->next
;
3295 if (ain
->peer
== peer
)
3297 bgp_adj_in_remove (rn
, ain
);
3298 bgp_unlock_node (rn
);
3307 bgp_clear_stale_route (struct peer
*peer
, afi_t afi
, safi_t safi
)
3309 struct bgp_node
*rn
;
3310 struct bgp_info
*ri
;
3311 struct bgp_table
*table
;
3313 table
= peer
->bgp
->rib
[afi
][safi
];
3315 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3317 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3318 if (ri
->peer
== peer
)
3320 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
3321 bgp_rib_remove (rn
, ri
, peer
, afi
, safi
);
3328 bgp_cleanup_table(struct bgp_table
*table
, safi_t safi
)
3330 struct bgp_node
*rn
;
3331 struct bgp_info
*ri
;
3332 struct bgp_info
*next
;
3334 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
3335 for (ri
= rn
->info
; ri
; ri
= next
)
3338 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)
3339 && ri
->type
== ZEBRA_ROUTE_BGP
3340 && (ri
->sub_type
== BGP_ROUTE_NORMAL
||
3341 ri
->sub_type
== BGP_ROUTE_AGGREGATE
))
3344 if (table
->owner
&& table
->owner
->bgp
)
3345 vnc_import_bgp_del_route(table
->owner
->bgp
, &rn
->p
, ri
);
3347 bgp_zebra_withdraw (&rn
->p
, ri
, safi
);
3348 bgp_info_reap (rn
, ri
);
3353 /* Delete all kernel routes. */
3355 bgp_cleanup_routes (struct bgp
*bgp
)
3359 for (afi
= AFI_IP
; afi
< AFI_MAX
; ++afi
)
3361 struct bgp_node
*rn
;
3363 bgp_cleanup_table(bgp
->rib
[afi
][SAFI_UNICAST
], SAFI_UNICAST
);
3366 * VPN and ENCAP tables are two-level (RD is top level)
3368 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_MPLS_VPN
]); rn
;
3369 rn
= bgp_route_next (rn
))
3373 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_MPLS_VPN
);
3374 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3376 bgp_unlock_node(rn
);
3380 for (rn
= bgp_table_top(bgp
->rib
[afi
][SAFI_ENCAP
]); rn
;
3381 rn
= bgp_route_next (rn
))
3385 bgp_cleanup_table((struct bgp_table
*)(rn
->info
), SAFI_ENCAP
);
3386 bgp_table_finish ((struct bgp_table
**)&(rn
->info
));
3388 bgp_unlock_node(rn
);
3398 bgp_zclient_reset ();
3399 access_list_reset ();
3400 prefix_list_reset ();
3404 bgp_addpath_encode_rx (struct peer
*peer
, afi_t afi
, safi_t safi
)
3406 return (CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_RX_ADV
) &&
3407 CHECK_FLAG (peer
->af_cap
[afi
][safi
], PEER_CAP_ADDPATH_AF_TX_RCV
));
3410 /* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
3413 bgp_nlri_parse_ip (struct peer
*peer
, struct attr
*attr
,
3414 struct bgp_nlri
*packet
)
3423 int addpath_encoded
;
3424 u_int32_t addpath_id
;
3426 /* Check peer status. */
3427 if (peer
->status
!= Established
)
3431 lim
= pnt
+ packet
->length
;
3433 safi
= packet
->safi
;
3435 addpath_encoded
= bgp_addpath_encode_rx (peer
, afi
, safi
);
3437 /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
3438 syntactic validity. If the field is syntactically incorrect,
3439 then the Error Subcode is set to Invalid Network Field. */
3440 for (; pnt
< lim
; pnt
+= psize
)
3442 /* Clear prefix structure. */
3443 memset (&p
, 0, sizeof (struct prefix
));
3445 if (addpath_encoded
)
3448 /* When packet overflow occurs return immediately. */
3449 if (pnt
+ BGP_ADDPATH_ID_LEN
> lim
)
3452 addpath_id
= ntohl(*((uint32_t*) pnt
));
3453 pnt
+= BGP_ADDPATH_ID_LEN
;
3456 /* Fetch prefix length. */
3457 p
.prefixlen
= *pnt
++;
3458 /* afi/safi validity already verified by caller, bgp_update_receive */
3459 p
.family
= afi2family (afi
);
3461 /* Prefix length check. */
3462 if (p
.prefixlen
> prefix_blen (&p
) * 8)
3464 zlog_err("%s [Error] Update packet error (wrong perfix length %d for afi %u)",
3465 peer
->host
, p
.prefixlen
, packet
->afi
);
3469 /* Packet size overflow check. */
3470 psize
= PSIZE (p
.prefixlen
);
3472 /* When packet overflow occur return immediately. */
3473 if (pnt
+ psize
> lim
)
3475 zlog_err("%s [Error] Update packet error (prefix length %d overflows packet)",
3476 peer
->host
, p
.prefixlen
);
3480 /* Defensive coding, double-check the psize fits in a struct prefix */
3481 if (psize
> (ssize_t
) sizeof(p
.u
))
3483 zlog_err("%s [Error] Update packet error (prefix length %d too large for prefix storage %zu)",
3484 peer
->host
, p
.prefixlen
, sizeof(p
.u
));
3488 /* Fetch prefix from NLRI packet. */
3489 memcpy (&p
.u
.prefix
, pnt
, psize
);
3491 /* Check address. */
3492 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3494 if (IN_CLASSD (ntohl (p
.u
.prefix4
.s_addr
)))
3496 /* From RFC4271 Section 6.3:
3498 * If a prefix in the NLRI field is semantically incorrect
3499 * (e.g., an unexpected multicast IP address), an error SHOULD
3500 * be logged locally, and the prefix SHOULD be ignored.
3502 zlog_err ("%s: IPv4 unicast NLRI is multicast address %s, ignoring",
3503 peer
->host
, inet_ntoa (p
.u
.prefix4
));
3509 /* Check address. */
3510 if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
3512 if (IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
3516 zlog_err ("%s: IPv6 unicast NLRI is link-local address %s, ignoring",
3517 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3521 if (IN6_IS_ADDR_MULTICAST (&p
.u
.prefix6
))
3525 zlog_err ("%s: IPv6 unicast NLRI is multicast address %s, ignoring",
3526 peer
->host
, inet_ntop (AF_INET6
, &p
.u
.prefix6
, buf
, BUFSIZ
));
3531 #endif /* HAVE_IPV6 */
3533 /* Normal process. */
3535 ret
= bgp_update (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3536 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
, 0);
3538 ret
= bgp_withdraw (peer
, &p
, addpath_id
, attr
, afi
, safi
,
3539 ZEBRA_ROUTE_BGP
, BGP_ROUTE_NORMAL
, NULL
, NULL
);
3541 /* Address family configuration mismatch or maximum-prefix count
3547 /* Packet length consistency check. */
3550 zlog_err ("%s [Error] Update packet error (prefix length mismatch with total length)",
3558 static struct bgp_static
*
3559 bgp_static_new (void)
3561 return XCALLOC (MTYPE_BGP_STATIC
, sizeof (struct bgp_static
));
3565 bgp_static_free (struct bgp_static
*bgp_static
)
3567 if (bgp_static
->rmap
.name
)
3568 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
3569 XFREE (MTYPE_BGP_STATIC
, bgp_static
);
3573 bgp_static_update_main (struct bgp
*bgp
, struct prefix
*p
,
3574 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3576 struct bgp_node
*rn
;
3577 struct bgp_info
*ri
;
3578 struct bgp_info
*new;
3579 struct bgp_info info
;
3581 struct attr
*attr_new
;
3584 int vnc_implicit_withdraw
= 0;
3587 assert (bgp_static
);
3591 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3593 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3595 attr
.nexthop
= bgp_static
->igpnexthop
;
3596 attr
.med
= bgp_static
->igpmetric
;
3597 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3599 if (bgp_static
->atomic
)
3600 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
);
3602 /* Apply route-map. */
3603 if (bgp_static
->rmap
.name
)
3605 struct attr attr_tmp
= attr
;
3606 info
.peer
= bgp
->peer_self
;
3607 info
.attr
= &attr_tmp
;
3609 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3611 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3613 bgp
->peer_self
->rmap_type
= 0;
3615 if (ret
== RMAP_DENYMATCH
)
3617 /* Free uninterned attribute. */
3618 bgp_attr_flush (&attr_tmp
);
3620 /* Unintern original. */
3621 aspath_unintern (&attr
.aspath
);
3622 bgp_attr_extra_free (&attr
);
3623 bgp_static_withdraw (bgp
, p
, afi
, safi
);
3626 attr_new
= bgp_attr_intern (&attr_tmp
);
3629 attr_new
= bgp_attr_intern (&attr
);
3631 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3632 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3633 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3638 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3639 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
) &&
3640 !bgp_flag_check(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
))
3642 bgp_unlock_node (rn
);
3643 bgp_attr_unintern (&attr_new
);
3644 aspath_unintern (&attr
.aspath
);
3645 bgp_attr_extra_free (&attr
);
3650 /* The attribute is changed. */
3651 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3653 /* Rewrite BGP route information. */
3654 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3655 bgp_info_restore(rn
, ri
);
3657 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3659 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3661 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
3664 * Implicit withdraw case.
3665 * We have to do this before ri is changed
3667 ++vnc_implicit_withdraw
;
3668 vnc_import_bgp_del_route(bgp
, p
, ri
);
3669 vnc_import_bgp_exterior_del_route(bgp
, p
, ri
);
3673 bgp_attr_unintern (&ri
->attr
);
3674 ri
->attr
= attr_new
;
3675 ri
->uptime
= bgp_clock ();
3677 if ((afi
== AFI_IP
|| afi
== AFI_IP6
) && (safi
== SAFI_UNICAST
))
3679 if (vnc_implicit_withdraw
)
3681 vnc_import_bgp_add_route(bgp
, p
, ri
);
3682 vnc_import_bgp_exterior_add_route(bgp
, p
, ri
);
3687 /* Nexthop reachability check. */
3688 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3690 if (bgp_find_or_add_nexthop (bgp
, afi
, ri
, NULL
, 0))
3691 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3694 if (BGP_DEBUG(nht
, NHT
))
3696 char buf1
[INET6_ADDRSTRLEN
];
3697 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3699 zlog_debug("%s(%s): Route not in table, not advertising",
3700 __FUNCTION__
, buf1
);
3702 bgp_info_unset_flag (rn
, ri
, BGP_INFO_VALID
);
3707 /* Delete the NHT structure if any, if we're toggling between
3708 * enabling/disabling import check. We deregister the route
3709 * from NHT to avoid overloading NHT and the process interaction
3711 bgp_unlink_nexthop(ri
);
3712 bgp_info_set_flag (rn
, ri
, BGP_INFO_VALID
);
3714 /* Process change. */
3715 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3716 bgp_process (bgp
, rn
, afi
, safi
);
3717 bgp_unlock_node (rn
);
3718 aspath_unintern (&attr
.aspath
);
3719 bgp_attr_extra_free (&attr
);
3724 /* Make new BGP info. */
3725 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3727 /* Nexthop reachability check. */
3728 if (bgp_flag_check (bgp
, BGP_FLAG_IMPORT_CHECK
))
3730 if (bgp_find_or_add_nexthop (bgp
, afi
, new, NULL
, 0))
3731 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3734 if (BGP_DEBUG(nht
, NHT
))
3736 char buf1
[INET6_ADDRSTRLEN
];
3737 inet_ntop(p
->family
, &p
->u
.prefix
, buf1
,
3739 zlog_debug("%s(%s): Route not in table, not advertising",
3740 __FUNCTION__
, buf1
);
3742 bgp_info_unset_flag (rn
, new, BGP_INFO_VALID
);
3747 /* Delete the NHT structure if any, if we're toggling between
3748 * enabling/disabling import check. We deregister the route
3749 * from NHT to avoid overloading NHT and the process interaction
3751 bgp_unlink_nexthop(new);
3753 bgp_info_set_flag (rn
, new, BGP_INFO_VALID
);
3756 /* Aggregate address increment. */
3757 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3759 /* Register new BGP information. */
3760 bgp_info_add (rn
, new);
3762 /* route_node_get lock */
3763 bgp_unlock_node (rn
);
3765 /* Process change. */
3766 bgp_process (bgp
, rn
, afi
, safi
);
3768 /* Unintern original. */
3769 aspath_unintern (&attr
.aspath
);
3770 bgp_attr_extra_free (&attr
);
3774 bgp_static_update (struct bgp
*bgp
, struct prefix
*p
,
3775 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3777 bgp_static_update_main (bgp
, p
, bgp_static
, afi
, safi
);
3781 bgp_static_withdraw (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3784 struct bgp_node
*rn
;
3785 struct bgp_info
*ri
;
3787 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, NULL
);
3789 /* Check selected route and self inserted route. */
3790 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3791 if (ri
->peer
== bgp
->peer_self
3792 && ri
->type
== ZEBRA_ROUTE_BGP
3793 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3796 /* Withdraw static BGP route from routing table. */
3799 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3800 bgp_unlink_nexthop(ri
);
3801 bgp_info_delete (rn
, ri
);
3802 bgp_process (bgp
, rn
, afi
, safi
);
3805 /* Unlock bgp_node_lookup. */
3806 bgp_unlock_node (rn
);
3810 * Used for SAFI_MPLS_VPN and SAFI_ENCAP
3813 bgp_static_withdraw_safi (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
3814 safi_t safi
, struct prefix_rd
*prd
, u_char
*tag
)
3816 struct bgp_node
*rn
;
3817 struct bgp_info
*ri
;
3819 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, prd
);
3821 /* Check selected route and self inserted route. */
3822 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3823 if (ri
->peer
== bgp
->peer_self
3824 && ri
->type
== ZEBRA_ROUTE_BGP
3825 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3828 /* Withdraw static BGP route from routing table. */
3832 rfapiProcessWithdraw(
3841 1); /* Kill, since it is an administrative change */
3843 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3844 bgp_info_delete (rn
, ri
);
3845 bgp_process (bgp
, rn
, afi
, safi
);
3848 /* Unlock bgp_node_lookup. */
3849 bgp_unlock_node (rn
);
3853 bgp_static_update_safi (struct bgp
*bgp
, struct prefix
*p
,
3854 struct bgp_static
*bgp_static
, afi_t afi
, safi_t safi
)
3856 struct bgp_node
*rn
;
3857 struct bgp_info
*new;
3858 struct attr
*attr_new
;
3859 struct attr attr
= { 0 };
3860 struct bgp_info
*ri
;
3862 u_int32_t label
= 0;
3865 assert (bgp_static
);
3867 rn
= bgp_afi_node_get (bgp
->rib
[afi
][safi
], afi
, safi
, p
, &bgp_static
->prd
);
3869 bgp_attr_default_set (&attr
, BGP_ORIGIN_IGP
);
3871 attr
.nexthop
= bgp_static
->igpnexthop
;
3872 attr
.med
= bgp_static
->igpmetric
;
3873 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
3875 /* Apply route-map. */
3876 if (bgp_static
->rmap
.name
)
3878 struct attr attr_tmp
= attr
;
3879 struct bgp_info info
;
3882 info
.peer
= bgp
->peer_self
;
3883 info
.attr
= &attr_tmp
;
3885 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_NETWORK
);
3887 ret
= route_map_apply (bgp_static
->rmap
.map
, p
, RMAP_BGP
, &info
);
3889 bgp
->peer_self
->rmap_type
= 0;
3891 if (ret
== RMAP_DENYMATCH
)
3893 /* Free uninterned attribute. */
3894 bgp_attr_flush (&attr_tmp
);
3896 /* Unintern original. */
3897 aspath_unintern (&attr
.aspath
);
3898 bgp_attr_extra_free (&attr
);
3899 bgp_static_withdraw_safi (bgp
, p
, afi
, safi
, &bgp_static
->prd
,
3904 attr_new
= bgp_attr_intern (&attr_tmp
);
3908 attr_new
= bgp_attr_intern (&attr
);
3911 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
3912 if (ri
->peer
== bgp
->peer_self
&& ri
->type
== ZEBRA_ROUTE_BGP
3913 && ri
->sub_type
== BGP_ROUTE_STATIC
)
3918 if (attrhash_cmp (ri
->attr
, attr_new
) &&
3919 !CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3921 bgp_unlock_node (rn
);
3922 bgp_attr_unintern (&attr_new
);
3923 aspath_unintern (&attr
.aspath
);
3924 bgp_attr_extra_free (&attr
);
3929 /* The attribute is changed. */
3930 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
3932 /* Rewrite BGP route information. */
3933 if (CHECK_FLAG(ri
->flags
, BGP_INFO_REMOVED
))
3934 bgp_info_restore(rn
, ri
);
3936 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, safi
);
3937 bgp_attr_unintern (&ri
->attr
);
3938 ri
->attr
= attr_new
;
3939 ri
->uptime
= bgp_clock ();
3942 label
= decode_label (ri
->extra
->tag
);
3945 /* Process change. */
3946 bgp_aggregate_increment (bgp
, p
, ri
, afi
, safi
);
3947 bgp_process (bgp
, rn
, afi
, safi
);
3949 rfapiProcessUpdate(ri
->peer
, NULL
, p
, &bgp_static
->prd
,
3950 ri
->attr
, afi
, safi
,
3951 ri
->type
, ri
->sub_type
, &label
);
3953 bgp_unlock_node (rn
);
3954 aspath_unintern (&attr
.aspath
);
3955 bgp_attr_extra_free (&attr
);
3961 /* Make new BGP info. */
3962 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_STATIC
, 0, bgp
->peer_self
, attr_new
,
3964 SET_FLAG (new->flags
, BGP_INFO_VALID
);
3965 new->extra
= bgp_info_extra_new();
3966 memcpy (new->extra
->tag
, bgp_static
->tag
, 3);
3968 label
= decode_label (bgp_static
->tag
);
3971 /* Aggregate address increment. */
3972 bgp_aggregate_increment (bgp
, p
, new, afi
, safi
);
3974 /* Register new BGP information. */
3975 bgp_info_add (rn
, new);
3977 /* route_node_get lock */
3978 bgp_unlock_node (rn
);
3980 /* Process change. */
3981 bgp_process (bgp
, rn
, afi
, safi
);
3984 rfapiProcessUpdate(new->peer
, NULL
, p
, &bgp_static
->prd
,
3985 new->attr
, afi
, safi
,
3986 new->type
, new->sub_type
, &label
);
3989 /* Unintern original. */
3990 aspath_unintern (&attr
.aspath
);
3991 bgp_attr_extra_free (&attr
);
3994 /* Configure static BGP network. When user don't run zebra, static
3995 route should be installed as valid. */
3997 bgp_static_set (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
3998 afi_t afi
, safi_t safi
, const char *rmap
, int backdoor
)
4002 struct bgp_static
*bgp_static
;
4003 struct bgp_node
*rn
;
4004 u_char need_update
= 0;
4006 /* Convert IP prefix string to struct prefix. */
4007 ret
= str2prefix (ip_str
, &p
);
4010 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4014 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4016 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4020 #endif /* HAVE_IPV6 */
4024 /* Set BGP static route configuration. */
4025 rn
= bgp_node_get (bgp
->route
[afi
][safi
], &p
);
4029 /* Configuration change. */
4030 bgp_static
= rn
->info
;
4032 /* Check previous routes are installed into BGP. */
4033 if (bgp_static
->valid
&& bgp_static
->backdoor
!= backdoor
)
4036 bgp_static
->backdoor
= backdoor
;
4040 if (bgp_static
->rmap
.name
)
4041 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4042 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4043 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4047 if (bgp_static
->rmap
.name
)
4048 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4049 bgp_static
->rmap
.name
= NULL
;
4050 bgp_static
->rmap
.map
= NULL
;
4051 bgp_static
->valid
= 0;
4053 bgp_unlock_node (rn
);
4057 /* New configuration. */
4058 bgp_static
= bgp_static_new ();
4059 bgp_static
->backdoor
= backdoor
;
4060 bgp_static
->valid
= 0;
4061 bgp_static
->igpmetric
= 0;
4062 bgp_static
->igpnexthop
.s_addr
= 0;
4066 if (bgp_static
->rmap
.name
)
4067 XFREE(MTYPE_ROUTE_MAP_NAME
, bgp_static
->rmap
.name
);
4068 bgp_static
->rmap
.name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap
);
4069 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap
);
4071 rn
->info
= bgp_static
;
4074 bgp_static
->valid
= 1;
4076 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4078 if (! bgp_static
->backdoor
)
4079 bgp_static_update (bgp
, &p
, bgp_static
, afi
, safi
);
4084 /* Configure static BGP network. */
4086 bgp_static_unset (struct vty
*vty
, struct bgp
*bgp
, const char *ip_str
,
4087 afi_t afi
, safi_t safi
)
4091 struct bgp_static
*bgp_static
;
4092 struct bgp_node
*rn
;
4094 /* Convert IP prefix string to struct prefix. */
4095 ret
= str2prefix (ip_str
, &p
);
4098 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4102 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL (&p
.u
.prefix6
))
4104 vty_out (vty
, "%% Malformed prefix (link-local address)%s",
4108 #endif /* HAVE_IPV6 */
4112 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], &p
);
4115 vty_out (vty
, "%% Can't find specified static route configuration.%s",
4120 bgp_static
= rn
->info
;
4122 /* Update BGP RIB. */
4123 if (! bgp_static
->backdoor
)
4124 bgp_static_withdraw (bgp
, &p
, afi
, safi
);
4126 /* Clear configuration. */
4127 bgp_static_free (bgp_static
);
4129 bgp_unlock_node (rn
);
4130 bgp_unlock_node (rn
);
4136 bgp_static_add (struct bgp
*bgp
)
4140 struct bgp_node
*rn
;
4141 struct bgp_node
*rm
;
4142 struct bgp_table
*table
;
4143 struct bgp_static
*bgp_static
;
4145 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4146 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4147 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4148 if (rn
->info
!= NULL
)
4150 if (safi
== SAFI_MPLS_VPN
)
4154 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4156 bgp_static
= rn
->info
;
4157 bgp_static_update_safi (bgp
, &rm
->p
, bgp_static
, afi
, safi
);
4162 bgp_static_update (bgp
, &rn
->p
, rn
->info
, afi
, safi
);
4167 /* Called from bgp_delete(). Delete all static routes from the BGP
4170 bgp_static_delete (struct bgp
*bgp
)
4174 struct bgp_node
*rn
;
4175 struct bgp_node
*rm
;
4176 struct bgp_table
*table
;
4177 struct bgp_static
*bgp_static
;
4179 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4180 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4181 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4182 if (rn
->info
!= NULL
)
4184 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
4188 for (rm
= bgp_table_top (table
); rm
; rm
= bgp_route_next (rm
))
4190 bgp_static
= rn
->info
;
4191 bgp_static_withdraw_safi (bgp
, &rm
->p
,
4193 (struct prefix_rd
*)&rn
->p
,
4195 bgp_static_free (bgp_static
);
4197 bgp_unlock_node (rn
);
4202 bgp_static
= rn
->info
;
4203 bgp_static_withdraw (bgp
, &rn
->p
, afi
, safi
);
4204 bgp_static_free (bgp_static
);
4206 bgp_unlock_node (rn
);
4212 bgp_static_redo_import_check (struct bgp
*bgp
)
4216 struct bgp_node
*rn
;
4217 struct bgp_static
*bgp_static
;
4219 /* Use this flag to force reprocessing of the route */
4220 bgp_flag_set(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4221 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4222 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4223 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
4224 if (rn
->info
!= NULL
)
4226 bgp_static
= rn
->info
;
4227 bgp_static_update (bgp
, &rn
->p
, bgp_static
, afi
, safi
);
4229 bgp_flag_unset(bgp
, BGP_FLAG_FORCE_STATIC_PROCESS
);
4233 bgp_purge_af_static_redist_routes (struct bgp
*bgp
, afi_t afi
, safi_t safi
)
4235 struct bgp_table
*table
;
4236 struct bgp_node
*rn
;
4237 struct bgp_info
*ri
;
4239 table
= bgp
->rib
[afi
][safi
];
4240 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
4242 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4244 if (ri
->peer
== bgp
->peer_self
&&
4245 ((ri
->type
== ZEBRA_ROUTE_BGP
&&
4246 ri
->sub_type
== BGP_ROUTE_STATIC
) ||
4247 (ri
->type
!= ZEBRA_ROUTE_BGP
&&
4248 ri
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)))
4250 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, safi
);
4251 bgp_unlink_nexthop(ri
);
4252 bgp_info_delete (rn
, ri
);
4253 bgp_process (bgp
, rn
, afi
, safi
);
4260 * Purge all networks and redistributed routes from routing table.
4261 * Invoked upon the instance going down.
4264 bgp_purge_static_redist_routes (struct bgp
*bgp
)
4269 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4270 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4271 bgp_purge_af_static_redist_routes (bgp
, afi
, safi
);
4276 * Currently this is used to set static routes for VPN and ENCAP.
4277 * I think it can probably be factored with bgp_static_set.
4280 bgp_static_set_safi (safi_t safi
, struct vty
*vty
, const char *ip_str
,
4281 const char *rd_str
, const char *tag_str
,
4282 const char *rmap_str
)
4286 struct prefix_rd prd
;
4288 struct bgp_node
*prn
;
4289 struct bgp_node
*rn
;
4290 struct bgp_table
*table
;
4291 struct bgp_static
*bgp_static
;
4296 ret
= str2prefix (ip_str
, &p
);
4299 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4304 ret
= str2prefix_rd (rd_str
, &prd
);
4307 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4311 ret
= str2tag (tag_str
, tag
);
4314 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4318 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4319 (struct prefix
*)&prd
);
4320 if (prn
->info
== NULL
)
4321 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4323 bgp_unlock_node (prn
);
4326 rn
= bgp_node_get (table
, &p
);
4330 vty_out (vty
, "%% Same network configuration exists%s", VTY_NEWLINE
);
4331 bgp_unlock_node (rn
);
4335 /* New configuration. */
4336 bgp_static
= bgp_static_new ();
4337 bgp_static
->backdoor
= 0;
4338 bgp_static
->valid
= 0;
4339 bgp_static
->igpmetric
= 0;
4340 bgp_static
->igpnexthop
.s_addr
= 0;
4341 memcpy(bgp_static
->tag
, tag
, 3);
4342 bgp_static
->prd
= prd
;
4346 if (bgp_static
->rmap
.name
)
4347 free (bgp_static
->rmap
.name
);
4348 bgp_static
->rmap
.name
= strdup (rmap_str
);
4349 bgp_static
->rmap
.map
= route_map_lookup_by_name (rmap_str
);
4351 rn
->info
= bgp_static
;
4353 bgp_static
->valid
= 1;
4354 bgp_static_update_safi (bgp
, &p
, bgp_static
, AFI_IP
, safi
);
4360 /* Configure static BGP network. */
4362 bgp_static_unset_safi(safi_t safi
, struct vty
*vty
, const char *ip_str
,
4363 const char *rd_str
, const char *tag_str
)
4368 struct prefix_rd prd
;
4369 struct bgp_node
*prn
;
4370 struct bgp_node
*rn
;
4371 struct bgp_table
*table
;
4372 struct bgp_static
*bgp_static
;
4377 /* Convert IP prefix string to struct prefix. */
4378 ret
= str2prefix (ip_str
, &p
);
4381 vty_out (vty
, "%% Malformed prefix%s", VTY_NEWLINE
);
4386 ret
= str2prefix_rd (rd_str
, &prd
);
4389 vty_out (vty
, "%% Malformed rd%s", VTY_NEWLINE
);
4393 ret
= str2tag (tag_str
, tag
);
4396 vty_out (vty
, "%% Malformed tag%s", VTY_NEWLINE
);
4400 prn
= bgp_node_get (bgp
->route
[AFI_IP
][safi
],
4401 (struct prefix
*)&prd
);
4402 if (prn
->info
== NULL
)
4403 prn
->info
= bgp_table_init (AFI_IP
, safi
);
4405 bgp_unlock_node (prn
);
4408 rn
= bgp_node_lookup (table
, &p
);
4412 bgp_static_withdraw_safi (bgp
, &p
, AFI_IP
, safi
, &prd
, tag
);
4414 bgp_static
= rn
->info
;
4415 bgp_static_free (bgp_static
);
4417 bgp_unlock_node (rn
);
4418 bgp_unlock_node (rn
);
4421 vty_out (vty
, "%% Can't find the route%s", VTY_NEWLINE
);
4427 bgp_table_map_set (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4428 const char *rmap_name
)
4430 struct bgp_rmap
*rmap
;
4432 rmap
= &bgp
->table_map
[afi
][safi
];
4436 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4437 rmap
->name
= XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_name
);
4438 rmap
->map
= route_map_lookup_by_name (rmap_name
);
4443 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4448 bgp_zebra_announce_table(bgp
, afi
, safi
);
4454 bgp_table_map_unset (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
4455 const char *rmap_name
)
4457 struct bgp_rmap
*rmap
;
4459 rmap
= &bgp
->table_map
[afi
][safi
];
4461 XFREE(MTYPE_ROUTE_MAP_NAME
, rmap
->name
);
4465 bgp_zebra_announce_table(bgp
, afi
, safi
);
4471 bgp_config_write_table_map (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
4472 safi_t safi
, int *write
)
4474 if (bgp
->table_map
[afi
][safi
].name
)
4476 bgp_config_write_family_header (vty
, afi
, safi
, write
);
4477 vty_out (vty
, " table-map %s%s",
4478 bgp
->table_map
[afi
][safi
].name
, VTY_NEWLINE
);
4484 DEFUN (bgp_table_map
,
4487 "BGP table to RIB route download filter\n"
4488 "Name of the route map\n")
4490 return bgp_table_map_set (vty
, vty
->index
,
4491 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4493 DEFUN (no_bgp_table_map
,
4494 no_bgp_table_map_cmd
,
4495 "no table-map WORD",
4496 "BGP table to RIB route download filter\n"
4497 "Name of the route map\n")
4499 return bgp_table_map_unset (vty
, vty
->index
,
4500 bgp_node_afi (vty
), bgp_node_safi (vty
), argv
[0]);
4505 "network A.B.C.D/M",
4506 "Specify a network to announce via BGP\n"
4507 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4509 return bgp_static_set (vty
, vty
->index
, argv
[0],
4510 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4513 DEFUN (bgp_network_route_map
,
4514 bgp_network_route_map_cmd
,
4515 "network A.B.C.D/M route-map WORD",
4516 "Specify a network to announce via BGP\n"
4517 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4518 "Route-map to modify the attributes\n"
4519 "Name of the route map\n")
4521 return bgp_static_set (vty
, vty
->index
, argv
[0],
4522 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4525 DEFUN (bgp_network_backdoor
,
4526 bgp_network_backdoor_cmd
,
4527 "network A.B.C.D/M backdoor",
4528 "Specify a network to announce via BGP\n"
4529 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4530 "Specify a BGP backdoor route\n")
4532 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP
, SAFI_UNICAST
,
4536 DEFUN (bgp_network_mask
,
4537 bgp_network_mask_cmd
,
4538 "network A.B.C.D mask A.B.C.D",
4539 "Specify a network to announce via BGP\n"
4545 char prefix_str
[BUFSIZ
];
4547 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4550 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4554 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4555 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4558 DEFUN (bgp_network_mask_route_map
,
4559 bgp_network_mask_route_map_cmd
,
4560 "network A.B.C.D mask A.B.C.D route-map WORD",
4561 "Specify a network to announce via BGP\n"
4565 "Route-map to modify the attributes\n"
4566 "Name of the route map\n")
4569 char prefix_str
[BUFSIZ
];
4571 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4574 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4578 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4579 AFI_IP
, bgp_node_safi (vty
), argv
[2], 0);
4582 DEFUN (bgp_network_mask_backdoor
,
4583 bgp_network_mask_backdoor_cmd
,
4584 "network A.B.C.D mask A.B.C.D backdoor",
4585 "Specify a network to announce via BGP\n"
4589 "Specify a BGP backdoor route\n")
4592 char prefix_str
[BUFSIZ
];
4594 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4597 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4601 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4605 DEFUN (bgp_network_mask_natural
,
4606 bgp_network_mask_natural_cmd
,
4608 "Specify a network to announce via BGP\n"
4612 char prefix_str
[BUFSIZ
];
4614 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4617 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4621 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4622 AFI_IP
, bgp_node_safi (vty
), NULL
, 0);
4625 DEFUN (bgp_network_mask_natural_route_map
,
4626 bgp_network_mask_natural_route_map_cmd
,
4627 "network A.B.C.D route-map WORD",
4628 "Specify a network to announce via BGP\n"
4630 "Route-map to modify the attributes\n"
4631 "Name of the route map\n")
4634 char prefix_str
[BUFSIZ
];
4636 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4639 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4643 return bgp_static_set (vty
, vty
->index
, prefix_str
,
4644 AFI_IP
, bgp_node_safi (vty
), argv
[1], 0);
4647 DEFUN (bgp_network_mask_natural_backdoor
,
4648 bgp_network_mask_natural_backdoor_cmd
,
4649 "network A.B.C.D backdoor",
4650 "Specify a network to announce via BGP\n"
4652 "Specify a BGP backdoor route\n")
4655 char prefix_str
[BUFSIZ
];
4657 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4660 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4664 return bgp_static_set (vty
, vty
->index
, prefix_str
, AFI_IP
, SAFI_UNICAST
,
4668 DEFUN (no_bgp_network
,
4670 "no network A.B.C.D/M",
4672 "Specify a network to announce via BGP\n"
4673 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
4675 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP
,
4676 bgp_node_safi (vty
));
4679 ALIAS (no_bgp_network
,
4680 no_bgp_network_route_map_cmd
,
4681 "no network A.B.C.D/M route-map WORD",
4683 "Specify a network to announce via BGP\n"
4684 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4685 "Route-map to modify the attributes\n"
4686 "Name of the route map\n")
4688 ALIAS (no_bgp_network
,
4689 no_bgp_network_backdoor_cmd
,
4690 "no network A.B.C.D/M backdoor",
4692 "Specify a network to announce via BGP\n"
4693 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
4694 "Specify a BGP backdoor route\n")
4696 DEFUN (no_bgp_network_mask
,
4697 no_bgp_network_mask_cmd
,
4698 "no network A.B.C.D mask A.B.C.D",
4700 "Specify a network to announce via BGP\n"
4706 char prefix_str
[BUFSIZ
];
4708 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
4711 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4715 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4716 bgp_node_safi (vty
));
4719 ALIAS (no_bgp_network_mask
,
4720 no_bgp_network_mask_route_map_cmd
,
4721 "no network A.B.C.D mask A.B.C.D route-map WORD",
4723 "Specify a network to announce via BGP\n"
4727 "Route-map to modify the attributes\n"
4728 "Name of the route map\n")
4730 ALIAS (no_bgp_network_mask
,
4731 no_bgp_network_mask_backdoor_cmd
,
4732 "no network A.B.C.D mask A.B.C.D backdoor",
4734 "Specify a network to announce via BGP\n"
4738 "Specify a BGP backdoor route\n")
4740 DEFUN (no_bgp_network_mask_natural
,
4741 no_bgp_network_mask_natural_cmd
,
4742 "no network A.B.C.D",
4744 "Specify a network to announce via BGP\n"
4748 char prefix_str
[BUFSIZ
];
4750 ret
= netmask_str2prefix_str (argv
[0], NULL
, prefix_str
);
4753 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
4757 return bgp_static_unset (vty
, vty
->index
, prefix_str
, AFI_IP
,
4758 bgp_node_safi (vty
));
4761 ALIAS (no_bgp_network_mask_natural
,
4762 no_bgp_network_mask_natural_route_map_cmd
,
4763 "no network A.B.C.D route-map WORD",
4765 "Specify a network to announce via BGP\n"
4767 "Route-map to modify the attributes\n"
4768 "Name of the route map\n")
4770 ALIAS (no_bgp_network_mask_natural
,
4771 no_bgp_network_mask_natural_backdoor_cmd
,
4772 "no network A.B.C.D backdoor",
4774 "Specify a network to announce via BGP\n"
4776 "Specify a BGP backdoor route\n")
4779 DEFUN (ipv6_bgp_network
,
4780 ipv6_bgp_network_cmd
,
4781 "network X:X::X:X/M",
4782 "Specify a network to announce via BGP\n"
4783 "IPv6 prefix <network>/<length>\n")
4785 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
),
4789 DEFUN (ipv6_bgp_network_route_map
,
4790 ipv6_bgp_network_route_map_cmd
,
4791 "network X:X::X:X/M route-map WORD",
4792 "Specify a network to announce via BGP\n"
4793 "IPv6 prefix <network>/<length>\n"
4794 "Route-map to modify the attributes\n"
4795 "Name of the route map\n")
4797 return bgp_static_set (vty
, vty
->index
, argv
[0], AFI_IP6
,
4798 bgp_node_safi (vty
), argv
[1], 0);
4801 DEFUN (no_ipv6_bgp_network
,
4802 no_ipv6_bgp_network_cmd
,
4803 "no network X:X::X:X/M",
4805 "Specify a network to announce via BGP\n"
4806 "IPv6 prefix <network>/<length>\n")
4808 return bgp_static_unset (vty
, vty
->index
, argv
[0], AFI_IP6
, bgp_node_safi(vty
));
4811 ALIAS (no_ipv6_bgp_network
,
4812 no_ipv6_bgp_network_route_map_cmd
,
4813 "no network X:X::X:X/M route-map WORD",
4815 "Specify a network to announce via BGP\n"
4816 "IPv6 prefix <network>/<length>\n"
4817 "Route-map to modify the attributes\n"
4818 "Name of the route map\n")
4820 ALIAS (ipv6_bgp_network
,
4821 old_ipv6_bgp_network_cmd
,
4822 "ipv6 bgp network X:X::X:X/M",
4825 "Specify a network to announce via BGP\n"
4826 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4828 ALIAS (no_ipv6_bgp_network
,
4829 old_no_ipv6_bgp_network_cmd
,
4830 "no ipv6 bgp network X:X::X:X/M",
4834 "Specify a network to announce via BGP\n"
4835 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
4836 #endif /* HAVE_IPV6 */
4838 /* Aggreagete address:
4840 advertise-map Set condition to advertise attribute
4841 as-set Generate AS set path information
4842 attribute-map Set attributes of aggregate
4843 route-map Set parameters of aggregate
4844 summary-only Filter more specific routes from updates
4845 suppress-map Conditionally filter more specific routes from updates
4848 struct bgp_aggregate
4850 /* Summary-only flag. */
4851 u_char summary_only
;
4853 /* AS set generation. */
4856 /* Route-map for aggregated route. */
4857 struct route_map
*map
;
4859 /* Suppress-count. */
4860 unsigned long count
;
4862 /* SAFI configuration. */
4866 static struct bgp_aggregate
*
4867 bgp_aggregate_new (void)
4869 return XCALLOC (MTYPE_BGP_AGGREGATE
, sizeof (struct bgp_aggregate
));
4873 bgp_aggregate_free (struct bgp_aggregate
*aggregate
)
4875 XFREE (MTYPE_BGP_AGGREGATE
, aggregate
);
4878 /* Update an aggregate as routes are added/removed from the BGP table */
4880 bgp_aggregate_route (struct bgp
*bgp
, struct prefix
*p
, struct bgp_info
*rinew
,
4881 afi_t afi
, safi_t safi
, struct bgp_info
*del
,
4882 struct bgp_aggregate
*aggregate
)
4884 struct bgp_table
*table
;
4885 struct bgp_node
*top
;
4886 struct bgp_node
*rn
;
4888 struct aspath
*aspath
= NULL
;
4889 struct aspath
*asmerge
= NULL
;
4890 struct community
*community
= NULL
;
4891 struct community
*commerge
= NULL
;
4892 #if defined(AGGREGATE_NEXTHOP_CHECK)
4893 struct in_addr nexthop
;
4896 struct bgp_info
*ri
;
4897 struct bgp_info
*new;
4899 unsigned long match
= 0;
4900 u_char atomic_aggregate
= 0;
4902 /* Record adding route's nexthop and med. */
4905 #if defined(AGGREGATE_NEXTHOP_CHECK)
4906 nexthop
= rinew
->attr
->nexthop
;
4907 med
= rinew
->attr
->med
;
4911 /* ORIGIN attribute: If at least one route among routes that are
4912 aggregated has ORIGIN with the value INCOMPLETE, then the
4913 aggregated route must have the ORIGIN attribute with the value
4914 INCOMPLETE. Otherwise, if at least one route among routes that
4915 are aggregated has ORIGIN with the value EGP, then the aggregated
4916 route must have the origin attribute with the value EGP. In all
4917 other case the value of the ORIGIN attribute of the aggregated
4918 route is INTERNAL. */
4919 origin
= BGP_ORIGIN_IGP
;
4921 table
= bgp
->rib
[afi
][safi
];
4923 top
= bgp_node_get (table
, p
);
4924 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
4925 if (rn
->p
.prefixlen
> p
->prefixlen
)
4929 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
4931 if (BGP_INFO_HOLDDOWN (ri
))
4934 if (del
&& ri
== del
)
4937 if (! rinew
&& first
)
4939 #if defined(AGGREGATE_NEXTHOP_CHECK)
4940 nexthop
= ri
->attr
->nexthop
;
4941 med
= ri
->attr
->med
;
4946 #ifdef AGGREGATE_NEXTHOP_CHECK
4947 if (! IPV4_ADDR_SAME (&ri
->attr
->nexthop
, &nexthop
)
4948 || ri
->attr
->med
!= med
)
4951 aspath_free (aspath
);
4953 community_free (community
);
4954 bgp_unlock_node (rn
);
4955 bgp_unlock_node (top
);
4958 #endif /* AGGREGATE_NEXTHOP_CHECK */
4960 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
4961 atomic_aggregate
= 1;
4963 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
4965 if (aggregate
->summary_only
)
4967 (bgp_info_extra_get (ri
))->suppress
++;
4968 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
4974 if (origin
< ri
->attr
->origin
)
4975 origin
= ri
->attr
->origin
;
4977 if (aggregate
->as_set
)
4981 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
4982 aspath_free (aspath
);
4986 aspath
= aspath_dup (ri
->attr
->aspath
);
4988 if (ri
->attr
->community
)
4992 commerge
= community_merge (community
,
4993 ri
->attr
->community
);
4994 community
= community_uniq_sort (commerge
);
4995 community_free (commerge
);
4998 community
= community_dup (ri
->attr
->community
);
5004 bgp_process (bgp
, rn
, afi
, safi
);
5006 bgp_unlock_node (top
);
5012 if (aggregate
->summary_only
)
5013 (bgp_info_extra_get (rinew
))->suppress
++;
5015 if (origin
< rinew
->attr
->origin
)
5016 origin
= rinew
->attr
->origin
;
5018 if (aggregate
->as_set
)
5022 asmerge
= aspath_aggregate (aspath
, rinew
->attr
->aspath
);
5023 aspath_free (aspath
);
5027 aspath
= aspath_dup (rinew
->attr
->aspath
);
5029 if (rinew
->attr
->community
)
5033 commerge
= community_merge (community
,
5034 rinew
->attr
->community
);
5035 community
= community_uniq_sort (commerge
);
5036 community_free (commerge
);
5039 community
= community_dup (rinew
->attr
->community
);
5044 if (aggregate
->count
> 0)
5046 rn
= bgp_node_get (table
, p
);
5047 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5048 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5050 atomic_aggregate
), rn
);
5051 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5053 bgp_info_add (rn
, new);
5054 bgp_unlock_node (rn
);
5055 bgp_process (bgp
, rn
, afi
, safi
);
5060 aspath_free (aspath
);
5062 community_free (community
);
5066 void bgp_aggregate_delete (struct bgp
*, struct prefix
*, afi_t
, safi_t
,
5067 struct bgp_aggregate
*);
5070 bgp_aggregate_increment (struct bgp
*bgp
, struct prefix
*p
,
5071 struct bgp_info
*ri
, afi_t afi
, safi_t safi
)
5073 struct bgp_node
*child
;
5074 struct bgp_node
*rn
;
5075 struct bgp_aggregate
*aggregate
;
5076 struct bgp_table
*table
;
5078 /* MPLS-VPN aggregation is not yet supported. */
5079 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5082 table
= bgp
->aggregate
[afi
][safi
];
5084 /* No aggregates configured. */
5085 if (bgp_table_top_nolock (table
) == NULL
)
5088 if (p
->prefixlen
== 0)
5091 if (BGP_INFO_HOLDDOWN (ri
))
5094 child
= bgp_node_get (table
, p
);
5096 /* Aggregate address configuration check. */
5097 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5098 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5100 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5101 bgp_aggregate_route (bgp
, &rn
->p
, ri
, afi
, safi
, NULL
, aggregate
);
5103 bgp_unlock_node (child
);
5107 bgp_aggregate_decrement (struct bgp
*bgp
, struct prefix
*p
,
5108 struct bgp_info
*del
, afi_t afi
, safi_t safi
)
5110 struct bgp_node
*child
;
5111 struct bgp_node
*rn
;
5112 struct bgp_aggregate
*aggregate
;
5113 struct bgp_table
*table
;
5115 /* MPLS-VPN aggregation is not yet supported. */
5116 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
5119 table
= bgp
->aggregate
[afi
][safi
];
5121 /* No aggregates configured. */
5122 if (bgp_table_top_nolock (table
) == NULL
)
5125 if (p
->prefixlen
== 0)
5128 child
= bgp_node_get (table
, p
);
5130 /* Aggregate address configuration check. */
5131 for (rn
= child
; rn
; rn
= bgp_node_parent_nolock (rn
))
5132 if ((aggregate
= rn
->info
) != NULL
&& rn
->p
.prefixlen
< p
->prefixlen
)
5134 bgp_aggregate_delete (bgp
, &rn
->p
, afi
, safi
, aggregate
);
5135 bgp_aggregate_route (bgp
, &rn
->p
, NULL
, afi
, safi
, del
, aggregate
);
5137 bgp_unlock_node (child
);
5140 /* Called via bgp_aggregate_set when the user configures aggregate-address */
5142 bgp_aggregate_add (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
, safi_t safi
,
5143 struct bgp_aggregate
*aggregate
)
5145 struct bgp_table
*table
;
5146 struct bgp_node
*top
;
5147 struct bgp_node
*rn
;
5148 struct bgp_info
*new;
5149 struct bgp_info
*ri
;
5150 unsigned long match
;
5151 u_char origin
= BGP_ORIGIN_IGP
;
5152 struct aspath
*aspath
= NULL
;
5153 struct aspath
*asmerge
= NULL
;
5154 struct community
*community
= NULL
;
5155 struct community
*commerge
= NULL
;
5156 u_char atomic_aggregate
= 0;
5158 table
= bgp
->rib
[afi
][safi
];
5161 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5163 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5166 /* If routes exists below this node, generate aggregate routes. */
5167 top
= bgp_node_get (table
, p
);
5168 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5169 if (rn
->p
.prefixlen
> p
->prefixlen
)
5173 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5175 if (BGP_INFO_HOLDDOWN (ri
))
5178 if (ri
->attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
5179 atomic_aggregate
= 1;
5181 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5183 /* summary-only aggregate route suppress aggregated
5184 route announcement. */
5185 if (aggregate
->summary_only
)
5187 (bgp_info_extra_get (ri
))->suppress
++;
5188 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5192 /* If at least one route among routes that are aggregated has
5193 * ORIGIN with the value INCOMPLETE, then the aggregated route
5194 * MUST have the ORIGIN attribute with the value INCOMPLETE.
5195 * Otherwise, if at least one route among routes that are
5196 * aggregated has ORIGIN with the value EGP, then the aggregated
5197 * route MUST have the ORIGIN attribute with the value EGP.
5199 if (origin
< ri
->attr
->origin
)
5200 origin
= ri
->attr
->origin
;
5202 /* as-set aggregate route generate origin, as path,
5203 community aggregation. */
5204 if (aggregate
->as_set
)
5208 asmerge
= aspath_aggregate (aspath
, ri
->attr
->aspath
);
5209 aspath_free (aspath
);
5213 aspath
= aspath_dup (ri
->attr
->aspath
);
5215 if (ri
->attr
->community
)
5219 commerge
= community_merge (community
,
5220 ri
->attr
->community
);
5221 community
= community_uniq_sort (commerge
);
5222 community_free (commerge
);
5225 community
= community_dup (ri
->attr
->community
);
5232 /* If this node is suppressed, process the change. */
5234 bgp_process (bgp
, rn
, afi
, safi
);
5236 bgp_unlock_node (top
);
5238 /* Add aggregate route to BGP table. */
5239 if (aggregate
->count
)
5241 rn
= bgp_node_get (table
, p
);
5242 new = info_make(ZEBRA_ROUTE_BGP
, BGP_ROUTE_AGGREGATE
, 0, bgp
->peer_self
,
5243 bgp_attr_aggregate_intern(bgp
, origin
, aspath
, community
,
5245 atomic_aggregate
), rn
);
5246 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5248 bgp_info_add (rn
, new);
5249 bgp_unlock_node (rn
);
5251 /* Process change. */
5252 bgp_process (bgp
, rn
, afi
, safi
);
5257 aspath_free (aspath
);
5259 community_free (community
);
5264 bgp_aggregate_delete (struct bgp
*bgp
, struct prefix
*p
, afi_t afi
,
5265 safi_t safi
, struct bgp_aggregate
*aggregate
)
5267 struct bgp_table
*table
;
5268 struct bgp_node
*top
;
5269 struct bgp_node
*rn
;
5270 struct bgp_info
*ri
;
5271 unsigned long match
;
5273 table
= bgp
->rib
[afi
][safi
];
5275 if (afi
== AFI_IP
&& p
->prefixlen
== IPV4_MAX_BITLEN
)
5277 if (afi
== AFI_IP6
&& p
->prefixlen
== IPV6_MAX_BITLEN
)
5280 /* If routes exists below this node, generate aggregate routes. */
5281 top
= bgp_node_get (table
, p
);
5282 for (rn
= bgp_node_get (table
, p
); rn
; rn
= bgp_route_next_until (rn
, top
))
5283 if (rn
->p
.prefixlen
> p
->prefixlen
)
5287 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5289 if (BGP_INFO_HOLDDOWN (ri
))
5292 if (ri
->sub_type
!= BGP_ROUTE_AGGREGATE
)
5294 if (aggregate
->summary_only
&& ri
->extra
)
5296 ri
->extra
->suppress
--;
5298 if (ri
->extra
->suppress
== 0)
5300 bgp_info_set_flag (rn
, ri
, BGP_INFO_ATTR_CHANGED
);
5308 /* If this node was suppressed, process the change. */
5310 bgp_process (bgp
, rn
, afi
, safi
);
5312 bgp_unlock_node (top
);
5314 /* Delete aggregate route from BGP table. */
5315 rn
= bgp_node_get (table
, p
);
5317 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5318 if (ri
->peer
== bgp
->peer_self
5319 && ri
->type
== ZEBRA_ROUTE_BGP
5320 && ri
->sub_type
== BGP_ROUTE_AGGREGATE
)
5323 /* Withdraw static BGP route from routing table. */
5326 bgp_info_delete (rn
, ri
);
5327 bgp_process (bgp
, rn
, afi
, safi
);
5330 /* Unlock bgp_node_lookup. */
5331 bgp_unlock_node (rn
);
5334 /* Aggregate route attribute. */
5335 #define AGGREGATE_SUMMARY_ONLY 1
5336 #define AGGREGATE_AS_SET 1
5339 bgp_aggregate_unset (struct vty
*vty
, const char *prefix_str
,
5340 afi_t afi
, safi_t safi
)
5344 struct bgp_node
*rn
;
5346 struct bgp_aggregate
*aggregate
;
5348 /* Convert string to prefix structure. */
5349 ret
= str2prefix (prefix_str
, &p
);
5352 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5357 /* Get BGP structure. */
5360 /* Old configuration check. */
5361 rn
= bgp_node_lookup (bgp
->aggregate
[afi
][safi
], &p
);
5364 vty_out (vty
, "%% There is no aggregate-address configuration.%s",
5369 aggregate
= rn
->info
;
5370 if (aggregate
->safi
& SAFI_UNICAST
)
5371 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5372 if (aggregate
->safi
& SAFI_MULTICAST
)
5373 bgp_aggregate_delete (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5375 /* Unlock aggregate address configuration. */
5377 bgp_aggregate_free (aggregate
);
5378 bgp_unlock_node (rn
);
5379 bgp_unlock_node (rn
);
5385 bgp_aggregate_set (struct vty
*vty
, const char *prefix_str
,
5386 afi_t afi
, safi_t safi
,
5387 u_char summary_only
, u_char as_set
)
5391 struct bgp_node
*rn
;
5393 struct bgp_aggregate
*aggregate
;
5395 /* Convert string to prefix structure. */
5396 ret
= str2prefix (prefix_str
, &p
);
5399 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
5404 /* Get BGP structure. */
5407 /* Old configuration check. */
5408 rn
= bgp_node_get (bgp
->aggregate
[afi
][safi
], &p
);
5412 vty_out (vty
, "There is already same aggregate network.%s", VTY_NEWLINE
);
5413 /* try to remove the old entry */
5414 ret
= bgp_aggregate_unset (vty
, prefix_str
, afi
, safi
);
5417 vty_out (vty
, "Error deleting aggregate.%s", VTY_NEWLINE
);
5418 bgp_unlock_node (rn
);
5423 /* Make aggregate address structure. */
5424 aggregate
= bgp_aggregate_new ();
5425 aggregate
->summary_only
= summary_only
;
5426 aggregate
->as_set
= as_set
;
5427 aggregate
->safi
= safi
;
5428 rn
->info
= aggregate
;
5430 /* Aggregate address insert into BGP routing table. */
5431 if (safi
& SAFI_UNICAST
)
5432 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_UNICAST
, aggregate
);
5433 if (safi
& SAFI_MULTICAST
)
5434 bgp_aggregate_add (bgp
, &p
, afi
, SAFI_MULTICAST
, aggregate
);
5439 DEFUN (aggregate_address
,
5440 aggregate_address_cmd
,
5441 "aggregate-address A.B.C.D/M",
5442 "Configure BGP aggregate entries\n"
5443 "Aggregate prefix\n")
5445 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
), 0, 0);
5448 DEFUN (aggregate_address_mask
,
5449 aggregate_address_mask_cmd
,
5450 "aggregate-address A.B.C.D A.B.C.D",
5451 "Configure BGP aggregate entries\n"
5452 "Aggregate address\n"
5456 char prefix_str
[BUFSIZ
];
5458 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5462 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5466 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5470 DEFUN (aggregate_address_summary_only
,
5471 aggregate_address_summary_only_cmd
,
5472 "aggregate-address A.B.C.D/M summary-only",
5473 "Configure BGP aggregate entries\n"
5474 "Aggregate prefix\n"
5475 "Filter more specific routes from updates\n")
5477 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5478 AGGREGATE_SUMMARY_ONLY
, 0);
5481 DEFUN (aggregate_address_mask_summary_only
,
5482 aggregate_address_mask_summary_only_cmd
,
5483 "aggregate-address A.B.C.D A.B.C.D summary-only",
5484 "Configure BGP aggregate entries\n"
5485 "Aggregate address\n"
5487 "Filter more specific routes from updates\n")
5490 char prefix_str
[BUFSIZ
];
5492 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5496 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5500 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5501 AGGREGATE_SUMMARY_ONLY
, 0);
5504 DEFUN (aggregate_address_as_set
,
5505 aggregate_address_as_set_cmd
,
5506 "aggregate-address A.B.C.D/M as-set",
5507 "Configure BGP aggregate entries\n"
5508 "Aggregate prefix\n"
5509 "Generate AS set path information\n")
5511 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5512 0, AGGREGATE_AS_SET
);
5515 DEFUN (aggregate_address_mask_as_set
,
5516 aggregate_address_mask_as_set_cmd
,
5517 "aggregate-address A.B.C.D A.B.C.D as-set",
5518 "Configure BGP aggregate entries\n"
5519 "Aggregate address\n"
5521 "Generate AS set path information\n")
5524 char prefix_str
[BUFSIZ
];
5526 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5530 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5534 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5535 0, AGGREGATE_AS_SET
);
5539 DEFUN (aggregate_address_as_set_summary
,
5540 aggregate_address_as_set_summary_cmd
,
5541 "aggregate-address A.B.C.D/M as-set summary-only",
5542 "Configure BGP aggregate entries\n"
5543 "Aggregate prefix\n"
5544 "Generate AS set path information\n"
5545 "Filter more specific routes from updates\n")
5547 return bgp_aggregate_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5548 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5551 ALIAS (aggregate_address_as_set_summary
,
5552 aggregate_address_summary_as_set_cmd
,
5553 "aggregate-address A.B.C.D/M summary-only as-set",
5554 "Configure BGP aggregate entries\n"
5555 "Aggregate prefix\n"
5556 "Filter more specific routes from updates\n"
5557 "Generate AS set path information\n")
5559 DEFUN (aggregate_address_mask_as_set_summary
,
5560 aggregate_address_mask_as_set_summary_cmd
,
5561 "aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5562 "Configure BGP aggregate entries\n"
5563 "Aggregate address\n"
5565 "Generate AS set path information\n"
5566 "Filter more specific routes from updates\n")
5569 char prefix_str
[BUFSIZ
];
5571 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5575 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5579 return bgp_aggregate_set (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
),
5580 AGGREGATE_SUMMARY_ONLY
, AGGREGATE_AS_SET
);
5583 ALIAS (aggregate_address_mask_as_set_summary
,
5584 aggregate_address_mask_summary_as_set_cmd
,
5585 "aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5586 "Configure BGP aggregate entries\n"
5587 "Aggregate address\n"
5589 "Filter more specific routes from updates\n"
5590 "Generate AS set path information\n")
5592 DEFUN (no_aggregate_address
,
5593 no_aggregate_address_cmd
,
5594 "no aggregate-address A.B.C.D/M",
5596 "Configure BGP aggregate entries\n"
5597 "Aggregate prefix\n")
5599 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
));
5602 ALIAS (no_aggregate_address
,
5603 no_aggregate_address_summary_only_cmd
,
5604 "no aggregate-address A.B.C.D/M summary-only",
5606 "Configure BGP aggregate entries\n"
5607 "Aggregate prefix\n"
5608 "Filter more specific routes from updates\n")
5610 ALIAS (no_aggregate_address
,
5611 no_aggregate_address_as_set_cmd
,
5612 "no aggregate-address A.B.C.D/M as-set",
5614 "Configure BGP aggregate entries\n"
5615 "Aggregate prefix\n"
5616 "Generate AS set path information\n")
5618 ALIAS (no_aggregate_address
,
5619 no_aggregate_address_as_set_summary_cmd
,
5620 "no aggregate-address A.B.C.D/M as-set summary-only",
5622 "Configure BGP aggregate entries\n"
5623 "Aggregate prefix\n"
5624 "Generate AS set path information\n"
5625 "Filter more specific routes from updates\n")
5627 ALIAS (no_aggregate_address
,
5628 no_aggregate_address_summary_as_set_cmd
,
5629 "no aggregate-address A.B.C.D/M summary-only as-set",
5631 "Configure BGP aggregate entries\n"
5632 "Aggregate prefix\n"
5633 "Filter more specific routes from updates\n"
5634 "Generate AS set path information\n")
5636 DEFUN (no_aggregate_address_mask
,
5637 no_aggregate_address_mask_cmd
,
5638 "no aggregate-address A.B.C.D A.B.C.D",
5640 "Configure BGP aggregate entries\n"
5641 "Aggregate address\n"
5645 char prefix_str
[BUFSIZ
];
5647 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
5651 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
5655 return bgp_aggregate_unset (vty
, prefix_str
, AFI_IP
, bgp_node_safi (vty
));
5658 ALIAS (no_aggregate_address_mask
,
5659 no_aggregate_address_mask_summary_only_cmd
,
5660 "no aggregate-address A.B.C.D A.B.C.D summary-only",
5662 "Configure BGP aggregate entries\n"
5663 "Aggregate address\n"
5665 "Filter more specific routes from updates\n")
5667 ALIAS (no_aggregate_address_mask
,
5668 no_aggregate_address_mask_as_set_cmd
,
5669 "no aggregate-address A.B.C.D A.B.C.D as-set",
5671 "Configure BGP aggregate entries\n"
5672 "Aggregate address\n"
5674 "Generate AS set path information\n")
5676 ALIAS (no_aggregate_address_mask
,
5677 no_aggregate_address_mask_as_set_summary_cmd
,
5678 "no aggregate-address A.B.C.D A.B.C.D as-set summary-only",
5680 "Configure BGP aggregate entries\n"
5681 "Aggregate address\n"
5683 "Generate AS set path information\n"
5684 "Filter more specific routes from updates\n")
5686 ALIAS (no_aggregate_address_mask
,
5687 no_aggregate_address_mask_summary_as_set_cmd
,
5688 "no aggregate-address A.B.C.D A.B.C.D summary-only as-set",
5690 "Configure BGP aggregate entries\n"
5691 "Aggregate address\n"
5693 "Filter more specific routes from updates\n"
5694 "Generate AS set path information\n")
5697 DEFUN (ipv6_aggregate_address
,
5698 ipv6_aggregate_address_cmd
,
5699 "aggregate-address X:X::X:X/M",
5700 "Configure BGP aggregate entries\n"
5701 "Aggregate prefix\n")
5703 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, 0, 0);
5706 DEFUN (ipv6_aggregate_address_summary_only
,
5707 ipv6_aggregate_address_summary_only_cmd
,
5708 "aggregate-address X:X::X:X/M summary-only",
5709 "Configure BGP aggregate entries\n"
5710 "Aggregate prefix\n"
5711 "Filter more specific routes from updates\n")
5713 return bgp_aggregate_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5714 AGGREGATE_SUMMARY_ONLY
, 0);
5717 DEFUN (no_ipv6_aggregate_address
,
5718 no_ipv6_aggregate_address_cmd
,
5719 "no aggregate-address X:X::X:X/M",
5721 "Configure BGP aggregate entries\n"
5722 "Aggregate prefix\n")
5724 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5727 DEFUN (no_ipv6_aggregate_address_summary_only
,
5728 no_ipv6_aggregate_address_summary_only_cmd
,
5729 "no aggregate-address X:X::X:X/M summary-only",
5731 "Configure BGP aggregate entries\n"
5732 "Aggregate prefix\n"
5733 "Filter more specific routes from updates\n")
5735 return bgp_aggregate_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
);
5738 ALIAS (ipv6_aggregate_address
,
5739 old_ipv6_aggregate_address_cmd
,
5740 "ipv6 bgp aggregate-address X:X::X:X/M",
5743 "Configure BGP aggregate entries\n"
5744 "Aggregate prefix\n")
5746 ALIAS (ipv6_aggregate_address_summary_only
,
5747 old_ipv6_aggregate_address_summary_only_cmd
,
5748 "ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5751 "Configure BGP aggregate entries\n"
5752 "Aggregate prefix\n"
5753 "Filter more specific routes from updates\n")
5755 ALIAS (no_ipv6_aggregate_address
,
5756 old_no_ipv6_aggregate_address_cmd
,
5757 "no ipv6 bgp aggregate-address X:X::X:X/M",
5761 "Configure BGP aggregate entries\n"
5762 "Aggregate prefix\n")
5764 ALIAS (no_ipv6_aggregate_address_summary_only
,
5765 old_no_ipv6_aggregate_address_summary_only_cmd
,
5766 "no ipv6 bgp aggregate-address X:X::X:X/M summary-only",
5770 "Configure BGP aggregate entries\n"
5771 "Aggregate prefix\n"
5772 "Filter more specific routes from updates\n")
5773 #endif /* HAVE_IPV6 */
5775 /* Redistribute route treatment. */
5777 bgp_redistribute_add (struct bgp
*bgp
, struct prefix
*p
, const struct in_addr
*nexthop
,
5778 const struct in6_addr
*nexthop6
, unsigned int ifindex
,
5779 u_int32_t metric
, u_char type
, u_short instance
, route_tag_t tag
)
5781 struct bgp_info
*new;
5782 struct bgp_info
*bi
;
5783 struct bgp_info info
;
5784 struct bgp_node
*bn
;
5786 struct attr
*new_attr
;
5789 struct bgp_redist
*red
;
5791 /* Make default attribute. */
5792 bgp_attr_default_set (&attr
, BGP_ORIGIN_INCOMPLETE
);
5794 attr
.nexthop
= *nexthop
;
5795 attr
.nh_ifindex
= ifindex
;
5800 struct attr_extra
*extra
= bgp_attr_extra_get(&attr
);
5801 extra
->mp_nexthop_global
= *nexthop6
;
5802 extra
->mp_nexthop_len
= BGP_ATTR_NHLEN_IPV6_GLOBAL
;
5807 attr
.flag
|= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
);
5808 attr
.extra
->tag
= tag
;
5810 afi
= family2afi (p
->family
);
5812 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5815 struct attr attr_new
;
5816 struct attr_extra extra_new
;
5818 /* Copy attribute for modification. */
5819 attr_new
.extra
= &extra_new
;
5820 bgp_attr_dup (&attr_new
, &attr
);
5822 if (red
->redist_metric_flag
)
5823 attr_new
.med
= red
->redist_metric
;
5825 /* Apply route-map. */
5828 info
.peer
= bgp
->peer_self
;
5829 info
.attr
= &attr_new
;
5831 SET_FLAG (bgp
->peer_self
->rmap_type
, PEER_RMAP_TYPE_REDISTRIBUTE
);
5833 ret
= route_map_apply (red
->rmap
.map
, p
, RMAP_BGP
, &info
);
5835 bgp
->peer_self
->rmap_type
= 0;
5837 if (ret
== RMAP_DENYMATCH
)
5839 /* Free uninterned attribute. */
5840 bgp_attr_flush (&attr_new
);
5842 /* Unintern original. */
5843 aspath_unintern (&attr
.aspath
);
5844 bgp_attr_extra_free (&attr
);
5845 bgp_redistribute_delete (bgp
, p
, type
, instance
);
5850 bn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
],
5851 afi
, SAFI_UNICAST
, p
, NULL
);
5853 new_attr
= bgp_attr_intern (&attr_new
);
5855 for (bi
= bn
->info
; bi
; bi
= bi
->next
)
5856 if (bi
->peer
== bgp
->peer_self
5857 && bi
->sub_type
== BGP_ROUTE_REDISTRIBUTE
)
5862 /* Ensure the (source route) type is updated. */
5864 if (attrhash_cmp (bi
->attr
, new_attr
) &&
5865 !CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5867 bgp_attr_unintern (&new_attr
);
5868 aspath_unintern (&attr
.aspath
);
5869 bgp_attr_extra_free (&attr
);
5870 bgp_unlock_node (bn
);
5875 /* The attribute is changed. */
5876 bgp_info_set_flag (bn
, bi
, BGP_INFO_ATTR_CHANGED
);
5878 /* Rewrite BGP route information. */
5879 if (CHECK_FLAG(bi
->flags
, BGP_INFO_REMOVED
))
5880 bgp_info_restore(bn
, bi
);
5882 bgp_aggregate_decrement (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5883 bgp_attr_unintern (&bi
->attr
);
5884 bi
->attr
= new_attr
;
5885 bi
->uptime
= bgp_clock ();
5887 /* Process change. */
5888 bgp_aggregate_increment (bgp
, p
, bi
, afi
, SAFI_UNICAST
);
5889 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5890 bgp_unlock_node (bn
);
5891 aspath_unintern (&attr
.aspath
);
5892 bgp_attr_extra_free (&attr
);
5897 new = info_make(type
, BGP_ROUTE_REDISTRIBUTE
, instance
, bgp
->peer_self
,
5899 SET_FLAG (new->flags
, BGP_INFO_VALID
);
5901 bgp_aggregate_increment (bgp
, p
, new, afi
, SAFI_UNICAST
);
5902 bgp_info_add (bn
, new);
5903 bgp_unlock_node (bn
);
5904 bgp_process (bgp
, bn
, afi
, SAFI_UNICAST
);
5907 /* Unintern original. */
5908 aspath_unintern (&attr
.aspath
);
5909 bgp_attr_extra_free (&attr
);
5913 bgp_redistribute_delete (struct bgp
*bgp
, struct prefix
*p
, u_char type
, u_short instance
)
5916 struct bgp_node
*rn
;
5917 struct bgp_info
*ri
;
5918 struct bgp_redist
*red
;
5920 afi
= family2afi (p
->family
);
5922 red
= bgp_redist_lookup(bgp
, afi
, type
, instance
);
5925 rn
= bgp_afi_node_get (bgp
->rib
[afi
][SAFI_UNICAST
], afi
, SAFI_UNICAST
, p
, NULL
);
5927 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5928 if (ri
->peer
== bgp
->peer_self
5929 && ri
->type
== type
)
5934 bgp_aggregate_decrement (bgp
, p
, ri
, afi
, SAFI_UNICAST
);
5935 bgp_info_delete (rn
, ri
);
5936 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5938 bgp_unlock_node (rn
);
5942 /* Withdraw specified route type's route. */
5944 bgp_redistribute_withdraw (struct bgp
*bgp
, afi_t afi
, int type
, u_short instance
)
5946 struct bgp_node
*rn
;
5947 struct bgp_info
*ri
;
5948 struct bgp_table
*table
;
5950 table
= bgp
->rib
[afi
][SAFI_UNICAST
];
5952 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
5954 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
5955 if (ri
->peer
== bgp
->peer_self
5957 && ri
->instance
== instance
)
5962 bgp_aggregate_decrement (bgp
, &rn
->p
, ri
, afi
, SAFI_UNICAST
);
5963 bgp_info_delete (rn
, ri
);
5964 bgp_process (bgp
, rn
, afi
, SAFI_UNICAST
);
5969 /* Static function to display route. */
5971 route_vty_out_route (struct prefix
*p
, struct vty
*vty
)
5974 u_int32_t destination
;
5977 if (p
->family
== AF_INET
)
5979 len
= vty_out (vty
, "%s", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
));
5980 destination
= ntohl (p
->u
.prefix4
.s_addr
);
5982 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
5983 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
5984 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
5985 || p
->u
.prefix4
.s_addr
== 0)
5987 /* When mask is natural, mask is not displayed. */
5990 len
+= vty_out (vty
, "/%d", p
->prefixlen
);
5993 len
= vty_out (vty
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
5998 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 20, " ");
6000 vty_out (vty
, "%*s", len
, " ");
6003 enum bgp_display_type
6008 /* Print the short form route status for a bgp_info */
6010 route_vty_short_status_out (struct vty
*vty
, struct bgp_info
*binfo
,
6011 json_object
*json_path
)
6016 /* Route status display. */
6017 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6018 json_object_boolean_true_add(json_path
, "removed");
6020 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6021 json_object_boolean_true_add(json_path
, "stale");
6023 if (binfo
->extra
&& binfo
->extra
->suppress
)
6024 json_object_boolean_true_add(json_path
, "suppressed");
6026 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6027 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6028 json_object_boolean_true_add(json_path
, "valid");
6031 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6032 json_object_boolean_true_add(json_path
, "history");
6034 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6035 json_object_boolean_true_add(json_path
, "damped");
6037 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6038 json_object_boolean_true_add(json_path
, "bestpath");
6040 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6041 json_object_boolean_true_add(json_path
, "multipath");
6043 /* Internal route. */
6044 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6045 json_object_string_add(json_path
, "pathFrom", "internal");
6047 json_object_string_add(json_path
, "pathFrom", "external");
6052 /* Route status display. */
6053 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6055 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6057 else if (binfo
->extra
&& binfo
->extra
->suppress
)
6059 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
) &&
6060 ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6066 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6068 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6070 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
6072 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
))
6077 /* Internal route. */
6078 if ((binfo
->peer
->as
) && (binfo
->peer
->as
== binfo
->peer
->local_as
))
6084 /* called from terminal list command */
6086 route_vty_out (struct vty
*vty
, struct prefix
*p
,
6087 struct bgp_info
*binfo
, int display
, safi_t safi
,
6088 json_object
*json_paths
)
6091 json_object
*json_path
= NULL
;
6092 json_object
*json_nexthops
= NULL
;
6093 json_object
*json_nexthop_global
= NULL
;
6094 json_object
*json_nexthop_ll
= NULL
;
6097 json_path
= json_object_new_object();
6099 /* short status lead text */
6100 route_vty_short_status_out (vty
, binfo
, json_path
);
6104 /* print prefix and mask */
6106 route_vty_out_route (p
, vty
);
6108 vty_out (vty
, "%*s", 17, " ");
6111 /* Print attribute */
6116 * For ENCAP routes, nexthop address family is not
6117 * neccessarily the same as the prefix address family.
6118 * Both SAFI_MPLS_VPN and SAFI_ENCAP use the MP nexthop field
6120 if ((safi
== SAFI_ENCAP
) || (safi
== SAFI_MPLS_VPN
))
6125 int af
= NEXTHOP_FAMILY(attr
->extra
->mp_nexthop_len
);
6130 vty_out (vty
, "%s", inet_ntop(af
,
6131 &attr
->extra
->mp_nexthop_global_in
, buf
, BUFSIZ
));
6135 vty_out (vty
, "%s", inet_ntop(af
,
6136 &attr
->extra
->mp_nexthop_global
, buf
, BUFSIZ
));
6148 else if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6152 json_nexthop_global
= json_object_new_object();
6154 if (safi
== SAFI_MPLS_VPN
)
6155 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6157 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6159 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6160 json_object_boolean_true_add(json_nexthop_global
, "used");
6164 if (safi
== SAFI_MPLS_VPN
)
6165 vty_out (vty
, "%-16s",
6166 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6168 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6173 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6180 json_nexthop_global
= json_object_new_object();
6181 json_object_string_add(json_nexthop_global
, "ip",
6182 inet_ntop (AF_INET6
,
6183 &attr
->extra
->mp_nexthop_global
,
6185 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6186 json_object_string_add(json_nexthop_global
, "scope", "global");
6188 /* We display both LL & GL if both have been received */
6189 if ((attr
->extra
->mp_nexthop_len
== 32) || (binfo
->peer
->conf_if
))
6191 json_nexthop_ll
= json_object_new_object();
6192 json_object_string_add(json_nexthop_ll
, "ip",
6193 inet_ntop (AF_INET6
,
6194 &attr
->extra
->mp_nexthop_local
,
6196 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
6197 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
6199 if ((IPV6_ADDR_CMP (&attr
->extra
->mp_nexthop_global
,
6200 &attr
->extra
->mp_nexthop_local
) != 0) &&
6201 !attr
->extra
->mp_nexthop_prefer_global
)
6202 json_object_boolean_true_add(json_nexthop_ll
, "used");
6204 json_object_boolean_true_add(json_nexthop_global
, "used");
6207 json_object_boolean_true_add(json_nexthop_global
, "used");
6211 /* Display LL if LL/Global both in table unless prefer-global is set */
6212 if (((attr
->extra
->mp_nexthop_len
== 32) &&
6213 !attr
->extra
->mp_nexthop_prefer_global
) ||
6214 (binfo
->peer
->conf_if
))
6216 if (binfo
->peer
->conf_if
)
6218 len
= vty_out (vty
, "%s",
6219 binfo
->peer
->conf_if
);
6220 len
= 7 - len
; /* len of IPv6 addr + max len of def ifname */
6223 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 45, " ");
6225 vty_out (vty
, "%*s", len
, " ");
6229 len
= vty_out (vty
, "%s",
6230 inet_ntop (AF_INET6
,
6231 &attr
->extra
->mp_nexthop_local
,
6236 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6238 vty_out (vty
, "%*s", len
, " ");
6243 len
= vty_out (vty
, "%s",
6244 inet_ntop (AF_INET6
,
6245 &attr
->extra
->mp_nexthop_global
,
6250 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6252 vty_out (vty
, "%*s", len
, " ");
6258 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6260 json_object_int_add(json_path
, "med", attr
->med
);
6262 vty_out (vty
, "%10u", attr
->med
);
6268 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6270 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
6272 vty_out (vty
, "%7u", attr
->local_pref
);
6280 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
6282 json_object_int_add(json_path
, "weight", 0);
6285 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6289 json_object_string_add(json_path
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
6296 json_object_string_add(json_path
, "aspath", attr
->aspath
->str
);
6298 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6303 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
6305 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6310 json_object_string_add(json_path
, "alert", "No attributes");
6312 vty_out (vty
, "No attributes to print%s", VTY_NEWLINE
);
6317 if (json_nexthop_global
|| json_nexthop_ll
)
6319 json_nexthops
= json_object_new_array();
6321 if (json_nexthop_global
)
6322 json_object_array_add(json_nexthops
, json_nexthop_global
);
6324 if (json_nexthop_ll
)
6325 json_object_array_add(json_nexthops
, json_nexthop_ll
);
6327 json_object_object_add(json_path
, "nexthops", json_nexthops
);
6330 json_object_array_add(json_paths
, json_path
);
6334 vty_out (vty
, "%s", VTY_NEWLINE
);
6336 /* prints an additional line, indented, with VNC info, if present */
6337 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
6338 rfapi_vty_out_vncinfo(vty
, p
, binfo
, safi
);
6343 /* called from terminal list command */
6345 route_vty_out_tmp (struct vty
*vty
, struct prefix
*p
, struct attr
*attr
, safi_t safi
,
6346 u_char use_json
, json_object
*json_ar
)
6348 json_object
*json_status
= NULL
;
6349 json_object
*json_net
= NULL
;
6351 /* Route status display. */
6354 json_status
= json_object_new_object();
6355 json_net
= json_object_new_object();
6364 /* print prefix and mask */
6366 json_object_string_add(json_net
, "addrPrefix", inet_ntop (p
->family
, &p
->u
.prefix
, buff
, BUFSIZ
));
6368 route_vty_out_route (p
, vty
);
6370 /* Print attribute */
6375 if (p
->family
== AF_INET
&&
6376 (safi
== SAFI_MPLS_VPN
||
6377 safi
== SAFI_ENCAP
||
6378 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6380 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6381 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6383 json_object_string_add(json_net
, "nextHop", inet_ntoa (attr
->nexthop
));
6386 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6390 json_object_string_add(json_net
, "netHopGloabal", inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6393 #endif /* HAVE_IPV6 */
6395 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6396 json_object_int_add(json_net
, "metric", attr
->med
);
6398 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6399 json_object_int_add(json_net
, "localPref", attr
->local_pref
);
6402 json_object_int_add(json_net
, "weight", attr
->extra
->weight
);
6404 json_object_int_add(json_net
, "weight", 0);
6408 json_object_string_add(json_net
, "asPath", attr
->aspath
->str
);
6411 json_object_string_add(json_net
, "bgpOriginCode", bgp_origin_str
[attr
->origin
]);
6415 if (p
->family
== AF_INET
&&
6416 (safi
== SAFI_MPLS_VPN
||
6417 safi
== SAFI_ENCAP
||
6418 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6421 (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
))
6422 vty_out (vty
, "%-16s",
6423 inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6425 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6428 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6434 len
= vty_out (vty
, "%s",
6435 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6442 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 36, " ");
6444 vty_out (vty
, "%*s", len
, " ");
6446 #endif /* HAVE_IPV6 */
6447 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC
))
6448 vty_out (vty
, "%10u", attr
->med
);
6452 if (attr
->flag
& ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF
))
6453 vty_out (vty
, "%7u", attr
->local_pref
);
6457 vty_out (vty
, "%7u ", (attr
->extra
? attr
->extra
->weight
: 0));
6461 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6464 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6469 json_object_boolean_true_add(json_status
, "*");
6470 json_object_boolean_true_add(json_status
, ">");
6471 json_object_object_add(json_net
, "appliedStatusSymbols", json_status
);
6472 char buf_cut
[BUFSIZ
];
6473 json_object_object_add(json_ar
, inet_ntop (p
->family
, &p
->u
.prefix
, buf_cut
, BUFSIZ
), json_net
);
6476 vty_out (vty
, "%s", VTY_NEWLINE
);
6480 route_vty_out_tag (struct vty
*vty
, struct prefix
*p
,
6481 struct bgp_info
*binfo
, int display
, safi_t safi
, json_object
*json
)
6483 json_object
*json_out
= NULL
;
6485 u_int32_t label
= 0;
6491 json_out
= json_object_new_object();
6493 /* short status lead text */
6494 route_vty_short_status_out (vty
, binfo
, json_out
);
6496 /* print prefix and mask */
6500 route_vty_out_route (p
, vty
);
6502 vty_out (vty
, "%*s", 17, " ");
6505 /* Print attribute */
6509 if (p
->family
== AF_INET
6510 && (safi
== SAFI_MPLS_VPN
|| !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6512 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6515 json_object_string_add(json_out
, "mpNexthopGlobalIn", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6517 vty_out (vty
, "%-16s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6522 json_object_string_add(json_out
, "nexthop", inet_ntoa (attr
->nexthop
));
6524 vty_out (vty
, "%-16s", inet_ntoa (attr
->nexthop
));
6528 else if (p
->family
== AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
6530 assert (attr
->extra
);
6534 if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL
)
6537 json_object_string_add(json_out
, "mpNexthopGlobalIn",
6538 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
, buf_a
, BUFSIZ
));
6541 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6544 else if (attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
6548 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6550 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6552 sprintf(buf_c
, "%s(%s)", buf_a
, buf_b
);
6553 json_object_string_add(json_out
, "mpNexthopGlobalLocal", buf_c
);
6556 vty_out (vty
, "%s(%s)",
6557 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6559 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
6564 #endif /* HAVE_IPV6 */
6567 label
= decode_label (binfo
->extra
->tag
);
6572 json_object_int_add(json_out
, "notag", label
);
6573 json_object_array_add(json
, json_out
);
6577 vty_out (vty
, "notag/%d", label
);
6578 vty_out (vty
, "%s", VTY_NEWLINE
);
6582 /* dampening route */
6584 damp_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6585 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6589 char timebuf
[BGP_UPTIME_LEN
];
6591 /* short status lead text */
6592 route_vty_short_status_out (vty
, binfo
, json
);
6594 /* print prefix and mask */
6598 route_vty_out_route (p
, vty
);
6600 vty_out (vty
, "%*s", 17, " ");
6603 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6608 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 34, " ");
6613 json_object_int_add(json
, "peerHost", len
);
6615 vty_out (vty
, "%*s", len
, " ");
6619 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6621 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6623 /* Print attribute */
6631 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6633 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6638 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6640 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6643 vty_out (vty
, "%s", VTY_NEWLINE
);
6648 flap_route_vty_out (struct vty
*vty
, struct prefix
*p
, struct bgp_info
*binfo
,
6649 int display
, safi_t safi
, u_char use_json
, json_object
*json
)
6652 struct bgp_damp_info
*bdi
;
6653 char timebuf
[BGP_UPTIME_LEN
];
6659 bdi
= binfo
->extra
->damp_info
;
6661 /* short status lead text */
6662 route_vty_short_status_out (vty
, binfo
, json
);
6664 /* print prefix and mask */
6668 route_vty_out_route (p
, vty
);
6670 vty_out (vty
, "%*s", 17, " ");
6673 len
= vty_out (vty
, "%s", binfo
->peer
->host
);
6678 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 33, " ");
6683 json_object_int_add(json
, "peerHost", len
);
6685 vty_out (vty
, "%*s", len
, " ");
6688 len
= vty_out (vty
, "%d", bdi
->flap
);
6698 json_object_int_add(json
, "bdiFlap", len
);
6700 vty_out (vty
, "%*s", len
, " ");
6704 peer_uptime (bdi
->start_time
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6706 vty_out (vty
, "%s ", peer_uptime (bdi
->start_time
,
6707 timebuf
, BGP_UPTIME_LEN
, 0, NULL
));
6709 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
)
6710 && ! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6713 bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
);
6715 vty_out (vty
, "%s ", bgp_damp_reuse_time_vty (vty
, binfo
, timebuf
, BGP_UPTIME_LEN
, use_json
, json
));
6720 vty_out (vty
, "%*s ", 8, " ");
6723 /* Print attribute */
6731 json_object_string_add(json
, "asPath", attr
->aspath
->str
);
6733 aspath_print_vty (vty
, "%s", attr
->aspath
, " ");
6738 json_object_string_add(json
, "origin", bgp_origin_str
[attr
->origin
]);
6740 vty_out (vty
, "%s", bgp_origin_str
[attr
->origin
]);
6743 vty_out (vty
, "%s", VTY_NEWLINE
);
6747 route_vty_out_advertised_to (struct vty
*vty
, struct peer
*peer
, int *first
,
6748 const char *header
, json_object
*json_adv_to
)
6750 char buf1
[INET6_ADDRSTRLEN
];
6751 json_object
*json_peer
= NULL
;
6755 /* 'advertised-to' is a dictionary of peers we have advertised this
6756 * prefix too. The key is the peer's IP or swpX, the value is the
6757 * hostname if we know it and "" if not.
6759 json_peer
= json_object_new_object();
6762 json_object_string_add(json_peer
, "hostname", peer
->hostname
);
6765 json_object_object_add(json_adv_to
, peer
->conf_if
, json_peer
);
6767 json_object_object_add(json_adv_to
,
6768 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
),
6775 vty_out (vty
, "%s", header
);
6779 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
6782 vty_out (vty
, " %s(%s)", peer
->hostname
, peer
->conf_if
);
6784 vty_out (vty
, " %s(%s)", peer
->hostname
,
6785 sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6790 vty_out (vty
, " %s", peer
->conf_if
);
6792 vty_out (vty
, " %s", sockunion2str (&peer
->su
, buf1
, SU_ADDRSTRLEN
));
6798 route_vty_out_detail (struct vty
*vty
, struct bgp
*bgp
, struct prefix
*p
,
6799 struct bgp_info
*binfo
, afi_t afi
, safi_t safi
,
6800 json_object
*json_paths
)
6802 char buf
[INET6_ADDRSTRLEN
];
6805 int sockunion_vty_out (struct vty
*, union sockunion
*);
6806 #ifdef HAVE_CLOCK_MONOTONIC
6809 json_object
*json_bestpath
= NULL
;
6810 json_object
*json_cluster_list
= NULL
;
6811 json_object
*json_cluster_list_list
= NULL
;
6812 json_object
*json_ext_community
= NULL
;
6813 json_object
*json_last_update
= NULL
;
6814 json_object
*json_nexthop_global
= NULL
;
6815 json_object
*json_nexthop_ll
= NULL
;
6816 json_object
*json_nexthops
= NULL
;
6817 json_object
*json_path
= NULL
;
6818 json_object
*json_peer
= NULL
;
6819 json_object
*json_string
= NULL
;
6820 json_object
*json_adv_to
= NULL
;
6822 struct listnode
*node
, *nnode
;
6824 int addpath_capable
;
6826 unsigned int first_as
;
6830 json_path
= json_object_new_object();
6831 json_peer
= json_object_new_object();
6832 json_nexthop_global
= json_object_new_object();
6839 /* Line1 display AS-path, Aggregator */
6844 json_object_lock(attr
->aspath
->json
);
6845 json_object_object_add(json_path
, "aspath", attr
->aspath
->json
);
6849 if (attr
->aspath
->segments
)
6850 aspath_print_vty (vty
, " %s", attr
->aspath
, "");
6852 vty_out (vty
, " Local");
6856 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_REMOVED
))
6859 json_object_boolean_true_add(json_path
, "removed");
6861 vty_out (vty
, ", (removed)");
6864 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_STALE
))
6867 json_object_boolean_true_add(json_path
, "stale");
6869 vty_out (vty
, ", (stale)");
6872 if (CHECK_FLAG (attr
->flag
, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR
)))
6876 json_object_int_add(json_path
, "aggregatorAs", attr
->extra
->aggregator_as
);
6877 json_object_string_add(json_path
, "aggregatorId", inet_ntoa (attr
->extra
->aggregator_addr
));
6881 vty_out (vty
, ", (aggregated by %u %s)",
6882 attr
->extra
->aggregator_as
,
6883 inet_ntoa (attr
->extra
->aggregator_addr
));
6887 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
6890 json_object_boolean_true_add(json_path
, "rxedFromRrClient");
6892 vty_out (vty
, ", (Received from a RR-client)");
6895 if (CHECK_FLAG (binfo
->peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
6898 json_object_boolean_true_add(json_path
, "rxedFromRsClient");
6900 vty_out (vty
, ", (Received from a RS-client)");
6903 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
6906 json_object_boolean_true_add(json_path
, "dampeningHistoryEntry");
6908 vty_out (vty
, ", (history entry)");
6910 else if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DAMPED
))
6913 json_object_boolean_true_add(json_path
, "dampeningSuppressed");
6915 vty_out (vty
, ", (suppressed due to dampening)");
6919 vty_out (vty
, "%s", VTY_NEWLINE
);
6921 /* Line2 display Next-hop, Neighbor, Router-id */
6922 /* Display the nexthop */
6923 if (p
->family
== AF_INET
&&
6924 (safi
== SAFI_MPLS_VPN
||
6925 safi
== SAFI_ENCAP
||
6926 !BGP_ATTR_NEXTHOP_AFI_IP6(attr
)))
6928 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
6931 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6933 vty_out (vty
, " %s", inet_ntoa (attr
->extra
->mp_nexthop_global_in
));
6938 json_object_string_add(json_nexthop_global
, "ip", inet_ntoa (attr
->nexthop
));
6940 vty_out (vty
, " %s", inet_ntoa (attr
->nexthop
));
6944 json_object_string_add(json_nexthop_global
, "afi", "ipv4");
6948 assert (attr
->extra
);
6951 json_object_string_add(json_nexthop_global
, "ip",
6952 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6953 buf
, INET6_ADDRSTRLEN
));
6954 json_object_string_add(json_nexthop_global
, "afi", "ipv6");
6955 json_object_string_add(json_nexthop_global
, "scope", "global");
6959 vty_out (vty
, " %s",
6960 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_global
,
6961 buf
, INET6_ADDRSTRLEN
));
6965 /* Display the IGP cost or 'inaccessible' */
6966 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
6969 json_object_boolean_false_add(json_nexthop_global
, "accessible");
6971 vty_out (vty
, " (inaccessible)");
6975 if (binfo
->extra
&& binfo
->extra
->igpmetric
)
6978 json_object_int_add(json_nexthop_global
, "metric", binfo
->extra
->igpmetric
);
6980 vty_out (vty
, " (metric %u)", binfo
->extra
->igpmetric
);
6983 /* IGP cost is 0, display this only for json */
6987 json_object_int_add(json_nexthop_global
, "metric", 0);
6991 json_object_boolean_true_add(json_nexthop_global
, "accessible");
6994 /* Display peer "from" output */
6995 /* This path was originated locally */
6996 if (binfo
->peer
== bgp
->peer_self
)
6999 if (p
->family
== AF_INET
&& !BGP_ATTR_NEXTHOP_AFI_IP6(attr
))
7002 json_object_string_add(json_peer
, "peerId", "0.0.0.0");
7004 vty_out (vty
, " from 0.0.0.0 ");
7009 json_object_string_add(json_peer
, "peerId", "::");
7011 vty_out (vty
, " from :: ");
7015 json_object_string_add(json_peer
, "routerId", inet_ntoa(bgp
->router_id
));
7017 vty_out (vty
, "(%s)", inet_ntoa(bgp
->router_id
));
7020 /* We RXed this path from one of our peers */
7026 json_object_string_add(json_peer
, "peerId", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7027 json_object_string_add(json_peer
, "routerId", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7029 if (binfo
->peer
->hostname
)
7030 json_object_string_add(json_peer
, "hostname", binfo
->peer
->hostname
);
7032 if (binfo
->peer
->domainname
)
7033 json_object_string_add(json_peer
, "domainname", binfo
->peer
->domainname
);
7035 if (binfo
->peer
->conf_if
)
7036 json_object_string_add(json_peer
, "interface", binfo
->peer
->conf_if
);
7040 if (binfo
->peer
->conf_if
)
7042 if (binfo
->peer
->hostname
&&
7043 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7044 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7045 binfo
->peer
->conf_if
);
7047 vty_out (vty
, " from %s", binfo
->peer
->conf_if
);
7051 if (binfo
->peer
->hostname
&&
7052 bgp_flag_check(binfo
->peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7053 vty_out (vty
, " from %s(%s)", binfo
->peer
->hostname
,
7056 vty_out (vty
, " from %s", sockunion2str (&binfo
->peer
->su
, buf
, SU_ADDRSTRLEN
));
7059 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7060 vty_out (vty
, " (%s)", inet_ntoa (attr
->extra
->originator_id
));
7062 vty_out (vty
, " (%s)", inet_ntop (AF_INET
, &binfo
->peer
->remote_id
, buf1
, BUFSIZ
));
7067 vty_out (vty
, "%s", VTY_NEWLINE
);
7069 /* display the link-local nexthop */
7070 if (attr
->extra
&& attr
->extra
->mp_nexthop_len
== BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
)
7074 json_nexthop_ll
= json_object_new_object();
7075 json_object_string_add(json_nexthop_ll
, "ip",
7076 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7077 buf
, INET6_ADDRSTRLEN
));
7078 json_object_string_add(json_nexthop_ll
, "afi", "ipv6");
7079 json_object_string_add(json_nexthop_ll
, "scope", "link-local");
7081 json_object_boolean_true_add(json_nexthop_ll
, "accessible");
7083 if (!attr
->extra
->mp_nexthop_prefer_global
)
7084 json_object_boolean_true_add(json_nexthop_ll
, "used");
7086 json_object_boolean_true_add(json_nexthop_global
, "used");
7090 vty_out (vty
, " (%s) %s%s",
7091 inet_ntop (AF_INET6
, &attr
->extra
->mp_nexthop_local
,
7092 buf
, INET6_ADDRSTRLEN
),
7093 attr
->extra
->mp_nexthop_prefer_global
?
7094 "(prefer-global)" : "(used)",
7098 /* If we do not have a link-local nexthop then we must flag the global as "used" */
7102 json_object_boolean_true_add(json_nexthop_global
, "used");
7105 /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
7107 json_object_string_add(json_path
, "origin", bgp_origin_long_str
[attr
->origin
]);
7109 vty_out (vty
, " Origin %s", bgp_origin_long_str
[attr
->origin
]);
7111 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC
))
7114 json_object_int_add(json_path
, "med", attr
->med
);
7116 vty_out (vty
, ", metric %u", attr
->med
);
7119 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF
))
7122 json_object_int_add(json_path
, "localpref", attr
->local_pref
);
7124 vty_out (vty
, ", localpref %u", attr
->local_pref
);
7129 json_object_int_add(json_path
, "localpref", bgp
->default_local_pref
);
7131 vty_out (vty
, ", localpref %u", bgp
->default_local_pref
);
7134 if (attr
->extra
&& attr
->extra
->weight
!= 0)
7137 json_object_int_add(json_path
, "weight", attr
->extra
->weight
);
7139 vty_out (vty
, ", weight %u", attr
->extra
->weight
);
7142 if (attr
->extra
&& attr
->extra
->tag
!= 0)
7145 json_object_int_add(json_path
, "tag", attr
->extra
->tag
);
7147 vty_out (vty
, ", tag %"ROUTE_TAG_PRI
, attr
->extra
->tag
);
7150 if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_VALID
))
7153 json_object_boolean_false_add(json_path
, "valid");
7155 vty_out (vty
, ", invalid");
7157 else if (! CHECK_FLAG (binfo
->flags
, BGP_INFO_HISTORY
))
7160 json_object_boolean_true_add(json_path
, "valid");
7162 vty_out (vty
, ", valid");
7165 if (binfo
->peer
!= bgp
->peer_self
)
7167 if (binfo
->peer
->as
== binfo
->peer
->local_as
)
7169 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
7172 json_object_string_add(json_peer
, "type", "confed-internal");
7174 vty_out (vty
, ", confed-internal");
7179 json_object_string_add(json_peer
, "type", "internal");
7181 vty_out (vty
, ", internal");
7186 if (bgp_confederation_peers_check(bgp
, binfo
->peer
->as
))
7189 json_object_string_add(json_peer
, "type", "confed-external");
7191 vty_out (vty
, ", confed-external");
7196 json_object_string_add(json_peer
, "type", "external");
7198 vty_out (vty
, ", external");
7202 else if (binfo
->sub_type
== BGP_ROUTE_AGGREGATE
)
7206 json_object_boolean_true_add(json_path
, "aggregated");
7207 json_object_boolean_true_add(json_path
, "local");
7211 vty_out (vty
, ", aggregated, local");
7214 else if (binfo
->type
!= ZEBRA_ROUTE_BGP
)
7217 json_object_boolean_true_add(json_path
, "sourced");
7219 vty_out (vty
, ", sourced");
7225 json_object_boolean_true_add(json_path
, "sourced");
7226 json_object_boolean_true_add(json_path
, "local");
7230 vty_out (vty
, ", sourced, local");
7234 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE
))
7237 json_object_boolean_true_add(json_path
, "atomicAggregate");
7239 vty_out (vty
, ", atomic-aggregate");
7242 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_MULTIPATH
) ||
7243 (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
) &&
7244 bgp_info_mpath_count (binfo
)))
7247 json_object_boolean_true_add(json_path
, "multipath");
7249 vty_out (vty
, ", multipath");
7252 // Mark the bestpath(s)
7253 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_DMED_SELECTED
))
7255 first_as
= aspath_get_first_as(attr
->aspath
);
7260 json_bestpath
= json_object_new_object();
7261 json_object_int_add(json_bestpath
, "bestpathFromAs", first_as
);
7266 vty_out (vty
, ", bestpath-from-AS %d", first_as
);
7268 vty_out (vty
, ", bestpath-from-AS Local");
7272 if (CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
))
7277 json_bestpath
= json_object_new_object();
7278 json_object_boolean_true_add(json_bestpath
, "overall");
7281 vty_out (vty
, ", best");
7285 json_object_object_add(json_path
, "bestpath", json_bestpath
);
7288 vty_out (vty
, "%s", VTY_NEWLINE
);
7290 /* Line 4 display Community */
7291 if (attr
->community
)
7295 json_object_lock(attr
->community
->json
);
7296 json_object_object_add(json_path
, "community", attr
->community
->json
);
7300 vty_out (vty
, " Community: %s%s", attr
->community
->str
,
7305 /* Line 5 display Extended-community */
7306 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES
))
7310 json_ext_community
= json_object_new_object();
7311 json_object_string_add(json_ext_community
, "string", attr
->extra
->ecommunity
->str
);
7312 json_object_object_add(json_path
, "extendedCommunity", json_ext_community
);
7316 vty_out (vty
, " Extended Community: %s%s",
7317 attr
->extra
->ecommunity
->str
, VTY_NEWLINE
);
7321 /* Line 6 display Originator, Cluster-id */
7322 if ((attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
)) ||
7323 (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
)))
7325 assert (attr
->extra
);
7326 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID
))
7329 json_object_string_add(json_path
, "originatorId", inet_ntoa (attr
->extra
->originator_id
));
7331 vty_out (vty
, " Originator: %s",
7332 inet_ntoa (attr
->extra
->originator_id
));
7335 if (attr
->flag
& ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST
))
7341 json_cluster_list
= json_object_new_object();
7342 json_cluster_list_list
= json_object_new_array();
7344 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7346 json_string
= json_object_new_string(inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7347 json_object_array_add(json_cluster_list_list
, json_string
);
7350 /* struct cluster_list does not have "str" variable like
7351 * aspath and community do. Add this someday if someone
7353 json_object_string_add(json_cluster_list, "string", attr->extra->cluster->str);
7355 json_object_object_add(json_cluster_list
, "list", json_cluster_list_list
);
7356 json_object_object_add(json_path
, "clusterList", json_cluster_list
);
7360 vty_out (vty
, ", Cluster list: ");
7362 for (i
= 0; i
< attr
->extra
->cluster
->length
/ 4; i
++)
7364 vty_out (vty
, "%s ",
7365 inet_ntoa (attr
->extra
->cluster
->list
[i
]));
7371 vty_out (vty
, "%s", VTY_NEWLINE
);
7374 if (binfo
->extra
&& binfo
->extra
->damp_info
)
7375 bgp_damp_info_vty (vty
, binfo
, json_path
);
7377 /* Line 7 display Addpath IDs */
7378 if (binfo
->addpath_rx_id
|| binfo
->addpath_tx_id
)
7382 json_object_int_add(json_path
, "addpathRxId", binfo
->addpath_rx_id
);
7383 json_object_int_add(json_path
, "addpathTxId", binfo
->addpath_tx_id
);
7387 vty_out (vty
, " AddPath ID: RX %u, TX %u%s",
7388 binfo
->addpath_rx_id
, binfo
->addpath_tx_id
,
7393 /* If we used addpath to TX a non-bestpath we need to display
7394 * "Advertised to" on a path-by-path basis */
7395 if (bgp
->addpath_tx_used
[afi
][safi
])
7399 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7401 addpath_capable
= bgp_addpath_encode_tx (peer
, afi
, safi
);
7402 has_adj
= bgp_adj_out_lookup (peer
, binfo
->net
, binfo
->addpath_tx_id
);
7404 if ((addpath_capable
&& has_adj
) ||
7405 (!addpath_capable
&& has_adj
&& CHECK_FLAG (binfo
->flags
, BGP_INFO_SELECTED
)))
7407 if (json_path
&& !json_adv_to
)
7408 json_adv_to
= json_object_new_object();
7410 route_vty_out_advertised_to(vty
, peer
, &first
,
7420 json_object_object_add(json_path
, "advertisedTo", json_adv_to
);
7427 vty_out (vty
, "%s", VTY_NEWLINE
);
7432 /* Line 8 display Uptime */
7433 #ifdef HAVE_CLOCK_MONOTONIC
7434 tbuf
= time(NULL
) - (bgp_clock() - binfo
->uptime
);
7437 json_last_update
= json_object_new_object();
7438 json_object_int_add(json_last_update
, "epoch", tbuf
);
7439 json_object_string_add(json_last_update
, "string", ctime(&tbuf
));
7440 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7443 vty_out (vty
, " Last update: %s", ctime(&tbuf
));
7447 json_last_update
= json_object_new_object();
7448 json_object_int_add(json_last_update
, "epoch", tbuf
);
7449 json_object_string_add(json_last_update
, "string", ctime(&binfo
->uptime
));
7450 json_object_object_add(json_path
, "lastUpdate", json_last_update
);
7453 vty_out (vty
, " Last update: %s", ctime(&binfo
->uptime
));
7454 #endif /* HAVE_CLOCK_MONOTONIC */
7457 /* We've constructed the json object for this path, add it to the json
7462 if (json_nexthop_global
|| json_nexthop_ll
)
7464 json_nexthops
= json_object_new_array();
7466 if (json_nexthop_global
)
7467 json_object_array_add(json_nexthops
, json_nexthop_global
);
7469 if (json_nexthop_ll
)
7470 json_object_array_add(json_nexthops
, json_nexthop_ll
);
7472 json_object_object_add(json_path
, "nexthops", json_nexthops
);
7475 json_object_object_add(json_path
, "peer", json_peer
);
7476 json_object_array_add(json_paths
, json_path
);
7479 vty_out (vty
, "%s", VTY_NEWLINE
);
7482 #define BGP_SHOW_HEADER_CSV "Flags, Network, Next Hop, Metric, LocPrf, Weight, Path%s"
7483 #define BGP_SHOW_DAMP_HEADER " Network From Reuse Path%s"
7484 #define BGP_SHOW_FLAP_HEADER " Network From Flaps Duration Reuse Path%s"
7488 bgp_show_type_normal
,
7489 bgp_show_type_regexp
,
7490 bgp_show_type_prefix_list
,
7491 bgp_show_type_filter_list
,
7492 bgp_show_type_route_map
,
7493 bgp_show_type_neighbor
,
7494 bgp_show_type_cidr_only
,
7495 bgp_show_type_prefix_longer
,
7496 bgp_show_type_community_all
,
7497 bgp_show_type_community
,
7498 bgp_show_type_community_exact
,
7499 bgp_show_type_community_list
,
7500 bgp_show_type_community_list_exact
,
7501 bgp_show_type_flap_statistics
,
7502 bgp_show_type_flap_address
,
7503 bgp_show_type_flap_prefix
,
7504 bgp_show_type_flap_cidr_only
,
7505 bgp_show_type_flap_regexp
,
7506 bgp_show_type_flap_filter_list
,
7507 bgp_show_type_flap_prefix_list
,
7508 bgp_show_type_flap_prefix_longer
,
7509 bgp_show_type_flap_route_map
,
7510 bgp_show_type_flap_neighbor
,
7511 bgp_show_type_dampend_paths
,
7512 bgp_show_type_damp_neighbor
7516 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
7517 const char *prefix_list_str
, afi_t afi
,
7518 safi_t safi
, enum bgp_show_type type
);
7520 bgp_show_filter_list (struct vty
*vty
, const char *name
,
7521 const char *filter
, afi_t afi
,
7522 safi_t safi
, enum bgp_show_type type
);
7524 bgp_show_route_map (struct vty
*vty
, const char *name
,
7525 const char *rmap_str
, afi_t afi
,
7526 safi_t safi
, enum bgp_show_type type
);
7528 bgp_show_community_list (struct vty
*vty
, const char *name
,
7529 const char *com
, int exact
,
7530 afi_t afi
, safi_t safi
);
7532 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
7533 const char *prefix
, afi_t afi
,
7534 safi_t safi
, enum bgp_show_type type
);
7537 bgp_show_table (struct vty
*vty
, struct bgp
*bgp
, struct bgp_table
*table
,
7538 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7540 struct bgp_info
*ri
;
7541 struct bgp_node
*rn
;
7544 unsigned long output_count
;
7545 unsigned long total_count
;
7549 json_object
*json_paths
= NULL
;
7554 vty_out (vty
, "{ \"vrfId\": %d, \"vrfName\": \"%s\", \"tableVersion\": %" PRId64
", \"routerId\": \"%s\", \"routes\": { ",
7555 bgp
->vrf_id
== VRF_UNKNOWN
? -1 : bgp
->vrf_id
,
7556 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
? "Default" : bgp
->name
,
7557 table
->version
, inet_ntoa (bgp
->router_id
));
7558 json_paths
= json_object_new_object();
7561 /* This is first entry point, so reset total line. */
7565 /* Start processing of routes. */
7566 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
7567 if (rn
->info
!= NULL
)
7570 if (!first
&& use_json
)
7575 json_paths
= json_object_new_array();
7579 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7582 if (type
== bgp_show_type_flap_statistics
7583 || type
== bgp_show_type_flap_address
7584 || type
== bgp_show_type_flap_prefix
7585 || type
== bgp_show_type_flap_cidr_only
7586 || type
== bgp_show_type_flap_regexp
7587 || type
== bgp_show_type_flap_filter_list
7588 || type
== bgp_show_type_flap_prefix_list
7589 || type
== bgp_show_type_flap_prefix_longer
7590 || type
== bgp_show_type_flap_route_map
7591 || type
== bgp_show_type_flap_neighbor
7592 || type
== bgp_show_type_dampend_paths
7593 || type
== bgp_show_type_damp_neighbor
)
7595 if (!(ri
->extra
&& ri
->extra
->damp_info
))
7598 if (type
== bgp_show_type_regexp
7599 || type
== bgp_show_type_flap_regexp
)
7601 regex_t
*regex
= output_arg
;
7603 if (bgp_regexec (regex
, ri
->attr
->aspath
) == REG_NOMATCH
)
7606 if (type
== bgp_show_type_prefix_list
7607 || type
== bgp_show_type_flap_prefix_list
)
7609 struct prefix_list
*plist
= output_arg
;
7611 if (prefix_list_apply (plist
, &rn
->p
) != PREFIX_PERMIT
)
7614 if (type
== bgp_show_type_filter_list
7615 || type
== bgp_show_type_flap_filter_list
)
7617 struct as_list
*as_list
= output_arg
;
7619 if (as_list_apply (as_list
, ri
->attr
->aspath
) != AS_FILTER_PERMIT
)
7622 if (type
== bgp_show_type_route_map
7623 || type
== bgp_show_type_flap_route_map
)
7625 struct route_map
*rmap
= output_arg
;
7626 struct bgp_info binfo
;
7627 struct attr dummy_attr
;
7628 struct attr_extra dummy_extra
;
7631 dummy_attr
.extra
= &dummy_extra
;
7632 bgp_attr_dup (&dummy_attr
, ri
->attr
);
7634 binfo
.peer
= ri
->peer
;
7635 binfo
.attr
= &dummy_attr
;
7637 ret
= route_map_apply (rmap
, &rn
->p
, RMAP_BGP
, &binfo
);
7638 if (ret
== RMAP_DENYMATCH
)
7641 if (type
== bgp_show_type_neighbor
7642 || type
== bgp_show_type_flap_neighbor
7643 || type
== bgp_show_type_damp_neighbor
)
7645 union sockunion
*su
= output_arg
;
7647 if (ri
->peer
->su_remote
== NULL
|| ! sockunion_same(ri
->peer
->su_remote
, su
))
7650 if (type
== bgp_show_type_cidr_only
7651 || type
== bgp_show_type_flap_cidr_only
)
7653 u_int32_t destination
;
7655 destination
= ntohl (rn
->p
.u
.prefix4
.s_addr
);
7656 if (IN_CLASSC (destination
) && rn
->p
.prefixlen
== 24)
7658 if (IN_CLASSB (destination
) && rn
->p
.prefixlen
== 16)
7660 if (IN_CLASSA (destination
) && rn
->p
.prefixlen
== 8)
7663 if (type
== bgp_show_type_prefix_longer
7664 || type
== bgp_show_type_flap_prefix_longer
)
7666 struct prefix
*p
= output_arg
;
7668 if (! prefix_match (p
, &rn
->p
))
7671 if (type
== bgp_show_type_community_all
)
7673 if (! ri
->attr
->community
)
7676 if (type
== bgp_show_type_community
)
7678 struct community
*com
= output_arg
;
7680 if (! ri
->attr
->community
||
7681 ! community_match (ri
->attr
->community
, com
))
7684 if (type
== bgp_show_type_community_exact
)
7686 struct community
*com
= output_arg
;
7688 if (! ri
->attr
->community
||
7689 ! community_cmp (ri
->attr
->community
, com
))
7692 if (type
== bgp_show_type_community_list
)
7694 struct community_list
*list
= output_arg
;
7696 if (! community_list_match (ri
->attr
->community
, list
))
7699 if (type
== bgp_show_type_community_list_exact
)
7701 struct community_list
*list
= output_arg
;
7703 if (! community_list_exact_match (ri
->attr
->community
, list
))
7706 if (type
== bgp_show_type_flap_address
7707 || type
== bgp_show_type_flap_prefix
)
7709 struct prefix
*p
= output_arg
;
7711 if (! prefix_match (&rn
->p
, p
))
7714 if (type
== bgp_show_type_flap_prefix
)
7715 if (p
->prefixlen
!= rn
->p
.prefixlen
)
7718 if (type
== bgp_show_type_dampend_paths
7719 || type
== bgp_show_type_damp_neighbor
)
7721 if (! CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
)
7722 || CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
7726 if (!use_json
&& header
)
7728 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
7729 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7730 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
7731 if (type
== bgp_show_type_dampend_paths
7732 || type
== bgp_show_type_damp_neighbor
)
7733 vty_out (vty
, BGP_SHOW_DAMP_HEADER
, VTY_NEWLINE
);
7734 else if (type
== bgp_show_type_flap_statistics
7735 || type
== bgp_show_type_flap_address
7736 || type
== bgp_show_type_flap_prefix
7737 || type
== bgp_show_type_flap_cidr_only
7738 || type
== bgp_show_type_flap_regexp
7739 || type
== bgp_show_type_flap_filter_list
7740 || type
== bgp_show_type_flap_prefix_list
7741 || type
== bgp_show_type_flap_prefix_longer
7742 || type
== bgp_show_type_flap_route_map
7743 || type
== bgp_show_type_flap_neighbor
)
7744 vty_out (vty
, BGP_SHOW_FLAP_HEADER
, VTY_NEWLINE
);
7746 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
7750 if (type
== bgp_show_type_dampend_paths
7751 || type
== bgp_show_type_damp_neighbor
)
7752 damp_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7753 else if (type
== bgp_show_type_flap_statistics
7754 || type
== bgp_show_type_flap_address
7755 || type
== bgp_show_type_flap_prefix
7756 || type
== bgp_show_type_flap_cidr_only
7757 || type
== bgp_show_type_flap_regexp
7758 || type
== bgp_show_type_flap_filter_list
7759 || type
== bgp_show_type_flap_prefix_list
7760 || type
== bgp_show_type_flap_prefix_longer
7761 || type
== bgp_show_type_flap_route_map
7762 || type
== bgp_show_type_flap_neighbor
)
7763 flap_route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, use_json
, json_paths
);
7765 route_vty_out (vty
, &rn
->p
, ri
, display
, SAFI_UNICAST
, json_paths
);
7775 sprintf(buf2
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
), p
->prefixlen
);
7776 vty_out (vty
, "\"%s\": ", buf2
);
7777 vty_out (vty
, "%s", json_object_to_json_string (json_paths
));
7778 json_object_free (json_paths
);
7787 json_object_free (json_paths
);
7788 vty_out (vty
, " } }%s", VTY_NEWLINE
);
7792 /* No route is displayed */
7793 if (output_count
== 0)
7795 if (type
== bgp_show_type_normal
)
7796 vty_out (vty
, "No BGP prefixes displayed, %ld exist%s", total_count
, VTY_NEWLINE
);
7799 vty_out (vty
, "%sDisplayed %ld routes and %ld total paths%s",
7800 VTY_NEWLINE
, output_count
, total_count
, VTY_NEWLINE
);
7807 bgp_show (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
7808 enum bgp_show_type type
, void *output_arg
, u_char use_json
)
7810 struct bgp_table
*table
;
7814 bgp
= bgp_get_default ();
7820 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
7824 table
= bgp
->rib
[afi
][safi
];
7826 return bgp_show_table (vty
, bgp
, table
, type
, output_arg
,
7831 bgp_show_all_instances_routes_vty (struct vty
*vty
, afi_t afi
, safi_t safi
,
7834 struct listnode
*node
, *nnode
;
7836 struct bgp_table
*table
;
7840 vty_out (vty
, "{%s", VTY_NEWLINE
);
7842 for (ALL_LIST_ELEMENTS (bm
->bgp
, node
, nnode
, bgp
))
7847 vty_out (vty
, ",%s", VTY_NEWLINE
);
7851 vty_out(vty
, "\"%s\":", (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7852 ? "Default" : bgp
->name
);
7856 vty_out (vty
, "%sInstance %s:%s",
7858 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7859 ? "Default" : bgp
->name
,
7862 table
= bgp
->rib
[afi
][safi
];
7863 bgp_show_table (vty
, bgp
, table
,
7864 bgp_show_type_normal
, NULL
, use_json
);
7869 vty_out (vty
, "}%s", VTY_NEWLINE
);
7872 /* Header of detailed BGP route information */
7874 route_vty_out_detail_header (struct vty
*vty
, struct bgp
*bgp
,
7875 struct bgp_node
*rn
,
7876 struct prefix_rd
*prd
, afi_t afi
, safi_t safi
,
7879 struct bgp_info
*ri
;
7882 struct listnode
*node
, *nnode
;
7883 char buf1
[INET6_ADDRSTRLEN
];
7884 char buf2
[INET6_ADDRSTRLEN
];
7889 int no_advertise
= 0;
7892 json_object
*json_adv_to
= NULL
;
7898 json_object_string_add(json
, "prefix", inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
));
7899 json_object_int_add(json
, "prefixlen", p
->prefixlen
);
7903 vty_out (vty
, "BGP routing table entry for %s%s%s/%d%s",
7904 ((safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
) ?
7905 prefix_rd2str (prd
, buf1
, RD_ADDRSTRLEN
) : ""),
7906 safi
== SAFI_MPLS_VPN
? ":" : "",
7907 inet_ntop (p
->family
, &p
->u
.prefix
, buf2
, INET6_ADDRSTRLEN
),
7908 p
->prefixlen
, VTY_NEWLINE
);
7911 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
7914 if (CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))
7917 if (ri
->extra
&& ri
->extra
->suppress
)
7919 if (ri
->attr
->community
!= NULL
)
7921 if (community_include (ri
->attr
->community
, COMMUNITY_NO_ADVERTISE
))
7923 if (community_include (ri
->attr
->community
, COMMUNITY_NO_EXPORT
))
7925 if (community_include (ri
->attr
->community
, COMMUNITY_LOCAL_AS
))
7933 vty_out (vty
, "Paths: (%d available", count
);
7936 vty_out (vty
, ", best #%d", best
);
7937 if (safi
== SAFI_UNICAST
)
7938 vty_out (vty
, ", table %s",
7939 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
7940 ? "Default-IP-Routing-Table" : bgp
->name
);
7943 vty_out (vty
, ", no best path");
7946 vty_out (vty
, ", not advertised to any peer");
7948 vty_out (vty
, ", not advertised to EBGP peer");
7950 vty_out (vty
, ", not advertised outside local AS");
7953 vty_out (vty
, ", Advertisements suppressed by an aggregate.");
7954 vty_out (vty
, ")%s", VTY_NEWLINE
);
7957 /* If we are not using addpath then we can display Advertised to and that will
7958 * show what peers we advertised the bestpath to. If we are using addpath
7959 * though then we must display Advertised to on a path-by-path basis. */
7960 if (!bgp
->addpath_tx_used
[afi
][safi
])
7962 for (ALL_LIST_ELEMENTS (bgp
->peer
, node
, nnode
, peer
))
7964 if (bgp_adj_out_lookup (peer
, rn
, 0))
7966 if (json
&& !json_adv_to
)
7967 json_adv_to
= json_object_new_object();
7969 route_vty_out_advertised_to(vty
, peer
, &first
,
7970 " Advertised to non peer-group peers:\n ",
7979 json_object_object_add(json
, "advertisedTo", json_adv_to
);
7985 vty_out (vty
, " Not advertised to any peer");
7986 vty_out (vty
, "%s", VTY_NEWLINE
);
7991 /* Display specified route of BGP table. */
7993 bgp_show_route_in_table (struct vty
*vty
, struct bgp
*bgp
,
7994 struct bgp_table
*rib
, const char *ip_str
,
7995 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
7996 int prefix_check
, enum bgp_path_type pathtype
,
8002 struct prefix match
;
8003 struct bgp_node
*rn
;
8004 struct bgp_node
*rm
;
8005 struct bgp_info
*ri
;
8006 struct bgp_table
*table
;
8007 json_object
*json
= NULL
;
8008 json_object
*json_paths
= NULL
;
8010 /* Check IP address argument. */
8011 ret
= str2prefix (ip_str
, &match
);
8014 vty_out (vty
, "address is malformed%s", VTY_NEWLINE
);
8018 match
.family
= afi2family (afi
);
8022 json
= json_object_new_object();
8023 json_paths
= json_object_new_array();
8026 if (safi
== SAFI_MPLS_VPN
|| safi
== SAFI_ENCAP
)
8028 for (rn
= bgp_table_top (rib
); rn
; rn
= bgp_route_next (rn
))
8030 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
8033 if ((table
= rn
->info
) != NULL
)
8037 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
8039 if (prefix_check
&& rm
->p
.prefixlen
!= match
.prefixlen
)
8041 bgp_unlock_node (rm
);
8045 for (ri
= rm
->info
; ri
; ri
= ri
->next
)
8049 route_vty_out_detail_header (vty
, bgp
, rm
, (struct prefix_rd
*)&rn
->p
,
8050 AFI_IP
, safi
, json
);
8055 if (pathtype
== BGP_PATH_ALL
||
8056 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8057 (pathtype
== BGP_PATH_MULTIPATH
&&
8058 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8059 route_vty_out_detail (vty
, bgp
, &rm
->p
, ri
, AFI_IP
, safi
, json_paths
);
8062 bgp_unlock_node (rm
);
8071 if ((rn
= bgp_node_match (rib
, &match
)) != NULL
)
8073 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
8075 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
8079 route_vty_out_detail_header (vty
, bgp
, rn
, NULL
, afi
, safi
, json
);
8084 if (pathtype
== BGP_PATH_ALL
||
8085 (pathtype
== BGP_PATH_BESTPATH
&& CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
)) ||
8086 (pathtype
== BGP_PATH_MULTIPATH
&&
8087 (CHECK_FLAG (ri
->flags
, BGP_INFO_MULTIPATH
) || CHECK_FLAG (ri
->flags
, BGP_INFO_SELECTED
))))
8088 route_vty_out_detail (vty
, bgp
, &rn
->p
, ri
, afi
, safi
, json_paths
);
8092 bgp_unlock_node (rn
);
8099 json_object_object_add(json
, "paths", json_paths
);
8101 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
8102 json_object_free(json
);
8108 vty_out (vty
, "%% Network not in table%s", VTY_NEWLINE
);
8116 /* Display specified route of Main RIB */
8118 bgp_show_route (struct vty
*vty
, const char *view_name
, const char *ip_str
,
8119 afi_t afi
, safi_t safi
, struct prefix_rd
*prd
,
8120 int prefix_check
, enum bgp_path_type pathtype
,
8125 /* BGP structure lookup. */
8128 bgp
= bgp_lookup_by_name (view_name
);
8131 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
8137 bgp
= bgp_get_default ();
8140 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
8145 return bgp_show_route_in_table (vty
, bgp
, bgp
->rib
[afi
][safi
], ip_str
,
8146 afi
, safi
, prd
, prefix_check
, pathtype
,
8150 /* BGP route print out function. */
8153 "show ip bgp {json}",
8157 "JavaScript Object Notation\n")
8159 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8162 DEFUN (show_ip_bgp_ipv4
,
8163 show_ip_bgp_ipv4_cmd
,
8164 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" {json}",
8170 "JavaScript Object Notation\n")
8172 u_char uj
= use_json(argc
, argv
);
8174 return bgp_show (vty
, NULL
, AFI_IP
,
8175 bgp_vty_safi_from_arg(argv
[0]),
8176 bgp_show_type_normal
, NULL
, uj
);
8179 ALIAS (show_ip_bgp_ipv4
,
8180 show_bgp_ipv4_safi_cmd
,
8181 "show bgp ipv4 "BGP_SAFI_CMD_STR
" {json}",
8186 "JavaScript Object Notation\n")
8188 DEFUN (show_ip_bgp_route
,
8189 show_ip_bgp_route_cmd
,
8190 "show ip bgp A.B.C.D {json}",
8194 "Network in the BGP routing table to display\n"
8195 "JavaScript Object Notation\n")
8197 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8200 DEFUN (show_ip_bgp_route_pathtype
,
8201 show_ip_bgp_route_pathtype_cmd
,
8202 "show ip bgp A.B.C.D (bestpath|multipath) {json}",
8206 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8207 "Display only the bestpath\n"
8208 "Display only multipaths\n"
8209 "JavaScript Object Notation\n")
8211 u_char uj
= use_json(argc
, argv
);
8213 if (strncmp (argv
[1], "b", 1) == 0)
8214 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8216 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8219 DEFUN (show_bgp_ipv4_safi_route_pathtype
,
8220 show_bgp_ipv4_safi_route_pathtype_cmd
,
8221 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D (bestpath|multipath) {json}",
8224 BGP_AFI_SAFI_HELP_STR
8225 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8226 "Display only the bestpath\n"
8227 "Display only multipaths\n"
8228 "JavaScript Object Notation\n")
8230 u_char uj
= use_json(argc
, argv
);
8232 if (strncmp (argv
[2], "b", 1) == 0)
8233 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8234 bgp_vty_safi_from_arg(argv
[0]),
8235 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8237 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8238 bgp_vty_safi_from_arg(argv
[0]),
8239 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8242 DEFUN (show_bgp_ipv4_prefix
,
8243 show_bgp_ipv4_prefix_cmd
,
8244 "show bgp ipv4 A.B.C.D/M {json}",
8248 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8251 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8254 DEFUN (show_bgp_ipv6_route
,
8255 show_bgp_ipv6_route_cmd
,
8256 "show bgp ipv6 X:X::X:X {json}",
8260 "Network in the BGP routing table to display\n"
8263 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8266 DEFUN (show_bgp_ipv6_prefix
,
8267 show_bgp_ipv6_prefix_cmd
,
8268 "show bgp ipv6 X:X::X:X/M {json}",
8272 "IPv6 prefix <network>/<length>\n"
8275 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json (argc
,argv
));
8278 DEFUN (show_ip_bgp_ipv4_route
,
8279 show_ip_bgp_ipv4_route_cmd
,
8280 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8284 BGP_AFI_SAFI_HELP_STR
8285 "Network in the BGP routing table to display\n"
8286 "JavaScript Object Notation\n")
8288 u_char uj
= use_json(argc
, argv
);
8290 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8291 bgp_vty_safi_from_arg(argv
[0]),
8292 NULL
, 0, BGP_PATH_ALL
, uj
);
8295 ALIAS (show_ip_bgp_ipv4_route
,
8296 show_bgp_ipv4_safi_route_cmd
,
8297 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D {json}",
8300 BGP_AFI_SAFI_HELP_STR
8301 "Network in the BGP routing table to display\n"
8302 "JavaScript Object Notation\n")
8304 DEFUN (show_bgp_ipv4_safi_rd_route
,
8305 show_bgp_ipv4_safi_rd_route_cmd
,
8306 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
8310 "Address Family Modifier\n"
8311 "Address Family Modifier\n"
8312 "Display information for a route distinguisher\n"
8313 "ENCAP Route Distinguisher\n"
8314 "Network in the BGP routing table to display\n")
8317 struct prefix_rd prd
;
8320 if (bgp_parse_safi(argv
[0], &safi
)) {
8321 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8324 ret
= str2prefix_rd (argv
[1], &prd
);
8327 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8330 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8333 DEFUN (show_bgp_ipv6_safi_rd_route
,
8334 show_bgp_ipv6_safi_rd_route_cmd
,
8335 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
8339 "Address Family Modifier\n"
8340 "Address Family Modifier\n"
8341 "Display information for a route distinguisher\n"
8342 "ENCAP Route Distinguisher\n"
8343 "Network in the BGP routing table to display\n")
8346 struct prefix_rd prd
;
8349 if (bgp_parse_safi(argv
[0], &safi
)) {
8350 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8353 ret
= str2prefix_rd (argv
[1], &prd
);
8356 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8359 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, SAFI_ENCAP
, &prd
, 0, BGP_PATH_ALL
, use_json (argc
, argv
));
8363 DEFUN (show_bgp_ipv4_safi_rd_prefix
,
8364 show_bgp_ipv4_safi_rd_prefix_cmd
,
8365 "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
8369 "Address Family Modifier\n"
8370 "Address Family Modifier\n"
8371 "Display information for a route distinguisher\n"
8372 "ENCAP Route Distinguisher\n"
8373 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8376 struct prefix_rd prd
;
8379 if (bgp_parse_safi(argv
[0], &safi
)) {
8380 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8384 ret
= str2prefix_rd (argv
[1], &prd
);
8387 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8390 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8393 DEFUN (show_bgp_ipv6_safi_rd_prefix
,
8394 show_bgp_ipv6_safi_rd_prefix_cmd
,
8395 "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M {json}",
8399 "Address Family Modifier\n"
8400 "Address Family Modifier\n"
8401 "Display information for a route distinguisher\n"
8402 "ENCAP Route Distinguisher\n"
8403 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
8406 struct prefix_rd prd
;
8409 if (bgp_parse_safi(argv
[0], &safi
)) {
8410 vty_out (vty
, "Error: Bad SAFI: %s%s", argv
[0], VTY_NEWLINE
);
8414 ret
= str2prefix_rd (argv
[1], &prd
);
8417 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8420 return bgp_show_route (vty
, NULL
, argv
[2], AFI_IP6
, safi
, &prd
, 1, BGP_PATH_ALL
, use_json (argc
, argv
));
8423 DEFUN (show_ip_bgp_prefix
,
8424 show_ip_bgp_prefix_cmd
,
8425 "show ip bgp A.B.C.D/M {json}",
8429 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8430 "JavaScript Object Notation\n")
8432 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8435 DEFUN (show_ip_bgp_prefix_pathtype
,
8436 show_ip_bgp_prefix_pathtype_cmd
,
8437 "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
8441 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8442 "Display only the bestpath\n"
8443 "Display only multipaths\n"
8444 "JavaScript Object Notation\n")
8446 u_char uj
= use_json(argc
, argv
);
8447 if (strncmp (argv
[1], "b", 1) == 0)
8448 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8450 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8453 DEFUN (show_ip_bgp_ipv4_prefix
,
8454 show_ip_bgp_ipv4_prefix_cmd
,
8455 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8459 BGP_AFI_SAFI_HELP_STR
8460 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8461 "JavaScript Object Notation\n")
8463 u_char uj
= use_json(argc
, argv
);
8465 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8466 bgp_vty_safi_from_arg(argv
[0]),
8467 NULL
, 1, BGP_PATH_ALL
, uj
);
8470 ALIAS (show_ip_bgp_ipv4_prefix
,
8471 show_bgp_ipv4_safi_prefix_cmd
,
8472 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M {json}",
8475 BGP_AFI_SAFI_HELP_STR
8476 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8477 "JavaScript Object Notation\n")
8479 DEFUN (show_ip_bgp_ipv4_prefix_pathtype
,
8480 show_ip_bgp_ipv4_prefix_pathtype_cmd
,
8481 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8485 BGP_AFI_SAFI_HELP_STR
8486 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8487 "Display only the bestpath\n"
8488 "Display only multipaths\n"
8489 "JavaScript Object Notation\n")
8491 u_char uj
= use_json(argc
, argv
);
8493 if (strncmp (argv
[2], "b", 1) == 0)
8494 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8495 bgp_vty_safi_from_arg(argv
[0]),
8496 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8498 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP
,
8499 bgp_vty_safi_from_arg(argv
[0]),
8500 NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8503 ALIAS (show_ip_bgp_ipv4_prefix_pathtype
,
8504 show_bgp_ipv4_safi_prefix_pathtype_cmd
,
8505 "show bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M (bestpath|multipath) {json}",
8508 BGP_AFI_SAFI_HELP_STR
8509 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8510 "Display only the bestpath\n"
8511 "Display only multipaths\n"
8512 "JavaScript Object Notation\n")
8515 DEFUN (show_ip_bgp_view
,
8516 show_ip_bgp_instance_cmd
,
8517 "show ip bgp " BGP_INSTANCE_CMD
" {json}",
8521 BGP_INSTANCE_HELP_STR
8522 "JavaScript Object Notation\n")
8526 /* BGP structure lookup. */
8527 bgp
= bgp_lookup_by_name (argv
[1]);
8530 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8534 return bgp_show (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8537 DEFUN (show_ip_bgp_instance_all
,
8538 show_ip_bgp_instance_all_cmd
,
8539 "show ip bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8543 BGP_INSTANCE_ALL_HELP_STR
8544 "JavaScript Object Notation\n")
8546 u_char uj
= use_json(argc
, argv
);
8548 bgp_show_all_instances_routes_vty (vty
, AFI_IP
, SAFI_UNICAST
, uj
);
8552 DEFUN (show_ip_bgp_instance_route
,
8553 show_ip_bgp_instance_route_cmd
,
8554 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D {json}",
8558 BGP_INSTANCE_HELP_STR
8559 "Network in the BGP routing table to display\n"
8560 "JavaScript Object Notation\n")
8562 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8565 DEFUN (show_ip_bgp_instance_route_pathtype
,
8566 show_ip_bgp_instance_route_pathtype_cmd
,
8567 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D (bestpath|multipath) {json}",
8571 BGP_INSTANCE_HELP_STR
8572 "Network in the BGP routing table to display\n"
8573 "Display only the bestpath\n"
8574 "Display only multipaths\n"
8575 "JavaScript Object Notation\n")
8577 u_char uj
= use_json(argc
, argv
);
8579 if (strncmp (argv
[3], "b", 1) == 0)
8580 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8582 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8585 DEFUN (show_ip_bgp_instance_prefix
,
8586 show_ip_bgp_instance_prefix_cmd
,
8587 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M {json}",
8591 BGP_INSTANCE_HELP_STR
8592 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8593 "JavaScript Object Notation\n")
8595 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8598 DEFUN (show_ip_bgp_instance_prefix_pathtype
,
8599 show_ip_bgp_instance_prefix_pathtype_cmd
,
8600 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M (bestpath|multipath) {json}",
8604 BGP_INSTANCE_HELP_STR
8605 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
8606 "Display only the bestpath\n"
8607 "Display only multipaths\n"
8608 "JavaScript Object Notation\n")
8610 u_char uj
= use_json(argc
, argv
);
8611 if (strncmp (argv
[3], "b", 1) == 0)
8612 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8614 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8623 "JavaScript Object Notation\n")
8625 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8626 NULL
, use_json(argc
, argv
));
8631 "show bgp ipv6 {json}",
8635 "JavaScript Object Notation\n")
8637 DEFUN (show_bgp_ipv6_safi
,
8638 show_bgp_ipv6_safi_cmd
,
8639 "show bgp ipv6 "BGP_SAFI_CMD_STR
" {json}",
8644 "JavaScript Object Notation\n")
8646 u_char uj
= use_json(argc
, argv
);
8648 return bgp_show (vty
, NULL
, AFI_IP6
,
8649 bgp_vty_safi_from_arg(argv
[0]),
8650 bgp_show_type_normal
, NULL
, uj
);
8654 bgp_show_ipv6_bgp_deprecate_warning (struct vty
*vty
)
8656 vty_out (vty
, "WARNING: The 'show ipv6 bgp' parse tree will be deprecated in our"
8657 " next release%sPlese use 'show bgp ipv6' instead%s%s",
8658 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
8662 DEFUN (show_ipv6_bgp
,
8664 "show ipv6 bgp {json}",
8668 "JavaScript Object Notation\n")
8670 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8671 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
,
8672 NULL
, use_json(argc
, argv
));
8675 DEFUN (show_bgp_route
,
8677 "show bgp X:X::X:X {json}",
8680 "Network in the BGP routing table to display\n"
8681 "JavaScript Object Notation\n")
8683 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8686 DEFUN (show_bgp_ipv6_safi_route
,
8687 show_bgp_ipv6_safi_route_cmd
,
8688 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X {json}",
8691 BGP_AFI_SAFI_HELP_STR
8692 "Network in the BGP routing table to display\n"
8693 "JavaScript Object Notation\n")
8695 u_char uj
= use_json(argc
, argv
);
8697 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8698 bgp_vty_safi_from_arg(argv
[0]),
8699 NULL
, 0, BGP_PATH_ALL
, uj
);
8702 DEFUN (show_bgp_route_pathtype
,
8703 show_bgp_route_pathtype_cmd
,
8704 "show bgp X:X::X:X (bestpath|multipath) {json}",
8707 "Network in the BGP routing table to display\n"
8708 "Display only the bestpath\n"
8709 "Display only multipaths\n"
8710 "JavaScript Object Notation\n")
8712 u_char uj
= use_json(argc
, argv
);
8713 if (strncmp (argv
[1], "b", 1) == 0)
8714 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8716 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8719 ALIAS (show_bgp_route_pathtype
,
8720 show_bgp_ipv6_route_pathtype_cmd
,
8721 "show bgp ipv6 X:X::X:X (bestpath|multipath) {json}",
8725 "Network in the BGP routing table to display\n"
8726 "Display only the bestpath\n"
8727 "Display only multipaths\n"
8728 "JavaScript Object Notation\n")
8730 DEFUN (show_bgp_ipv6_safi_route_pathtype
,
8731 show_bgp_ipv6_safi_route_pathtype_cmd
,
8732 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X (bestpath|multipath) {json}",
8735 BGP_AFI_SAFI_HELP_STR
8736 "Network in the BGP routing table to display\n"
8737 "Display only the bestpath\n"
8738 "Display only multipaths\n"
8739 "JavaScript Object Notation\n")
8741 u_char uj
= use_json(argc
, argv
);
8742 if (strncmp (argv
[2], "b", 1) == 0)
8743 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8744 bgp_vty_safi_from_arg(argv
[0]),
8745 NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8747 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8748 bgp_vty_safi_from_arg(argv
[0]),
8749 NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8753 DEFUN (show_ipv6_bgp_route
,
8754 show_ipv6_bgp_route_cmd
,
8755 "show ipv6 bgp X:X::X:X {json}",
8759 "Network in the BGP routing table to display\n"
8760 "JavaScript Object Notation\n")
8762 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8763 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8766 DEFUN (show_bgp_prefix
,
8767 show_bgp_prefix_cmd
,
8768 "show bgp X:X::X:X/M {json}",
8771 "IPv6 prefix <network>/<length>\n"
8772 "JavaScript Object Notation\n")
8774 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8777 DEFUN (show_bgp_ipv6_safi_prefix
,
8778 show_bgp_ipv6_safi_prefix_cmd
,
8779 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M {json}",
8782 BGP_AFI_SAFI_HELP_STR
8783 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8784 "JavaScript Object Notation\n")
8786 u_char uj
= use_json(argc
, argv
);
8788 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8789 bgp_vty_safi_from_arg(argv
[0]),
8790 NULL
, 1, BGP_PATH_ALL
, uj
);
8793 DEFUN (show_bgp_prefix_pathtype
,
8794 show_bgp_prefix_pathtype_cmd
,
8795 "show bgp X:X::X:X/M (bestpath|multipath) {json}",
8798 "IPv6 prefix <network>/<length>\n"
8799 "Display only the bestpath\n"
8800 "Display only multipaths\n"
8801 "JavaScript Object Notation\n")
8803 u_char uj
= use_json(argc
, argv
);
8804 if (strncmp (argv
[1], "b", 1) == 0)
8805 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8807 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8810 ALIAS (show_bgp_prefix_pathtype
,
8811 show_bgp_ipv6_prefix_pathtype_cmd
,
8812 "show bgp ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8816 "IPv6 prefix <network>/<length>\n"
8817 "Display only the bestpath\n"
8818 "Display only multipaths\n"
8819 "JavaScript Object Notation\n")
8821 DEFUN (show_bgp_ipv6_safi_prefix_pathtype
,
8822 show_bgp_ipv6_safi_prefix_pathtype_cmd
,
8823 "show bgp ipv6 "BGP_SAFI_CMD_STR
" X:X::X:X/M (bestpath|multipath) {json}",
8826 BGP_AFI_SAFI_HELP_STR
8827 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8828 "Display only the bestpath\n"
8829 "Display only multipaths\n"
8830 "JavaScript Object Notation\n")
8832 u_char uj
= use_json(argc
, argv
);
8833 if (strncmp (argv
[2], "b", 1) == 0)
8834 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8835 bgp_vty_safi_from_arg(argv
[0]),
8836 NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8838 return bgp_show_route (vty
, NULL
, argv
[1], AFI_IP6
,
8839 bgp_vty_safi_from_arg(argv
[0]), NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8843 DEFUN (show_ipv6_bgp_prefix
,
8844 show_ipv6_bgp_prefix_cmd
,
8845 "show ipv6 bgp X:X::X:X/M {json}",
8849 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
8850 "JavaScript Object Notation\n")
8852 bgp_show_ipv6_bgp_deprecate_warning(vty
);
8853 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8856 DEFUN (show_bgp_view
,
8857 show_bgp_instance_cmd
,
8858 "show bgp " BGP_INSTANCE_CMD
" {json}",
8861 BGP_INSTANCE_HELP_STR
8862 "JavaScript Object Notation\n")
8866 /* BGP structure lookup. */
8867 bgp
= bgp_lookup_by_name (argv
[1]);
8870 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
8874 return bgp_show (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
, bgp_show_type_normal
, NULL
, use_json(argc
, argv
));
8877 DEFUN (show_bgp_instance_all
,
8878 show_bgp_instance_all_cmd
,
8879 "show bgp " BGP_INSTANCE_ALL_CMD
" {json}",
8882 BGP_INSTANCE_ALL_HELP_STR
8883 "JavaScript Object Notation\n")
8885 u_char uj
= use_json(argc
, argv
);
8887 bgp_show_all_instances_routes_vty (vty
, AFI_IP6
, SAFI_UNICAST
, uj
);
8891 ALIAS (show_bgp_view
,
8892 show_bgp_instance_ipv6_cmd
,
8893 "show bgp " BGP_INSTANCE_CMD
" ipv6 {json}",
8896 BGP_INSTANCE_HELP_STR
8898 "JavaScript Object Notation\n")
8900 DEFUN (show_bgp_instance_route
,
8901 show_bgp_instance_route_cmd
,
8902 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X {json}",
8905 BGP_INSTANCE_HELP_STR
8906 "Network in the BGP routing table to display\n"
8907 "JavaScript Object Notation\n")
8909 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
8912 ALIAS (show_bgp_instance_route
,
8913 show_bgp_instance_ipv6_route_cmd
,
8914 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X {json}",
8917 BGP_INSTANCE_HELP_STR
8919 "Network in the BGP routing table to display\n"
8920 "JavaScript Object Notation\n")
8922 DEFUN (show_bgp_instance_route_pathtype
,
8923 show_bgp_instance_route_pathtype_cmd
,
8924 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X (bestpath|multipath) {json}",
8927 BGP_INSTANCE_HELP_STR
8928 "Network in the BGP routing table to display\n"
8929 "Display only the bestpath\n"
8930 "Display only multipaths\n"
8931 "JavaScript Object Notation\n")
8933 u_char uj
= use_json(argc
, argv
);
8934 if (strncmp (argv
[3], "b", 1) == 0)
8935 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_BESTPATH
, uj
);
8937 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 0, BGP_PATH_MULTIPATH
, uj
);
8940 ALIAS (show_bgp_instance_route_pathtype
,
8941 show_bgp_instance_ipv6_route_pathtype_cmd
,
8942 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X (bestpath|multipath) {json}",
8945 BGP_INSTANCE_HELP_STR
8947 "Network in the BGP routing table to display\n"
8948 "Display only the bestpath\n"
8949 "Display only multipaths\n"
8950 "JavaScript Object Notation\n")
8952 DEFUN (show_bgp_instance_prefix
,
8953 show_bgp_instance_prefix_cmd
,
8954 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M {json}",
8957 BGP_INSTANCE_HELP_STR
8958 "IPv6 prefix <network>/<length>\n"
8959 "JavaScript Object Notation\n")
8961 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
8964 ALIAS (show_bgp_instance_prefix
,
8965 show_bgp_instance_ipv6_prefix_cmd
,
8966 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M {json}",
8969 BGP_INSTANCE_HELP_STR
8971 "IPv6 prefix <network>/<length>\n"
8972 "JavaScript Object Notation\n")
8974 DEFUN (show_bgp_instance_prefix_pathtype
,
8975 show_bgp_instance_prefix_pathtype_cmd
,
8976 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M (bestpath|multipath) {json}",
8979 BGP_INSTANCE_HELP_STR
8980 "IPv6 prefix <network>/<length>\n"
8981 "Display only the bestpath\n"
8982 "Display only multipaths\n"
8983 "JavaScript Object Notation\n")
8985 u_char uj
= use_json(argc
, argv
);
8986 if (strncmp (argv
[3], "b", 1) == 0)
8987 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_BESTPATH
, uj
);
8989 return bgp_show_route (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
, NULL
, 1, BGP_PATH_MULTIPATH
, uj
);
8992 ALIAS (show_bgp_instance_prefix_pathtype
,
8993 show_bgp_instance_ipv6_prefix_pathtype_cmd
,
8994 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M (bestpath|multipath) {json}",
8997 BGP_INSTANCE_HELP_STR
8999 "IPv6 prefix <network>/<length>\n"
9000 "Display only the bestpath\n"
9001 "Display only multipaths\n"
9002 "JavaScript Object Notation\n")
9004 DEFUN (show_bgp_instance_prefix_list
,
9005 show_bgp_instance_prefix_list_cmd
,
9006 "show bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9009 BGP_INSTANCE_HELP_STR
9010 "Display routes conforming to the prefix-list\n"
9011 "IPv6 prefix-list name\n")
9013 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9014 bgp_show_type_prefix_list
);
9017 ALIAS (show_bgp_instance_prefix_list
,
9018 show_bgp_instance_ipv6_prefix_list_cmd
,
9019 "show bgp " BGP_INSTANCE_CMD
" ipv6 prefix-list WORD",
9022 BGP_INSTANCE_HELP_STR
9024 "Display routes conforming to the prefix-list\n"
9025 "IPv6 prefix-list name\n")
9027 DEFUN (show_bgp_instance_filter_list
,
9028 show_bgp_instance_filter_list_cmd
,
9029 "show bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9032 BGP_INSTANCE_HELP_STR
9033 "Display routes conforming to the filter-list\n"
9034 "Regular expression access list name\n")
9036 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9037 bgp_show_type_filter_list
);
9040 ALIAS (show_bgp_instance_filter_list
,
9041 show_bgp_instance_ipv6_filter_list_cmd
,
9042 "show bgp " BGP_INSTANCE_CMD
" ipv6 filter-list WORD",
9045 BGP_INSTANCE_HELP_STR
9047 "Display routes conforming to the filter-list\n"
9048 "Regular expression access list name\n")
9050 DEFUN (show_bgp_instance_route_map
,
9051 show_bgp_instance_route_map_cmd
,
9052 "show bgp " BGP_INSTANCE_CMD
" route-map WORD",
9055 BGP_INSTANCE_HELP_STR
9056 "Display routes matching the route-map\n"
9057 "A route-map to match on\n")
9059 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9060 bgp_show_type_route_map
);
9063 ALIAS (show_bgp_instance_route_map
,
9064 show_bgp_instance_ipv6_route_map_cmd
,
9065 "show bgp " BGP_INSTANCE_CMD
" ipv6 route-map WORD",
9068 BGP_INSTANCE_HELP_STR
9070 "Display routes matching the route-map\n"
9071 "A route-map to match on\n")
9073 DEFUN (show_bgp_instance_community_list
,
9074 show_bgp_instance_community_list_cmd
,
9075 "show bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
9078 BGP_INSTANCE_HELP_STR
9079 "Display routes matching the community-list\n"
9080 "community-list number\n"
9081 "community-list name\n")
9083 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP6
, SAFI_UNICAST
);
9086 ALIAS (show_bgp_instance_community_list
,
9087 show_bgp_instance_ipv6_community_list_cmd
,
9088 "show bgp " BGP_INSTANCE_CMD
" ipv6 community-list (<1-500>|WORD)",
9091 BGP_INSTANCE_HELP_STR
9093 "Display routes matching the community-list\n"
9094 "community-list number\n"
9095 "community-list name\n")
9097 DEFUN (show_bgp_instance_prefix_longer
,
9098 show_bgp_instance_prefix_longer_cmd
,
9099 "show bgp " BGP_INSTANCE_CMD
" X:X::X:X/M longer-prefixes",
9102 BGP_INSTANCE_HELP_STR
9103 "IPv6 prefix <network>/<length>\n"
9104 "Display route and more specific routes\n")
9106 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP6
, SAFI_UNICAST
,
9107 bgp_show_type_prefix_longer
);
9110 ALIAS (show_bgp_instance_prefix_longer
,
9111 show_bgp_instance_ipv6_prefix_longer_cmd
,
9112 "show bgp " BGP_INSTANCE_CMD
" ipv6 X:X::X:X/M longer-prefixes",
9115 BGP_INSTANCE_HELP_STR
9117 "IPv6 prefix <network>/<length>\n"
9118 "Display route and more specific routes\n")
9121 DEFUN (show_ipv6_mbgp
,
9123 "show ipv6 mbgp {json}",
9127 "JavaScript Object Notation\n")
9129 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9130 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
, bgp_show_type_normal
,
9131 NULL
, use_json(argc
, argv
));
9135 DEFUN (show_ipv6_mbgp_route
,
9136 show_ipv6_mbgp_route_cmd
,
9137 "show ipv6 mbgp X:X::X:X {json}",
9141 "Network in the MBGP routing table to display\n"
9142 "JavaScript Object Notation\n")
9144 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9145 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 0, BGP_PATH_ALL
, use_json(argc
, argv
));
9149 DEFUN (show_ipv6_mbgp_prefix
,
9150 show_ipv6_mbgp_prefix_cmd
,
9151 "show ipv6 mbgp X:X::X:X/M {json}",
9155 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
9156 "JavaScript Object Notation\n")
9158 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9159 return bgp_show_route (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
, NULL
, 1, BGP_PATH_ALL
, use_json(argc
, argv
));
9165 bgp_show_regexp (struct vty
*vty
, int argc
, const char **argv
, afi_t afi
,
9166 safi_t safi
, enum bgp_show_type type
)
9176 b
= buffer_new (1024);
9177 for (i
= 0; i
< argc
; i
++)
9180 buffer_putc (b
, ' ');
9183 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9188 buffer_putstr (b
, argv
[i
]);
9190 buffer_putc (b
, '\0');
9192 regstr
= buffer_getstr (b
);
9195 regex
= bgp_regcomp (regstr
);
9196 XFREE(MTYPE_TMP
, regstr
);
9199 vty_out (vty
, "Can't compile regexp %s%s", argv
[0],
9204 rc
= bgp_show (vty
, NULL
, afi
, safi
, type
, regex
, 0);
9205 bgp_regex_free (regex
);
9209 DEFUN (show_ip_bgp_regexp
,
9210 show_ip_bgp_regexp_cmd
,
9211 "show ip bgp regexp .LINE",
9215 "Display routes matching the AS path regular expression\n"
9216 "A regular-expression to match the BGP AS paths\n")
9218 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9219 bgp_show_type_regexp
);
9222 DEFUN (show_ip_bgp_flap_regexp
,
9223 show_ip_bgp_flap_regexp_cmd
,
9224 "show ip bgp flap-statistics regexp .LINE",
9228 "Display flap statistics of routes\n"
9229 "Display routes matching the AS path regular expression\n"
9230 "A regular-expression to match the BGP AS paths\n")
9232 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, SAFI_UNICAST
,
9233 bgp_show_type_flap_regexp
);
9236 ALIAS (show_ip_bgp_flap_regexp
,
9237 show_ip_bgp_damp_flap_regexp_cmd
,
9238 "show ip bgp dampening flap-statistics regexp .LINE",
9242 "Display detailed information about dampening\n"
9243 "Display flap statistics of routes\n"
9244 "Display routes matching the AS path regular expression\n"
9245 "A regular-expression to match the BGP AS paths\n")
9247 DEFUN (show_ip_bgp_ipv4_regexp
,
9248 show_ip_bgp_ipv4_regexp_cmd
,
9249 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" regexp .LINE",
9255 "Display routes matching the AS path regular expression\n"
9256 "A regular-expression to match the BGP AS paths\n")
9259 safi
= bgp_vty_safi_from_arg(argv
[0]);
9260 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP
, safi
,
9261 bgp_show_type_regexp
);
9265 DEFUN (show_bgp_regexp
,
9266 show_bgp_regexp_cmd
,
9267 "show bgp regexp .LINE",
9270 "Display routes matching the AS path regular expression\n"
9271 "A regular-expression to match the BGP AS paths\n")
9273 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9274 bgp_show_type_regexp
);
9277 ALIAS (show_bgp_regexp
,
9278 show_bgp_ipv6_regexp_cmd
,
9279 "show bgp ipv6 regexp .LINE",
9283 "Display routes matching the AS path regular expression\n"
9284 "A regular-expression to match the BGP AS paths\n")
9287 DEFUN (show_ipv6_bgp_regexp
,
9288 show_ipv6_bgp_regexp_cmd
,
9289 "show ipv6 bgp regexp .LINE",
9293 "Display routes matching the AS path regular expression\n"
9294 "A regular-expression to match the BGP AS paths\n")
9296 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9297 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_UNICAST
,
9298 bgp_show_type_regexp
);
9302 DEFUN (show_ipv6_mbgp_regexp
,
9303 show_ipv6_mbgp_regexp_cmd
,
9304 "show ipv6 mbgp regexp .LINE",
9308 "Display routes matching the AS path regular expression\n"
9309 "A regular-expression to match the MBGP AS paths\n")
9311 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9312 return bgp_show_regexp (vty
, argc
, argv
, AFI_IP6
, SAFI_MULTICAST
,
9313 bgp_show_type_regexp
);
9315 #endif /* HAVE_IPV6 */
9318 bgp_show_prefix_list (struct vty
*vty
, const char *name
,
9319 const char *prefix_list_str
, afi_t afi
,
9320 safi_t safi
, enum bgp_show_type type
)
9322 struct prefix_list
*plist
;
9323 struct bgp
*bgp
= NULL
;
9325 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9327 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9331 plist
= prefix_list_lookup (afi
, prefix_list_str
);
9334 vty_out (vty
, "%% %s is not a valid prefix-list name%s",
9335 prefix_list_str
, VTY_NEWLINE
);
9339 return bgp_show (vty
, bgp
, afi
, safi
, type
, plist
, 0);
9342 DEFUN (show_ip_bgp_prefix_list
,
9343 show_ip_bgp_prefix_list_cmd
,
9344 "show ip bgp prefix-list WORD",
9348 "Display routes conforming to the prefix-list\n"
9349 "IP prefix-list name\n")
9351 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9352 bgp_show_type_prefix_list
);
9355 DEFUN (show_ip_bgp_instance_prefix_list
,
9356 show_ip_bgp_instance_prefix_list_cmd
,
9357 "show ip bgp " BGP_INSTANCE_CMD
" prefix-list WORD",
9361 BGP_INSTANCE_HELP_STR
9362 "Display routes conforming to the prefix-list\n"
9363 "IP prefix-list name\n")
9365 return bgp_show_prefix_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9366 bgp_show_type_prefix_list
);
9369 DEFUN (show_ip_bgp_flap_prefix_list
,
9370 show_ip_bgp_flap_prefix_list_cmd
,
9371 "show ip bgp flap-statistics prefix-list WORD",
9375 "Display flap statistics of routes\n"
9376 "Display routes conforming to the prefix-list\n"
9377 "IP prefix-list name\n")
9379 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9380 bgp_show_type_flap_prefix_list
);
9383 ALIAS (show_ip_bgp_flap_prefix_list
,
9384 show_ip_bgp_damp_flap_prefix_list_cmd
,
9385 "show ip bgp dampening flap-statistics prefix-list WORD",
9389 "Display detailed information about dampening\n"
9390 "Display flap statistics of routes\n"
9391 "Display routes conforming to the prefix-list\n"
9392 "IP prefix-list name\n")
9394 DEFUN (show_ip_bgp_ipv4_prefix_list
,
9395 show_ip_bgp_ipv4_prefix_list_cmd
,
9396 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" prefix-list WORD",
9402 "Display routes conforming to the prefix-list\n"
9403 "IP prefix-list name\n")
9406 safi
= bgp_vty_safi_from_arg(argv
[0]);
9407 return bgp_show_prefix_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9408 bgp_show_type_prefix_list
);
9412 DEFUN (show_bgp_prefix_list
,
9413 show_bgp_prefix_list_cmd
,
9414 "show bgp prefix-list WORD",
9417 "Display routes conforming to the prefix-list\n"
9418 "IPv6 prefix-list name\n")
9420 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9421 bgp_show_type_prefix_list
);
9424 ALIAS (show_bgp_prefix_list
,
9425 show_bgp_ipv6_prefix_list_cmd
,
9426 "show bgp ipv6 prefix-list WORD",
9430 "Display routes conforming to the prefix-list\n"
9431 "IPv6 prefix-list name\n")
9434 DEFUN (show_ipv6_bgp_prefix_list
,
9435 show_ipv6_bgp_prefix_list_cmd
,
9436 "show ipv6 bgp prefix-list WORD",
9440 "Display routes matching the prefix-list\n"
9441 "IPv6 prefix-list name\n")
9443 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9444 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9445 bgp_show_type_prefix_list
);
9449 DEFUN (show_ipv6_mbgp_prefix_list
,
9450 show_ipv6_mbgp_prefix_list_cmd
,
9451 "show ipv6 mbgp prefix-list WORD",
9455 "Display routes matching the prefix-list\n"
9456 "IPv6 prefix-list name\n")
9458 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9459 return bgp_show_prefix_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9460 bgp_show_type_prefix_list
);
9462 #endif /* HAVE_IPV6 */
9465 bgp_show_filter_list (struct vty
*vty
, const char *name
,
9466 const char *filter
, afi_t afi
,
9467 safi_t safi
, enum bgp_show_type type
)
9469 struct as_list
*as_list
;
9470 struct bgp
*bgp
= NULL
;
9472 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9474 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9478 as_list
= as_list_lookup (filter
);
9479 if (as_list
== NULL
)
9481 vty_out (vty
, "%% %s is not a valid AS-path access-list name%s", filter
, VTY_NEWLINE
);
9485 return bgp_show (vty
, bgp
, afi
, safi
, type
, as_list
, 0);
9488 DEFUN (show_ip_bgp_filter_list
,
9489 show_ip_bgp_filter_list_cmd
,
9490 "show ip bgp filter-list WORD",
9494 "Display routes conforming to the filter-list\n"
9495 "Regular expression access list name\n")
9497 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9498 bgp_show_type_filter_list
);
9501 DEFUN (show_ip_bgp_instance_filter_list
,
9502 show_ip_bgp_instance_filter_list_cmd
,
9503 "show ip bgp " BGP_INSTANCE_CMD
" filter-list WORD",
9507 BGP_INSTANCE_HELP_STR
9508 "Display routes conforming to the filter-list\n"
9509 "Regular expression access list name\n")
9511 return bgp_show_filter_list (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9512 bgp_show_type_filter_list
);
9515 DEFUN (show_ip_bgp_flap_filter_list
,
9516 show_ip_bgp_flap_filter_list_cmd
,
9517 "show ip bgp flap-statistics filter-list WORD",
9521 "Display flap statistics of routes\n"
9522 "Display routes conforming to the filter-list\n"
9523 "Regular expression access list name\n")
9525 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9526 bgp_show_type_flap_filter_list
);
9529 ALIAS (show_ip_bgp_flap_filter_list
,
9530 show_ip_bgp_damp_flap_filter_list_cmd
,
9531 "show ip bgp dampening flap-statistics filter-list WORD",
9535 "Display detailed information about dampening\n"
9536 "Display flap statistics of routes\n"
9537 "Display routes conforming to the filter-list\n"
9538 "Regular expression access list name\n")
9540 DEFUN (show_ip_bgp_ipv4_filter_list
,
9541 show_ip_bgp_ipv4_filter_list_cmd
,
9542 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" filter-list WORD",
9548 "Display routes conforming to the filter-list\n"
9549 "Regular expression access list name\n")
9552 safi
= bgp_vty_safi_from_arg(argv
[0]);
9553 return bgp_show_filter_list (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9554 bgp_show_type_filter_list
);
9558 DEFUN (show_bgp_filter_list
,
9559 show_bgp_filter_list_cmd
,
9560 "show bgp filter-list WORD",
9563 "Display routes conforming to the filter-list\n"
9564 "Regular expression access list name\n")
9566 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9567 bgp_show_type_filter_list
);
9570 ALIAS (show_bgp_filter_list
,
9571 show_bgp_ipv6_filter_list_cmd
,
9572 "show bgp ipv6 filter-list WORD",
9576 "Display routes conforming to the filter-list\n"
9577 "Regular expression access list name\n")
9580 DEFUN (show_ipv6_bgp_filter_list
,
9581 show_ipv6_bgp_filter_list_cmd
,
9582 "show ipv6 bgp filter-list WORD",
9586 "Display routes conforming to the filter-list\n"
9587 "Regular expression access list name\n")
9589 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9590 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9591 bgp_show_type_filter_list
);
9595 DEFUN (show_ipv6_mbgp_filter_list
,
9596 show_ipv6_mbgp_filter_list_cmd
,
9597 "show ipv6 mbgp filter-list WORD",
9601 "Display routes conforming to the filter-list\n"
9602 "Regular expression access list name\n")
9604 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9605 return bgp_show_filter_list (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
9606 bgp_show_type_filter_list
);
9608 #endif /* HAVE_IPV6 */
9610 DEFUN (show_ip_bgp_dampening_info
,
9611 show_ip_bgp_dampening_params_cmd
,
9612 "show ip bgp dampening parameters",
9616 "Display detailed information about dampening\n"
9617 "Display detail of configured dampening parameters\n")
9619 return bgp_show_dampening_parameters (vty
, AFI_IP
, SAFI_UNICAST
);
9623 DEFUN (show_ip_bgp_ipv4_dampening_parameters
,
9624 show_ip_bgp_ipv4_dampening_parameters_cmd
,
9625 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" dampening parameters",
9631 "Display detailed information about dampening\n"
9632 "Display detail of configured dampening parameters\n")
9635 safi
= bgp_vty_safi_from_arg(argv
[0]);
9636 return bgp_show_dampening_parameters (vty
, AFI_IP
, safi
);
9640 DEFUN (show_ip_bgp_ipv4_dampening_flap_stats
,
9641 show_ip_bgp_ipv4_dampening_flap_stats_cmd
,
9642 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" dampening flap-statistics",
9648 "Display detailed information about dampening\n"
9649 "Display flap statistics of routes\n")
9652 safi
= bgp_vty_safi_from_arg(argv
[0]);
9653 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9654 bgp_show_type_flap_statistics
, NULL
, 0);
9657 DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths
,
9658 show_ip_bgp_ipv4_dampening_dampd_paths_cmd
,
9659 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" dampening dampened-paths",
9665 "Display detailed information about dampening\n"
9666 "Display paths suppressed due to dampening\n")
9669 safi
= bgp_vty_safi_from_arg(argv
[0]);
9670 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9671 bgp_show_type_dampend_paths
, NULL
, 0);
9675 bgp_show_route_map (struct vty
*vty
, const char *name
,
9676 const char *rmap_str
, afi_t afi
,
9677 safi_t safi
, enum bgp_show_type type
)
9679 struct route_map
*rmap
;
9680 struct bgp
*bgp
= NULL
;
9682 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
9684 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
9688 rmap
= route_map_lookup_by_name (rmap_str
);
9691 vty_out (vty
, "%% %s is not a valid route-map name%s",
9692 rmap_str
, VTY_NEWLINE
);
9696 return bgp_show (vty
, bgp
, afi
, safi
, type
, rmap
, 0);
9699 DEFUN (show_ip_bgp_route_map
,
9700 show_ip_bgp_route_map_cmd
,
9701 "show ip bgp route-map WORD",
9705 "Display routes matching the route-map\n"
9706 "A route-map to match on\n")
9708 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9709 bgp_show_type_route_map
);
9712 DEFUN (show_ip_bgp_instance_route_map
,
9713 show_ip_bgp_instance_route_map_cmd
,
9714 "show ip bgp " BGP_INSTANCE_CMD
" route-map WORD",
9718 BGP_INSTANCE_HELP_STR
9719 "Display routes matching the route-map\n"
9720 "A route-map to match on\n")
9722 return bgp_show_route_map (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
9723 bgp_show_type_route_map
);
9726 DEFUN (show_ip_bgp_flap_route_map
,
9727 show_ip_bgp_flap_route_map_cmd
,
9728 "show ip bgp flap-statistics route-map WORD",
9732 "Display flap statistics of routes\n"
9733 "Display routes matching the route-map\n"
9734 "A route-map to match on\n")
9736 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
9737 bgp_show_type_flap_route_map
);
9740 ALIAS (show_ip_bgp_flap_route_map
,
9741 show_ip_bgp_damp_flap_route_map_cmd
,
9742 "show ip bgp dampening flap-statistics route-map WORD",
9746 "Display detailed information about dampening\n"
9747 "Display flap statistics of routes\n"
9748 "Display routes matching the route-map\n"
9749 "A route-map to match on\n")
9751 DEFUN (show_ip_bgp_ipv4_route_map
,
9752 show_ip_bgp_ipv4_route_map_cmd
,
9753 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" route-map WORD",
9759 "Display routes matching the route-map\n"
9760 "A route-map to match on\n")
9763 safi
= bgp_vty_safi_from_arg(argv
[0]);
9764 return bgp_show_route_map (vty
, NULL
, argv
[1], AFI_IP
, safi
,
9765 bgp_show_type_route_map
);
9768 DEFUN (show_bgp_route_map
,
9769 show_bgp_route_map_cmd
,
9770 "show bgp route-map WORD",
9773 "Display routes matching the route-map\n"
9774 "A route-map to match on\n")
9776 return bgp_show_route_map (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
9777 bgp_show_type_route_map
);
9780 ALIAS (show_bgp_route_map
,
9781 show_bgp_ipv6_route_map_cmd
,
9782 "show bgp ipv6 route-map WORD",
9786 "Display routes matching the route-map\n"
9787 "A route-map to match on\n")
9789 DEFUN (show_ip_bgp_cidr_only
,
9790 show_ip_bgp_cidr_only_cmd
,
9791 "show ip bgp cidr-only",
9795 "Display only routes with non-natural netmasks\n")
9797 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9798 bgp_show_type_cidr_only
, NULL
, 0);
9801 DEFUN (show_ip_bgp_flap_cidr_only
,
9802 show_ip_bgp_flap_cidr_only_cmd
,
9803 "show ip bgp flap-statistics cidr-only",
9807 "Display flap statistics of routes\n"
9808 "Display only routes with non-natural netmasks\n")
9810 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9811 bgp_show_type_flap_cidr_only
, NULL
, 0);
9814 ALIAS (show_ip_bgp_flap_cidr_only
,
9815 show_ip_bgp_damp_flap_cidr_only_cmd
,
9816 "show ip bgp dampening flap-statistics cidr-only",
9820 "Display detailed information about dampening\n"
9821 "Display flap statistics of routes\n"
9822 "Display only routes with non-natural netmasks\n")
9824 DEFUN (show_ip_bgp_ipv4_cidr_only
,
9825 show_ip_bgp_ipv4_cidr_only_cmd
,
9826 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" cidr-only",
9832 "Display only routes with non-natural netmasks\n")
9835 safi
= bgp_vty_safi_from_arg(argv
[0]);
9836 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9837 bgp_show_type_cidr_only
, NULL
, 0);
9840 DEFUN (show_ip_bgp_community_all
,
9841 show_ip_bgp_community_all_cmd
,
9842 "show ip bgp community",
9846 "Display routes matching the communities\n")
9848 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
9849 bgp_show_type_community_all
, NULL
, 0);
9852 DEFUN (show_ip_bgp_ipv4_community_all
,
9853 show_ip_bgp_ipv4_community_all_cmd
,
9854 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community",
9860 "Display routes matching the communities\n")
9863 safi
= bgp_vty_safi_from_arg(argv
[0]);
9864 return bgp_show (vty
, NULL
, AFI_IP
, safi
,
9865 bgp_show_type_community_all
, NULL
, 0);
9869 DEFUN (show_bgp_community_all
,
9870 show_bgp_community_all_cmd
,
9871 "show bgp community",
9874 "Display routes matching the communities\n")
9876 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9877 bgp_show_type_community_all
, NULL
, 0);
9880 ALIAS (show_bgp_community_all
,
9881 show_bgp_ipv6_community_all_cmd
,
9882 "show bgp ipv6 community",
9886 "Display routes matching the communities\n")
9889 DEFUN (show_ipv6_bgp_community_all
,
9890 show_ipv6_bgp_community_all_cmd
,
9891 "show ipv6 bgp community",
9895 "Display routes matching the communities\n")
9897 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9898 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_UNICAST
,
9899 bgp_show_type_community_all
, NULL
, 0);
9903 DEFUN (show_ipv6_mbgp_community_all
,
9904 show_ipv6_mbgp_community_all_cmd
,
9905 "show ipv6 mbgp community",
9909 "Display routes matching the communities\n")
9911 bgp_show_ipv6_bgp_deprecate_warning(vty
);
9912 return bgp_show (vty
, NULL
, AFI_IP6
, SAFI_MULTICAST
,
9913 bgp_show_type_community_all
, NULL
, 0);
9915 #endif /* HAVE_IPV6 */
9918 bgp_show_community (struct vty
*vty
, const char *view_name
, int argc
,
9919 const char **argv
, int exact
, afi_t afi
, safi_t safi
)
9921 struct community
*com
;
9928 /* BGP structure lookup */
9931 bgp
= bgp_lookup_by_name (view_name
);
9934 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
9940 bgp
= bgp_get_default ();
9943 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
9948 b
= buffer_new (1024);
9949 for (i
= 0; i
< argc
; i
++)
9952 buffer_putc (b
, ' ');
9955 if ((strcmp (argv
[i
], "unicast") == 0) || (strcmp (argv
[i
], "multicast") == 0))
9960 buffer_putstr (b
, argv
[i
]);
9962 buffer_putc (b
, '\0');
9964 str
= buffer_getstr (b
);
9967 com
= community_str2com (str
);
9968 XFREE (MTYPE_TMP
, str
);
9971 vty_out (vty
, "%% Community malformed: %s", VTY_NEWLINE
);
9975 return bgp_show (vty
, bgp
, afi
, safi
,
9976 (exact
? bgp_show_type_community_exact
:
9977 bgp_show_type_community
), com
, 0);
9980 DEFUN (show_ip_bgp_community
,
9981 show_ip_bgp_community_cmd
,
9982 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export)",
9986 "Display routes matching the communities\n"
9988 "Do not send outside local AS (well-known community)\n"
9989 "Do not advertise to any peer (well-known community)\n"
9990 "Do not export to next AS (well-known community)\n")
9992 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, SAFI_UNICAST
);
9995 ALIAS (show_ip_bgp_community
,
9996 show_ip_bgp_community2_cmd
,
9997 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10001 "Display routes matching the communities\n"
10003 "Do not send outside local AS (well-known community)\n"
10004 "Do not advertise to any peer (well-known community)\n"
10005 "Do not export to next AS (well-known community)\n"
10007 "Do not send outside local AS (well-known community)\n"
10008 "Do not advertise to any peer (well-known community)\n"
10009 "Do not export to next AS (well-known community)\n")
10011 ALIAS (show_ip_bgp_community
,
10012 show_ip_bgp_community3_cmd
,
10013 "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)",
10017 "Display routes matching the communities\n"
10019 "Do not send outside local AS (well-known community)\n"
10020 "Do not advertise to any peer (well-known community)\n"
10021 "Do not export to next AS (well-known community)\n"
10023 "Do not send outside local AS (well-known community)\n"
10024 "Do not advertise to any peer (well-known community)\n"
10025 "Do not export to next AS (well-known community)\n"
10027 "Do not send outside local AS (well-known community)\n"
10028 "Do not advertise to any peer (well-known community)\n"
10029 "Do not export to next AS (well-known community)\n")
10031 ALIAS (show_ip_bgp_community
,
10032 show_ip_bgp_community4_cmd
,
10033 "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)",
10037 "Display routes matching the communities\n"
10039 "Do not send outside local AS (well-known community)\n"
10040 "Do not advertise to any peer (well-known community)\n"
10041 "Do not export to next AS (well-known community)\n"
10043 "Do not send outside local AS (well-known community)\n"
10044 "Do not advertise to any peer (well-known community)\n"
10045 "Do not export to next AS (well-known community)\n"
10047 "Do not send outside local AS (well-known community)\n"
10048 "Do not advertise to any peer (well-known community)\n"
10049 "Do not export to next AS (well-known community)\n"
10051 "Do not send outside local AS (well-known community)\n"
10052 "Do not advertise to any peer (well-known community)\n"
10053 "Do not export to next AS (well-known community)\n")
10055 DEFUN (show_ip_bgp_ipv4_community
,
10056 show_ip_bgp_ipv4_community_cmd
,
10057 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export)",
10063 "Display routes matching the communities\n"
10065 "Do not send outside local AS (well-known community)\n"
10066 "Do not advertise to any peer (well-known community)\n"
10067 "Do not export to next AS (well-known community)\n")
10070 safi
= bgp_vty_safi_from_arg(argv
[0]);
10071 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP
, safi
);
10074 ALIAS (show_ip_bgp_ipv4_community
,
10075 show_ip_bgp_ipv4_community2_cmd
,
10076 "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)",
10082 "Display routes matching the communities\n"
10084 "Do not send outside local AS (well-known community)\n"
10085 "Do not advertise to any peer (well-known community)\n"
10086 "Do not export to next AS (well-known community)\n"
10088 "Do not send outside local AS (well-known community)\n"
10089 "Do not advertise to any peer (well-known community)\n"
10090 "Do not export to next AS (well-known community)\n")
10092 ALIAS (show_ip_bgp_ipv4_community
,
10093 show_ip_bgp_ipv4_community3_cmd
,
10094 "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)",
10100 "Display routes matching the communities\n"
10102 "Do not send outside local AS (well-known community)\n"
10103 "Do not advertise to any peer (well-known community)\n"
10104 "Do not export to next AS (well-known community)\n"
10106 "Do not send outside local AS (well-known community)\n"
10107 "Do not advertise to any peer (well-known community)\n"
10108 "Do not export to next AS (well-known community)\n"
10110 "Do not send outside local AS (well-known community)\n"
10111 "Do not advertise to any peer (well-known community)\n"
10112 "Do not export to next AS (well-known community)\n")
10114 ALIAS (show_ip_bgp_ipv4_community
,
10115 show_ip_bgp_ipv4_community4_cmd
,
10116 "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)",
10122 "Display routes matching the communities\n"
10124 "Do not send outside local AS (well-known community)\n"
10125 "Do not advertise to any peer (well-known community)\n"
10126 "Do not export to next AS (well-known community)\n"
10128 "Do not send outside local AS (well-known community)\n"
10129 "Do not advertise to any peer (well-known community)\n"
10130 "Do not export to next AS (well-known community)\n"
10132 "Do not send outside local AS (well-known community)\n"
10133 "Do not advertise to any peer (well-known community)\n"
10134 "Do not export to next AS (well-known community)\n"
10136 "Do not send outside local AS (well-known community)\n"
10137 "Do not advertise to any peer (well-known community)\n"
10138 "Do not export to next AS (well-known community)\n")
10140 DEFUN (show_bgp_instance_afi_safi_community_all
,
10141 show_bgp_instance_afi_safi_community_all_cmd
,
10142 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" community",
10145 BGP_INSTANCE_HELP_STR
10146 BGP_AFI_SAFI_HELP_STR
10147 "Display routes matching the communities\n")
10153 /* BGP structure lookup. */
10154 bgp
= bgp_lookup_by_name (argv
[1]);
10157 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
10158 return CMD_WARNING
;
10161 afi
= bgp_vty_safi_from_arg(argv
[2]);
10162 safi
= bgp_vty_safi_from_arg(argv
[3]);
10163 return bgp_show (vty
, bgp
, afi
, safi
, bgp_show_type_community_all
, NULL
, 0);
10166 DEFUN (show_bgp_instance_afi_safi_community
,
10167 show_bgp_instance_afi_safi_community_cmd
,
10168 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export)",
10171 BGP_INSTANCE_HELP_STR
10174 "Address family modifier\n"
10175 "Address family modifier\n"
10176 "Display routes matching the communities\n"
10178 "Do not send outside local AS (well-known community)\n"
10179 "Do not advertise to any peer (well-known community)\n"
10180 "Do not export to next AS (well-known community)\n")
10185 afi
= bgp_vty_safi_from_arg(argv
[2]);
10186 safi
= bgp_vty_safi_from_arg(argv
[3]);
10187 return bgp_show_community (vty
, argv
[1], argc
-4, &argv
[4], 0, afi
, safi
);
10190 ALIAS (show_bgp_instance_afi_safi_community
,
10191 show_bgp_instance_afi_safi_community2_cmd
,
10192 "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)",
10195 BGP_INSTANCE_HELP_STR
10198 "Address family modifier\n"
10199 "Address family modifier\n"
10200 "Display routes matching the communities\n"
10202 "Do not send outside local AS (well-known community)\n"
10203 "Do not advertise to any peer (well-known community)\n"
10204 "Do not export to next AS (well-known community)\n"
10206 "Do not send outside local AS (well-known community)\n"
10207 "Do not advertise to any peer (well-known community)\n"
10208 "Do not export to next AS (well-known community)\n")
10210 ALIAS (show_bgp_instance_afi_safi_community
,
10211 show_bgp_instance_afi_safi_community3_cmd
,
10212 "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)",
10215 BGP_INSTANCE_HELP_STR
10218 "Address family modifier\n"
10219 "Address family modifier\n"
10220 "Display routes matching the communities\n"
10222 "Do not send outside local AS (well-known community)\n"
10223 "Do not advertise to any peer (well-known community)\n"
10224 "Do not export to next AS (well-known community)\n"
10226 "Do not send outside local AS (well-known community)\n"
10227 "Do not advertise to any peer (well-known community)\n"
10228 "Do not export to next AS (well-known community)\n"
10230 "Do not send outside local AS (well-known community)\n"
10231 "Do not advertise to any peer (well-known community)\n"
10232 "Do not export to next AS (well-known community)\n")
10234 ALIAS (show_bgp_instance_afi_safi_community
,
10235 show_bgp_instance_afi_safi_community4_cmd
,
10236 "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)",
10239 BGP_INSTANCE_HELP_STR
10242 "Address family modifier\n"
10243 "Address family modifier\n"
10244 "Display routes matching the communities\n"
10246 "Do not send outside local AS (well-known community)\n"
10247 "Do not advertise to any peer (well-known community)\n"
10248 "Do not export to next AS (well-known community)\n"
10250 "Do not send outside local AS (well-known community)\n"
10251 "Do not advertise to any peer (well-known community)\n"
10252 "Do not export to next AS (well-known community)\n"
10254 "Do not send outside local AS (well-known community)\n"
10255 "Do not advertise to any peer (well-known community)\n"
10256 "Do not export to next AS (well-known community)\n"
10258 "Do not send outside local AS (well-known community)\n"
10259 "Do not advertise to any peer (well-known community)\n"
10260 "Do not export to next AS (well-known community)\n")
10262 DEFUN (show_ip_bgp_community_exact
,
10263 show_ip_bgp_community_exact_cmd
,
10264 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10268 "Display routes matching the communities\n"
10270 "Do not send outside local AS (well-known community)\n"
10271 "Do not advertise to any peer (well-known community)\n"
10272 "Do not export to next AS (well-known community)\n"
10273 "Exact match of the communities")
10275 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, SAFI_UNICAST
);
10278 ALIAS (show_ip_bgp_community_exact
,
10279 show_ip_bgp_community2_exact_cmd
,
10280 "show ip bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10284 "Display routes matching the communities\n"
10286 "Do not send outside local AS (well-known community)\n"
10287 "Do not advertise to any peer (well-known community)\n"
10288 "Do not export to next AS (well-known community)\n"
10290 "Do not send outside local AS (well-known community)\n"
10291 "Do not advertise to any peer (well-known community)\n"
10292 "Do not export to next AS (well-known community)\n"
10293 "Exact match of the communities")
10295 ALIAS (show_ip_bgp_community_exact
,
10296 show_ip_bgp_community3_exact_cmd
,
10297 "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",
10301 "Display routes matching the communities\n"
10303 "Do not send outside local AS (well-known community)\n"
10304 "Do not advertise to any peer (well-known community)\n"
10305 "Do not export to next AS (well-known community)\n"
10307 "Do not send outside local AS (well-known community)\n"
10308 "Do not advertise to any peer (well-known community)\n"
10309 "Do not export to next AS (well-known community)\n"
10311 "Do not send outside local AS (well-known community)\n"
10312 "Do not advertise to any peer (well-known community)\n"
10313 "Do not export to next AS (well-known community)\n"
10314 "Exact match of the communities")
10316 ALIAS (show_ip_bgp_community_exact
,
10317 show_ip_bgp_community4_exact_cmd
,
10318 "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",
10322 "Display routes matching the communities\n"
10324 "Do not send outside local AS (well-known community)\n"
10325 "Do not advertise to any peer (well-known community)\n"
10326 "Do not export to next AS (well-known community)\n"
10328 "Do not send outside local AS (well-known community)\n"
10329 "Do not advertise to any peer (well-known community)\n"
10330 "Do not export to next AS (well-known community)\n"
10332 "Do not send outside local AS (well-known community)\n"
10333 "Do not advertise to any peer (well-known community)\n"
10334 "Do not export to next AS (well-known community)\n"
10336 "Do not send outside local AS (well-known community)\n"
10337 "Do not advertise to any peer (well-known community)\n"
10338 "Do not export to next AS (well-known community)\n"
10339 "Exact match of the communities")
10341 DEFUN (show_ip_bgp_ipv4_community_exact
,
10342 show_ip_bgp_ipv4_community_exact_cmd
,
10343 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10349 "Display routes matching the communities\n"
10351 "Do not send outside local AS (well-known community)\n"
10352 "Do not advertise to any peer (well-known community)\n"
10353 "Do not export to next AS (well-known community)\n"
10354 "Exact match of the communities")
10357 safi
= bgp_vty_safi_from_arg(argv
[0]);
10358 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP
, safi
);
10361 ALIAS (show_ip_bgp_ipv4_community_exact
,
10362 show_ip_bgp_ipv4_community2_exact_cmd
,
10363 "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",
10369 "Display routes matching the communities\n"
10371 "Do not send outside local AS (well-known community)\n"
10372 "Do not advertise to any peer (well-known community)\n"
10373 "Do not export to next AS (well-known community)\n"
10375 "Do not send outside local AS (well-known community)\n"
10376 "Do not advertise to any peer (well-known community)\n"
10377 "Do not export to next AS (well-known community)\n"
10378 "Exact match of the communities")
10380 ALIAS (show_ip_bgp_ipv4_community_exact
,
10381 show_ip_bgp_ipv4_community3_exact_cmd
,
10382 "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",
10388 "Display routes matching the communities\n"
10390 "Do not send outside local AS (well-known community)\n"
10391 "Do not advertise to any peer (well-known community)\n"
10392 "Do not export to next AS (well-known community)\n"
10394 "Do not send outside local AS (well-known community)\n"
10395 "Do not advertise to any peer (well-known community)\n"
10396 "Do not export to next AS (well-known community)\n"
10398 "Do not send outside local AS (well-known community)\n"
10399 "Do not advertise to any peer (well-known community)\n"
10400 "Do not export to next AS (well-known community)\n"
10401 "Exact match of the communities")
10403 ALIAS (show_ip_bgp_ipv4_community_exact
,
10404 show_ip_bgp_ipv4_community4_exact_cmd
,
10405 "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",
10411 "Display routes matching the communities\n"
10413 "Do not send outside local AS (well-known community)\n"
10414 "Do not advertise to any peer (well-known community)\n"
10415 "Do not export to next AS (well-known community)\n"
10417 "Do not send outside local AS (well-known community)\n"
10418 "Do not advertise to any peer (well-known community)\n"
10419 "Do not export to next AS (well-known community)\n"
10421 "Do not send outside local AS (well-known community)\n"
10422 "Do not advertise to any peer (well-known community)\n"
10423 "Do not export to next AS (well-known community)\n"
10425 "Do not send outside local AS (well-known community)\n"
10426 "Do not advertise to any peer (well-known community)\n"
10427 "Do not export to next AS (well-known community)\n"
10428 "Exact match of the communities")
10431 DEFUN (show_bgp_community
,
10432 show_bgp_community_cmd
,
10433 "show bgp community (AA:NN|local-AS|no-advertise|no-export)",
10436 "Display routes matching the communities\n"
10438 "Do not send outside local AS (well-known community)\n"
10439 "Do not advertise to any peer (well-known community)\n"
10440 "Do not export to next AS (well-known community)\n")
10442 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10445 ALIAS (show_bgp_community
,
10446 show_bgp_ipv6_community_cmd
,
10447 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export)",
10451 "Display routes matching the communities\n"
10453 "Do not send outside local AS (well-known community)\n"
10454 "Do not advertise to any peer (well-known community)\n"
10455 "Do not export to next AS (well-known community)\n")
10457 ALIAS (show_bgp_community
,
10458 show_bgp_community2_cmd
,
10459 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10462 "Display routes matching the communities\n"
10464 "Do not send outside local AS (well-known community)\n"
10465 "Do not advertise to any peer (well-known community)\n"
10466 "Do not export to next AS (well-known community)\n"
10468 "Do not send outside local AS (well-known community)\n"
10469 "Do not advertise to any peer (well-known community)\n"
10470 "Do not export to next AS (well-known community)\n")
10472 ALIAS (show_bgp_community
,
10473 show_bgp_ipv6_community2_cmd
,
10474 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10478 "Display routes matching the communities\n"
10480 "Do not send outside local AS (well-known community)\n"
10481 "Do not advertise to any peer (well-known community)\n"
10482 "Do not export to next AS (well-known community)\n"
10484 "Do not send outside local AS (well-known community)\n"
10485 "Do not advertise to any peer (well-known community)\n"
10486 "Do not export to next AS (well-known community)\n")
10488 ALIAS (show_bgp_community
,
10489 show_bgp_community3_cmd
,
10490 "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)",
10493 "Display routes matching the communities\n"
10495 "Do not send outside local AS (well-known community)\n"
10496 "Do not advertise to any peer (well-known community)\n"
10497 "Do not export to next AS (well-known community)\n"
10499 "Do not send outside local AS (well-known community)\n"
10500 "Do not advertise to any peer (well-known community)\n"
10501 "Do not export to next AS (well-known community)\n"
10503 "Do not send outside local AS (well-known community)\n"
10504 "Do not advertise to any peer (well-known community)\n"
10505 "Do not export to next AS (well-known community)\n")
10507 ALIAS (show_bgp_community
,
10508 show_bgp_ipv6_community3_cmd
,
10509 "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)",
10513 "Display routes matching the communities\n"
10515 "Do not send outside local AS (well-known community)\n"
10516 "Do not advertise to any peer (well-known community)\n"
10517 "Do not export to next AS (well-known community)\n"
10519 "Do not send outside local AS (well-known community)\n"
10520 "Do not advertise to any peer (well-known community)\n"
10521 "Do not export to next AS (well-known community)\n"
10523 "Do not send outside local AS (well-known community)\n"
10524 "Do not advertise to any peer (well-known community)\n"
10525 "Do not export to next AS (well-known community)\n")
10527 ALIAS (show_bgp_community
,
10528 show_bgp_community4_cmd
,
10529 "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)",
10532 "Display routes matching the communities\n"
10534 "Do not send outside local AS (well-known community)\n"
10535 "Do not advertise to any peer (well-known community)\n"
10536 "Do not export to next AS (well-known community)\n"
10538 "Do not send outside local AS (well-known community)\n"
10539 "Do not advertise to any peer (well-known community)\n"
10540 "Do not export to next AS (well-known community)\n"
10542 "Do not send outside local AS (well-known community)\n"
10543 "Do not advertise to any peer (well-known community)\n"
10544 "Do not export to next AS (well-known community)\n"
10546 "Do not send outside local AS (well-known community)\n"
10547 "Do not advertise to any peer (well-known community)\n"
10548 "Do not export to next AS (well-known community)\n")
10550 ALIAS (show_bgp_community
,
10551 show_bgp_ipv6_community4_cmd
,
10552 "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)",
10556 "Display routes matching the communities\n"
10558 "Do not send outside local AS (well-known community)\n"
10559 "Do not advertise to any peer (well-known community)\n"
10560 "Do not export to next AS (well-known community)\n"
10562 "Do not send outside local AS (well-known community)\n"
10563 "Do not advertise to any peer (well-known community)\n"
10564 "Do not export to next AS (well-known community)\n"
10566 "Do not send outside local AS (well-known community)\n"
10567 "Do not advertise to any peer (well-known community)\n"
10568 "Do not export to next AS (well-known community)\n"
10570 "Do not send outside local AS (well-known community)\n"
10571 "Do not advertise to any peer (well-known community)\n"
10572 "Do not export to next AS (well-known community)\n")
10575 DEFUN (show_ipv6_bgp_community
,
10576 show_ipv6_bgp_community_cmd
,
10577 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export)",
10581 "Display routes matching the communities\n"
10583 "Do not send outside local AS (well-known community)\n"
10584 "Do not advertise to any peer (well-known community)\n"
10585 "Do not export to next AS (well-known community)\n")
10587 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10588 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_UNICAST
);
10592 ALIAS (show_ipv6_bgp_community
,
10593 show_ipv6_bgp_community2_cmd
,
10594 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10598 "Display routes matching the communities\n"
10600 "Do not send outside local AS (well-known community)\n"
10601 "Do not advertise to any peer (well-known community)\n"
10602 "Do not export to next AS (well-known community)\n"
10604 "Do not send outside local AS (well-known community)\n"
10605 "Do not advertise to any peer (well-known community)\n"
10606 "Do not export to next AS (well-known community)\n")
10609 ALIAS (show_ipv6_bgp_community
,
10610 show_ipv6_bgp_community3_cmd
,
10611 "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)",
10615 "Display routes matching the communities\n"
10617 "Do not send outside local AS (well-known community)\n"
10618 "Do not advertise to any peer (well-known community)\n"
10619 "Do not export to next AS (well-known community)\n"
10621 "Do not send outside local AS (well-known community)\n"
10622 "Do not advertise to any peer (well-known community)\n"
10623 "Do not export to next AS (well-known community)\n"
10625 "Do not send outside local AS (well-known community)\n"
10626 "Do not advertise to any peer (well-known community)\n"
10627 "Do not export to next AS (well-known community)\n")
10630 ALIAS (show_ipv6_bgp_community
,
10631 show_ipv6_bgp_community4_cmd
,
10632 "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)",
10636 "Display routes matching the communities\n"
10638 "Do not send outside local AS (well-known community)\n"
10639 "Do not advertise to any peer (well-known community)\n"
10640 "Do not export to next AS (well-known community)\n"
10642 "Do not send outside local AS (well-known community)\n"
10643 "Do not advertise to any peer (well-known community)\n"
10644 "Do not export to next AS (well-known community)\n"
10646 "Do not send outside local AS (well-known community)\n"
10647 "Do not advertise to any peer (well-known community)\n"
10648 "Do not export to next AS (well-known community)\n"
10650 "Do not send outside local AS (well-known community)\n"
10651 "Do not advertise to any peer (well-known community)\n"
10652 "Do not export to next AS (well-known community)\n")
10654 DEFUN (show_bgp_community_exact
,
10655 show_bgp_community_exact_cmd
,
10656 "show bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10659 "Display routes matching the communities\n"
10661 "Do not send outside local AS (well-known community)\n"
10662 "Do not advertise to any peer (well-known community)\n"
10663 "Do not export to next AS (well-known community)\n"
10664 "Exact match of the communities")
10666 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10669 ALIAS (show_bgp_community_exact
,
10670 show_bgp_ipv6_community_exact_cmd
,
10671 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10675 "Display routes matching the communities\n"
10677 "Do not send outside local AS (well-known community)\n"
10678 "Do not advertise to any peer (well-known community)\n"
10679 "Do not export to next AS (well-known community)\n"
10680 "Exact match of the communities")
10682 ALIAS (show_bgp_community_exact
,
10683 show_bgp_community2_exact_cmd
,
10684 "show bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10687 "Display routes matching the communities\n"
10689 "Do not send outside local AS (well-known community)\n"
10690 "Do not advertise to any peer (well-known community)\n"
10691 "Do not export to next AS (well-known community)\n"
10693 "Do not send outside local AS (well-known community)\n"
10694 "Do not advertise to any peer (well-known community)\n"
10695 "Do not export to next AS (well-known community)\n"
10696 "Exact match of the communities")
10698 ALIAS (show_bgp_community_exact
,
10699 show_bgp_ipv6_community2_exact_cmd
,
10700 "show bgp ipv6 community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10704 "Display routes matching the communities\n"
10706 "Do not send outside local AS (well-known community)\n"
10707 "Do not advertise to any peer (well-known community)\n"
10708 "Do not export to next AS (well-known community)\n"
10710 "Do not send outside local AS (well-known community)\n"
10711 "Do not advertise to any peer (well-known community)\n"
10712 "Do not export to next AS (well-known community)\n"
10713 "Exact match of the communities")
10715 ALIAS (show_bgp_community_exact
,
10716 show_bgp_community3_exact_cmd
,
10717 "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",
10720 "Display routes matching the communities\n"
10722 "Do not send outside local AS (well-known community)\n"
10723 "Do not advertise to any peer (well-known community)\n"
10724 "Do not export to next AS (well-known community)\n"
10726 "Do not send outside local AS (well-known community)\n"
10727 "Do not advertise to any peer (well-known community)\n"
10728 "Do not export to next AS (well-known community)\n"
10730 "Do not send outside local AS (well-known community)\n"
10731 "Do not advertise to any peer (well-known community)\n"
10732 "Do not export to next AS (well-known community)\n"
10733 "Exact match of the communities")
10735 ALIAS (show_bgp_community_exact
,
10736 show_bgp_ipv6_community3_exact_cmd
,
10737 "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",
10741 "Display routes matching the communities\n"
10743 "Do not send outside local AS (well-known community)\n"
10744 "Do not advertise to any peer (well-known community)\n"
10745 "Do not export to next AS (well-known community)\n"
10747 "Do not send outside local AS (well-known community)\n"
10748 "Do not advertise to any peer (well-known community)\n"
10749 "Do not export to next AS (well-known community)\n"
10751 "Do not send outside local AS (well-known community)\n"
10752 "Do not advertise to any peer (well-known community)\n"
10753 "Do not export to next AS (well-known community)\n"
10754 "Exact match of the communities")
10756 ALIAS (show_bgp_community_exact
,
10757 show_bgp_community4_exact_cmd
,
10758 "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",
10761 "Display routes matching the communities\n"
10763 "Do not send outside local AS (well-known community)\n"
10764 "Do not advertise to any peer (well-known community)\n"
10765 "Do not export to next AS (well-known community)\n"
10767 "Do not send outside local AS (well-known community)\n"
10768 "Do not advertise to any peer (well-known community)\n"
10769 "Do not export to next AS (well-known community)\n"
10771 "Do not send outside local AS (well-known community)\n"
10772 "Do not advertise to any peer (well-known community)\n"
10773 "Do not export to next AS (well-known community)\n"
10775 "Do not send outside local AS (well-known community)\n"
10776 "Do not advertise to any peer (well-known community)\n"
10777 "Do not export to next AS (well-known community)\n"
10778 "Exact match of the communities")
10780 ALIAS (show_bgp_community_exact
,
10781 show_bgp_ipv6_community4_exact_cmd
,
10782 "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",
10786 "Display routes matching the communities\n"
10788 "Do not send outside local AS (well-known community)\n"
10789 "Do not advertise to any peer (well-known community)\n"
10790 "Do not export to next AS (well-known community)\n"
10792 "Do not send outside local AS (well-known community)\n"
10793 "Do not advertise to any peer (well-known community)\n"
10794 "Do not export to next AS (well-known community)\n"
10796 "Do not send outside local AS (well-known community)\n"
10797 "Do not advertise to any peer (well-known community)\n"
10798 "Do not export to next AS (well-known community)\n"
10800 "Do not send outside local AS (well-known community)\n"
10801 "Do not advertise to any peer (well-known community)\n"
10802 "Do not export to next AS (well-known community)\n"
10803 "Exact match of the communities")
10806 DEFUN (show_ipv6_bgp_community_exact
,
10807 show_ipv6_bgp_community_exact_cmd
,
10808 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10812 "Display routes matching the communities\n"
10814 "Do not send outside local AS (well-known community)\n"
10815 "Do not advertise to any peer (well-known community)\n"
10816 "Do not export to next AS (well-known community)\n"
10817 "Exact match of the communities")
10819 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10820 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_UNICAST
);
10824 ALIAS (show_ipv6_bgp_community_exact
,
10825 show_ipv6_bgp_community2_exact_cmd
,
10826 "show ipv6 bgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10830 "Display routes matching the communities\n"
10832 "Do not send outside local AS (well-known community)\n"
10833 "Do not advertise to any peer (well-known community)\n"
10834 "Do not export to next AS (well-known community)\n"
10836 "Do not send outside local AS (well-known community)\n"
10837 "Do not advertise to any peer (well-known community)\n"
10838 "Do not export to next AS (well-known community)\n"
10839 "Exact match of the communities")
10842 ALIAS (show_ipv6_bgp_community_exact
,
10843 show_ipv6_bgp_community3_exact_cmd
,
10844 "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",
10848 "Display routes matching the communities\n"
10850 "Do not send outside local AS (well-known community)\n"
10851 "Do not advertise to any peer (well-known community)\n"
10852 "Do not export to next AS (well-known community)\n"
10854 "Do not send outside local AS (well-known community)\n"
10855 "Do not advertise to any peer (well-known community)\n"
10856 "Do not export to next AS (well-known community)\n"
10858 "Do not send outside local AS (well-known community)\n"
10859 "Do not advertise to any peer (well-known community)\n"
10860 "Do not export to next AS (well-known community)\n"
10861 "Exact match of the communities")
10864 ALIAS (show_ipv6_bgp_community_exact
,
10865 show_ipv6_bgp_community4_exact_cmd
,
10866 "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",
10870 "Display routes matching the communities\n"
10872 "Do not send outside local AS (well-known community)\n"
10873 "Do not advertise to any peer (well-known community)\n"
10874 "Do not export to next AS (well-known community)\n"
10876 "Do not send outside local AS (well-known community)\n"
10877 "Do not advertise to any peer (well-known community)\n"
10878 "Do not export to next AS (well-known community)\n"
10880 "Do not send outside local AS (well-known community)\n"
10881 "Do not advertise to any peer (well-known community)\n"
10882 "Do not export to next AS (well-known community)\n"
10884 "Do not send outside local AS (well-known community)\n"
10885 "Do not advertise to any peer (well-known community)\n"
10886 "Do not export to next AS (well-known community)\n"
10887 "Exact match of the communities")
10890 DEFUN (show_ipv6_mbgp_community
,
10891 show_ipv6_mbgp_community_cmd
,
10892 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export)",
10896 "Display routes matching the communities\n"
10898 "Do not send outside local AS (well-known community)\n"
10899 "Do not advertise to any peer (well-known community)\n"
10900 "Do not export to next AS (well-known community)\n")
10902 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10903 return bgp_show_community (vty
, NULL
, argc
, argv
, 0, AFI_IP6
, SAFI_MULTICAST
);
10907 ALIAS (show_ipv6_mbgp_community
,
10908 show_ipv6_mbgp_community2_cmd
,
10909 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)",
10913 "Display routes matching the communities\n"
10915 "Do not send outside local AS (well-known community)\n"
10916 "Do not advertise to any peer (well-known community)\n"
10917 "Do not export to next AS (well-known community)\n"
10919 "Do not send outside local AS (well-known community)\n"
10920 "Do not advertise to any peer (well-known community)\n"
10921 "Do not export to next AS (well-known community)\n")
10924 ALIAS (show_ipv6_mbgp_community
,
10925 show_ipv6_mbgp_community3_cmd
,
10926 "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)",
10930 "Display routes matching the communities\n"
10932 "Do not send outside local AS (well-known community)\n"
10933 "Do not advertise to any peer (well-known community)\n"
10934 "Do not export to next AS (well-known community)\n"
10936 "Do not send outside local AS (well-known community)\n"
10937 "Do not advertise to any peer (well-known community)\n"
10938 "Do not export to next AS (well-known community)\n"
10940 "Do not send outside local AS (well-known community)\n"
10941 "Do not advertise to any peer (well-known community)\n"
10942 "Do not export to next AS (well-known community)\n")
10945 ALIAS (show_ipv6_mbgp_community
,
10946 show_ipv6_mbgp_community4_cmd
,
10947 "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)",
10951 "Display routes matching the communities\n"
10953 "Do not send outside local AS (well-known community)\n"
10954 "Do not advertise to any peer (well-known community)\n"
10955 "Do not export to next AS (well-known community)\n"
10957 "Do not send outside local AS (well-known community)\n"
10958 "Do not advertise to any peer (well-known community)\n"
10959 "Do not export to next AS (well-known community)\n"
10961 "Do not send outside local AS (well-known community)\n"
10962 "Do not advertise to any peer (well-known community)\n"
10963 "Do not export to next AS (well-known community)\n"
10965 "Do not send outside local AS (well-known community)\n"
10966 "Do not advertise to any peer (well-known community)\n"
10967 "Do not export to next AS (well-known community)\n")
10970 DEFUN (show_ipv6_mbgp_community_exact
,
10971 show_ipv6_mbgp_community_exact_cmd
,
10972 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) exact-match",
10976 "Display routes matching the communities\n"
10978 "Do not send outside local AS (well-known community)\n"
10979 "Do not advertise to any peer (well-known community)\n"
10980 "Do not export to next AS (well-known community)\n"
10981 "Exact match of the communities")
10983 bgp_show_ipv6_bgp_deprecate_warning(vty
);
10984 return bgp_show_community (vty
, NULL
, argc
, argv
, 1, AFI_IP6
, SAFI_MULTICAST
);
10988 ALIAS (show_ipv6_mbgp_community_exact
,
10989 show_ipv6_mbgp_community2_exact_cmd
,
10990 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
10994 "Display routes matching the communities\n"
10996 "Do not send outside local AS (well-known community)\n"
10997 "Do not advertise to any peer (well-known community)\n"
10998 "Do not export to next AS (well-known community)\n"
11000 "Do not send outside local AS (well-known community)\n"
11001 "Do not advertise to any peer (well-known community)\n"
11002 "Do not export to next AS (well-known community)\n"
11003 "Exact match of the communities")
11006 ALIAS (show_ipv6_mbgp_community_exact
,
11007 show_ipv6_mbgp_community3_exact_cmd
,
11008 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11012 "Display routes matching the communities\n"
11014 "Do not send outside local AS (well-known community)\n"
11015 "Do not advertise to any peer (well-known community)\n"
11016 "Do not export to next AS (well-known community)\n"
11018 "Do not send outside local AS (well-known community)\n"
11019 "Do not advertise to any peer (well-known community)\n"
11020 "Do not export to next AS (well-known community)\n"
11022 "Do not send outside local AS (well-known community)\n"
11023 "Do not advertise to any peer (well-known community)\n"
11024 "Do not export to next AS (well-known community)\n"
11025 "Exact match of the communities")
11028 ALIAS (show_ipv6_mbgp_community_exact
,
11029 show_ipv6_mbgp_community4_exact_cmd
,
11030 "show ipv6 mbgp community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match",
11034 "Display routes matching the communities\n"
11036 "Do not send outside local AS (well-known community)\n"
11037 "Do not advertise to any peer (well-known community)\n"
11038 "Do not export to next AS (well-known community)\n"
11040 "Do not send outside local AS (well-known community)\n"
11041 "Do not advertise to any peer (well-known community)\n"
11042 "Do not export to next AS (well-known community)\n"
11044 "Do not send outside local AS (well-known community)\n"
11045 "Do not advertise to any peer (well-known community)\n"
11046 "Do not export to next AS (well-known community)\n"
11048 "Do not send outside local AS (well-known community)\n"
11049 "Do not advertise to any peer (well-known community)\n"
11050 "Do not export to next AS (well-known community)\n"
11051 "Exact match of the communities")
11052 #endif /* HAVE_IPV6 */
11055 bgp_show_community_list (struct vty
*vty
, const char *name
,
11056 const char *com
, int exact
,
11057 afi_t afi
, safi_t safi
)
11059 struct community_list
*list
;
11060 struct bgp
*bgp
= NULL
;
11062 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11064 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11065 return CMD_WARNING
;
11068 list
= community_list_lookup (bgp_clist
, com
, COMMUNITY_LIST_MASTER
);
11071 vty_out (vty
, "%% %s is not a valid community-list name%s", com
,
11073 return CMD_WARNING
;
11076 return bgp_show (vty
, bgp
, afi
, safi
,
11077 (exact
? bgp_show_type_community_list_exact
:
11078 bgp_show_type_community_list
), list
, 0);
11081 DEFUN (show_ip_bgp_community_list
,
11082 show_ip_bgp_community_list_cmd
,
11083 "show ip bgp community-list (<1-500>|WORD)",
11087 "Display routes matching the community-list\n"
11088 "community-list number\n"
11089 "community-list name\n")
11091 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP
, SAFI_UNICAST
);
11094 DEFUN (show_ip_bgp_instance_community_list
,
11095 show_ip_bgp_instance_community_list_cmd
,
11096 "show ip bgp " BGP_INSTANCE_CMD
" community-list (<1-500>|WORD)",
11100 BGP_INSTANCE_HELP_STR
11101 "Display routes matching the community-list\n"
11102 "community-list number\n"
11103 "community-list name\n")
11105 return bgp_show_community_list (vty
, argv
[1], argv
[2], 0, AFI_IP
, SAFI_UNICAST
);
11108 DEFUN (show_ip_bgp_ipv4_community_list
,
11109 show_ip_bgp_ipv4_community_list_cmd
,
11110 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community-list (<1-500>|WORD)",
11116 "Display routes matching the community-list\n"
11117 "community-list number\n"
11118 "community-list name\n")
11121 safi
= bgp_vty_safi_from_arg(argv
[0]);
11122 return bgp_show_community_list (vty
, NULL
, argv
[1], 0, AFI_IP
, safi
);
11125 DEFUN (show_ip_bgp_community_list_exact
,
11126 show_ip_bgp_community_list_exact_cmd
,
11127 "show ip bgp community-list (<1-500>|WORD) exact-match",
11131 "Display routes matching the community-list\n"
11132 "community-list number\n"
11133 "community-list name\n"
11134 "Exact match of the communities\n")
11136 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP
, SAFI_UNICAST
);
11139 DEFUN (show_ip_bgp_ipv4_community_list_exact
,
11140 show_ip_bgp_ipv4_community_list_exact_cmd
,
11141 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" community-list (<1-500>|WORD) exact-match",
11147 "Display routes matching the community-list\n"
11148 "community-list number\n"
11149 "community-list name\n"
11150 "Exact match of the communities\n")
11153 safi
= bgp_vty_safi_from_arg(argv
[0]);
11154 return bgp_show_community_list (vty
, NULL
, argv
[1], 1, AFI_IP
, safi
);
11158 DEFUN (show_bgp_community_list
,
11159 show_bgp_community_list_cmd
,
11160 "show bgp community-list (<1-500>|WORD)",
11163 "Display routes matching the community-list\n"
11164 "community-list number\n"
11165 "community-list name\n")
11167 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11170 ALIAS (show_bgp_community_list
,
11171 show_bgp_ipv6_community_list_cmd
,
11172 "show bgp ipv6 community-list (<1-500>|WORD)",
11176 "Display routes matching the community-list\n"
11177 "community-list number\n"
11178 "community-list name\n")
11181 DEFUN (show_ipv6_bgp_community_list
,
11182 show_ipv6_bgp_community_list_cmd
,
11183 "show ipv6 bgp community-list WORD",
11187 "Display routes matching the community-list\n"
11188 "community-list name\n")
11190 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11191 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_UNICAST
);
11195 DEFUN (show_ipv6_mbgp_community_list
,
11196 show_ipv6_mbgp_community_list_cmd
,
11197 "show ipv6 mbgp community-list WORD",
11201 "Display routes matching the community-list\n"
11202 "community-list name\n")
11204 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11205 return bgp_show_community_list (vty
, NULL
, argv
[0], 0, AFI_IP6
, SAFI_MULTICAST
);
11208 DEFUN (show_bgp_community_list_exact
,
11209 show_bgp_community_list_exact_cmd
,
11210 "show bgp community-list (<1-500>|WORD) exact-match",
11213 "Display routes matching the community-list\n"
11214 "community-list number\n"
11215 "community-list name\n"
11216 "Exact match of the communities\n")
11218 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11221 ALIAS (show_bgp_community_list_exact
,
11222 show_bgp_ipv6_community_list_exact_cmd
,
11223 "show bgp ipv6 community-list (<1-500>|WORD) exact-match",
11227 "Display routes matching the community-list\n"
11228 "community-list number\n"
11229 "community-list name\n"
11230 "Exact match of the communities\n")
11233 DEFUN (show_ipv6_bgp_community_list_exact
,
11234 show_ipv6_bgp_community_list_exact_cmd
,
11235 "show ipv6 bgp community-list WORD exact-match",
11239 "Display routes matching the community-list\n"
11240 "community-list name\n"
11241 "Exact match of the communities\n")
11243 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11244 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_UNICAST
);
11248 DEFUN (show_ipv6_mbgp_community_list_exact
,
11249 show_ipv6_mbgp_community_list_exact_cmd
,
11250 "show ipv6 mbgp community-list WORD exact-match",
11254 "Display routes matching the community-list\n"
11255 "community-list name\n"
11256 "Exact match of the communities\n")
11258 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11259 return bgp_show_community_list (vty
, NULL
, argv
[0], 1, AFI_IP6
, SAFI_MULTICAST
);
11261 #endif /* HAVE_IPV6 */
11264 bgp_show_prefix_longer (struct vty
*vty
, const char *name
,
11265 const char *prefix
, afi_t afi
,
11266 safi_t safi
, enum bgp_show_type type
)
11270 struct bgp
*bgp
= NULL
;
11272 if (name
&& !(bgp
= bgp_lookup_by_name(name
)))
11274 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11275 return CMD_WARNING
;
11280 ret
= str2prefix (prefix
, p
);
11283 vty_out (vty
, "%% Malformed Prefix%s", VTY_NEWLINE
);
11284 return CMD_WARNING
;
11287 ret
= bgp_show (vty
, bgp
, afi
, safi
, type
, p
, 0);
11292 DEFUN (show_ip_bgp_prefix_longer
,
11293 show_ip_bgp_prefix_longer_cmd
,
11294 "show ip bgp A.B.C.D/M longer-prefixes",
11298 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11299 "Display route and more specific routes\n")
11301 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11302 bgp_show_type_prefix_longer
);
11305 DEFUN (show_ip_bgp_instance_prefix_longer
,
11306 show_ip_bgp_instance_prefix_longer_cmd
,
11307 "show ip bgp " BGP_INSTANCE_CMD
" A.B.C.D/M longer-prefixes",
11311 BGP_INSTANCE_HELP_STR
11312 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11313 "Display route and more specific routes\n")
11315 return bgp_show_prefix_longer (vty
, argv
[1], argv
[2], AFI_IP
, SAFI_UNICAST
,
11316 bgp_show_type_prefix_longer
);
11319 DEFUN (show_ip_bgp_flap_prefix_longer
,
11320 show_ip_bgp_flap_prefix_longer_cmd
,
11321 "show ip bgp flap-statistics A.B.C.D/M longer-prefixes",
11325 "Display flap statistics of routes\n"
11326 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11327 "Display route and more specific routes\n")
11329 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11330 bgp_show_type_flap_prefix_longer
);
11333 ALIAS (show_ip_bgp_flap_prefix_longer
,
11334 show_ip_bgp_damp_flap_prefix_longer_cmd
,
11335 "show ip bgp dampening flap-statistics A.B.C.D/M longer-prefixes",
11339 "Display detailed information about dampening\n"
11340 "Display flap statistics of routes\n"
11341 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11342 "Display route and more specific routes\n")
11344 DEFUN (show_ip_bgp_ipv4_prefix_longer
,
11345 show_ip_bgp_ipv4_prefix_longer_cmd
,
11346 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" A.B.C.D/M longer-prefixes",
11352 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
11353 "Display route and more specific routes\n")
11356 safi
= bgp_vty_safi_from_arg(argv
[0]);
11357 return bgp_show_prefix_longer (vty
, NULL
, argv
[1], AFI_IP
, safi
,
11358 bgp_show_type_prefix_longer
);
11361 DEFUN (show_ip_bgp_flap_address
,
11362 show_ip_bgp_flap_address_cmd
,
11363 "show ip bgp flap-statistics A.B.C.D",
11367 "Display flap statistics of routes\n"
11368 "Network in the BGP routing table to display\n")
11370 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11371 bgp_show_type_flap_address
);
11374 ALIAS (show_ip_bgp_flap_address
,
11375 show_ip_bgp_damp_flap_address_cmd
,
11376 "show ip bgp dampening flap-statistics A.B.C.D",
11380 "Display detailed information about dampening\n"
11381 "Display flap statistics of routes\n"
11382 "Network in the BGP routing table to display\n")
11384 DEFUN (show_ip_bgp_flap_prefix
,
11385 show_ip_bgp_flap_prefix_cmd
,
11386 "show ip bgp flap-statistics A.B.C.D/M",
11390 "Display flap statistics of routes\n"
11391 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11393 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP
, SAFI_UNICAST
,
11394 bgp_show_type_flap_prefix
);
11397 ALIAS (show_ip_bgp_flap_prefix
,
11398 show_ip_bgp_damp_flap_prefix_cmd
,
11399 "show ip bgp dampening flap-statistics A.B.C.D/M",
11403 "Display detailed information about dampening\n"
11404 "Display flap statistics of routes\n"
11405 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
11408 DEFUN (show_bgp_prefix_longer
,
11409 show_bgp_prefix_longer_cmd
,
11410 "show bgp X:X::X:X/M longer-prefixes",
11413 "IPv6 prefix <network>/<length>\n"
11414 "Display route and more specific routes\n")
11416 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11417 bgp_show_type_prefix_longer
);
11420 ALIAS (show_bgp_prefix_longer
,
11421 show_bgp_ipv6_prefix_longer_cmd
,
11422 "show bgp ipv6 X:X::X:X/M longer-prefixes",
11426 "IPv6 prefix <network>/<length>\n"
11427 "Display route and more specific routes\n")
11430 DEFUN (show_ipv6_bgp_prefix_longer
,
11431 show_ipv6_bgp_prefix_longer_cmd
,
11432 "show ipv6 bgp X:X::X:X/M longer-prefixes",
11436 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11437 "Display route and more specific routes\n")
11439 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11440 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
11441 bgp_show_type_prefix_longer
);
11445 DEFUN (show_ipv6_mbgp_prefix_longer
,
11446 show_ipv6_mbgp_prefix_longer_cmd
,
11447 "show ipv6 mbgp X:X::X:X/M longer-prefixes",
11451 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
11452 "Display route and more specific routes\n")
11454 bgp_show_ipv6_bgp_deprecate_warning(vty
);
11455 return bgp_show_prefix_longer (vty
, NULL
, argv
[0], AFI_IP6
, SAFI_MULTICAST
,
11456 bgp_show_type_prefix_longer
);
11458 #endif /* HAVE_IPV6 */
11460 static struct peer
*
11461 peer_lookup_in_view (struct vty
*vty
, const char *view_name
,
11462 const char *ip_str
, u_char use_json
)
11467 union sockunion su
;
11469 /* BGP structure lookup. */
11472 bgp
= bgp_lookup_by_name (view_name
);
11477 json_object
*json_no
= NULL
;
11478 json_no
= json_object_new_object();
11479 json_object_string_add(json_no
, "warning", "Can't find BGP view");
11480 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11481 json_object_free(json_no
);
11484 vty_out (vty
, "Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
11490 bgp
= bgp_get_default ();
11495 json_object
*json_no
= NULL
;
11496 json_no
= json_object_new_object();
11497 json_object_string_add(json_no
, "warning", "No BGP process configured");
11498 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11499 json_object_free(json_no
);
11502 vty_out (vty
, "No BGP process is configured%s", VTY_NEWLINE
);
11507 /* Get peer sockunion. */
11508 ret
= str2sockunion (ip_str
, &su
);
11511 peer
= peer_lookup_by_conf_if (bgp
, ip_str
);
11514 peer
= peer_lookup_by_hostname(bgp
, ip_str
);
11520 json_object
*json_no
= NULL
;
11521 json_no
= json_object_new_object();
11522 json_object_string_add(json_no
, "malformedAddressOrName", ip_str
);
11523 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11524 json_object_free(json_no
);
11527 vty_out (vty
, "%% Malformed address or name: %s%s", ip_str
, VTY_NEWLINE
);
11534 /* Peer structure lookup. */
11535 peer
= peer_lookup (bgp
, &su
);
11540 json_object
*json_no
= NULL
;
11541 json_no
= json_object_new_object();
11542 json_object_string_add(json_no
, "warning","No such neighbor");
11543 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
11544 json_object_free(json_no
);
11547 vty_out (vty
, "No such neighbor%s", VTY_NEWLINE
);
11556 BGP_STATS_MAXBITLEN
= 0,
11558 BGP_STATS_PREFIXES
,
11560 BGP_STATS_UNAGGREGATEABLE
,
11561 BGP_STATS_MAX_AGGREGATEABLE
,
11562 BGP_STATS_AGGREGATES
,
11564 BGP_STATS_ASPATH_COUNT
,
11565 BGP_STATS_ASPATH_MAXHOPS
,
11566 BGP_STATS_ASPATH_TOTHOPS
,
11567 BGP_STATS_ASPATH_MAXSIZE
,
11568 BGP_STATS_ASPATH_TOTSIZE
,
11569 BGP_STATS_ASN_HIGHEST
,
11573 static const char *table_stats_strs
[] =
11575 [BGP_STATS_PREFIXES
] = "Total Prefixes",
11576 [BGP_STATS_TOTPLEN
] = "Average prefix length",
11577 [BGP_STATS_RIB
] = "Total Advertisements",
11578 [BGP_STATS_UNAGGREGATEABLE
] = "Unaggregateable prefixes",
11579 [BGP_STATS_MAX_AGGREGATEABLE
] = "Maximum aggregateable prefixes",
11580 [BGP_STATS_AGGREGATES
] = "BGP Aggregate advertisements",
11581 [BGP_STATS_SPACE
] = "Address space advertised",
11582 [BGP_STATS_ASPATH_COUNT
] = "Advertisements with paths",
11583 [BGP_STATS_ASPATH_MAXHOPS
] = "Longest AS-Path (hops)",
11584 [BGP_STATS_ASPATH_MAXSIZE
] = "Largest AS-Path (bytes)",
11585 [BGP_STATS_ASPATH_TOTHOPS
] = "Average AS-Path length (hops)",
11586 [BGP_STATS_ASPATH_TOTSIZE
] = "Average AS-Path size (bytes)",
11587 [BGP_STATS_ASN_HIGHEST
] = "Highest public ASN",
11588 [BGP_STATS_MAX
] = NULL
,
11591 struct bgp_table_stats
11593 struct bgp_table
*table
;
11594 unsigned long long counts
[BGP_STATS_MAX
];
11598 #define TALLY_SIGFIG 100000
11599 static unsigned long
11600 ravg_tally (unsigned long count
, unsigned long oldavg
, unsigned long newval
)
11602 unsigned long newtot
= (count
-1) * oldavg
+ (newval
* TALLY_SIGFIG
);
11603 unsigned long res
= (newtot
* TALLY_SIGFIG
) / count
;
11604 unsigned long ret
= newtot
/ count
;
11606 if ((res
% TALLY_SIGFIG
) > (TALLY_SIGFIG
/2))
11614 bgp_table_stats_walker (struct thread
*t
)
11616 struct bgp_node
*rn
;
11617 struct bgp_node
*top
;
11618 struct bgp_table_stats
*ts
= THREAD_ARG (t
);
11619 unsigned int space
= 0;
11621 if (!(top
= bgp_table_top (ts
->table
)))
11624 switch (top
->p
.family
)
11627 space
= IPV4_MAX_BITLEN
;
11630 space
= IPV6_MAX_BITLEN
;
11634 ts
->counts
[BGP_STATS_MAXBITLEN
] = space
;
11636 for (rn
= top
; rn
; rn
= bgp_route_next (rn
))
11638 struct bgp_info
*ri
;
11639 struct bgp_node
*prn
= bgp_node_parent_nolock (rn
);
11640 unsigned int rinum
= 0;
11648 ts
->counts
[BGP_STATS_PREFIXES
]++;
11649 ts
->counts
[BGP_STATS_TOTPLEN
] += rn
->p
.prefixlen
;
11652 ts
->counts
[BGP_STATS_AVGPLEN
]
11653 = ravg_tally (ts
->counts
[BGP_STATS_PREFIXES
],
11654 ts
->counts
[BGP_STATS_AVGPLEN
],
11658 /* check if the prefix is included by any other announcements */
11659 while (prn
&& !prn
->info
)
11660 prn
= bgp_node_parent_nolock (prn
);
11662 if (prn
== NULL
|| prn
== top
)
11664 ts
->counts
[BGP_STATS_UNAGGREGATEABLE
]++;
11665 /* announced address space */
11667 ts
->counts
[BGP_STATS_SPACE
] += 1 << (space
- rn
->p
.prefixlen
);
11669 else if (prn
->info
)
11670 ts
->counts
[BGP_STATS_MAX_AGGREGATEABLE
]++;
11672 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11675 ts
->counts
[BGP_STATS_RIB
]++;
11678 (CHECK_FLAG (ri
->attr
->flag
,
11679 ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE
))))
11680 ts
->counts
[BGP_STATS_AGGREGATES
]++;
11682 /* as-path stats */
11683 if (ri
->attr
&& ri
->attr
->aspath
)
11685 unsigned int hops
= aspath_count_hops (ri
->attr
->aspath
);
11686 unsigned int size
= aspath_size (ri
->attr
->aspath
);
11687 as_t highest
= aspath_highest (ri
->attr
->aspath
);
11689 ts
->counts
[BGP_STATS_ASPATH_COUNT
]++;
11691 if (hops
> ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
])
11692 ts
->counts
[BGP_STATS_ASPATH_MAXHOPS
] = hops
;
11694 if (size
> ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
])
11695 ts
->counts
[BGP_STATS_ASPATH_MAXSIZE
] = size
;
11697 ts
->counts
[BGP_STATS_ASPATH_TOTHOPS
] += hops
;
11698 ts
->counts
[BGP_STATS_ASPATH_TOTSIZE
] += size
;
11700 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
]
11701 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11702 ts
->counts
[BGP_STATS_ASPATH_AVGHOPS
],
11704 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
]
11705 = ravg_tally (ts
->counts
[BGP_STATS_ASPATH_COUNT
],
11706 ts
->counts
[BGP_STATS_ASPATH_AVGSIZE
],
11709 if (highest
> ts
->counts
[BGP_STATS_ASN_HIGHEST
])
11710 ts
->counts
[BGP_STATS_ASN_HIGHEST
] = highest
;
11718 bgp_table_stats (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
)
11720 struct bgp_table_stats ts
;
11723 if (!bgp
->rib
[afi
][safi
])
11725 vty_out (vty
, "%% No RIB exists for the AFI(%d)/SAFI(%d)%s",
11726 afi
, safi
, VTY_NEWLINE
);
11727 return CMD_WARNING
;
11730 memset (&ts
, 0, sizeof (ts
));
11731 ts
.table
= bgp
->rib
[afi
][safi
];
11732 thread_execute (bm
->master
, bgp_table_stats_walker
, &ts
, 0);
11734 vty_out (vty
, "BGP %s RIB statistics%s%s",
11735 afi_safi_print (afi
, safi
), VTY_NEWLINE
, VTY_NEWLINE
);
11737 for (i
= 0; i
< BGP_STATS_MAX
; i
++)
11739 if (!table_stats_strs
[i
])
11745 case BGP_STATS_ASPATH_AVGHOPS
:
11746 case BGP_STATS_ASPATH_AVGSIZE
:
11747 case BGP_STATS_AVGPLEN
:
11748 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11749 vty_out (vty
, "%12.2f",
11750 (float)ts
.counts
[i
] / (float)TALLY_SIGFIG
);
11753 case BGP_STATS_ASPATH_TOTHOPS
:
11754 case BGP_STATS_ASPATH_TOTSIZE
:
11755 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11756 vty_out (vty
, "%12.2f",
11758 (float)ts
.counts
[i
] /
11759 (float)ts
.counts
[BGP_STATS_ASPATH_COUNT
]
11762 case BGP_STATS_TOTPLEN
:
11763 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11764 vty_out (vty
, "%12.2f",
11766 (float)ts
.counts
[i
] /
11767 (float)ts
.counts
[BGP_STATS_PREFIXES
]
11770 case BGP_STATS_SPACE
:
11771 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11772 vty_out (vty
, "%12llu%s", ts
.counts
[i
], VTY_NEWLINE
);
11773 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 9)
11775 vty_out (vty
, "%30s: ", "%% announced ");
11776 vty_out (vty
, "%12.2f%s",
11777 100 * (float)ts
.counts
[BGP_STATS_SPACE
] /
11778 (float)((uint64_t)1UL << ts
.counts
[BGP_STATS_MAXBITLEN
]),
11780 vty_out (vty
, "%30s: ", "/8 equivalent ");
11781 vty_out (vty
, "%12.2f%s",
11782 (float)ts
.counts
[BGP_STATS_SPACE
] /
11783 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 8)),
11785 if (ts
.counts
[BGP_STATS_MAXBITLEN
] < 25)
11787 vty_out (vty
, "%30s: ", "/24 equivalent ");
11788 vty_out (vty
, "%12.2f",
11789 (float)ts
.counts
[BGP_STATS_SPACE
] /
11790 (float)(1UL << (ts
.counts
[BGP_STATS_MAXBITLEN
] - 24)));
11793 vty_out (vty
, "%-30s: ", table_stats_strs
[i
]);
11794 vty_out (vty
, "%12llu", ts
.counts
[i
]);
11797 vty_out (vty
, "%s", VTY_NEWLINE
);
11799 return CMD_SUCCESS
;
11803 bgp_table_stats_vty (struct vty
*vty
, const char *name
,
11804 const char *afi_str
, const char *safi_str
)
11811 bgp
= bgp_lookup_by_name (name
);
11813 bgp
= bgp_get_default ();
11817 vty_out (vty
, "%% No such BGP instance exists%s", VTY_NEWLINE
);
11818 return CMD_WARNING
;
11820 afi
= bgp_vty_afi_from_arg(afi_str
);
11821 if (afi
== AFI_MAX
)
11823 vty_out (vty
, "%% Invalid address family \"%s\"%s",
11824 afi_str
, VTY_NEWLINE
);
11825 return CMD_WARNING
;
11827 safi
= bgp_vty_safi_from_arg(safi_str
);
11828 if (safi
== SAFI_MAX
)
11830 vty_out (vty
, "%% Invalid subsequent address family %s%s",
11831 safi_str
, VTY_NEWLINE
);
11832 return CMD_WARNING
;
11835 return bgp_table_stats (vty
, bgp
, afi
, safi
);
11838 DEFUN (show_bgp_statistics
,
11839 show_bgp_statistics_cmd
,
11840 "show bgp "BGP_AFI_SAFI_CMD_STR
" statistics",
11843 BGP_INSTANCE_HELP_STR
11844 "BGP RIB advertisement statistics\n")
11846 return bgp_table_stats_vty (vty
, NULL
, argv
[0], argv
[1]);
11849 DEFUN (show_bgp_statistics_view
,
11850 show_bgp_statistics_view_cmd
,
11851 "show bgp " BGP_INSTANCE_CMD
" "BGP_AFI_SAFI_CMD_STR
" statistics",
11854 BGP_INSTANCE_HELP_STR
11855 BGP_AFI_SAFI_HELP_STR
11856 "BGP RIB advertisement statistics\n")
11858 return bgp_table_stats_vty (vty
, NULL
, argv
[1], argv
[2]);
11871 PCOUNT_PFCNT
, /* the figure we display to users */
11875 static const char *pcount_strs
[] =
11877 [PCOUNT_ADJ_IN
] = "Adj-in",
11878 [PCOUNT_DAMPED
] = "Damped",
11879 [PCOUNT_REMOVED
] = "Removed",
11880 [PCOUNT_HISTORY
] = "History",
11881 [PCOUNT_STALE
] = "Stale",
11882 [PCOUNT_VALID
] = "Valid",
11883 [PCOUNT_ALL
] = "All RIB",
11884 [PCOUNT_COUNTED
] = "PfxCt counted",
11885 [PCOUNT_PFCNT
] = "Useable",
11886 [PCOUNT_MAX
] = NULL
,
11889 struct peer_pcounts
11891 unsigned int count
[PCOUNT_MAX
];
11892 const struct peer
*peer
;
11893 const struct bgp_table
*table
;
11897 bgp_peer_count_walker (struct thread
*t
)
11899 struct bgp_node
*rn
;
11900 struct peer_pcounts
*pc
= THREAD_ARG (t
);
11901 const struct peer
*peer
= pc
->peer
;
11903 for (rn
= bgp_table_top (pc
->table
); rn
; rn
= bgp_route_next (rn
))
11905 struct bgp_adj_in
*ain
;
11906 struct bgp_info
*ri
;
11908 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
11909 if (ain
->peer
== peer
)
11910 pc
->count
[PCOUNT_ADJ_IN
]++;
11912 for (ri
= rn
->info
; ri
; ri
= ri
->next
)
11914 char buf
[SU_ADDRSTRLEN
];
11916 if (ri
->peer
!= peer
)
11919 pc
->count
[PCOUNT_ALL
]++;
11921 if (CHECK_FLAG (ri
->flags
, BGP_INFO_DAMPED
))
11922 pc
->count
[PCOUNT_DAMPED
]++;
11923 if (CHECK_FLAG (ri
->flags
, BGP_INFO_HISTORY
))
11924 pc
->count
[PCOUNT_HISTORY
]++;
11925 if (CHECK_FLAG (ri
->flags
, BGP_INFO_REMOVED
))
11926 pc
->count
[PCOUNT_REMOVED
]++;
11927 if (CHECK_FLAG (ri
->flags
, BGP_INFO_STALE
))
11928 pc
->count
[PCOUNT_STALE
]++;
11929 if (CHECK_FLAG (ri
->flags
, BGP_INFO_VALID
))
11930 pc
->count
[PCOUNT_VALID
]++;
11931 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11932 pc
->count
[PCOUNT_PFCNT
]++;
11934 if (CHECK_FLAG (ri
->flags
, BGP_INFO_COUNTED
))
11936 pc
->count
[PCOUNT_COUNTED
]++;
11937 if (CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11938 zlog_warn ("%s [pcount] %s/%d is counted but flags 0x%x",
11940 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11941 buf
, SU_ADDRSTRLEN
),
11947 if (!CHECK_FLAG (ri
->flags
, BGP_INFO_UNUSEABLE
))
11948 zlog_warn ("%s [pcount] %s/%d not counted but flags 0x%x",
11950 inet_ntop(rn
->p
.family
, &rn
->p
.u
.prefix
,
11951 buf
, SU_ADDRSTRLEN
),
11961 bgp_peer_counts (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
, u_char use_json
)
11963 struct peer_pcounts pcounts
= { .peer
= peer
};
11965 json_object
*json
= NULL
;
11966 json_object
*json_loop
= NULL
;
11970 json
= json_object_new_object();
11971 json_loop
= json_object_new_object();
11974 if (!peer
|| !peer
->bgp
|| !peer
->afc
[afi
][safi
]
11975 || !peer
->bgp
->rib
[afi
][safi
])
11979 json_object_string_add(json
, "warning", "No such neighbor or address family");
11980 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
11981 json_object_free(json
);
11984 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
11986 return CMD_WARNING
;
11989 memset (&pcounts
, 0, sizeof(pcounts
));
11990 pcounts
.peer
= peer
;
11991 pcounts
.table
= peer
->bgp
->rib
[afi
][safi
];
11993 /* in-place call via thread subsystem so as to record execution time
11994 * * stats for the thread-walk (i.e. ensure this can't be blamed on
11995 * * on just vty_read()).
11997 thread_execute (bm
->master
, bgp_peer_count_walker
, &pcounts
, 0);
12001 json_object_string_add(json
, "prefixCountsFor", peer
->host
);
12002 json_object_string_add(json
, "multiProtocol", afi_safi_print (afi
, safi
));
12003 json_object_int_add(json
, "pfxCounter", peer
->pcount
[afi
][safi
]);
12005 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12006 json_object_int_add(json_loop
, pcount_strs
[i
], pcounts
.count
[i
]);
12008 json_object_object_add(json
, "ribTableWalkCounters", json_loop
);
12010 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12012 json_object_string_add(json
, "pfxctDriftFor", peer
->host
);
12013 json_object_string_add(json
, "recommended", "Please report this bug, with the above command output");
12015 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12016 json_object_free(json
);
12021 if (peer
->hostname
&& bgp_flag_check(peer
->bgp
, BGP_FLAG_SHOW_HOSTNAME
))
12023 vty_out (vty
, "Prefix counts for %s/%s, %s%s",
12024 peer
->hostname
, peer
->host
, afi_safi_print (afi
, safi
),
12029 vty_out (vty
, "Prefix counts for %s, %s%s",
12030 peer
->host
, afi_safi_print (afi
, safi
), VTY_NEWLINE
);
12033 vty_out (vty
, "PfxCt: %ld%s", peer
->pcount
[afi
][safi
], VTY_NEWLINE
);
12034 vty_out (vty
, "%sCounts from RIB table walk:%s%s",
12035 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
12037 for (i
= 0; i
< PCOUNT_MAX
; i
++)
12038 vty_out (vty
, "%20s: %-10d%s", pcount_strs
[i
], pcounts
.count
[i
], VTY_NEWLINE
);
12040 if (pcounts
.count
[PCOUNT_PFCNT
] != peer
->pcount
[afi
][safi
])
12042 vty_out (vty
, "%s [pcount] PfxCt drift!%s",
12043 peer
->host
, VTY_NEWLINE
);
12044 vty_out (vty
, "Please report this bug, with the above command output%s",
12049 return CMD_SUCCESS
;
12052 DEFUN (show_ip_bgp_neighbor_prefix_counts
,
12053 show_ip_bgp_neighbor_prefix_counts_cmd
,
12054 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12058 "Detailed information on TCP and BGP neighbor connections\n"
12059 "Neighbor to display information about\n"
12060 "Neighbor to display information about\n"
12061 "Neighbor on bgp configured interface\n"
12062 "Display detailed prefix count information\n"
12063 "JavaScript Object Notation\n")
12066 u_char uj
= use_json(argc
, argv
);
12068 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12070 return CMD_WARNING
;
12072 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12075 DEFUN (show_ip_bgp_instance_neighbor_prefix_counts
,
12076 show_ip_bgp_instance_neighbor_prefix_counts_cmd
,
12077 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12081 BGP_INSTANCE_HELP_STR
12082 "Detailed information on TCP and BGP neighbor connections\n"
12083 "Neighbor to display information about\n"
12084 "Neighbor to display information about\n"
12085 "Neighbor on bgp configured interface\n"
12086 "Display detailed prefix count information\n"
12087 "JavaScript Object Notation\n")
12090 u_char uj
= use_json(argc
, argv
);
12092 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12094 return CMD_WARNING
;
12096 return bgp_peer_counts (vty
, peer
, AFI_IP
, SAFI_UNICAST
, uj
);
12099 DEFUN (show_bgp_ipv6_neighbor_prefix_counts
,
12100 show_bgp_ipv6_neighbor_prefix_counts_cmd
,
12101 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12105 "Detailed information on TCP and BGP neighbor connections\n"
12106 "Neighbor to display information about\n"
12107 "Neighbor to display information about\n"
12108 "Neighbor on bgp configured interface\n"
12109 "Display detailed prefix count information\n"
12110 "JavaScript Object Notation\n")
12113 u_char uj
= use_json(argc
, argv
);
12115 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12117 return CMD_WARNING
;
12119 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12122 DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts
,
12123 show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
,
12124 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12127 BGP_INSTANCE_HELP_STR
12129 "Detailed information on TCP and BGP neighbor connections\n"
12130 "Neighbor to display information about\n"
12131 "Neighbor to display information about\n"
12132 "Neighbor on bgp configured interface\n"
12133 "Display detailed prefix count information\n"
12134 "JavaScript Object Notation\n")
12137 u_char uj
= use_json(argc
, argv
);
12139 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12141 return CMD_WARNING
;
12143 return bgp_peer_counts (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, uj
);
12146 DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts
,
12147 show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
,
12148 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
12154 "Detailed information on TCP and BGP neighbor connections\n"
12155 "Neighbor to display information about\n"
12156 "Neighbor to display information about\n"
12157 "Neighbor on bgp configured interface\n"
12158 "Display detailed prefix count information\n"
12159 "JavaScript Object Notation\n")
12162 u_char uj
= use_json(argc
, argv
);
12164 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12166 return CMD_WARNING
;
12169 safi
= bgp_vty_safi_from_arg(argv
[0]);
12170 return bgp_peer_counts (vty
, peer
, AFI_IP
, safi
, uj
);
12174 show_adj_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12175 int in
, const char *rmap_name
, u_char use_json
, json_object
*json
)
12177 struct bgp_table
*table
;
12178 struct bgp_adj_in
*ain
;
12179 struct bgp_adj_out
*adj
;
12180 unsigned long output_count
;
12181 unsigned long filtered_count
;
12182 struct bgp_node
*rn
;
12187 struct attr_extra extra
;
12189 struct update_subgroup
*subgrp
;
12190 json_object
*json_scode
= NULL
;
12191 json_object
*json_ocode
= NULL
;
12192 json_object
*json_ar
= NULL
;
12193 struct peer_af
*paf
;
12197 json_scode
= json_object_new_object();
12198 json_ocode
= json_object_new_object();
12199 json_ar
= json_object_new_object();
12201 json_object_string_add(json_scode
, "suppressed", "s");
12202 json_object_string_add(json_scode
, "damped", "d");
12203 json_object_string_add(json_scode
, "history", "h");
12204 json_object_string_add(json_scode
, "valid", "*");
12205 json_object_string_add(json_scode
, "best", ">");
12206 json_object_string_add(json_scode
, "multipath", "=");
12207 json_object_string_add(json_scode
, "internal", "i");
12208 json_object_string_add(json_scode
, "ribFailure", "r");
12209 json_object_string_add(json_scode
, "stale", "S");
12210 json_object_string_add(json_scode
, "removed", "R");
12212 json_object_string_add(json_ocode
, "igp", "i");
12213 json_object_string_add(json_ocode
, "egp", "e");
12214 json_object_string_add(json_ocode
, "incomplete", "?");
12223 json_object_string_add(json
, "alert", "no BGP");
12224 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12225 json_object_free(json
);
12228 vty_out (vty
, "%% No bgp%s", VTY_NEWLINE
);
12232 table
= bgp
->rib
[afi
][safi
];
12234 output_count
= filtered_count
= 0;
12235 subgrp
= peer_subgroup(peer
, afi
, safi
);
12237 if (!in
&& subgrp
&& CHECK_FLAG (subgrp
->sflags
, SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12241 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12242 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12243 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12244 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12245 json_object_string_add(json
, "bgpOriginatingDefaultNetwork", "0.0.0.0");
12249 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
, inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12250 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12251 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12253 vty_out (vty
, "Originating default network 0.0.0.0%s%s",
12254 VTY_NEWLINE
, VTY_NEWLINE
);
12259 attr
.extra
= &extra
;
12260 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
12264 for (ain
= rn
->adj_in
; ain
; ain
= ain
->next
)
12266 if (ain
->peer
== peer
)
12272 json_object_int_add(json
, "bgpTableVersion", 0);
12273 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12274 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12275 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12279 vty_out (vty
, "BGP table version is 0, local router ID is %s%s", inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12280 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12281 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12288 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12293 bgp_attr_dup(&attr
, ain
->attr
);
12294 if (bgp_input_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
) != RMAP_DENY
)
12296 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12307 for (adj
= rn
->adj_out
; adj
; adj
= adj
->next
)
12308 SUBGRP_FOREACH_PEER(adj
->subgroup
, paf
)
12309 if (paf
->peer
== peer
)
12315 json_object_int_add(json
, "bgpTableVersion", table
->version
);
12316 json_object_string_add(json
, "bgpLocalRouterId", inet_ntoa (bgp
->router_id
));
12317 json_object_object_add(json
, "bgpStatusCodes", json_scode
);
12318 json_object_object_add(json
, "bgpOriginCodes", json_ocode
);
12322 vty_out (vty
, "BGP table version is %" PRIu64
", local router ID is %s%s", table
->version
,
12323 inet_ntoa (bgp
->router_id
), VTY_NEWLINE
);
12324 vty_out (vty
, BGP_SHOW_SCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12325 vty_out (vty
, BGP_SHOW_OCODE_HEADER
, VTY_NEWLINE
, VTY_NEWLINE
);
12333 vty_out (vty
, BGP_SHOW_HEADER
, VTY_NEWLINE
);
12339 bgp_attr_dup(&attr
, adj
->attr
);
12340 ret
= bgp_output_modifier(peer
, &rn
->p
, &attr
, afi
, safi
, rmap_name
);
12341 if (ret
!= RMAP_DENY
)
12343 route_vty_out_tmp (vty
, &rn
->p
, &attr
, safi
, use_json
, json_ar
);
12353 json_object_object_add(json
, "advertisedRoutes", json_ar
);
12355 if (output_count
!= 0)
12358 json_object_int_add(json
, "totalPrefixCounter", output_count
);
12360 vty_out (vty
, "%sTotal number of prefixes %ld%s",
12361 VTY_NEWLINE
, output_count
, VTY_NEWLINE
);
12365 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12366 json_object_free(json
);
12372 peer_adj_routes (struct vty
*vty
, struct peer
*peer
, afi_t afi
, safi_t safi
,
12373 int in
, const char *rmap_name
, u_char use_json
)
12375 json_object
*json
= NULL
;
12378 json
= json_object_new_object();
12380 if (!peer
|| !peer
->afc
[afi
][safi
])
12384 json_object_string_add(json
, "warning", "No such neighbor or address family");
12385 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12386 json_object_free(json
);
12389 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
12391 return CMD_WARNING
;
12394 if (in
&& !CHECK_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12398 json_object_string_add(json
, "warning", "Inbound soft reconfiguration not enabled");
12399 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
12400 json_object_free(json
);
12403 vty_out (vty
, "%% Inbound soft reconfiguration not enabled%s", VTY_NEWLINE
);
12405 return CMD_WARNING
;
12408 show_adj_route (vty
, peer
, afi
, safi
, in
, rmap_name
, use_json
, json
);
12410 return CMD_SUCCESS
;
12413 DEFUN (show_ip_bgp_instance_neighbor_advertised_route
,
12414 show_ip_bgp_instance_neighbor_advertised_route_cmd
,
12415 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12419 BGP_INSTANCE_HELP_STR
12420 "Detailed information on TCP and BGP neighbor connections\n"
12421 "Neighbor to display information about\n"
12422 "Neighbor to display information about\n"
12423 "Display the routes advertised to a BGP neighbor\n"
12424 "JavaScript Object Notation\n")
12427 u_char uj
= use_json(argc
, argv
);
12429 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12430 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12432 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12435 return CMD_WARNING
;
12437 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, NULL
, uj
);
12440 DEFUN (show_ip_bgp_neighbor_advertised_route
,
12441 show_ip_bgp_neighbor_advertised_route_cmd
,
12442 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12446 "Detailed information on TCP and BGP neighbor connections\n"
12447 "Neighbor to display information about\n"
12448 "Neighbor to display information about\n"
12449 "Neighbor on bgp configured interface\n"
12450 "Display the routes advertised to a BGP neighbor\n"
12451 "JavaScript Object Notation\n")
12455 const char *rmap_name
= NULL
;
12456 u_char uj
= use_json(argc
, argv
);
12458 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12461 return CMD_WARNING
;
12463 if ((argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0)
12465 rmap_name
= argv
[1];
12467 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12470 ALIAS (show_ip_bgp_neighbor_advertised_route
,
12471 show_ip_bgp_neighbor_advertised_route_rmap_cmd
,
12472 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12476 "Detailed information on TCP and BGP neighbor connections\n"
12477 "Neighbor to display information about\n"
12478 "Neighbor to display information about\n"
12479 "Neighbor on bgp configured interface\n"
12480 "Display the routes advertised to a BGP neighbor\n"
12481 "JavaScript Object Notation\n")
12483 ALIAS (show_ip_bgp_instance_neighbor_advertised_route
,
12484 show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
,
12485 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12489 BGP_INSTANCE_HELP_STR
12490 "Detailed information on TCP and BGP neighbor connections\n"
12491 "Neighbor to display information about\n"
12492 "Neighbor to display information about\n"
12493 "Neighbor on bgp configured interface\n"
12494 "Display the routes advertised to a BGP neighbor\n"
12495 "JavaScript Object Notation\n")
12496 DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route
,
12497 show_ip_bgp_ipv4_neighbor_advertised_route_cmd
,
12498 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12504 "Detailed information on TCP and BGP neighbor connections\n"
12505 "Neighbor to display information about\n"
12506 "Neighbor to display information about\n"
12507 "Neighbor on bgp configured interface\n"
12508 "Display the routes advertised to a BGP neighbor\n"
12509 "JavaScript Object Notation\n")
12512 const char *rmap_name
= NULL
;
12515 u_char uj
= use_json(argc
, argv
);
12517 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12519 return CMD_WARNING
;
12521 if ((argc
== 4) || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12522 rmap_name
= argv
[2];
12524 safi
= bgp_vty_safi_from_arg(argv
[0]);
12525 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 0, rmap_name
, uj
);
12528 ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route
,
12529 show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
,
12530 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}",
12536 "Detailed information on TCP and BGP neighbor connections\n"
12537 "Neighbor to display information about\n"
12538 "Neighbor to display information about\n"
12539 "Neighbor on bgp configured interface\n"
12540 "Display the routes advertised to a BGP neighbor\n"
12541 "Route-map to control what is displayed\n"
12542 "JavaScript Object Notation\n")
12545 DEFUN (show_bgp_instance_neighbor_advertised_route
,
12546 show_bgp_instance_neighbor_advertised_route_cmd
,
12547 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12550 BGP_INSTANCE_HELP_STR
12551 "Detailed information on TCP and BGP neighbor connections\n"
12552 "Neighbor to display information about\n"
12553 "Neighbor to display information about\n"
12554 "Neighbor on bgp configured interface\n"
12555 "Display the routes advertised to a BGP neighbor\n"
12556 "JavaScript Object Notation\n")
12559 u_char uj
= use_json(argc
, argv
);
12561 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12562 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12564 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12567 return CMD_WARNING
;
12569 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, NULL
, uj
);
12572 ALIAS (show_bgp_instance_neighbor_advertised_route
,
12573 show_bgp_instance_ipv6_neighbor_advertised_route_cmd
,
12574 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12577 BGP_INSTANCE_HELP_STR
12579 "Detailed information on TCP and BGP neighbor connections\n"
12580 "Neighbor to display information about\n"
12581 "Neighbor to display information about\n"
12582 "Neighbor on bgp configured interface\n"
12583 "Display the routes advertised to a BGP neighbor\n"
12584 "JavaScript Object Notation\n")
12586 DEFUN (show_bgp_neighbor_advertised_route
,
12587 show_bgp_neighbor_advertised_route_cmd
,
12588 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12591 "Detailed information on TCP and BGP neighbor connections\n"
12592 "Neighbor to display information about\n"
12593 "Neighbor to display information about\n"
12594 "Neighbor on bgp configured interface\n"
12595 "Display the routes advertised to a BGP neighbor\n"
12596 "JavaScript Object Notation\n")
12600 const char *rmap_name
= NULL
;
12601 u_char uj
= use_json(argc
, argv
);
12603 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12606 return CMD_WARNING
;
12608 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12609 rmap_name
= argv
[1];
12611 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 0, rmap_name
, uj
);
12614 ALIAS (show_bgp_neighbor_advertised_route
,
12615 show_bgp_ipv6_neighbor_advertised_route_cmd
,
12616 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12620 "Detailed information on TCP and BGP neighbor connections\n"
12621 "Neighbor to display information about\n"
12622 "Neighbor to display information about\n"
12623 "Neighbor on bgp configured interface\n"
12624 "Display the routes advertised to a BGP neighbor\n"
12625 "JavaScript Object Notation\n")
12628 ALIAS (show_bgp_neighbor_advertised_route
,
12629 ipv6_bgp_neighbor_advertised_route_cmd
,
12630 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12634 "Detailed information on TCP and BGP neighbor connections\n"
12635 "Neighbor to display information about\n"
12636 "Neighbor to display information about\n"
12637 "Neighbor on bgp configured interface\n"
12638 "Display the routes advertised to a BGP neighbor\n"
12639 "JavaScript Object Notation\n")
12642 DEFUN (ipv6_mbgp_neighbor_advertised_route
,
12643 ipv6_mbgp_neighbor_advertised_route_cmd
,
12644 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}",
12648 "Detailed information on TCP and BGP neighbor connections\n"
12649 "Neighbor to display information about\n"
12650 "Neighbor to display information about\n"
12651 "Neighbor on bgp configured interface\n"
12652 "Neighbor on bgp configured interface\n"
12653 "Display the routes advertised to a BGP neighbor\n"
12654 "JavaScript Object Notation\n")
12657 u_char uj
= use_json(argc
, argv
);
12659 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12661 return CMD_WARNING
;
12663 bgp_show_ipv6_bgp_deprecate_warning(vty
);
12664 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 0, NULL
, uj
);
12666 #endif /* HAVE_IPV6 */
12668 DEFUN (show_bgp_instance_neighbor_received_routes
,
12669 show_bgp_instance_neighbor_received_routes_cmd
,
12670 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12673 BGP_INSTANCE_HELP_STR
12674 "Detailed information on TCP and BGP neighbor connections\n"
12675 "Neighbor to display information about\n"
12676 "Neighbor to display information about\n"
12677 "Neighbor on bgp configured interface\n"
12678 "Display the received routes from neighbor\n"
12679 "JavaScript Object Notation\n")
12682 u_char uj
= use_json(argc
, argv
);
12684 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12686 return CMD_WARNING
;
12688 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, NULL
, uj
);
12691 DEFUN (show_ip_bgp_instance_neighbor_received_routes
,
12692 show_ip_bgp_instance_neighbor_received_routes_cmd
,
12693 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12697 BGP_INSTANCE_HELP_STR
12698 "Detailed information on TCP and BGP neighbor connections\n"
12699 "Neighbor to display information about\n"
12700 "Neighbor to display information about\n"
12701 "Neighbor on bgp configured interface\n"
12702 "Display the received routes from neighbor\n"
12703 "JavaScript Object Notation\n")
12706 u_char uj
= use_json(argc
, argv
);
12708 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
12710 return CMD_WARNING
;
12712 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, NULL
, uj
);
12715 ALIAS (show_bgp_instance_neighbor_received_routes
,
12716 show_bgp_instance_ipv6_neighbor_received_routes_cmd
,
12717 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12720 BGP_INSTANCE_HELP_STR
12722 "Detailed information on TCP and BGP neighbor connections\n"
12723 "Neighbor to display information about\n"
12724 "Neighbor to display information about\n"
12725 "Neighbor on bgp configured interface\n"
12726 "Display the received routes from neighbor\n"
12727 "JavaScript Object Notation\n")
12729 DEFUN (show_ip_bgp_neighbor_received_routes
,
12730 show_ip_bgp_neighbor_received_routes_cmd
,
12731 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12735 "Detailed information on TCP and BGP neighbor connections\n"
12736 "Neighbor to display information about\n"
12737 "Neighbor to display information about\n"
12738 "Neighbor on bgp configured interface\n"
12739 "Display the received routes from neighbor\n"
12740 "JavaScript Object Notation\n")
12744 const char *rmap_name
= NULL
;
12745 u_char uj
= use_json(argc
, argv
);
12747 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
12750 return CMD_WARNING
;
12752 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
12753 rmap_name
= argv
[1];
12755 return peer_adj_routes (vty
, peer
, AFI_IP
, SAFI_UNICAST
, 1, rmap_name
, uj
);
12758 ALIAS (show_ip_bgp_neighbor_received_routes
,
12759 show_ip_bgp_neighbor_received_routes_rmap_cmd
,
12760 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12764 "Detailed information on TCP and BGP neighbor connections\n"
12765 "Neighbor to display information about\n"
12766 "Neighbor to display information about\n"
12767 "Neighbor on bgp configured interface\n"
12768 "Display the received routes from neighbor\n"
12769 "JavaScript Object Notation\n")
12771 ALIAS (show_ip_bgp_instance_neighbor_received_routes
,
12772 show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
,
12773 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12777 BGP_INSTANCE_HELP_STR
12778 "Detailed information on TCP and BGP neighbor connections\n"
12779 "Neighbor to display information about\n"
12780 "Neighbor to display information about\n"
12781 "Neighbor on bgp configured interface\n"
12782 "Display the received routes from neighbor\n"
12783 "JavaScript Object Notation\n")
12785 DEFUN (show_ip_bgp_ipv4_neighbor_received_routes
,
12786 show_ip_bgp_ipv4_neighbor_received_routes_cmd
,
12787 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
12793 "Detailed information on TCP and BGP neighbor connections\n"
12794 "Neighbor to display information about\n"
12795 "Neighbor to display information about\n"
12796 "Neighbor on bgp configured interface\n"
12797 "Display the received routes from neighbor\n"
12798 "JavaScript Object Notation\n")
12801 const char *rmap_name
= NULL
;
12803 u_char uj
= use_json(argc
, argv
);
12805 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
12807 return CMD_WARNING
;
12809 if (argc
== 4 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
12810 rmap_name
= argv
[2];
12812 safi
= bgp_vty_safi_from_arg(argv
[0]);
12813 return peer_adj_routes (vty
, peer
, AFI_IP
, safi
, 1, rmap_name
, uj
);
12816 ALIAS (show_ip_bgp_ipv4_neighbor_received_routes
,
12817 show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
,
12818 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}",
12824 "Detailed information on TCP and BGP neighbor connections\n"
12825 "Neighbor to display information about\n"
12826 "Neighbor to display information about\n"
12827 "Neighbor on bgp configured interface\n"
12828 "Display the received routes from neighbor\n"
12829 "JavaScript Object Notation\n")
12831 DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes
,
12832 show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
,
12833 "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}",
12836 BGP_INSTANCE_HELP_STR
12837 BGP_AFI_SAFI_HELP_STR
12838 "Detailed information on TCP and BGP neighbor connections\n"
12839 "Neighbor to display information about\n"
12840 "Neighbor to display information about\n"
12841 "Neighbor on bgp configured interface\n"
12842 "Display the advertised routes to neighbor\n"
12843 "Display the received routes from neighbor\n"
12844 "JavaScript Object Notation\n")
12850 u_char uj
= use_json(argc
, argv
);
12852 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[4], uj
);
12855 return CMD_WARNING
;
12857 afi
= bgp_vty_safi_from_arg(argv
[2]);
12858 safi
= bgp_vty_safi_from_arg(argv
[3]);
12859 in
= (strncmp (argv
[5], "r", 1) == 0) ? 1 : 0;
12861 return peer_adj_routes (vty
, peer
, afi
, safi
, in
, NULL
, uj
);
12864 DEFUN (show_ip_bgp_neighbor_received_prefix_filter
,
12865 show_ip_bgp_neighbor_received_prefix_filter_cmd
,
12866 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12870 "Detailed information on TCP and BGP neighbor connections\n"
12871 "Neighbor to display information about\n"
12872 "Neighbor to display information about\n"
12873 "Neighbor on bgp configured interface\n"
12874 "Display information received from a BGP neighbor\n"
12875 "Display the prefixlist filter\n"
12876 "JavaScript Object Notation\n")
12879 union sockunion su
;
12882 u_char uj
= use_json(argc
, argv
);
12884 ret
= str2sockunion (argv
[0], &su
);
12887 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
12892 json_object
*json_no
= NULL
;
12893 json_object
*json_sub
= NULL
;
12894 json_no
= json_object_new_object();
12895 json_sub
= json_object_new_object();
12896 json_object_string_add(json_no
, "warning", "Malformed address or name");
12897 json_object_string_add(json_sub
, "warningCause", argv
[0]);
12898 json_object_object_add(json_no
, "detail", json_sub
);
12899 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12900 json_object_free(json_no
);
12903 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
12904 return CMD_WARNING
;
12909 peer
= peer_lookup (NULL
, &su
);
12914 json_object
*json_no
= NULL
;
12915 json_no
= json_object_new_object();
12916 json_object_string_add(json_no
, "warning", "Peer not found");
12917 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12918 json_object_free(json_no
);
12921 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
12922 return CMD_WARNING
;
12926 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, SAFI_UNICAST
);
12927 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
12931 vty_out (vty
, "Address family: IPv4 Unicast%s", VTY_NEWLINE
);
12932 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
12938 json_object
*json_no
= NULL
;
12939 json_no
= json_object_new_object();
12940 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
12941 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12942 json_object_free(json_no
);
12945 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
12948 return CMD_SUCCESS
;
12951 DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter
,
12952 show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
,
12953 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
12959 "Detailed information on TCP and BGP neighbor connections\n"
12960 "Neighbor to display information about\n"
12961 "Neighbor to display information about\n"
12962 "Neighbor on bgp configured interface\n"
12963 "Display information received from a BGP neighbor\n"
12964 "Display the prefixlist filter\n"
12965 "JavaScript Object Notation\n")
12968 union sockunion su
;
12971 u_char uj
= use_json(argc
, argv
);
12973 ret
= str2sockunion (argv
[1], &su
);
12976 peer
= peer_lookup_by_conf_if (NULL
, argv
[1]);
12981 json_object
*json_no
= NULL
;
12982 json_object
*json_sub
= NULL
;
12983 json_no
= json_object_new_object();
12984 json_sub
= json_object_new_object();
12985 json_object_string_add(json_no
, "warning", "Malformed address or name");
12986 json_object_string_add(json_sub
, "warningCause", argv
[1]);
12987 json_object_object_add(json_no
, "detail", json_sub
);
12988 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
12989 json_object_free(json_no
);
12992 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[1], VTY_NEWLINE
);
12993 return CMD_WARNING
;
12998 peer
= peer_lookup (NULL
, &su
);
13003 json_object
*json_no
= NULL
;
13004 json_no
= json_object_new_object();
13005 json_object_string_add(json_no
, "warning", "Peer not found");
13006 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13007 json_object_free(json_no
);
13010 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13011 return CMD_WARNING
;
13017 safi
= bgp_vty_safi_from_arg(argv
[0]);
13018 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP
, safi
);
13019 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP
, name
, uj
);
13023 vty_out (vty
, "Address family: %s%s",
13024 afi_safi_print (AFI_IP
, safi
), VTY_NEWLINE
);
13025 prefix_bgp_show_prefix_list (vty
, AFI_IP
, name
, uj
);
13031 json_object
*json_no
= NULL
;
13032 json_no
= json_object_new_object();
13033 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13034 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13035 json_object_free(json_no
);
13038 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13042 return CMD_SUCCESS
;
13045 DEFUN (show_bgp_neighbor_received_routes
,
13046 show_bgp_neighbor_received_routes_cmd
,
13047 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13050 "Detailed information on TCP and BGP neighbor connections\n"
13051 "Neighbor to display information about\n"
13052 "Neighbor to display information about\n"
13053 "Neighbor on bgp configured interface\n"
13054 "Display the received routes from neighbor\n"
13055 "JavaScript Object Notation\n")
13058 const char *rmap_name
= NULL
;
13059 u_char uj
= use_json(argc
, argv
);
13061 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13064 return CMD_WARNING
;
13066 if (argc
== 3 || (argc
== 2 && argv
[1] && strcmp(argv
[1], "json") != 0))
13067 rmap_name
= argv
[1];
13069 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_UNICAST
, 1, rmap_name
, uj
);
13072 ALIAS (show_bgp_neighbor_received_routes
,
13073 show_bgp_ipv6_neighbor_received_routes_cmd
,
13074 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13078 "Detailed information on TCP and BGP neighbor connections\n"
13079 "Neighbor to display information about\n"
13080 "Neighbor to display information about\n"
13081 "Neighbor on bgp configured interface\n"
13082 "Display the received routes from neighbor\n"
13083 "JavaScript Object Notation\n")
13085 DEFUN (show_bgp_neighbor_received_prefix_filter
,
13086 show_bgp_neighbor_received_prefix_filter_cmd
,
13087 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13090 "Detailed information on TCP and BGP neighbor connections\n"
13091 "Neighbor to display information about\n"
13092 "Neighbor to display information about\n"
13093 "Neighbor on bgp configured interface\n"
13094 "Display information received from a BGP neighbor\n"
13095 "Display the prefixlist filter\n"
13096 "JavaScript Object Notation\n")
13099 union sockunion su
;
13102 u_char uj
= use_json(argc
, argv
);
13104 ret
= str2sockunion (argv
[0], &su
);
13107 peer
= peer_lookup_by_conf_if (NULL
, argv
[0]);
13112 json_object
*json_no
= NULL
;
13113 json_object
*json_sub
= NULL
;
13114 json_no
= json_object_new_object();
13115 json_sub
= json_object_new_object();
13116 json_object_string_add(json_no
, "warning", "Malformed address or name");
13117 json_object_string_add(json_sub
, "warningCause", argv
[0]);
13118 json_object_object_add(json_no
, "detail", json_sub
);
13119 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13120 json_object_free(json_no
);
13123 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[0], VTY_NEWLINE
);
13124 return CMD_WARNING
;
13129 peer
= peer_lookup (NULL
, &su
);
13134 json_object
*json_no
= NULL
;
13135 json_no
= json_object_new_object();
13136 json_object_string_add(json_no
, "warning", "No Peer");
13137 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13138 json_object_free(json_no
);
13141 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13142 return CMD_WARNING
;
13146 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13147 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13151 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13152 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13158 json_object
*json_no
= NULL
;
13159 json_no
= json_object_new_object();
13160 json_object_boolean_true_add(json_no
, "noFuntionalOutput");
13161 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13162 json_object_free(json_no
);
13165 vty_out (vty
, "No functional output%s", VTY_NEWLINE
);
13168 return CMD_SUCCESS
;
13171 ALIAS (show_bgp_neighbor_received_prefix_filter
,
13172 show_bgp_ipv6_neighbor_received_prefix_filter_cmd
,
13173 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13177 "Detailed information on TCP and BGP neighbor connections\n"
13178 "Neighbor to display information about\n"
13179 "Neighbor to display information about\n"
13180 "Neighbor on bgp configured interface\n"
13181 "Display information received from a BGP neighbor\n"
13182 "Display the prefixlist filter\n"
13183 "JavaScript Object Notation\n")
13186 ALIAS (show_bgp_neighbor_received_routes
,
13187 ipv6_bgp_neighbor_received_routes_cmd
,
13188 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13192 "Detailed information on TCP and BGP neighbor connections\n"
13193 "Neighbor to display information about\n"
13194 "Neighbor to display information about\n"
13195 "Neighbor on bgp configured interface\n"
13196 "Display the received routes from neighbor\n"
13197 "JavaScript Object Notation\n")
13200 DEFUN (ipv6_mbgp_neighbor_received_routes
,
13201 ipv6_mbgp_neighbor_received_routes_cmd
,
13202 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}",
13206 "Detailed information on TCP and BGP neighbor connections\n"
13207 "Neighbor to display information about\n"
13208 "Neighbor to display information about\n"
13209 "Neighbor on bgp configured interface\n"
13210 "Display the received routes from neighbor\n"
13211 "JavaScript Object Notation\n")
13214 u_char uj
= use_json(argc
, argv
);
13216 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13218 return CMD_WARNING
;
13220 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13221 return peer_adj_routes (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
, 1, NULL
, uj
);
13224 DEFUN (show_bgp_instance_neighbor_received_prefix_filter
,
13225 show_bgp_instance_neighbor_received_prefix_filter_cmd
,
13226 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13229 BGP_INSTANCE_HELP_STR
13230 "Detailed information on TCP and BGP neighbor connections\n"
13231 "Neighbor to display information about\n"
13232 "Neighbor to display information about\n"
13233 "Neighbor on bgp configured interface\n"
13234 "Display information received from a BGP neighbor\n"
13235 "Display the prefixlist filter\n"
13236 "JavaScript Object Notation\n")
13239 union sockunion su
;
13243 u_char uj
= use_json(argc
, argv
);
13245 /* BGP structure lookup. */
13246 bgp
= bgp_lookup_by_name (argv
[1]);
13251 json_object
*json_no
= NULL
;
13252 json_no
= json_object_new_object();
13253 json_object_string_add(json_no
, "warning", "Can't find BGP view");
13254 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13255 json_object_free(json_no
);
13258 vty_out (vty
, "Can't find BGP instance %s%s", argv
[1], VTY_NEWLINE
);
13259 return CMD_WARNING
;
13262 ret
= str2sockunion (argv
[2], &su
);
13265 peer
= peer_lookup_by_conf_if (bgp
, argv
[2]);
13270 json_object
*json_no
= NULL
;
13271 json_object
*json_sub
= NULL
;
13272 json_no
= json_object_new_object();
13273 json_sub
= json_object_new_object();
13274 json_object_string_add(json_no
, "warning", "Malformed address or name");
13275 json_object_string_add(json_sub
, "warningCause", argv
[2]);
13276 json_object_object_add(json_no
, "detail", json_sub
);
13277 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13278 json_object_free(json_no
);
13281 vty_out (vty
, "%% Malformed address or name: %s%s", argv
[2], VTY_NEWLINE
);
13282 return CMD_WARNING
;
13287 peer
= peer_lookup (bgp
, &su
);
13292 json_object
*json_no
= NULL
;
13293 json_no
= json_object_new_object();
13294 json_object_boolean_true_add(json_no
, "noPeer");
13295 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13296 json_object_free(json_no
);
13299 vty_out (vty
, "No peer%s", VTY_NEWLINE
);
13300 return CMD_WARNING
;
13305 sprintf (name
, "%s.%d.%d", peer
->host
, AFI_IP6
, SAFI_UNICAST
);
13306 count
= prefix_bgp_show_prefix_list (NULL
, AFI_IP6
, name
, uj
);
13310 vty_out (vty
, "Address family: IPv6 Unicast%s", VTY_NEWLINE
);
13311 prefix_bgp_show_prefix_list (vty
, AFI_IP6
, name
, uj
);
13314 return CMD_SUCCESS
;
13316 ALIAS (show_bgp_instance_neighbor_received_prefix_filter
,
13317 show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
,
13318 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}",
13321 BGP_INSTANCE_HELP_STR
13323 "Detailed information on TCP and BGP neighbor connections\n"
13324 "Neighbor to display information about\n"
13325 "Neighbor to display information about\n"
13326 "Neighbor on bgp configured interface\n"
13327 "Display information received from a BGP neighbor\n"
13328 "Display the prefixlist filter\n"
13329 "JavaScript Object NOtation\n")
13330 #endif /* HAVE_IPV6 */
13333 bgp_show_neighbor_route (struct vty
*vty
, struct peer
*peer
, afi_t afi
,
13334 safi_t safi
, enum bgp_show_type type
, u_char use_json
)
13336 if (! peer
|| ! peer
->afc
[afi
][safi
])
13340 json_object
*json_no
= NULL
;
13341 json_no
= json_object_new_object();
13342 json_object_string_add(json_no
, "warning", "No such neighbor or address family");
13343 vty_out (vty
, "%s%s", json_object_to_json_string(json_no
), VTY_NEWLINE
);
13344 json_object_free(json_no
);
13347 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
13348 return CMD_WARNING
;
13351 return bgp_show (vty
, peer
->bgp
, afi
, safi
, type
, &peer
->su
, use_json
);
13354 DEFUN (show_ip_bgp_neighbor_routes
,
13355 show_ip_bgp_neighbor_routes_cmd
,
13356 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13360 "Detailed information on TCP and BGP neighbor connections\n"
13361 "Neighbor to display information about\n"
13362 "Neighbor to display information about\n"
13363 "Neighbor on bgp configured interface\n"
13364 "Display routes learned from neighbor\n"
13365 "JavaScript Object Notation\n")
13368 u_char uj
= use_json(argc
, argv
);
13370 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13372 return CMD_WARNING
;
13374 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13375 bgp_show_type_neighbor
, uj
);
13378 DEFUN (show_ip_bgp_instance_neighbor_routes
,
13379 show_ip_bgp_instance_neighbor_routes_cmd
,
13380 "show ip bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13384 BGP_INSTANCE_HELP_STR
13385 "Detailed information on TCP and BGP neighbor connections\n"
13386 "Neighbor to display information about\n"
13387 "Neighbor to display information about\n"
13388 "Neighbor on bgp configured interface\n"
13389 "Display routes learned from neighbor\n"
13390 "JavaScript Object Notation\n")
13393 u_char uj
= use_json(argc
, argv
);
13395 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13397 return CMD_WARNING
;
13399 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13400 bgp_show_type_neighbor
, uj
);
13403 DEFUN (show_ip_bgp_neighbor_flap
,
13404 show_ip_bgp_neighbor_flap_cmd
,
13405 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13409 "Detailed information on TCP and BGP neighbor connections\n"
13410 "Neighbor to display information about\n"
13411 "Neighbor to display information about\n"
13412 "Neighbor on bgp configured interface\n"
13413 "Display flap statistics of the routes learned from neighbor\n"
13414 "JavaScript Object Notation\n")
13417 u_char uj
= use_json(argc
, argv
);
13419 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13421 return CMD_WARNING
;
13423 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13424 bgp_show_type_flap_neighbor
, uj
);
13427 DEFUN (show_ip_bgp_neighbor_damp
,
13428 show_ip_bgp_neighbor_damp_cmd
,
13429 "show ip bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13433 "Detailed information on TCP and BGP neighbor connections\n"
13434 "Neighbor to display information about\n"
13435 "Neighbor to display information about\n"
13436 "Neighbor on bgp configured interface\n"
13437 "Display the dampened routes received from neighbor\n"
13438 "JavaScript Object Notation\n")
13441 u_char uj
= use_json(argc
, argv
);
13443 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13445 return CMD_WARNING
;
13447 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, SAFI_UNICAST
,
13448 bgp_show_type_damp_neighbor
, uj
);
13451 DEFUN (show_ip_bgp_ipv4_neighbor_routes
,
13452 show_ip_bgp_ipv4_neighbor_routes_cmd
,
13453 "show ip bgp ipv4 "BGP_SAFI_CMD_STR
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13459 "Detailed information on TCP and BGP neighbor connections\n"
13460 "Neighbor to display information about\n"
13461 "Neighbor to display information about\n"
13462 "Neighbor on bgp configured interface\n"
13463 "Display routes learned from neighbor\n"
13464 "JavaScript Object Notation\n")
13468 u_char uj
= use_json(argc
, argv
);
13470 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13472 return CMD_WARNING
;
13474 safi
= bgp_vty_safi_from_arg(argv
[0]);
13475 return bgp_show_neighbor_route (vty
, peer
, AFI_IP
, safi
,
13476 bgp_show_type_neighbor
, uj
);
13480 DEFUN (show_bgp_instance_neighbor_routes
,
13481 show_bgp_instance_neighbor_routes_cmd
,
13482 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13485 BGP_INSTANCE_HELP_STR
13486 "Detailed information on TCP and BGP neighbor connections\n"
13487 "Neighbor to display information about\n"
13488 "Neighbor to display information about\n"
13489 "Neighbor on bgp configured interface\n"
13490 "Display routes learned from neighbor\n"
13491 "JavaScript Object Notation\n")
13494 u_char uj
= use_json(argc
, argv
);
13496 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13498 return CMD_WARNING
;
13500 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13501 bgp_show_type_neighbor
, uj
);
13504 ALIAS (show_bgp_instance_neighbor_routes
,
13505 show_bgp_instance_ipv6_neighbor_routes_cmd
,
13506 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13509 BGP_INSTANCE_HELP_STR
13511 "Detailed information on TCP and BGP neighbor connections\n"
13512 "Neighbor to display information about\n"
13513 "Neighbor to display information about\n"
13514 "Neighbor on bgp configured interface\n"
13515 "Display routes learned from neighbor\n"
13516 "JavaScript Object Notation\n")
13518 DEFUN (show_bgp_instance_neighbor_damp
,
13519 show_bgp_instance_neighbor_damp_cmd
,
13520 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13523 BGP_INSTANCE_HELP_STR
13524 "Detailed information on TCP and BGP neighbor connections\n"
13525 "Neighbor to display information about\n"
13526 "Neighbor to display information about\n"
13527 "Neighbor on bgp configured interface\n"
13528 "Display the dampened routes received from neighbor\n"
13529 "JavaScript Object Notation\n")
13532 u_char uj
= use_json(argc
, argv
);
13534 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13535 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13536 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13538 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13541 return CMD_WARNING
;
13543 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13544 bgp_show_type_damp_neighbor
, uj
);
13547 ALIAS (show_bgp_instance_neighbor_damp
,
13548 show_bgp_instance_ipv6_neighbor_damp_cmd
,
13549 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13552 BGP_INSTANCE_HELP_STR
13554 "Detailed information on TCP and BGP neighbor connections\n"
13555 "Neighbor to display information about\n"
13556 "Neighbor to display information about\n"
13557 "Neighbor on bgp configured interface\n"
13558 "Display the dampened routes received from neighbor\n"
13559 "JavaScript Object Notation\n")
13561 DEFUN (show_bgp_instance_neighbor_flap
,
13562 show_bgp_instance_neighbor_flap_cmd
,
13563 "show bgp " BGP_INSTANCE_CMD
" neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13566 BGP_INSTANCE_HELP_STR
13567 "Detailed information on TCP and BGP neighbor connections\n"
13568 "Neighbor to display information about\n"
13569 "Neighbor to display information about\n"
13570 "Neighbor on bgp configured interface\n"
13571 "Display flap statistics of the routes learned from neighbor\n"
13572 "JavaScript Object Notation\n")
13575 u_char uj
= use_json(argc
, argv
);
13577 if ((argc
== 4 && argv
[3] && strcmp(argv
[3], "json") == 0)
13578 || (argc
== 3 && argv
[2] && strcmp(argv
[2], "json") != 0))
13579 peer
= peer_lookup_in_view (vty
, argv
[1], argv
[2], uj
);
13581 peer
= peer_lookup_in_view (vty
, NULL
, argv
[1], uj
);
13584 return CMD_WARNING
;
13586 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13587 bgp_show_type_flap_neighbor
, uj
);
13590 ALIAS (show_bgp_instance_neighbor_flap
,
13591 show_bgp_instance_ipv6_neighbor_flap_cmd
,
13592 "show bgp " BGP_INSTANCE_CMD
" ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13595 BGP_INSTANCE_HELP_STR
13597 "Detailed information on TCP and BGP neighbor connections\n"
13598 "Neighbor to display information about\n"
13599 "Neighbor to display information about\n"
13600 "Neighbor on bgp configured interface\n"
13601 "Display flap statistics of the routes learned from neighbor\n"
13602 "JavaScript Object Notation\n")
13604 DEFUN (show_bgp_neighbor_routes
,
13605 show_bgp_neighbor_routes_cmd
,
13606 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13609 "Detailed information on TCP and BGP neighbor connections\n"
13610 "Neighbor to display information about\n"
13611 "Neighbor to display information about\n"
13612 "Neighbor on bgp configured interface\n"
13613 "Display routes learned from neighbor\n"
13614 "JavaScript Object Notation\n")
13617 u_char uj
= use_json(argc
, argv
);
13619 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13621 return CMD_WARNING
;
13623 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_UNICAST
,
13624 bgp_show_type_neighbor
, uj
);
13628 ALIAS (show_bgp_neighbor_routes
,
13629 show_bgp_ipv6_neighbor_routes_cmd
,
13630 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13634 "Detailed information on TCP and BGP neighbor connections\n"
13635 "Neighbor to display information about\n"
13636 "Neighbor to display information about\n"
13637 "Neighbor on bgp configured interface\n"
13638 "Display routes learned from neighbor\n"
13639 "JavaScript Object Notation\n")
13642 ALIAS (show_bgp_neighbor_routes
,
13643 ipv6_bgp_neighbor_routes_cmd
,
13644 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13648 "Detailed information on TCP and BGP neighbor connections\n"
13649 "Neighbor to display information about\n"
13650 "Neighbor to display information about\n"
13651 "Neighbor on bgp configured interface\n"
13652 "Display routes learned from neighbor\n"
13653 "JavaScript Object Notation\n")
13656 DEFUN (ipv6_mbgp_neighbor_routes
,
13657 ipv6_mbgp_neighbor_routes_cmd
,
13658 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
13662 "Detailed information on TCP and BGP neighbor connections\n"
13663 "Neighbor to display information about\n"
13664 "Neighbor to display information about\n"
13665 "Neighbor on bgp configured interface\n"
13666 "Display routes learned from neighbor\n"
13667 "JavaScript Object Notation\n")
13670 u_char uj
= use_json(argc
, argv
);
13672 peer
= peer_lookup_in_view (vty
, NULL
, argv
[0], uj
);
13674 return CMD_WARNING
;
13676 bgp_show_ipv6_bgp_deprecate_warning(vty
);
13677 return bgp_show_neighbor_route (vty
, peer
, AFI_IP6
, SAFI_MULTICAST
,
13678 bgp_show_type_neighbor
, uj
);
13681 ALIAS (show_bgp_instance_neighbor_flap
,
13682 show_bgp_neighbor_flap_cmd
,
13683 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13686 "Detailed information on TCP and BGP neighbor connections\n"
13687 "Neighbor to display information about\n"
13688 "Neighbor to display information about\n"
13689 "Neighbor on bgp configured interface\n"
13690 "Display flap statistics of the routes learned from neighbor\n"
13691 "JavaScript Object Notation\n")
13693 ALIAS (show_bgp_instance_neighbor_flap
,
13694 show_bgp_ipv6_neighbor_flap_cmd
,
13695 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
13699 "Detailed information on TCP and BGP neighbor connections\n"
13700 "Neighbor to display information about\n"
13701 "Neighbor to display information about\n"
13702 "Neighbor on bgp configured interface\n"
13703 "Display flap statistics of the routes learned from neighbor\n"
13704 "JavaScript Object Notation\n")
13706 ALIAS (show_bgp_instance_neighbor_damp
,
13707 show_bgp_neighbor_damp_cmd
,
13708 "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13711 "Detailed information on TCP and BGP neighbor connections\n"
13712 "Neighbor to display information about\n"
13713 "Neighbor to display information about\n"
13714 "Neighbor on bgp configured interface\n"
13715 "Display the dampened routes received from neighbor\n"
13716 "JavaScript Object Notation\n")
13718 ALIAS (show_bgp_instance_neighbor_damp
,
13719 show_bgp_ipv6_neighbor_damp_cmd
,
13720 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
13724 "Detailed information on TCP and BGP neighbor connections\n"
13725 "Neighbor to display information about\n"
13726 "Neighbor to display information about\n"
13727 "Neighbor on bgp configured interface\n"
13728 "Display the dampened routes received from neighbor\n"
13729 "JavaScript Object Notation\n")
13731 #endif /* HAVE_IPV6 */
13733 struct bgp_table
*bgp_distance_table
[AFI_MAX
][SAFI_MAX
];
13735 struct bgp_distance
13737 /* Distance value for the IP source prefix. */
13740 /* Name of the access-list to be matched. */
13744 static struct bgp_distance
*
13745 bgp_distance_new (void)
13747 return XCALLOC (MTYPE_BGP_DISTANCE
, sizeof (struct bgp_distance
));
13751 bgp_distance_free (struct bgp_distance
*bdistance
)
13753 XFREE (MTYPE_BGP_DISTANCE
, bdistance
);
13757 bgp_distance_set (struct vty
*vty
, const char *distance_str
,
13758 const char *ip_str
, const char *access_list_str
)
13765 struct bgp_node
*rn
;
13766 struct bgp_distance
*bdistance
;
13768 afi
= bgp_node_afi (vty
);
13769 safi
= bgp_node_safi (vty
);
13771 ret
= str2prefix (ip_str
, &p
);
13774 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13775 return CMD_WARNING
;
13778 distance
= atoi (distance_str
);
13780 /* Get BGP distance node. */
13781 rn
= bgp_node_get (bgp_distance_table
[afi
][safi
], (struct prefix
*) &p
);
13784 bdistance
= rn
->info
;
13785 bgp_unlock_node (rn
);
13789 bdistance
= bgp_distance_new ();
13790 rn
->info
= bdistance
;
13793 /* Set distance value. */
13794 bdistance
->distance
= distance
;
13796 /* Reset access-list configuration. */
13797 if (bdistance
->access_list
)
13799 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13800 bdistance
->access_list
= NULL
;
13802 if (access_list_str
)
13803 bdistance
->access_list
= XSTRDUP(MTYPE_AS_LIST
, access_list_str
);
13805 return CMD_SUCCESS
;
13809 bgp_distance_unset (struct vty
*vty
, const char *distance_str
,
13810 const char *ip_str
, const char *access_list_str
)
13817 struct bgp_node
*rn
;
13818 struct bgp_distance
*bdistance
;
13820 afi
= bgp_node_afi (vty
);
13821 safi
= bgp_node_safi (vty
);
13823 ret
= str2prefix (ip_str
, &p
);
13826 vty_out (vty
, "Malformed prefix%s", VTY_NEWLINE
);
13827 return CMD_WARNING
;
13830 rn
= bgp_node_lookup (bgp_distance_table
[afi
][safi
], (struct prefix
*)&p
);
13833 vty_out (vty
, "Can't find specified prefix%s", VTY_NEWLINE
);
13834 return CMD_WARNING
;
13837 bdistance
= rn
->info
;
13838 distance
= atoi(distance_str
);
13840 if (bdistance
->distance
!= distance
)
13842 vty_out (vty
, "Distance does not match configured%s", VTY_NEWLINE
);
13843 return CMD_WARNING
;
13846 if (bdistance
->access_list
)
13847 XFREE(MTYPE_AS_LIST
, bdistance
->access_list
);
13848 bgp_distance_free (bdistance
);
13851 bgp_unlock_node (rn
);
13852 bgp_unlock_node (rn
);
13854 return CMD_SUCCESS
;
13857 /* Apply BGP information to distance method. */
13859 bgp_distance_apply (struct prefix
*p
, struct bgp_info
*rinfo
, afi_t afi
,
13860 safi_t safi
, struct bgp
*bgp
)
13862 struct bgp_node
*rn
;
13865 struct bgp_distance
*bdistance
;
13866 struct access_list
*alist
;
13867 struct bgp_static
*bgp_static
;
13872 peer
= rinfo
->peer
;
13874 /* Check source address. */
13875 sockunion2hostprefix (&peer
->su
, &q
);
13876 rn
= bgp_node_match (bgp_distance_table
[afi
][safi
], &q
);
13879 bdistance
= rn
->info
;
13880 bgp_unlock_node (rn
);
13882 if (bdistance
->access_list
)
13884 alist
= access_list_lookup (afi
, bdistance
->access_list
);
13885 if (alist
&& access_list_apply (alist
, p
) == FILTER_PERMIT
)
13886 return bdistance
->distance
;
13889 return bdistance
->distance
;
13892 /* Backdoor check. */
13893 rn
= bgp_node_lookup (bgp
->route
[afi
][safi
], p
);
13896 bgp_static
= rn
->info
;
13897 bgp_unlock_node (rn
);
13899 if (bgp_static
->backdoor
)
13901 if (bgp
->distance_local
[afi
][safi
])
13902 return bgp
->distance_local
[afi
][safi
];
13904 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13908 if (peer
->sort
== BGP_PEER_EBGP
)
13910 if (bgp
->distance_ebgp
[afi
][safi
])
13911 return bgp
->distance_ebgp
[afi
][safi
];
13912 return ZEBRA_EBGP_DISTANCE_DEFAULT
;
13916 if (bgp
->distance_ibgp
[afi
][safi
])
13917 return bgp
->distance_ibgp
[afi
][safi
];
13918 return ZEBRA_IBGP_DISTANCE_DEFAULT
;
13922 DEFUN (bgp_distance
,
13924 "distance bgp <1-255> <1-255> <1-255>",
13925 "Define an administrative distance\n"
13927 "Distance for routes external to the AS\n"
13928 "Distance for routes internal to the AS\n"
13929 "Distance for local routes\n")
13936 afi
= bgp_node_afi (vty
);
13937 safi
= bgp_node_safi (vty
);
13939 bgp
->distance_ebgp
[afi
][safi
] = atoi (argv
[0]);
13940 bgp
->distance_ibgp
[afi
][safi
] = atoi (argv
[1]);
13941 bgp
->distance_local
[afi
][safi
] = atoi (argv
[2]);
13942 return CMD_SUCCESS
;
13945 DEFUN (no_bgp_distance
,
13946 no_bgp_distance_cmd
,
13947 "no distance bgp <1-255> <1-255> <1-255>",
13949 "Define an administrative distance\n"
13951 "Distance for routes external to the AS\n"
13952 "Distance for routes internal to the AS\n"
13953 "Distance for local routes\n")
13960 afi
= bgp_node_afi (vty
);
13961 safi
= bgp_node_safi (vty
);
13963 bgp
->distance_ebgp
[afi
][safi
] = 0;
13964 bgp
->distance_ibgp
[afi
][safi
] = 0;
13965 bgp
->distance_local
[afi
][safi
] = 0;
13966 return CMD_SUCCESS
;
13969 ALIAS (no_bgp_distance
,
13970 no_bgp_distance2_cmd
,
13973 "Define an administrative distance\n"
13976 DEFUN (bgp_distance_source
,
13977 bgp_distance_source_cmd
,
13978 "distance <1-255> A.B.C.D/M",
13979 "Define an administrative distance\n"
13980 "Administrative distance\n"
13981 "IP source prefix\n")
13983 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
13984 return CMD_SUCCESS
;
13987 DEFUN (no_bgp_distance_source
,
13988 no_bgp_distance_source_cmd
,
13989 "no distance <1-255> A.B.C.D/M",
13991 "Define an administrative distance\n"
13992 "Administrative distance\n"
13993 "IP source prefix\n")
13995 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
13996 return CMD_SUCCESS
;
13999 DEFUN (bgp_distance_source_access_list
,
14000 bgp_distance_source_access_list_cmd
,
14001 "distance <1-255> A.B.C.D/M WORD",
14002 "Define an administrative distance\n"
14003 "Administrative distance\n"
14004 "IP source prefix\n"
14005 "Access list name\n")
14007 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14008 return CMD_SUCCESS
;
14011 DEFUN (no_bgp_distance_source_access_list
,
14012 no_bgp_distance_source_access_list_cmd
,
14013 "no distance <1-255> A.B.C.D/M WORD",
14015 "Define an administrative distance\n"
14016 "Administrative distance\n"
14017 "IP source prefix\n"
14018 "Access list name\n")
14020 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14021 return CMD_SUCCESS
;
14024 DEFUN (ipv6_bgp_distance_source
,
14025 ipv6_bgp_distance_source_cmd
,
14026 "distance <1-255> X:X::X:X/M",
14027 "Define an administrative distance\n"
14028 "Administrative distance\n"
14029 "IP source prefix\n")
14031 bgp_distance_set (vty
, argv
[0], argv
[1], NULL
);
14032 return CMD_SUCCESS
;
14035 DEFUN (no_ipv6_bgp_distance_source
,
14036 no_ipv6_bgp_distance_source_cmd
,
14037 "no distance <1-255> X:X::X:X/M",
14039 "Define an administrative distance\n"
14040 "Administrative distance\n"
14041 "IP source prefix\n")
14043 bgp_distance_unset (vty
, argv
[0], argv
[1], NULL
);
14044 return CMD_SUCCESS
;
14047 DEFUN (ipv6_bgp_distance_source_access_list
,
14048 ipv6_bgp_distance_source_access_list_cmd
,
14049 "distance <1-255> X:X::X:X/M WORD",
14050 "Define an administrative distance\n"
14051 "Administrative distance\n"
14052 "IP source prefix\n"
14053 "Access list name\n")
14055 bgp_distance_set (vty
, argv
[0], argv
[1], argv
[2]);
14056 return CMD_SUCCESS
;
14059 DEFUN (no_ipv6_bgp_distance_source_access_list
,
14060 no_ipv6_bgp_distance_source_access_list_cmd
,
14061 "no distance <1-255> X:X::X:X/M WORD",
14063 "Define an administrative distance\n"
14064 "Administrative distance\n"
14065 "IP source prefix\n"
14066 "Access list name\n")
14068 bgp_distance_unset (vty
, argv
[0], argv
[1], argv
[2]);
14069 return CMD_SUCCESS
;
14072 DEFUN (bgp_damp_set
,
14074 "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14075 "BGP Specific commands\n"
14076 "Enable route-flap dampening\n"
14077 "Half-life time for the penalty\n"
14078 "Value to start reusing a route\n"
14079 "Value to start suppressing a route\n"
14080 "Maximum duration to suppress a stable route\n")
14083 int half
= DEFAULT_HALF_LIFE
* 60;
14084 int reuse
= DEFAULT_REUSE
;
14085 int suppress
= DEFAULT_SUPPRESS
;
14086 int max
= 4 * half
;
14090 half
= atoi (argv
[0]) * 60;
14091 reuse
= atoi (argv
[1]);
14092 suppress
= atoi (argv
[2]);
14093 max
= atoi (argv
[3]) * 60;
14095 else if (argc
== 1)
14097 half
= atoi (argv
[0]) * 60;
14103 if (suppress
< reuse
)
14105 vty_out (vty
, "Suppress value cannot be less than reuse value %s",
14110 return bgp_damp_enable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
),
14111 half
, reuse
, suppress
, max
);
14114 ALIAS (bgp_damp_set
,
14116 "bgp dampening <1-45>",
14117 "BGP Specific commands\n"
14118 "Enable route-flap dampening\n"
14119 "Half-life time for the penalty\n")
14121 ALIAS (bgp_damp_set
,
14124 "BGP Specific commands\n"
14125 "Enable route-flap dampening\n")
14127 DEFUN (bgp_damp_unset
,
14128 bgp_damp_unset_cmd
,
14129 "no bgp dampening",
14131 "BGP Specific commands\n"
14132 "Enable route-flap dampening\n")
14137 return bgp_damp_disable (bgp
, bgp_node_afi (vty
), bgp_node_safi (vty
));
14140 ALIAS (bgp_damp_unset
,
14141 bgp_damp_unset2_cmd
,
14142 "no bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
14144 "BGP Specific commands\n"
14145 "Enable route-flap dampening\n"
14146 "Half-life time for the penalty\n"
14147 "Value to start reusing a route\n"
14148 "Value to start suppressing a route\n"
14149 "Maximum duration to suppress a stable route\n")
14151 ALIAS (bgp_damp_unset
,
14152 bgp_damp_unset3_cmd
,
14153 "no bgp dampening <1-45>",
14155 "BGP Specific commands\n"
14156 "Enable route-flap dampening\n"
14157 "Half-life time for the penalty\n")
14159 DEFUN (show_ip_bgp_dampened_paths
,
14160 show_ip_bgp_dampened_paths_cmd
,
14161 "show ip bgp dampened-paths",
14165 "Display paths suppressed due to dampening\n")
14167 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
, bgp_show_type_dampend_paths
,
14171 ALIAS (show_ip_bgp_dampened_paths
,
14172 show_ip_bgp_damp_dampened_paths_cmd
,
14173 "show ip bgp dampening dampened-paths",
14177 "Display detailed information about dampening\n"
14178 "Display paths suppressed due to dampening\n")
14180 DEFUN (show_ip_bgp_flap_statistics
,
14181 show_ip_bgp_flap_statistics_cmd
,
14182 "show ip bgp flap-statistics",
14186 "Display flap statistics of routes\n")
14188 return bgp_show (vty
, NULL
, AFI_IP
, SAFI_UNICAST
,
14189 bgp_show_type_flap_statistics
, NULL
, 0);
14192 ALIAS (show_ip_bgp_flap_statistics
,
14193 show_ip_bgp_damp_flap_statistics_cmd
,
14194 "show ip bgp dampening flap-statistics",
14198 "Display detailed information about dampening\n"
14199 "Display flap statistics of routes\n")
14201 /* Display specified route of BGP table. */
14203 bgp_clear_damp_route (struct vty
*vty
, const char *view_name
,
14204 const char *ip_str
, afi_t afi
, safi_t safi
,
14205 struct prefix_rd
*prd
, int prefix_check
)
14208 struct prefix match
;
14209 struct bgp_node
*rn
;
14210 struct bgp_node
*rm
;
14211 struct bgp_info
*ri
;
14212 struct bgp_info
*ri_temp
;
14214 struct bgp_table
*table
;
14216 /* BGP structure lookup. */
14219 bgp
= bgp_lookup_by_name (view_name
);
14222 vty_out (vty
, "%% Can't find BGP instance %s%s", view_name
, VTY_NEWLINE
);
14223 return CMD_WARNING
;
14228 bgp
= bgp_get_default ();
14231 vty_out (vty
, "%% No BGP process is configured%s", VTY_NEWLINE
);
14232 return CMD_WARNING
;
14236 /* Check IP address argument. */
14237 ret
= str2prefix (ip_str
, &match
);
14240 vty_out (vty
, "%% address is malformed%s", VTY_NEWLINE
);
14241 return CMD_WARNING
;
14244 match
.family
= afi2family (afi
);
14246 if ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
))
14248 for (rn
= bgp_table_top (bgp
->rib
[AFI_IP
][safi
]); rn
; rn
= bgp_route_next (rn
))
14250 if (prd
&& memcmp (rn
->p
.u
.val
, prd
->val
, 8) != 0)
14253 if ((table
= rn
->info
) != NULL
)
14254 if ((rm
= bgp_node_match (table
, &match
)) != NULL
)
14256 if (! prefix_check
|| rm
->p
.prefixlen
== match
.prefixlen
)
14261 if (ri
->extra
&& ri
->extra
->damp_info
)
14263 ri_temp
= ri
->next
;
14264 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14272 bgp_unlock_node (rm
);
14278 if ((rn
= bgp_node_match (bgp
->rib
[afi
][safi
], &match
)) != NULL
)
14280 if (! prefix_check
|| rn
->p
.prefixlen
== match
.prefixlen
)
14285 if (ri
->extra
&& ri
->extra
->damp_info
)
14287 ri_temp
= ri
->next
;
14288 bgp_damp_info_free (ri
->extra
->damp_info
, 1);
14296 bgp_unlock_node (rn
);
14300 return CMD_SUCCESS
;
14303 DEFUN (clear_ip_bgp_dampening
,
14304 clear_ip_bgp_dampening_cmd
,
14305 "clear ip bgp dampening",
14309 "Clear route flap dampening information\n")
14311 bgp_damp_info_clean ();
14312 return CMD_SUCCESS
;
14315 DEFUN (clear_ip_bgp_dampening_prefix
,
14316 clear_ip_bgp_dampening_prefix_cmd
,
14317 "clear ip bgp dampening A.B.C.D/M",
14321 "Clear route flap dampening information\n"
14322 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
14324 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14325 SAFI_UNICAST
, NULL
, 1);
14328 DEFUN (clear_ip_bgp_dampening_address
,
14329 clear_ip_bgp_dampening_address_cmd
,
14330 "clear ip bgp dampening A.B.C.D",
14334 "Clear route flap dampening information\n"
14335 "Network to clear damping information\n")
14337 return bgp_clear_damp_route (vty
, NULL
, argv
[0], AFI_IP
,
14338 SAFI_UNICAST
, NULL
, 0);
14341 DEFUN (clear_ip_bgp_dampening_address_mask
,
14342 clear_ip_bgp_dampening_address_mask_cmd
,
14343 "clear ip bgp dampening A.B.C.D A.B.C.D",
14347 "Clear route flap dampening information\n"
14348 "Network to clear damping information\n"
14352 char prefix_str
[BUFSIZ
];
14354 ret
= netmask_str2prefix_str (argv
[0], argv
[1], prefix_str
);
14357 vty_out (vty
, "%% Inconsistent address and mask%s", VTY_NEWLINE
);
14358 return CMD_WARNING
;
14361 return bgp_clear_damp_route (vty
, NULL
, prefix_str
, AFI_IP
,
14362 SAFI_UNICAST
, NULL
, 0);
14365 /* also used for encap safi */
14367 bgp_config_write_network_vpnv4 (struct vty
*vty
, struct bgp
*bgp
,
14368 afi_t afi
, safi_t safi
, int *write
)
14370 struct bgp_node
*prn
;
14371 struct bgp_node
*rn
;
14372 struct bgp_table
*table
;
14374 struct prefix_rd
*prd
;
14375 struct bgp_static
*bgp_static
;
14377 char buf
[SU_ADDRSTRLEN
];
14378 char rdbuf
[RD_ADDRSTRLEN
];
14380 /* Network configuration. */
14381 for (prn
= bgp_table_top (bgp
->route
[afi
][safi
]); prn
; prn
= bgp_route_next (prn
))
14382 if ((table
= prn
->info
) != NULL
)
14383 for (rn
= bgp_table_top (table
); rn
; rn
= bgp_route_next (rn
))
14384 if ((bgp_static
= rn
->info
) != NULL
)
14387 prd
= (struct prefix_rd
*) &prn
->p
;
14389 /* "address-family" display. */
14390 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14392 /* "network" configuration display. */
14393 prefix_rd2str (prd
, rdbuf
, RD_ADDRSTRLEN
);
14394 label
= decode_label (bgp_static
->tag
);
14396 vty_out (vty
, " network %s/%d rd %s tag %d",
14397 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14400 vty_out (vty
, "%s", VTY_NEWLINE
);
14405 /* Configuration of static route announcement and aggregate
14408 bgp_config_write_network (struct vty
*vty
, struct bgp
*bgp
,
14409 afi_t afi
, safi_t safi
, int *write
)
14411 struct bgp_node
*rn
;
14413 struct bgp_static
*bgp_static
;
14414 struct bgp_aggregate
*bgp_aggregate
;
14415 char buf
[SU_ADDRSTRLEN
];
14417 if (afi
== AFI_IP
&& ((safi
== SAFI_MPLS_VPN
) || (safi
== SAFI_ENCAP
)))
14418 return bgp_config_write_network_vpnv4 (vty
, bgp
, afi
, safi
, write
);
14420 /* Network configuration. */
14421 for (rn
= bgp_table_top (bgp
->route
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14422 if ((bgp_static
= rn
->info
) != NULL
)
14426 /* "address-family" display. */
14427 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14429 /* "network" configuration display. */
14430 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14432 u_int32_t destination
;
14433 struct in_addr netmask
;
14435 destination
= ntohl (p
->u
.prefix4
.s_addr
);
14436 masklen2ip (p
->prefixlen
, &netmask
);
14437 vty_out (vty
, " network %s",
14438 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
));
14440 if ((IN_CLASSC (destination
) && p
->prefixlen
== 24)
14441 || (IN_CLASSB (destination
) && p
->prefixlen
== 16)
14442 || (IN_CLASSA (destination
) && p
->prefixlen
== 8)
14443 || p
->u
.prefix4
.s_addr
== 0)
14445 /* Natural mask is not display. */
14448 vty_out (vty
, " mask %s", inet_ntoa (netmask
));
14452 vty_out (vty
, " network %s/%d",
14453 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14457 if (bgp_static
->rmap
.name
)
14458 vty_out (vty
, " route-map %s", bgp_static
->rmap
.name
);
14461 if (bgp_static
->backdoor
)
14462 vty_out (vty
, " backdoor");
14465 vty_out (vty
, "%s", VTY_NEWLINE
);
14468 /* Aggregate-address configuration. */
14469 for (rn
= bgp_table_top (bgp
->aggregate
[afi
][safi
]); rn
; rn
= bgp_route_next (rn
))
14470 if ((bgp_aggregate
= rn
->info
) != NULL
)
14474 /* "address-family" display. */
14475 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14477 if (bgp_option_check (BGP_OPT_CONFIG_CISCO
) && afi
== AFI_IP
)
14479 struct in_addr netmask
;
14481 masklen2ip (p
->prefixlen
, &netmask
);
14482 vty_out (vty
, " aggregate-address %s %s",
14483 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14484 inet_ntoa (netmask
));
14488 vty_out (vty
, " aggregate-address %s/%d",
14489 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, SU_ADDRSTRLEN
),
14493 if (bgp_aggregate
->as_set
)
14494 vty_out (vty
, " as-set");
14496 if (bgp_aggregate
->summary_only
)
14497 vty_out (vty
, " summary-only");
14499 vty_out (vty
, "%s", VTY_NEWLINE
);
14506 bgp_config_write_distance (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
14507 safi_t safi
, int *write
)
14509 struct bgp_node
*rn
;
14510 struct bgp_distance
*bdistance
;
14512 /* Distance configuration. */
14513 if (bgp
->distance_ebgp
[afi
][safi
]
14514 && bgp
->distance_ibgp
[afi
][safi
]
14515 && bgp
->distance_local
[afi
][safi
]
14516 && (bgp
->distance_ebgp
[afi
][safi
] != ZEBRA_EBGP_DISTANCE_DEFAULT
14517 || bgp
->distance_ibgp
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
14518 || bgp
->distance_local
[afi
][safi
] != ZEBRA_IBGP_DISTANCE_DEFAULT
))
14520 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14521 vty_out (vty
, " distance bgp %d %d %d%s",
14522 bgp
->distance_ebgp
[afi
][safi
], bgp
->distance_ibgp
[afi
][safi
],
14523 bgp
->distance_local
[afi
][safi
], VTY_NEWLINE
);
14526 for (rn
= bgp_table_top (bgp_distance_table
[afi
][safi
]); rn
;
14527 rn
= bgp_route_next (rn
))
14528 if ((bdistance
= rn
->info
) != NULL
)
14530 char buf
[PREFIX_STRLEN
];
14532 bgp_config_write_family_header (vty
, afi
, safi
, write
);
14533 vty_out (vty
, " distance %d %s %s%s", bdistance
->distance
,
14534 prefix2str (&rn
->p
, buf
, sizeof (buf
)),
14535 bdistance
->access_list
? bdistance
->access_list
: "",
14542 /* Allocate routing table structure and install commands. */
14544 bgp_route_init (void)
14549 /* Init BGP distance table. */
14550 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
14551 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
14552 bgp_distance_table
[afi
][safi
] = bgp_table_init (afi
, safi
);
14554 /* IPv4 BGP commands. */
14555 install_element (BGP_NODE
, &bgp_table_map_cmd
);
14556 install_element (BGP_NODE
, &bgp_network_cmd
);
14557 install_element (BGP_NODE
, &bgp_network_mask_cmd
);
14558 install_element (BGP_NODE
, &bgp_network_mask_natural_cmd
);
14559 install_element (BGP_NODE
, &bgp_network_route_map_cmd
);
14560 install_element (BGP_NODE
, &bgp_network_mask_route_map_cmd
);
14561 install_element (BGP_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14562 install_element (BGP_NODE
, &bgp_network_backdoor_cmd
);
14563 install_element (BGP_NODE
, &bgp_network_mask_backdoor_cmd
);
14564 install_element (BGP_NODE
, &bgp_network_mask_natural_backdoor_cmd
);
14565 install_element (BGP_NODE
, &no_bgp_table_map_cmd
);
14566 install_element (BGP_NODE
, &no_bgp_network_cmd
);
14567 install_element (BGP_NODE
, &no_bgp_network_mask_cmd
);
14568 install_element (BGP_NODE
, &no_bgp_network_mask_natural_cmd
);
14569 install_element (BGP_NODE
, &no_bgp_network_route_map_cmd
);
14570 install_element (BGP_NODE
, &no_bgp_network_mask_route_map_cmd
);
14571 install_element (BGP_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14572 install_element (BGP_NODE
, &no_bgp_network_backdoor_cmd
);
14573 install_element (BGP_NODE
, &no_bgp_network_mask_backdoor_cmd
);
14574 install_element (BGP_NODE
, &no_bgp_network_mask_natural_backdoor_cmd
);
14576 install_element (BGP_NODE
, &aggregate_address_cmd
);
14577 install_element (BGP_NODE
, &aggregate_address_mask_cmd
);
14578 install_element (BGP_NODE
, &aggregate_address_summary_only_cmd
);
14579 install_element (BGP_NODE
, &aggregate_address_mask_summary_only_cmd
);
14580 install_element (BGP_NODE
, &aggregate_address_as_set_cmd
);
14581 install_element (BGP_NODE
, &aggregate_address_mask_as_set_cmd
);
14582 install_element (BGP_NODE
, &aggregate_address_as_set_summary_cmd
);
14583 install_element (BGP_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14584 install_element (BGP_NODE
, &aggregate_address_summary_as_set_cmd
);
14585 install_element (BGP_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14586 install_element (BGP_NODE
, &no_aggregate_address_cmd
);
14587 install_element (BGP_NODE
, &no_aggregate_address_summary_only_cmd
);
14588 install_element (BGP_NODE
, &no_aggregate_address_as_set_cmd
);
14589 install_element (BGP_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14590 install_element (BGP_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14591 install_element (BGP_NODE
, &no_aggregate_address_mask_cmd
);
14592 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14593 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14594 install_element (BGP_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14595 install_element (BGP_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14597 /* IPv4 unicast configuration. */
14598 install_element (BGP_IPV4_NODE
, &bgp_table_map_cmd
);
14599 install_element (BGP_IPV4_NODE
, &bgp_network_cmd
);
14600 install_element (BGP_IPV4_NODE
, &bgp_network_mask_cmd
);
14601 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_cmd
);
14602 install_element (BGP_IPV4_NODE
, &bgp_network_route_map_cmd
);
14603 install_element (BGP_IPV4_NODE
, &bgp_network_mask_route_map_cmd
);
14604 install_element (BGP_IPV4_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14605 install_element (BGP_IPV4_NODE
, &no_bgp_table_map_cmd
);
14606 install_element (BGP_IPV4_NODE
, &no_bgp_network_cmd
);
14607 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_cmd
);
14608 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_cmd
);
14609 install_element (BGP_IPV4_NODE
, &no_bgp_network_route_map_cmd
);
14610 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_route_map_cmd
);
14611 install_element (BGP_IPV4_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14613 install_element (BGP_IPV4_NODE
, &aggregate_address_cmd
);
14614 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_cmd
);
14615 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_only_cmd
);
14616 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_only_cmd
);
14617 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_cmd
);
14618 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_cmd
);
14619 install_element (BGP_IPV4_NODE
, &aggregate_address_as_set_summary_cmd
);
14620 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14621 install_element (BGP_IPV4_NODE
, &aggregate_address_summary_as_set_cmd
);
14622 install_element (BGP_IPV4_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14623 install_element (BGP_IPV4_NODE
, &no_aggregate_address_cmd
);
14624 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_only_cmd
);
14625 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_cmd
);
14626 install_element (BGP_IPV4_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14627 install_element (BGP_IPV4_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14628 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_cmd
);
14629 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14630 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14631 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14632 install_element (BGP_IPV4_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14634 /* IPv4 multicast configuration. */
14635 install_element (BGP_IPV4M_NODE
, &bgp_table_map_cmd
);
14636 install_element (BGP_IPV4M_NODE
, &bgp_network_cmd
);
14637 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_cmd
);
14638 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_cmd
);
14639 install_element (BGP_IPV4M_NODE
, &bgp_network_route_map_cmd
);
14640 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_route_map_cmd
);
14641 install_element (BGP_IPV4M_NODE
, &bgp_network_mask_natural_route_map_cmd
);
14642 install_element (BGP_IPV4M_NODE
, &no_bgp_table_map_cmd
);
14643 install_element (BGP_IPV4M_NODE
, &no_bgp_network_cmd
);
14644 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_cmd
);
14645 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_cmd
);
14646 install_element (BGP_IPV4M_NODE
, &no_bgp_network_route_map_cmd
);
14647 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_route_map_cmd
);
14648 install_element (BGP_IPV4M_NODE
, &no_bgp_network_mask_natural_route_map_cmd
);
14649 install_element (BGP_IPV4M_NODE
, &aggregate_address_cmd
);
14650 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_cmd
);
14651 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_only_cmd
);
14652 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_only_cmd
);
14653 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_cmd
);
14654 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_cmd
);
14655 install_element (BGP_IPV4M_NODE
, &aggregate_address_as_set_summary_cmd
);
14656 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_as_set_summary_cmd
);
14657 install_element (BGP_IPV4M_NODE
, &aggregate_address_summary_as_set_cmd
);
14658 install_element (BGP_IPV4M_NODE
, &aggregate_address_mask_summary_as_set_cmd
);
14659 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_cmd
);
14660 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_only_cmd
);
14661 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_cmd
);
14662 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_as_set_summary_cmd
);
14663 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_summary_as_set_cmd
);
14664 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_cmd
);
14665 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_only_cmd
);
14666 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_cmd
);
14667 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_as_set_summary_cmd
);
14668 install_element (BGP_IPV4M_NODE
, &no_aggregate_address_mask_summary_as_set_cmd
);
14670 install_element (VIEW_NODE
, &show_ip_bgp_cmd
);
14671 install_element (VIEW_NODE
, &show_ip_bgp_instance_cmd
);
14672 install_element (VIEW_NODE
, &show_ip_bgp_instance_all_cmd
);
14673 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cmd
);
14674 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_cmd
);
14675 install_element (VIEW_NODE
, &show_ip_bgp_route_cmd
);
14676 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_cmd
);
14677 install_element (VIEW_NODE
, &show_ip_bgp_route_pathtype_cmd
);
14678 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_pathtype_cmd
);
14679 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_pathtype_cmd
);
14680 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_cmd
);
14681 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_route_cmd
);
14682 install_element (VIEW_NODE
, &show_ip_bgp_prefix_cmd
);
14683 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_cmd
);
14684 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_cmd
);
14685 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_pathtype_cmd
);
14686 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_pathtype_cmd
);
14687 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_prefix_cmd
);
14688 install_element (VIEW_NODE
, &show_ip_bgp_prefix_pathtype_cmd
);
14689 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_pathtype_cmd
);
14691 install_element (VIEW_NODE
, &show_ip_bgp_regexp_cmd
);
14692 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_regexp_cmd
);
14693 install_element (VIEW_NODE
, &show_ip_bgp_prefix_list_cmd
);
14694 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_list_cmd
);
14695 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_list_cmd
);
14696 install_element (VIEW_NODE
, &show_ip_bgp_filter_list_cmd
);
14697 install_element (VIEW_NODE
, &show_ip_bgp_instance_filter_list_cmd
);
14698 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_filter_list_cmd
);
14699 install_element (VIEW_NODE
, &show_ip_bgp_route_map_cmd
);
14700 install_element (VIEW_NODE
, &show_ip_bgp_instance_route_map_cmd
);
14701 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_route_map_cmd
);
14702 install_element (VIEW_NODE
, &show_ip_bgp_cidr_only_cmd
);
14703 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_cidr_only_cmd
);
14704 install_element (VIEW_NODE
, &show_ip_bgp_community_all_cmd
);
14705 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_all_cmd
);
14706 install_element (VIEW_NODE
, &show_ip_bgp_community_cmd
);
14707 install_element (VIEW_NODE
, &show_ip_bgp_community2_cmd
);
14708 install_element (VIEW_NODE
, &show_ip_bgp_community3_cmd
);
14709 install_element (VIEW_NODE
, &show_ip_bgp_community4_cmd
);
14710 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_cmd
);
14711 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_cmd
);
14712 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_cmd
);
14713 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_cmd
);
14714 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_all_cmd
);
14715 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community_cmd
);
14716 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community2_cmd
);
14717 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community3_cmd
);
14718 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_community4_cmd
);
14719 install_element (VIEW_NODE
, &show_ip_bgp_community_exact_cmd
);
14720 install_element (VIEW_NODE
, &show_ip_bgp_community2_exact_cmd
);
14721 install_element (VIEW_NODE
, &show_ip_bgp_community3_exact_cmd
);
14722 install_element (VIEW_NODE
, &show_ip_bgp_community4_exact_cmd
);
14723 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_exact_cmd
);
14724 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community2_exact_cmd
);
14725 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community3_exact_cmd
);
14726 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community4_exact_cmd
);
14727 install_element (VIEW_NODE
, &show_ip_bgp_community_list_cmd
);
14728 install_element (VIEW_NODE
, &show_ip_bgp_instance_community_list_cmd
);
14729 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_cmd
);
14730 install_element (VIEW_NODE
, &show_ip_bgp_community_list_exact_cmd
);
14731 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_community_list_exact_cmd
);
14732 install_element (VIEW_NODE
, &show_ip_bgp_prefix_longer_cmd
);
14733 install_element (VIEW_NODE
, &show_ip_bgp_instance_prefix_longer_cmd
);
14734 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_prefix_longer_cmd
);
14735 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_cmd
);
14736 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_cmd
);
14737 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_advertised_route_rmap_cmd
);
14738 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd
);
14739 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd
);
14740 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd
);
14741 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_cmd
);
14742 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_cmd
);
14743 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_routes_rmap_cmd
);
14744 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd
);
14745 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_cmd
);
14746 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd
);
14747 install_element (VIEW_NODE
, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd
);
14748 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_routes_cmd
);
14749 install_element (VIEW_NODE
, &show_ip_bgp_instance_neighbor_routes_cmd
);
14750 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_routes_cmd
);
14751 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_received_prefix_filter_cmd
);
14752 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd
);
14753 install_element (VIEW_NODE
, &show_ip_bgp_dampening_params_cmd
);
14754 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_parameters_cmd
);
14755 install_element (VIEW_NODE
, &show_ip_bgp_dampened_paths_cmd
);
14756 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd
);
14757 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_dampening_flap_stats_cmd
);
14758 install_element (VIEW_NODE
, &show_ip_bgp_damp_dampened_paths_cmd
);
14759 install_element (VIEW_NODE
, &show_ip_bgp_flap_statistics_cmd
);
14760 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_statistics_cmd
);
14761 install_element (VIEW_NODE
, &show_ip_bgp_flap_address_cmd
);
14762 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_address_cmd
);
14763 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_cmd
);
14764 install_element (VIEW_NODE
, &show_ip_bgp_flap_cidr_only_cmd
);
14765 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_cidr_only_cmd
);
14766 install_element (VIEW_NODE
, &show_ip_bgp_flap_regexp_cmd
);
14767 install_element (VIEW_NODE
, &show_ip_bgp_flap_filter_list_cmd
);
14768 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_filter_list_cmd
);
14769 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_list_cmd
);
14770 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_list_cmd
);
14771 install_element (VIEW_NODE
, &show_ip_bgp_flap_prefix_longer_cmd
);
14772 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_prefix_longer_cmd
);
14773 install_element (VIEW_NODE
, &show_ip_bgp_flap_route_map_cmd
);
14774 install_element (VIEW_NODE
, &show_ip_bgp_damp_flap_route_map_cmd
);
14775 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_flap_cmd
);
14776 install_element (VIEW_NODE
, &show_ip_bgp_neighbor_damp_cmd
);
14778 install_element (VIEW_NODE
, &show_bgp_ipv4_prefix_cmd
);
14779 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_route_cmd
);
14780 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_route_cmd
);
14781 install_element (VIEW_NODE
, &show_bgp_ipv4_safi_rd_prefix_cmd
);
14782 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_rd_prefix_cmd
);
14784 /* BGP dampening clear commands */
14785 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_cmd
);
14786 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_prefix_cmd
);
14787 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_cmd
);
14788 install_element (ENABLE_NODE
, &clear_ip_bgp_dampening_address_mask_cmd
);
14791 install_element (ENABLE_NODE
, &show_ip_bgp_neighbor_prefix_counts_cmd
);
14792 install_element (ENABLE_NODE
, &show_ip_bgp_instance_neighbor_prefix_counts_cmd
);
14793 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd
);
14795 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbor_prefix_counts_cmd
);
14796 install_element (ENABLE_NODE
, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd
);
14798 /* New config IPv6 BGP commands. */
14799 install_element (BGP_IPV6_NODE
, &bgp_table_map_cmd
);
14800 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_cmd
);
14801 install_element (BGP_IPV6_NODE
, &ipv6_bgp_network_route_map_cmd
);
14802 install_element (BGP_IPV6_NODE
, &no_bgp_table_map_cmd
);
14803 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_cmd
);
14804 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_network_route_map_cmd
);
14806 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_cmd
);
14807 install_element (BGP_IPV6_NODE
, &ipv6_aggregate_address_summary_only_cmd
);
14808 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_cmd
);
14809 install_element (BGP_IPV6_NODE
, &no_ipv6_aggregate_address_summary_only_cmd
);
14811 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_network_cmd
);
14812 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_network_cmd
);
14814 /* Old config IPv6 BGP commands. */
14815 install_element (BGP_NODE
, &old_ipv6_bgp_network_cmd
);
14816 install_element (BGP_NODE
, &old_no_ipv6_bgp_network_cmd
);
14818 install_element (BGP_NODE
, &old_ipv6_aggregate_address_cmd
);
14819 install_element (BGP_NODE
, &old_ipv6_aggregate_address_summary_only_cmd
);
14820 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_cmd
);
14821 install_element (BGP_NODE
, &old_no_ipv6_aggregate_address_summary_only_cmd
);
14823 install_element (VIEW_NODE
, &show_bgp_cmd
);
14824 install_element (VIEW_NODE
, &show_bgp_ipv6_cmd
);
14825 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_cmd
);
14826 install_element (VIEW_NODE
, &show_bgp_route_cmd
);
14827 install_element (VIEW_NODE
, &show_bgp_ipv6_route_cmd
);
14828 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_cmd
);
14829 install_element (VIEW_NODE
, &show_bgp_route_pathtype_cmd
);
14830 install_element (VIEW_NODE
, &show_bgp_ipv6_route_pathtype_cmd
);
14831 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_route_pathtype_cmd
);
14832 install_element (VIEW_NODE
, &show_bgp_prefix_cmd
);
14833 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_cmd
);
14834 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_cmd
);
14835 install_element (VIEW_NODE
, &show_bgp_prefix_pathtype_cmd
);
14836 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_pathtype_cmd
);
14837 install_element (VIEW_NODE
, &show_bgp_ipv6_safi_prefix_pathtype_cmd
);
14838 install_element (VIEW_NODE
, &show_bgp_regexp_cmd
);
14839 install_element (VIEW_NODE
, &show_bgp_ipv6_regexp_cmd
);
14840 install_element (VIEW_NODE
, &show_bgp_prefix_list_cmd
);
14841 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_list_cmd
);
14842 install_element (VIEW_NODE
, &show_bgp_filter_list_cmd
);
14843 install_element (VIEW_NODE
, &show_bgp_ipv6_filter_list_cmd
);
14844 install_element (VIEW_NODE
, &show_bgp_route_map_cmd
);
14845 install_element (VIEW_NODE
, &show_bgp_ipv6_route_map_cmd
);
14846 install_element (VIEW_NODE
, &show_bgp_community_all_cmd
);
14847 install_element (VIEW_NODE
, &show_bgp_ipv6_community_all_cmd
);
14848 install_element (VIEW_NODE
, &show_bgp_community_cmd
);
14849 install_element (VIEW_NODE
, &show_bgp_ipv6_community_cmd
);
14850 install_element (VIEW_NODE
, &show_bgp_community2_cmd
);
14851 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_cmd
);
14852 install_element (VIEW_NODE
, &show_bgp_community3_cmd
);
14853 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_cmd
);
14854 install_element (VIEW_NODE
, &show_bgp_community4_cmd
);
14855 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_cmd
);
14856 install_element (VIEW_NODE
, &show_bgp_community_exact_cmd
);
14857 install_element (VIEW_NODE
, &show_bgp_ipv6_community_exact_cmd
);
14858 install_element (VIEW_NODE
, &show_bgp_community2_exact_cmd
);
14859 install_element (VIEW_NODE
, &show_bgp_ipv6_community2_exact_cmd
);
14860 install_element (VIEW_NODE
, &show_bgp_community3_exact_cmd
);
14861 install_element (VIEW_NODE
, &show_bgp_ipv6_community3_exact_cmd
);
14862 install_element (VIEW_NODE
, &show_bgp_community4_exact_cmd
);
14863 install_element (VIEW_NODE
, &show_bgp_ipv6_community4_exact_cmd
);
14864 install_element (VIEW_NODE
, &show_bgp_community_list_cmd
);
14865 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_cmd
);
14866 install_element (VIEW_NODE
, &show_bgp_community_list_exact_cmd
);
14867 install_element (VIEW_NODE
, &show_bgp_ipv6_community_list_exact_cmd
);
14868 install_element (VIEW_NODE
, &show_bgp_prefix_longer_cmd
);
14869 install_element (VIEW_NODE
, &show_bgp_ipv6_prefix_longer_cmd
);
14870 install_element (VIEW_NODE
, &show_bgp_neighbor_advertised_route_cmd
);
14871 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_advertised_route_cmd
);
14872 install_element (VIEW_NODE
, &show_bgp_neighbor_received_routes_cmd
);
14873 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_routes_cmd
);
14874 install_element (VIEW_NODE
, &show_bgp_neighbor_routes_cmd
);
14875 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_routes_cmd
);
14876 install_element (VIEW_NODE
, &show_bgp_neighbor_received_prefix_filter_cmd
);
14877 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd
);
14878 install_element (VIEW_NODE
, &show_bgp_neighbor_flap_cmd
);
14879 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_flap_cmd
);
14880 install_element (VIEW_NODE
, &show_bgp_neighbor_damp_cmd
);
14881 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbor_damp_cmd
);
14882 install_element (VIEW_NODE
, &show_bgp_instance_cmd
);
14883 install_element (VIEW_NODE
, &show_bgp_instance_all_cmd
);
14884 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_cmd
);
14885 install_element (VIEW_NODE
, &show_bgp_instance_route_cmd
);
14886 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_cmd
);
14887 install_element (VIEW_NODE
, &show_bgp_instance_route_pathtype_cmd
);
14888 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_pathtype_cmd
);
14889 install_element (VIEW_NODE
, &show_bgp_instance_prefix_cmd
);
14890 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_cmd
);
14891 install_element (VIEW_NODE
, &show_bgp_instance_prefix_pathtype_cmd
);
14892 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_pathtype_cmd
);
14893 install_element (VIEW_NODE
, &show_bgp_instance_prefix_list_cmd
);
14894 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_list_cmd
);
14895 install_element (VIEW_NODE
, &show_bgp_instance_filter_list_cmd
);
14896 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_filter_list_cmd
);
14897 install_element (VIEW_NODE
, &show_bgp_instance_route_map_cmd
);
14898 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_route_map_cmd
);
14899 install_element (VIEW_NODE
, &show_bgp_instance_community_list_cmd
);
14900 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_community_list_cmd
);
14901 install_element (VIEW_NODE
, &show_bgp_instance_prefix_longer_cmd
);
14902 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_prefix_longer_cmd
);
14903 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_advertised_route_cmd
);
14904 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd
);
14905 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_routes_cmd
);
14906 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_routes_cmd
);
14907 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_routes_cmd
);
14908 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_routes_cmd
);
14909 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_received_prefix_filter_cmd
);
14910 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd
);
14911 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_flap_cmd
);
14912 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_flap_cmd
);
14913 install_element (VIEW_NODE
, &show_bgp_instance_neighbor_damp_cmd
);
14914 install_element (VIEW_NODE
, &show_bgp_instance_ipv6_neighbor_damp_cmd
);
14917 install_element (ENABLE_NODE
, &show_bgp_statistics_cmd
);
14918 //install_element (ENABLE_NODE, &show_bgp_statistics_vpnv4_cmd);
14919 install_element (ENABLE_NODE
, &show_bgp_statistics_view_cmd
);
14920 //install_element (ENABLE_NODE, &show_bgp_statistics_view_vpnv4_cmd);
14923 install_element (VIEW_NODE
, &show_ipv6_bgp_cmd
);
14924 install_element (VIEW_NODE
, &show_ipv6_bgp_route_cmd
);
14925 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_cmd
);
14926 install_element (VIEW_NODE
, &show_ipv6_bgp_regexp_cmd
);
14927 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_list_cmd
);
14928 install_element (VIEW_NODE
, &show_ipv6_bgp_filter_list_cmd
);
14929 install_element (VIEW_NODE
, &show_ipv6_bgp_community_all_cmd
);
14930 install_element (VIEW_NODE
, &show_ipv6_bgp_community_cmd
);
14931 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_cmd
);
14932 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_cmd
);
14933 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_cmd
);
14934 install_element (VIEW_NODE
, &show_ipv6_bgp_community_exact_cmd
);
14935 install_element (VIEW_NODE
, &show_ipv6_bgp_community2_exact_cmd
);
14936 install_element (VIEW_NODE
, &show_ipv6_bgp_community3_exact_cmd
);
14937 install_element (VIEW_NODE
, &show_ipv6_bgp_community4_exact_cmd
);
14938 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_cmd
);
14939 install_element (VIEW_NODE
, &show_ipv6_bgp_community_list_exact_cmd
);
14940 install_element (VIEW_NODE
, &show_ipv6_bgp_prefix_longer_cmd
);
14941 install_element (VIEW_NODE
, &show_ipv6_mbgp_cmd
);
14942 install_element (VIEW_NODE
, &show_ipv6_mbgp_route_cmd
);
14943 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_cmd
);
14944 install_element (VIEW_NODE
, &show_ipv6_mbgp_regexp_cmd
);
14945 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_list_cmd
);
14946 install_element (VIEW_NODE
, &show_ipv6_mbgp_filter_list_cmd
);
14947 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_all_cmd
);
14948 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_cmd
);
14949 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_cmd
);
14950 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_cmd
);
14951 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_cmd
);
14952 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_exact_cmd
);
14953 install_element (VIEW_NODE
, &show_ipv6_mbgp_community2_exact_cmd
);
14954 install_element (VIEW_NODE
, &show_ipv6_mbgp_community3_exact_cmd
);
14955 install_element (VIEW_NODE
, &show_ipv6_mbgp_community4_exact_cmd
);
14956 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_cmd
);
14957 install_element (VIEW_NODE
, &show_ipv6_mbgp_community_list_exact_cmd
);
14958 install_element (VIEW_NODE
, &show_ipv6_mbgp_prefix_longer_cmd
);
14961 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_advertised_route_cmd
);
14962 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_advertised_route_cmd
);
14965 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_received_routes_cmd
);
14966 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_received_routes_cmd
);
14969 install_element (VIEW_NODE
, &ipv6_bgp_neighbor_routes_cmd
);
14970 install_element (VIEW_NODE
, &ipv6_mbgp_neighbor_routes_cmd
);
14971 #endif /* HAVE_IPV6 */
14973 install_element (BGP_NODE
, &bgp_distance_cmd
);
14974 install_element (BGP_NODE
, &no_bgp_distance_cmd
);
14975 install_element (BGP_NODE
, &no_bgp_distance2_cmd
);
14976 install_element (BGP_NODE
, &bgp_distance_source_cmd
);
14977 install_element (BGP_NODE
, &no_bgp_distance_source_cmd
);
14978 install_element (BGP_NODE
, &bgp_distance_source_access_list_cmd
);
14979 install_element (BGP_NODE
, &no_bgp_distance_source_access_list_cmd
);
14980 install_element (BGP_IPV4_NODE
, &bgp_distance_cmd
);
14981 install_element (BGP_IPV4_NODE
, &no_bgp_distance_cmd
);
14982 install_element (BGP_IPV4_NODE
, &no_bgp_distance2_cmd
);
14983 install_element (BGP_IPV4_NODE
, &bgp_distance_source_cmd
);
14984 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_cmd
);
14985 install_element (BGP_IPV4_NODE
, &bgp_distance_source_access_list_cmd
);
14986 install_element (BGP_IPV4_NODE
, &no_bgp_distance_source_access_list_cmd
);
14987 install_element (BGP_IPV4M_NODE
, &bgp_distance_cmd
);
14988 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_cmd
);
14989 install_element (BGP_IPV4M_NODE
, &no_bgp_distance2_cmd
);
14990 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_cmd
);
14991 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_cmd
);
14992 install_element (BGP_IPV4M_NODE
, &bgp_distance_source_access_list_cmd
);
14993 install_element (BGP_IPV4M_NODE
, &no_bgp_distance_source_access_list_cmd
);
14994 install_element (BGP_IPV6_NODE
, &bgp_distance_cmd
);
14995 install_element (BGP_IPV6_NODE
, &no_bgp_distance_cmd
);
14996 install_element (BGP_IPV6_NODE
, &no_bgp_distance2_cmd
);
14997 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_cmd
);
14998 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_cmd
);
14999 install_element (BGP_IPV6_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15000 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15001 install_element (BGP_IPV6M_NODE
, &bgp_distance_cmd
);
15002 install_element (BGP_IPV6M_NODE
, &no_bgp_distance_cmd
);
15003 install_element (BGP_IPV6M_NODE
, &no_bgp_distance2_cmd
);
15004 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_cmd
);
15005 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_cmd
);
15006 install_element (BGP_IPV6M_NODE
, &ipv6_bgp_distance_source_access_list_cmd
);
15007 install_element (BGP_IPV6M_NODE
, &no_ipv6_bgp_distance_source_access_list_cmd
);
15009 install_element (BGP_NODE
, &bgp_damp_set_cmd
);
15010 install_element (BGP_NODE
, &bgp_damp_set2_cmd
);
15011 install_element (BGP_NODE
, &bgp_damp_set3_cmd
);
15012 install_element (BGP_NODE
, &bgp_damp_unset_cmd
);
15013 install_element (BGP_NODE
, &bgp_damp_unset2_cmd
);
15014 install_element (BGP_NODE
, &bgp_damp_unset3_cmd
);
15015 install_element (BGP_IPV4_NODE
, &bgp_damp_set_cmd
);
15016 install_element (BGP_IPV4_NODE
, &bgp_damp_set2_cmd
);
15017 install_element (BGP_IPV4_NODE
, &bgp_damp_set3_cmd
);
15018 install_element (BGP_IPV4_NODE
, &bgp_damp_unset_cmd
);
15019 install_element (BGP_IPV4_NODE
, &bgp_damp_unset2_cmd
);
15020 install_element (BGP_IPV4_NODE
, &bgp_damp_unset3_cmd
);
15022 /* IPv4 Multicast Mode */
15023 install_element (BGP_IPV4M_NODE
, &bgp_damp_set_cmd
);
15024 install_element (BGP_IPV4M_NODE
, &bgp_damp_set2_cmd
);
15025 install_element (BGP_IPV4M_NODE
, &bgp_damp_set3_cmd
);
15026 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset_cmd
);
15027 install_element (BGP_IPV4M_NODE
, &bgp_damp_unset2_cmd
);
15031 bgp_route_finish (void)
15036 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
15037 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
15039 bgp_table_unlock (bgp_distance_table
[afi
][safi
]);
15040 bgp_distance_table
[afi
][safi
] = NULL
;